Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fixes from Herbert Xu:
"This fixes a regression in RSA that was only half-fixed earlier in the
cycle. It also fixes an older regression that breaks the keyring
subsystem"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: rsa-pkcs1pad - Handle leading zero for decryption
KEYS: Fix skcipher IV clobbering

+31 -21
+24 -17
crypto/rsa-pkcs1pad.c
··· 298 298 struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req); 299 299 struct pkcs1pad_ctx *ctx = akcipher_tfm_ctx(tfm); 300 300 struct pkcs1pad_request *req_ctx = akcipher_request_ctx(req); 301 + unsigned int dst_len; 301 302 unsigned int pos; 302 - 303 - if (err == -EOVERFLOW) 304 - /* Decrypted value had no leading 0 byte */ 305 - err = -EINVAL; 303 + u8 *out_buf; 306 304 307 305 if (err) 308 306 goto done; 309 307 310 - if (req_ctx->child_req.dst_len != ctx->key_size - 1) { 311 - err = -EINVAL; 308 + err = -EINVAL; 309 + dst_len = req_ctx->child_req.dst_len; 310 + if (dst_len < ctx->key_size - 1) 312 311 goto done; 312 + 313 + out_buf = req_ctx->out_buf; 314 + if (dst_len == ctx->key_size) { 315 + if (out_buf[0] != 0x00) 316 + /* Decrypted value had no leading 0 byte */ 317 + goto done; 318 + 319 + dst_len--; 320 + out_buf++; 313 321 } 314 322 315 - if (req_ctx->out_buf[0] != 0x02) { 316 - err = -EINVAL; 323 + if (out_buf[0] != 0x02) 317 324 goto done; 318 - } 319 - for (pos = 1; pos < req_ctx->child_req.dst_len; pos++) 320 - if (req_ctx->out_buf[pos] == 0x00) 325 + 326 + for (pos = 1; pos < dst_len; pos++) 327 + if (out_buf[pos] == 0x00) 321 328 break; 322 - if (pos < 9 || pos == req_ctx->child_req.dst_len) { 323 - err = -EINVAL; 329 + if (pos < 9 || pos == dst_len) 324 330 goto done; 325 - } 326 331 pos++; 327 332 328 - if (req->dst_len < req_ctx->child_req.dst_len - pos) 333 + err = 0; 334 + 335 + if (req->dst_len < dst_len - pos) 329 336 err = -EOVERFLOW; 330 - req->dst_len = req_ctx->child_req.dst_len - pos; 337 + req->dst_len = dst_len - pos; 331 338 332 339 if (!err) 333 340 sg_copy_from_buffer(req->dst, 334 341 sg_nents_for_len(req->dst, req->dst_len), 335 - req_ctx->out_buf + pos, req->dst_len); 342 + out_buf + pos, req->dst_len); 336 343 337 344 done: 338 345 kzfree(req_ctx->out_buf);
+7 -4
security/keys/encrypted-keys/encrypted.c
··· 29 29 #include <linux/rcupdate.h> 30 30 #include <linux/scatterlist.h> 31 31 #include <linux/ctype.h> 32 + #include <crypto/aes.h> 32 33 #include <crypto/hash.h> 33 34 #include <crypto/sha.h> 34 35 #include <crypto/skcipher.h> ··· 479 478 struct crypto_skcipher *tfm; 480 479 struct skcipher_request *req; 481 480 unsigned int encrypted_datalen; 481 + u8 iv[AES_BLOCK_SIZE]; 482 482 unsigned int padlen; 483 483 char pad[16]; 484 484 int ret; ··· 502 500 sg_init_table(sg_out, 1); 503 501 sg_set_buf(sg_out, epayload->encrypted_data, encrypted_datalen); 504 502 505 - skcipher_request_set_crypt(req, sg_in, sg_out, encrypted_datalen, 506 - epayload->iv); 503 + memcpy(iv, epayload->iv, sizeof(iv)); 504 + skcipher_request_set_crypt(req, sg_in, sg_out, encrypted_datalen, iv); 507 505 ret = crypto_skcipher_encrypt(req); 508 506 tfm = crypto_skcipher_reqtfm(req); 509 507 skcipher_request_free(req); ··· 583 581 struct crypto_skcipher *tfm; 584 582 struct skcipher_request *req; 585 583 unsigned int encrypted_datalen; 584 + u8 iv[AES_BLOCK_SIZE]; 586 585 char pad[16]; 587 586 int ret; 588 587 ··· 602 599 epayload->decrypted_datalen); 603 600 sg_set_buf(&sg_out[1], pad, sizeof pad); 604 601 605 - skcipher_request_set_crypt(req, sg_in, sg_out, encrypted_datalen, 606 - epayload->iv); 602 + memcpy(iv, epayload->iv, sizeof(iv)); 603 + skcipher_request_set_crypt(req, sg_in, sg_out, encrypted_datalen, iv); 607 604 ret = crypto_skcipher_decrypt(req); 608 605 tfm = crypto_skcipher_reqtfm(req); 609 606 skcipher_request_free(req);