forked from Minki/linux
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:
parent
836d8f43c5
commit
68a51394f3
@ -376,6 +376,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);
|
||||
@ -439,6 +444,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);
|
||||
@ -503,6 +513,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);
|
||||
|
||||
|
@ -371,6 +371,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);
|
||||
@ -472,6 +477,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);
|
||||
@ -578,6 +588,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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user