mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
crypto: caam - check authsize
Check authsize to solve the extra tests that expect -EINVAL to be returned when the authentication tag size is not valid. Validated authsize for GCM, RFC4106 and RFC4543. Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com> Reviewed-by: Horia Geanta <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
836d8f43c5
commit
68a51394f3
@@ -720,6 +720,11 @@ static int gcm_set_sh_desc(struct crypto_aead *aead)
|
||||
static int gcm_setauthsize(struct crypto_aead *authenc, unsigned int authsize)
|
||||
{
|
||||
struct caam_ctx *ctx = crypto_aead_ctx(authenc);
|
||||
int err;
|
||||
|
||||
err = crypto_gcm_check_authsize(authsize);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ctx->authsize = authsize;
|
||||
gcm_set_sh_desc(authenc);
|
||||
@@ -812,6 +817,11 @@ static int rfc4106_setauthsize(struct crypto_aead *authenc,
|
||||
unsigned int authsize)
|
||||
{
|
||||
struct caam_ctx *ctx = crypto_aead_ctx(authenc);
|
||||
int err;
|
||||
|
||||
err = crypto_rfc4106_check_authsize(authsize);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ctx->authsize = authsize;
|
||||
rfc4106_set_sh_desc(authenc);
|
||||
@@ -911,6 +921,9 @@ static int rfc4543_setauthsize(struct crypto_aead *authenc,
|
||||
{
|
||||
struct caam_ctx *ctx = crypto_aead_ctx(authenc);
|
||||
|
||||
if (authsize != 16)
|
||||
return -EINVAL;
|
||||
|
||||
ctx->authsize = authsize;
|
||||
rfc4543_set_sh_desc(authenc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user