crypto: ccp - copy IV using skcipher ivsize
[ Upstream commit a7a1f3cdd64d8a165d9b8c9e9ad7fb46ac19dfc4 ]
AF_ALG rfc3686-ctr-aes-ccp requests pass an 8-byte IV to the driver.
ccp_aes_complete() restores AES_BLOCK_SIZE bytes into the caller's IV
buffer while RFC3686 skciphers expose an 8-byte IV, so the restore
overruns the provided buffer.
Use crypto_skcipher_ivsize() to copy only the algorithm's IV length.
Fixes: 2b789435d7 ("crypto: ccp - CCP AES crypto API support")
Signed-off-by: Paul Moses <p@1g4.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
[uli: backport to 4.19]
Signed-off-by: Ulrich Hecht <uli@kernel.org>
Reviewed-by: Pavel Machek <pavel@nabladev.com>
Reviewed-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>
This commit is contained in:
1 parent
15b89e406f
commit
215e0c0cb9
1 file changed
+5
-2
@@ -32,8 +32,11 @@ static int ccp_aes_complete(struct crypto_async_request *async_req, int ret)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (ctx->u.aes.mode != CCP_AES_MODE_ECB)
|
||||
memcpy(req->info, rctx->iv, AES_BLOCK_SIZE);
|
||||
if (ctx->u.aes.mode != CCP_AES_MODE_ECB) {
|
||||
size_t ivsize = crypto_ablkcipher_ivsize(crypto_ablkcipher_reqtfm(req));
|
||||
|
||||
memcpy(req->info, rctx->iv, ivsize);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user