diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-27 07:46:29 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-27 07:46:29 -0800 |
commit | ff2bad5f899421850f7e9bc956450e4c61b0b95d (patch) | |
tree | 739acb3863f185a21a870dda6f50bfdc1c241044 /crypto/authenc.c | |
parent | 78d70d48132ce4c678a95b771ffa1af4fb5a03ec (diff) | |
parent | 516280e735b034216de97eb7ba080ec6acbfc58f (diff) | |
download | blackbird-obmc-linux-ff2bad5f899421850f7e9bc956450e4c61b0b95d.tar.gz blackbird-obmc-linux-ff2bad5f899421850f7e9bc956450e4c61b0b95d.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: ccm - Fix handling of null assoc data
crypto: blkcipher - Fix WARN_ON handling in walk_done
crypto: authenc - Fix zero-length IV crash
Diffstat (limited to 'crypto/authenc.c')
-rw-r--r-- | crypto/authenc.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/crypto/authenc.c b/crypto/authenc.c index 40b6e9ec9e3a..5793b64c81a8 100644 --- a/crypto/authenc.c +++ b/crypto/authenc.c @@ -158,16 +158,19 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv, dstp = sg_page(dst); vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset; - sg_init_table(cipher, 2); - sg_set_buf(cipher, iv, ivsize); - authenc_chain(cipher, dst, vdst == iv + ivsize); + if (ivsize) { + sg_init_table(cipher, 2); + sg_set_buf(cipher, iv, ivsize); + authenc_chain(cipher, dst, vdst == iv + ivsize); + dst = cipher; + } cryptlen = req->cryptlen + ivsize; - hash = crypto_authenc_hash(req, flags, cipher, cryptlen); + hash = crypto_authenc_hash(req, flags, dst, cryptlen); if (IS_ERR(hash)) return PTR_ERR(hash); - scatterwalk_map_and_copy(hash, cipher, cryptlen, + scatterwalk_map_and_copy(hash, dst, cryptlen, crypto_aead_authsize(authenc), 1); return 0; } @@ -285,11 +288,14 @@ static int crypto_authenc_iverify(struct aead_request *req, u8 *iv, srcp = sg_page(src); vsrc = PageHighMem(srcp) ? NULL : page_address(srcp) + src->offset; - sg_init_table(cipher, 2); - sg_set_buf(cipher, iv, ivsize); - authenc_chain(cipher, src, vsrc == iv + ivsize); + if (ivsize) { + sg_init_table(cipher, 2); + sg_set_buf(cipher, iv, ivsize); + authenc_chain(cipher, src, vsrc == iv + ivsize); + src = cipher; + } - return crypto_authenc_verify(req, cipher, cryptlen + ivsize); + return crypto_authenc_verify(req, src, cryptlen + ivsize); } static int crypto_authenc_decrypt(struct aead_request *req) |