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

+18 -10
+15 -9
crypto/authenc.c
··· 158 158 dstp = sg_page(dst); 159 159 vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset; 160 160 161 - sg_init_table(cipher, 2); 162 - sg_set_buf(cipher, iv, ivsize); 163 - authenc_chain(cipher, dst, vdst == iv + ivsize); 161 + if (ivsize) { 162 + sg_init_table(cipher, 2); 163 + sg_set_buf(cipher, iv, ivsize); 164 + authenc_chain(cipher, dst, vdst == iv + ivsize); 165 + dst = cipher; 166 + } 164 167 165 168 cryptlen = req->cryptlen + ivsize; 166 - hash = crypto_authenc_hash(req, flags, cipher, cryptlen); 169 + hash = crypto_authenc_hash(req, flags, dst, cryptlen); 167 170 if (IS_ERR(hash)) 168 171 return PTR_ERR(hash); 169 172 170 - scatterwalk_map_and_copy(hash, cipher, cryptlen, 173 + scatterwalk_map_and_copy(hash, dst, cryptlen, 171 174 crypto_aead_authsize(authenc), 1); 172 175 return 0; 173 176 } ··· 288 285 srcp = sg_page(src); 289 286 vsrc = PageHighMem(srcp) ? NULL : page_address(srcp) + src->offset; 290 287 291 - sg_init_table(cipher, 2); 292 - sg_set_buf(cipher, iv, ivsize); 293 - authenc_chain(cipher, src, vsrc == iv + ivsize); 288 + if (ivsize) { 289 + sg_init_table(cipher, 2); 290 + sg_set_buf(cipher, iv, ivsize); 291 + authenc_chain(cipher, src, vsrc == iv + ivsize); 292 + src = cipher; 293 + } 294 294 295 - return crypto_authenc_verify(req, cipher, cryptlen + ivsize); 295 + return crypto_authenc_verify(req, src, cryptlen + ivsize); 296 296 } 297 297 298 298 static int crypto_authenc_decrypt(struct aead_request *req)
+1 -1
crypto/blkcipher.c
··· 124 124 scatterwalk_done(&walk->in, 0, nbytes); 125 125 scatterwalk_done(&walk->out, 1, nbytes); 126 126 127 + err: 127 128 walk->total = nbytes; 128 129 walk->nbytes = nbytes; 129 130 ··· 133 132 return blkcipher_walk_next(desc, walk); 134 133 } 135 134 136 - err: 137 135 if (walk->iv != desc->info) 138 136 memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm)); 139 137 if (walk->buffer != walk->page)
+2
crypto/ccm.c
··· 266 266 if (assoclen) { 267 267 pctx->ilen = format_adata(idata, assoclen); 268 268 get_data_to_compute(cipher, pctx, req->assoc, req->assoclen); 269 + } else { 270 + pctx->ilen = 0; 269 271 } 270 272 271 273 /* compute plaintext into mac */