| .. | .. |
|---|
| 53 | 53 | |
|---|
| 54 | 54 | u32 |
|---|
| 55 | 55 | krb5_encrypt( |
|---|
| 56 | | - struct crypto_skcipher *tfm, |
|---|
| 56 | + struct crypto_sync_skcipher *tfm, |
|---|
| 57 | 57 | void * iv, |
|---|
| 58 | 58 | void * in, |
|---|
| 59 | 59 | void * out, |
|---|
| .. | .. |
|---|
| 62 | 62 | u32 ret = -EINVAL; |
|---|
| 63 | 63 | struct scatterlist sg[1]; |
|---|
| 64 | 64 | u8 local_iv[GSS_KRB5_MAX_BLOCKSIZE] = {0}; |
|---|
| 65 | | - SKCIPHER_REQUEST_ON_STACK(req, tfm); |
|---|
| 65 | + SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm); |
|---|
| 66 | 66 | |
|---|
| 67 | | - if (length % crypto_skcipher_blocksize(tfm) != 0) |
|---|
| 67 | + if (length % crypto_sync_skcipher_blocksize(tfm) != 0) |
|---|
| 68 | 68 | goto out; |
|---|
| 69 | 69 | |
|---|
| 70 | | - if (crypto_skcipher_ivsize(tfm) > GSS_KRB5_MAX_BLOCKSIZE) { |
|---|
| 70 | + if (crypto_sync_skcipher_ivsize(tfm) > GSS_KRB5_MAX_BLOCKSIZE) { |
|---|
| 71 | 71 | dprintk("RPC: gss_k5encrypt: tfm iv size too large %d\n", |
|---|
| 72 | | - crypto_skcipher_ivsize(tfm)); |
|---|
| 72 | + crypto_sync_skcipher_ivsize(tfm)); |
|---|
| 73 | 73 | goto out; |
|---|
| 74 | 74 | } |
|---|
| 75 | 75 | |
|---|
| 76 | 76 | if (iv) |
|---|
| 77 | | - memcpy(local_iv, iv, crypto_skcipher_ivsize(tfm)); |
|---|
| 77 | + memcpy(local_iv, iv, crypto_sync_skcipher_ivsize(tfm)); |
|---|
| 78 | 78 | |
|---|
| 79 | 79 | memcpy(out, in, length); |
|---|
| 80 | 80 | sg_init_one(sg, out, length); |
|---|
| 81 | 81 | |
|---|
| 82 | | - skcipher_request_set_tfm(req, tfm); |
|---|
| 82 | + skcipher_request_set_sync_tfm(req, tfm); |
|---|
| 83 | 83 | skcipher_request_set_callback(req, 0, NULL, NULL); |
|---|
| 84 | 84 | skcipher_request_set_crypt(req, sg, sg, length, local_iv); |
|---|
| 85 | 85 | |
|---|
| .. | .. |
|---|
| 92 | 92 | |
|---|
| 93 | 93 | u32 |
|---|
| 94 | 94 | krb5_decrypt( |
|---|
| 95 | | - struct crypto_skcipher *tfm, |
|---|
| 95 | + struct crypto_sync_skcipher *tfm, |
|---|
| 96 | 96 | void * iv, |
|---|
| 97 | 97 | void * in, |
|---|
| 98 | 98 | void * out, |
|---|
| .. | .. |
|---|
| 101 | 101 | u32 ret = -EINVAL; |
|---|
| 102 | 102 | struct scatterlist sg[1]; |
|---|
| 103 | 103 | u8 local_iv[GSS_KRB5_MAX_BLOCKSIZE] = {0}; |
|---|
| 104 | | - SKCIPHER_REQUEST_ON_STACK(req, tfm); |
|---|
| 104 | + SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm); |
|---|
| 105 | 105 | |
|---|
| 106 | | - if (length % crypto_skcipher_blocksize(tfm) != 0) |
|---|
| 106 | + if (length % crypto_sync_skcipher_blocksize(tfm) != 0) |
|---|
| 107 | 107 | goto out; |
|---|
| 108 | 108 | |
|---|
| 109 | | - if (crypto_skcipher_ivsize(tfm) > GSS_KRB5_MAX_BLOCKSIZE) { |
|---|
| 109 | + if (crypto_sync_skcipher_ivsize(tfm) > GSS_KRB5_MAX_BLOCKSIZE) { |
|---|
| 110 | 110 | dprintk("RPC: gss_k5decrypt: tfm iv size too large %d\n", |
|---|
| 111 | | - crypto_skcipher_ivsize(tfm)); |
|---|
| 111 | + crypto_sync_skcipher_ivsize(tfm)); |
|---|
| 112 | 112 | goto out; |
|---|
| 113 | 113 | } |
|---|
| 114 | 114 | if (iv) |
|---|
| 115 | | - memcpy(local_iv,iv, crypto_skcipher_ivsize(tfm)); |
|---|
| 115 | + memcpy(local_iv, iv, crypto_sync_skcipher_ivsize(tfm)); |
|---|
| 116 | 116 | |
|---|
| 117 | 117 | memcpy(out, in, length); |
|---|
| 118 | 118 | sg_init_one(sg, out, length); |
|---|
| 119 | 119 | |
|---|
| 120 | | - skcipher_request_set_tfm(req, tfm); |
|---|
| 120 | + skcipher_request_set_sync_tfm(req, tfm); |
|---|
| 121 | 121 | skcipher_request_set_callback(req, 0, NULL, NULL); |
|---|
| 122 | 122 | skcipher_request_set_crypt(req, sg, sg, length, local_iv); |
|---|
| 123 | 123 | |
|---|
| .. | .. |
|---|
| 138 | 138 | return crypto_ahash_update(req); |
|---|
| 139 | 139 | } |
|---|
| 140 | 140 | |
|---|
| 141 | | -static int |
|---|
| 142 | | -arcfour_hmac_md5_usage_to_salt(unsigned int usage, u8 salt[4]) |
|---|
| 143 | | -{ |
|---|
| 144 | | - unsigned int ms_usage; |
|---|
| 145 | | - |
|---|
| 146 | | - switch (usage) { |
|---|
| 147 | | - case KG_USAGE_SIGN: |
|---|
| 148 | | - ms_usage = 15; |
|---|
| 149 | | - break; |
|---|
| 150 | | - case KG_USAGE_SEAL: |
|---|
| 151 | | - ms_usage = 13; |
|---|
| 152 | | - break; |
|---|
| 153 | | - default: |
|---|
| 154 | | - return -EINVAL; |
|---|
| 155 | | - } |
|---|
| 156 | | - salt[0] = (ms_usage >> 0) & 0xff; |
|---|
| 157 | | - salt[1] = (ms_usage >> 8) & 0xff; |
|---|
| 158 | | - salt[2] = (ms_usage >> 16) & 0xff; |
|---|
| 159 | | - salt[3] = (ms_usage >> 24) & 0xff; |
|---|
| 160 | | - |
|---|
| 161 | | - return 0; |
|---|
| 162 | | -} |
|---|
| 163 | | - |
|---|
| 164 | | -static u32 |
|---|
| 165 | | -make_checksum_hmac_md5(struct krb5_ctx *kctx, char *header, int hdrlen, |
|---|
| 166 | | - struct xdr_buf *body, int body_offset, u8 *cksumkey, |
|---|
| 167 | | - unsigned int usage, struct xdr_netobj *cksumout) |
|---|
| 168 | | -{ |
|---|
| 169 | | - struct scatterlist sg[1]; |
|---|
| 170 | | - int err = -1; |
|---|
| 171 | | - u8 *checksumdata; |
|---|
| 172 | | - u8 *rc4salt; |
|---|
| 173 | | - struct crypto_ahash *md5; |
|---|
| 174 | | - struct crypto_ahash *hmac_md5; |
|---|
| 175 | | - struct ahash_request *req; |
|---|
| 176 | | - |
|---|
| 177 | | - if (cksumkey == NULL) |
|---|
| 178 | | - return GSS_S_FAILURE; |
|---|
| 179 | | - |
|---|
| 180 | | - if (cksumout->len < kctx->gk5e->cksumlength) { |
|---|
| 181 | | - dprintk("%s: checksum buffer length, %u, too small for %s\n", |
|---|
| 182 | | - __func__, cksumout->len, kctx->gk5e->name); |
|---|
| 183 | | - return GSS_S_FAILURE; |
|---|
| 184 | | - } |
|---|
| 185 | | - |
|---|
| 186 | | - rc4salt = kmalloc_array(4, sizeof(*rc4salt), GFP_NOFS); |
|---|
| 187 | | - if (!rc4salt) |
|---|
| 188 | | - return GSS_S_FAILURE; |
|---|
| 189 | | - |
|---|
| 190 | | - if (arcfour_hmac_md5_usage_to_salt(usage, rc4salt)) { |
|---|
| 191 | | - dprintk("%s: invalid usage value %u\n", __func__, usage); |
|---|
| 192 | | - goto out_free_rc4salt; |
|---|
| 193 | | - } |
|---|
| 194 | | - |
|---|
| 195 | | - checksumdata = kmalloc(GSS_KRB5_MAX_CKSUM_LEN, GFP_NOFS); |
|---|
| 196 | | - if (!checksumdata) |
|---|
| 197 | | - goto out_free_rc4salt; |
|---|
| 198 | | - |
|---|
| 199 | | - md5 = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC); |
|---|
| 200 | | - if (IS_ERR(md5)) |
|---|
| 201 | | - goto out_free_cksum; |
|---|
| 202 | | - |
|---|
| 203 | | - hmac_md5 = crypto_alloc_ahash(kctx->gk5e->cksum_name, 0, |
|---|
| 204 | | - CRYPTO_ALG_ASYNC); |
|---|
| 205 | | - if (IS_ERR(hmac_md5)) |
|---|
| 206 | | - goto out_free_md5; |
|---|
| 207 | | - |
|---|
| 208 | | - req = ahash_request_alloc(md5, GFP_NOFS); |
|---|
| 209 | | - if (!req) |
|---|
| 210 | | - goto out_free_hmac_md5; |
|---|
| 211 | | - |
|---|
| 212 | | - ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); |
|---|
| 213 | | - |
|---|
| 214 | | - err = crypto_ahash_init(req); |
|---|
| 215 | | - if (err) |
|---|
| 216 | | - goto out; |
|---|
| 217 | | - sg_init_one(sg, rc4salt, 4); |
|---|
| 218 | | - ahash_request_set_crypt(req, sg, NULL, 4); |
|---|
| 219 | | - err = crypto_ahash_update(req); |
|---|
| 220 | | - if (err) |
|---|
| 221 | | - goto out; |
|---|
| 222 | | - |
|---|
| 223 | | - sg_init_one(sg, header, hdrlen); |
|---|
| 224 | | - ahash_request_set_crypt(req, sg, NULL, hdrlen); |
|---|
| 225 | | - err = crypto_ahash_update(req); |
|---|
| 226 | | - if (err) |
|---|
| 227 | | - goto out; |
|---|
| 228 | | - err = xdr_process_buf(body, body_offset, body->len - body_offset, |
|---|
| 229 | | - checksummer, req); |
|---|
| 230 | | - if (err) |
|---|
| 231 | | - goto out; |
|---|
| 232 | | - ahash_request_set_crypt(req, NULL, checksumdata, 0); |
|---|
| 233 | | - err = crypto_ahash_final(req); |
|---|
| 234 | | - if (err) |
|---|
| 235 | | - goto out; |
|---|
| 236 | | - |
|---|
| 237 | | - ahash_request_free(req); |
|---|
| 238 | | - req = ahash_request_alloc(hmac_md5, GFP_NOFS); |
|---|
| 239 | | - if (!req) |
|---|
| 240 | | - goto out_free_hmac_md5; |
|---|
| 241 | | - |
|---|
| 242 | | - ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); |
|---|
| 243 | | - |
|---|
| 244 | | - err = crypto_ahash_setkey(hmac_md5, cksumkey, kctx->gk5e->keylength); |
|---|
| 245 | | - if (err) |
|---|
| 246 | | - goto out; |
|---|
| 247 | | - |
|---|
| 248 | | - sg_init_one(sg, checksumdata, crypto_ahash_digestsize(md5)); |
|---|
| 249 | | - ahash_request_set_crypt(req, sg, checksumdata, |
|---|
| 250 | | - crypto_ahash_digestsize(md5)); |
|---|
| 251 | | - err = crypto_ahash_digest(req); |
|---|
| 252 | | - if (err) |
|---|
| 253 | | - goto out; |
|---|
| 254 | | - |
|---|
| 255 | | - memcpy(cksumout->data, checksumdata, kctx->gk5e->cksumlength); |
|---|
| 256 | | - cksumout->len = kctx->gk5e->cksumlength; |
|---|
| 257 | | -out: |
|---|
| 258 | | - ahash_request_free(req); |
|---|
| 259 | | -out_free_hmac_md5: |
|---|
| 260 | | - crypto_free_ahash(hmac_md5); |
|---|
| 261 | | -out_free_md5: |
|---|
| 262 | | - crypto_free_ahash(md5); |
|---|
| 263 | | -out_free_cksum: |
|---|
| 264 | | - kfree(checksumdata); |
|---|
| 265 | | -out_free_rc4salt: |
|---|
| 266 | | - kfree(rc4salt); |
|---|
| 267 | | - return err ? GSS_S_FAILURE : 0; |
|---|
| 268 | | -} |
|---|
| 269 | | - |
|---|
| 270 | 141 | /* |
|---|
| 271 | 142 | * checksum the plaintext data and hdrlen bytes of the token header |
|---|
| 272 | 143 | * The checksum is performed over the first 8 bytes of the |
|---|
| .. | .. |
|---|
| 283 | 154 | int err = -1; |
|---|
| 284 | 155 | u8 *checksumdata; |
|---|
| 285 | 156 | unsigned int checksumlen; |
|---|
| 286 | | - |
|---|
| 287 | | - if (kctx->gk5e->ctype == CKSUMTYPE_HMAC_MD5_ARCFOUR) |
|---|
| 288 | | - return make_checksum_hmac_md5(kctx, header, hdrlen, |
|---|
| 289 | | - body, body_offset, |
|---|
| 290 | | - cksumkey, usage, cksumout); |
|---|
| 291 | 157 | |
|---|
| 292 | 158 | if (cksumout->len < kctx->gk5e->cksumlength) { |
|---|
| 293 | 159 | dprintk("%s: checksum buffer length, %u, too small for %s\n", |
|---|
| .. | .. |
|---|
| 466 | 332 | { |
|---|
| 467 | 333 | struct encryptor_desc *desc = data; |
|---|
| 468 | 334 | struct xdr_buf *outbuf = desc->outbuf; |
|---|
| 469 | | - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(desc->req); |
|---|
| 335 | + struct crypto_sync_skcipher *tfm = |
|---|
| 336 | + crypto_sync_skcipher_reqtfm(desc->req); |
|---|
| 470 | 337 | struct page *in_page; |
|---|
| 471 | 338 | int thislen = desc->fraglen + sg->length; |
|---|
| 472 | 339 | int fraglen, ret; |
|---|
| .. | .. |
|---|
| 492 | 359 | desc->fraglen += sg->length; |
|---|
| 493 | 360 | desc->pos += sg->length; |
|---|
| 494 | 361 | |
|---|
| 495 | | - fraglen = thislen & (crypto_skcipher_blocksize(tfm) - 1); |
|---|
| 362 | + fraglen = thislen & (crypto_sync_skcipher_blocksize(tfm) - 1); |
|---|
| 496 | 363 | thislen -= fraglen; |
|---|
| 497 | 364 | |
|---|
| 498 | 365 | if (thislen == 0) |
|---|
| .. | .. |
|---|
| 526 | 393 | } |
|---|
| 527 | 394 | |
|---|
| 528 | 395 | int |
|---|
| 529 | | -gss_encrypt_xdr_buf(struct crypto_skcipher *tfm, struct xdr_buf *buf, |
|---|
| 396 | +gss_encrypt_xdr_buf(struct crypto_sync_skcipher *tfm, struct xdr_buf *buf, |
|---|
| 530 | 397 | int offset, struct page **pages) |
|---|
| 531 | 398 | { |
|---|
| 532 | 399 | int ret; |
|---|
| 533 | 400 | struct encryptor_desc desc; |
|---|
| 534 | | - SKCIPHER_REQUEST_ON_STACK(req, tfm); |
|---|
| 401 | + SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm); |
|---|
| 535 | 402 | |
|---|
| 536 | | - BUG_ON((buf->len - offset) % crypto_skcipher_blocksize(tfm) != 0); |
|---|
| 403 | + BUG_ON((buf->len - offset) % crypto_sync_skcipher_blocksize(tfm) != 0); |
|---|
| 537 | 404 | |
|---|
| 538 | | - skcipher_request_set_tfm(req, tfm); |
|---|
| 405 | + skcipher_request_set_sync_tfm(req, tfm); |
|---|
| 539 | 406 | skcipher_request_set_callback(req, 0, NULL, NULL); |
|---|
| 540 | 407 | |
|---|
| 541 | 408 | memset(desc.iv, 0, sizeof(desc.iv)); |
|---|
| .. | .. |
|---|
| 567 | 434 | { |
|---|
| 568 | 435 | struct decryptor_desc *desc = data; |
|---|
| 569 | 436 | int thislen = desc->fraglen + sg->length; |
|---|
| 570 | | - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(desc->req); |
|---|
| 437 | + struct crypto_sync_skcipher *tfm = |
|---|
| 438 | + crypto_sync_skcipher_reqtfm(desc->req); |
|---|
| 571 | 439 | int fraglen, ret; |
|---|
| 572 | 440 | |
|---|
| 573 | 441 | /* Worst case is 4 fragments: head, end of page 1, start |
|---|
| .. | .. |
|---|
| 578 | 446 | desc->fragno++; |
|---|
| 579 | 447 | desc->fraglen += sg->length; |
|---|
| 580 | 448 | |
|---|
| 581 | | - fraglen = thislen & (crypto_skcipher_blocksize(tfm) - 1); |
|---|
| 449 | + fraglen = thislen & (crypto_sync_skcipher_blocksize(tfm) - 1); |
|---|
| 582 | 450 | thislen -= fraglen; |
|---|
| 583 | 451 | |
|---|
| 584 | 452 | if (thislen == 0) |
|---|
| .. | .. |
|---|
| 608 | 476 | } |
|---|
| 609 | 477 | |
|---|
| 610 | 478 | int |
|---|
| 611 | | -gss_decrypt_xdr_buf(struct crypto_skcipher *tfm, struct xdr_buf *buf, |
|---|
| 479 | +gss_decrypt_xdr_buf(struct crypto_sync_skcipher *tfm, struct xdr_buf *buf, |
|---|
| 612 | 480 | int offset) |
|---|
| 613 | 481 | { |
|---|
| 614 | 482 | int ret; |
|---|
| 615 | 483 | struct decryptor_desc desc; |
|---|
| 616 | | - SKCIPHER_REQUEST_ON_STACK(req, tfm); |
|---|
| 484 | + SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm); |
|---|
| 617 | 485 | |
|---|
| 618 | 486 | /* XXXJBF: */ |
|---|
| 619 | | - BUG_ON((buf->len - offset) % crypto_skcipher_blocksize(tfm) != 0); |
|---|
| 487 | + BUG_ON((buf->len - offset) % crypto_sync_skcipher_blocksize(tfm) != 0); |
|---|
| 620 | 488 | |
|---|
| 621 | | - skcipher_request_set_tfm(req, tfm); |
|---|
| 489 | + skcipher_request_set_sync_tfm(req, tfm); |
|---|
| 622 | 490 | skcipher_request_set_callback(req, 0, NULL, NULL); |
|---|
| 623 | 491 | |
|---|
| 624 | 492 | memset(desc.iv, 0, sizeof(desc.iv)); |
|---|
| .. | .. |
|---|
| 672 | 540 | } |
|---|
| 673 | 541 | |
|---|
| 674 | 542 | static u32 |
|---|
| 675 | | -gss_krb5_cts_crypt(struct crypto_skcipher *cipher, struct xdr_buf *buf, |
|---|
| 543 | +gss_krb5_cts_crypt(struct crypto_sync_skcipher *cipher, struct xdr_buf *buf, |
|---|
| 676 | 544 | u32 offset, u8 *iv, struct page **pages, int encrypt) |
|---|
| 677 | 545 | { |
|---|
| 678 | 546 | u32 ret; |
|---|
| 679 | 547 | struct scatterlist sg[1]; |
|---|
| 680 | | - SKCIPHER_REQUEST_ON_STACK(req, cipher); |
|---|
| 548 | + SYNC_SKCIPHER_REQUEST_ON_STACK(req, cipher); |
|---|
| 681 | 549 | u8 *data; |
|---|
| 682 | 550 | struct page **save_pages; |
|---|
| 683 | 551 | u32 len = buf->len - offset; |
|---|
| .. | .. |
|---|
| 706 | 574 | |
|---|
| 707 | 575 | sg_init_one(sg, data, len); |
|---|
| 708 | 576 | |
|---|
| 709 | | - skcipher_request_set_tfm(req, cipher); |
|---|
| 577 | + skcipher_request_set_sync_tfm(req, cipher); |
|---|
| 710 | 578 | skcipher_request_set_callback(req, 0, NULL, NULL); |
|---|
| 711 | 579 | skcipher_request_set_crypt(req, sg, sg, len, iv); |
|---|
| 712 | 580 | |
|---|
| .. | .. |
|---|
| 735 | 603 | struct xdr_netobj hmac; |
|---|
| 736 | 604 | u8 *cksumkey; |
|---|
| 737 | 605 | u8 *ecptr; |
|---|
| 738 | | - struct crypto_skcipher *cipher, *aux_cipher; |
|---|
| 606 | + struct crypto_sync_skcipher *cipher, *aux_cipher; |
|---|
| 739 | 607 | int blocksize; |
|---|
| 740 | 608 | struct page **save_pages; |
|---|
| 741 | 609 | int nblocks, nbytes; |
|---|
| .. | .. |
|---|
| 754 | 622 | cksumkey = kctx->acceptor_integ; |
|---|
| 755 | 623 | usage = KG_USAGE_ACCEPTOR_SEAL; |
|---|
| 756 | 624 | } |
|---|
| 757 | | - blocksize = crypto_skcipher_blocksize(cipher); |
|---|
| 625 | + blocksize = crypto_sync_skcipher_blocksize(cipher); |
|---|
| 758 | 626 | |
|---|
| 759 | 627 | /* hide the gss token header and insert the confounder */ |
|---|
| 760 | 628 | offset += GSS_KRB5_TOK_HDR_LEN; |
|---|
| .. | .. |
|---|
| 807 | 675 | memset(desc.iv, 0, sizeof(desc.iv)); |
|---|
| 808 | 676 | |
|---|
| 809 | 677 | if (cbcbytes) { |
|---|
| 810 | | - SKCIPHER_REQUEST_ON_STACK(req, aux_cipher); |
|---|
| 678 | + SYNC_SKCIPHER_REQUEST_ON_STACK(req, aux_cipher); |
|---|
| 811 | 679 | |
|---|
| 812 | 680 | desc.pos = offset + GSS_KRB5_TOK_HDR_LEN; |
|---|
| 813 | 681 | desc.fragno = 0; |
|---|
| .. | .. |
|---|
| 816 | 684 | desc.outbuf = buf; |
|---|
| 817 | 685 | desc.req = req; |
|---|
| 818 | 686 | |
|---|
| 819 | | - skcipher_request_set_tfm(req, aux_cipher); |
|---|
| 687 | + skcipher_request_set_sync_tfm(req, aux_cipher); |
|---|
| 820 | 688 | skcipher_request_set_callback(req, 0, NULL, NULL); |
|---|
| 821 | 689 | |
|---|
| 822 | 690 | sg_init_table(desc.infrags, 4); |
|---|
| .. | .. |
|---|
| 849 | 717 | } |
|---|
| 850 | 718 | |
|---|
| 851 | 719 | u32 |
|---|
| 852 | | -gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, struct xdr_buf *buf, |
|---|
| 853 | | - u32 *headskip, u32 *tailskip) |
|---|
| 720 | +gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, u32 len, |
|---|
| 721 | + struct xdr_buf *buf, u32 *headskip, u32 *tailskip) |
|---|
| 854 | 722 | { |
|---|
| 855 | 723 | struct xdr_buf subbuf; |
|---|
| 856 | 724 | u32 ret = 0; |
|---|
| 857 | 725 | u8 *cksum_key; |
|---|
| 858 | | - struct crypto_skcipher *cipher, *aux_cipher; |
|---|
| 726 | + struct crypto_sync_skcipher *cipher, *aux_cipher; |
|---|
| 859 | 727 | struct xdr_netobj our_hmac_obj; |
|---|
| 860 | 728 | u8 our_hmac[GSS_KRB5_MAX_CKSUM_LEN]; |
|---|
| 861 | 729 | u8 pkt_hmac[GSS_KRB5_MAX_CKSUM_LEN]; |
|---|
| .. | .. |
|---|
| 874 | 742 | cksum_key = kctx->initiator_integ; |
|---|
| 875 | 743 | usage = KG_USAGE_INITIATOR_SEAL; |
|---|
| 876 | 744 | } |
|---|
| 877 | | - blocksize = crypto_skcipher_blocksize(cipher); |
|---|
| 745 | + blocksize = crypto_sync_skcipher_blocksize(cipher); |
|---|
| 878 | 746 | |
|---|
| 879 | 747 | |
|---|
| 880 | 748 | /* create a segment skipping the header and leaving out the checksum */ |
|---|
| 881 | 749 | xdr_buf_subsegment(buf, &subbuf, offset + GSS_KRB5_TOK_HDR_LEN, |
|---|
| 882 | | - (buf->len - offset - GSS_KRB5_TOK_HDR_LEN - |
|---|
| 750 | + (len - offset - GSS_KRB5_TOK_HDR_LEN - |
|---|
| 883 | 751 | kctx->gk5e->cksumlength)); |
|---|
| 884 | 752 | |
|---|
| 885 | 753 | nblocks = (subbuf.len + blocksize - 1) / blocksize; |
|---|
| .. | .. |
|---|
| 891 | 759 | memset(desc.iv, 0, sizeof(desc.iv)); |
|---|
| 892 | 760 | |
|---|
| 893 | 761 | if (cbcbytes) { |
|---|
| 894 | | - SKCIPHER_REQUEST_ON_STACK(req, aux_cipher); |
|---|
| 762 | + SYNC_SKCIPHER_REQUEST_ON_STACK(req, aux_cipher); |
|---|
| 895 | 763 | |
|---|
| 896 | 764 | desc.fragno = 0; |
|---|
| 897 | 765 | desc.fraglen = 0; |
|---|
| 898 | 766 | desc.req = req; |
|---|
| 899 | 767 | |
|---|
| 900 | | - skcipher_request_set_tfm(req, aux_cipher); |
|---|
| 768 | + skcipher_request_set_sync_tfm(req, aux_cipher); |
|---|
| 901 | 769 | skcipher_request_set_callback(req, 0, NULL, NULL); |
|---|
| 902 | 770 | |
|---|
| 903 | 771 | sg_init_table(desc.frags, 4); |
|---|
| .. | .. |
|---|
| 924 | 792 | goto out_err; |
|---|
| 925 | 793 | |
|---|
| 926 | 794 | /* Get the packet's hmac value */ |
|---|
| 927 | | - ret = read_bytes_from_xdr_buf(buf, buf->len - kctx->gk5e->cksumlength, |
|---|
| 795 | + ret = read_bytes_from_xdr_buf(buf, len - kctx->gk5e->cksumlength, |
|---|
| 928 | 796 | pkt_hmac, kctx->gk5e->cksumlength); |
|---|
| 929 | 797 | if (ret) |
|---|
| 930 | 798 | goto out_err; |
|---|
| .. | .. |
|---|
| 939 | 807 | if (ret && ret != GSS_S_BAD_SIG) |
|---|
| 940 | 808 | ret = GSS_S_FAILURE; |
|---|
| 941 | 809 | return ret; |
|---|
| 942 | | -} |
|---|
| 943 | | - |
|---|
| 944 | | -/* |
|---|
| 945 | | - * Compute Kseq given the initial session key and the checksum. |
|---|
| 946 | | - * Set the key of the given cipher. |
|---|
| 947 | | - */ |
|---|
| 948 | | -int |
|---|
| 949 | | -krb5_rc4_setup_seq_key(struct krb5_ctx *kctx, struct crypto_skcipher *cipher, |
|---|
| 950 | | - unsigned char *cksum) |
|---|
| 951 | | -{ |
|---|
| 952 | | - struct crypto_shash *hmac; |
|---|
| 953 | | - struct shash_desc *desc; |
|---|
| 954 | | - u8 Kseq[GSS_KRB5_MAX_KEYLEN]; |
|---|
| 955 | | - u32 zeroconstant = 0; |
|---|
| 956 | | - int err; |
|---|
| 957 | | - |
|---|
| 958 | | - dprintk("%s: entered\n", __func__); |
|---|
| 959 | | - |
|---|
| 960 | | - hmac = crypto_alloc_shash(kctx->gk5e->cksum_name, 0, 0); |
|---|
| 961 | | - if (IS_ERR(hmac)) { |
|---|
| 962 | | - dprintk("%s: error %ld, allocating hash '%s'\n", |
|---|
| 963 | | - __func__, PTR_ERR(hmac), kctx->gk5e->cksum_name); |
|---|
| 964 | | - return PTR_ERR(hmac); |
|---|
| 965 | | - } |
|---|
| 966 | | - |
|---|
| 967 | | - desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac), |
|---|
| 968 | | - GFP_NOFS); |
|---|
| 969 | | - if (!desc) { |
|---|
| 970 | | - dprintk("%s: failed to allocate shash descriptor for '%s'\n", |
|---|
| 971 | | - __func__, kctx->gk5e->cksum_name); |
|---|
| 972 | | - crypto_free_shash(hmac); |
|---|
| 973 | | - return -ENOMEM; |
|---|
| 974 | | - } |
|---|
| 975 | | - |
|---|
| 976 | | - desc->tfm = hmac; |
|---|
| 977 | | - desc->flags = 0; |
|---|
| 978 | | - |
|---|
| 979 | | - /* Compute intermediate Kseq from session key */ |
|---|
| 980 | | - err = crypto_shash_setkey(hmac, kctx->Ksess, kctx->gk5e->keylength); |
|---|
| 981 | | - if (err) |
|---|
| 982 | | - goto out_err; |
|---|
| 983 | | - |
|---|
| 984 | | - err = crypto_shash_digest(desc, (u8 *)&zeroconstant, 4, Kseq); |
|---|
| 985 | | - if (err) |
|---|
| 986 | | - goto out_err; |
|---|
| 987 | | - |
|---|
| 988 | | - /* Compute final Kseq from the checksum and intermediate Kseq */ |
|---|
| 989 | | - err = crypto_shash_setkey(hmac, Kseq, kctx->gk5e->keylength); |
|---|
| 990 | | - if (err) |
|---|
| 991 | | - goto out_err; |
|---|
| 992 | | - |
|---|
| 993 | | - err = crypto_shash_digest(desc, cksum, 8, Kseq); |
|---|
| 994 | | - if (err) |
|---|
| 995 | | - goto out_err; |
|---|
| 996 | | - |
|---|
| 997 | | - err = crypto_skcipher_setkey(cipher, Kseq, kctx->gk5e->keylength); |
|---|
| 998 | | - if (err) |
|---|
| 999 | | - goto out_err; |
|---|
| 1000 | | - |
|---|
| 1001 | | - err = 0; |
|---|
| 1002 | | - |
|---|
| 1003 | | -out_err: |
|---|
| 1004 | | - kzfree(desc); |
|---|
| 1005 | | - crypto_free_shash(hmac); |
|---|
| 1006 | | - dprintk("%s: returning %d\n", __func__, err); |
|---|
| 1007 | | - return err; |
|---|
| 1008 | | -} |
|---|
| 1009 | | - |
|---|
| 1010 | | -/* |
|---|
| 1011 | | - * Compute Kcrypt given the initial session key and the plaintext seqnum. |
|---|
| 1012 | | - * Set the key of cipher kctx->enc. |
|---|
| 1013 | | - */ |
|---|
| 1014 | | -int |
|---|
| 1015 | | -krb5_rc4_setup_enc_key(struct krb5_ctx *kctx, struct crypto_skcipher *cipher, |
|---|
| 1016 | | - s32 seqnum) |
|---|
| 1017 | | -{ |
|---|
| 1018 | | - struct crypto_shash *hmac; |
|---|
| 1019 | | - struct shash_desc *desc; |
|---|
| 1020 | | - u8 Kcrypt[GSS_KRB5_MAX_KEYLEN]; |
|---|
| 1021 | | - u8 zeroconstant[4] = {0}; |
|---|
| 1022 | | - u8 seqnumarray[4]; |
|---|
| 1023 | | - int err, i; |
|---|
| 1024 | | - |
|---|
| 1025 | | - dprintk("%s: entered, seqnum %u\n", __func__, seqnum); |
|---|
| 1026 | | - |
|---|
| 1027 | | - hmac = crypto_alloc_shash(kctx->gk5e->cksum_name, 0, 0); |
|---|
| 1028 | | - if (IS_ERR(hmac)) { |
|---|
| 1029 | | - dprintk("%s: error %ld, allocating hash '%s'\n", |
|---|
| 1030 | | - __func__, PTR_ERR(hmac), kctx->gk5e->cksum_name); |
|---|
| 1031 | | - return PTR_ERR(hmac); |
|---|
| 1032 | | - } |
|---|
| 1033 | | - |
|---|
| 1034 | | - desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac), |
|---|
| 1035 | | - GFP_NOFS); |
|---|
| 1036 | | - if (!desc) { |
|---|
| 1037 | | - dprintk("%s: failed to allocate shash descriptor for '%s'\n", |
|---|
| 1038 | | - __func__, kctx->gk5e->cksum_name); |
|---|
| 1039 | | - crypto_free_shash(hmac); |
|---|
| 1040 | | - return -ENOMEM; |
|---|
| 1041 | | - } |
|---|
| 1042 | | - |
|---|
| 1043 | | - desc->tfm = hmac; |
|---|
| 1044 | | - desc->flags = 0; |
|---|
| 1045 | | - |
|---|
| 1046 | | - /* Compute intermediate Kcrypt from session key */ |
|---|
| 1047 | | - for (i = 0; i < kctx->gk5e->keylength; i++) |
|---|
| 1048 | | - Kcrypt[i] = kctx->Ksess[i] ^ 0xf0; |
|---|
| 1049 | | - |
|---|
| 1050 | | - err = crypto_shash_setkey(hmac, Kcrypt, kctx->gk5e->keylength); |
|---|
| 1051 | | - if (err) |
|---|
| 1052 | | - goto out_err; |
|---|
| 1053 | | - |
|---|
| 1054 | | - err = crypto_shash_digest(desc, zeroconstant, 4, Kcrypt); |
|---|
| 1055 | | - if (err) |
|---|
| 1056 | | - goto out_err; |
|---|
| 1057 | | - |
|---|
| 1058 | | - /* Compute final Kcrypt from the seqnum and intermediate Kcrypt */ |
|---|
| 1059 | | - err = crypto_shash_setkey(hmac, Kcrypt, kctx->gk5e->keylength); |
|---|
| 1060 | | - if (err) |
|---|
| 1061 | | - goto out_err; |
|---|
| 1062 | | - |
|---|
| 1063 | | - seqnumarray[0] = (unsigned char) ((seqnum >> 24) & 0xff); |
|---|
| 1064 | | - seqnumarray[1] = (unsigned char) ((seqnum >> 16) & 0xff); |
|---|
| 1065 | | - seqnumarray[2] = (unsigned char) ((seqnum >> 8) & 0xff); |
|---|
| 1066 | | - seqnumarray[3] = (unsigned char) ((seqnum >> 0) & 0xff); |
|---|
| 1067 | | - |
|---|
| 1068 | | - err = crypto_shash_digest(desc, seqnumarray, 4, Kcrypt); |
|---|
| 1069 | | - if (err) |
|---|
| 1070 | | - goto out_err; |
|---|
| 1071 | | - |
|---|
| 1072 | | - err = crypto_skcipher_setkey(cipher, Kcrypt, kctx->gk5e->keylength); |
|---|
| 1073 | | - if (err) |
|---|
| 1074 | | - goto out_err; |
|---|
| 1075 | | - |
|---|
| 1076 | | - err = 0; |
|---|
| 1077 | | - |
|---|
| 1078 | | -out_err: |
|---|
| 1079 | | - kzfree(desc); |
|---|
| 1080 | | - crypto_free_shash(hmac); |
|---|
| 1081 | | - dprintk("%s: returning %d\n", __func__, err); |
|---|
| 1082 | | - return err; |
|---|
| 1083 | 810 | } |
|---|