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
This commit is contained in:
@@ -158,16 +158,19 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv,
|
|||||||
dstp = sg_page(dst);
|
dstp = sg_page(dst);
|
||||||
vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset;
|
vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset;
|
||||||
|
|
||||||
|
if (ivsize) {
|
||||||
sg_init_table(cipher, 2);
|
sg_init_table(cipher, 2);
|
||||||
sg_set_buf(cipher, iv, ivsize);
|
sg_set_buf(cipher, iv, ivsize);
|
||||||
authenc_chain(cipher, dst, vdst == iv + ivsize);
|
authenc_chain(cipher, dst, vdst == iv + ivsize);
|
||||||
|
dst = cipher;
|
||||||
|
}
|
||||||
|
|
||||||
cryptlen = req->cryptlen + ivsize;
|
cryptlen = req->cryptlen + ivsize;
|
||||||
hash = crypto_authenc_hash(req, flags, cipher, cryptlen);
|
hash = crypto_authenc_hash(req, flags, dst, cryptlen);
|
||||||
if (IS_ERR(hash))
|
if (IS_ERR(hash))
|
||||||
return PTR_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);
|
crypto_aead_authsize(authenc), 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -285,11 +288,14 @@ static int crypto_authenc_iverify(struct aead_request *req, u8 *iv,
|
|||||||
srcp = sg_page(src);
|
srcp = sg_page(src);
|
||||||
vsrc = PageHighMem(srcp) ? NULL : page_address(srcp) + src->offset;
|
vsrc = PageHighMem(srcp) ? NULL : page_address(srcp) + src->offset;
|
||||||
|
|
||||||
|
if (ivsize) {
|
||||||
sg_init_table(cipher, 2);
|
sg_init_table(cipher, 2);
|
||||||
sg_set_buf(cipher, iv, ivsize);
|
sg_set_buf(cipher, iv, ivsize);
|
||||||
authenc_chain(cipher, src, vsrc == 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)
|
static int crypto_authenc_decrypt(struct aead_request *req)
|
||||||
|
@@ -124,6 +124,7 @@ int blkcipher_walk_done(struct blkcipher_desc *desc,
|
|||||||
scatterwalk_done(&walk->in, 0, nbytes);
|
scatterwalk_done(&walk->in, 0, nbytes);
|
||||||
scatterwalk_done(&walk->out, 1, nbytes);
|
scatterwalk_done(&walk->out, 1, nbytes);
|
||||||
|
|
||||||
|
err:
|
||||||
walk->total = nbytes;
|
walk->total = nbytes;
|
||||||
walk->nbytes = nbytes;
|
walk->nbytes = nbytes;
|
||||||
|
|
||||||
@@ -132,7 +133,6 @@ int blkcipher_walk_done(struct blkcipher_desc *desc,
|
|||||||
return blkcipher_walk_next(desc, walk);
|
return blkcipher_walk_next(desc, walk);
|
||||||
}
|
}
|
||||||
|
|
||||||
err:
|
|
||||||
if (walk->iv != desc->info)
|
if (walk->iv != desc->info)
|
||||||
memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm));
|
memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm));
|
||||||
if (walk->buffer != walk->page)
|
if (walk->buffer != walk->page)
|
||||||
|
@@ -266,6 +266,8 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain,
|
|||||||
if (assoclen) {
|
if (assoclen) {
|
||||||
pctx->ilen = format_adata(idata, assoclen);
|
pctx->ilen = format_adata(idata, assoclen);
|
||||||
get_data_to_compute(cipher, pctx, req->assoc, req->assoclen);
|
get_data_to_compute(cipher, pctx, req->assoc, req->assoclen);
|
||||||
|
} else {
|
||||||
|
pctx->ilen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute plaintext into mac */
|
/* compute plaintext into mac */
|
||||||
|
Reference in New Issue
Block a user