Commit 5761498c authored by Kai Ye's avatar Kai Ye Committed by Herbert Xu

crypto: hisilicon/sec2 - Fix aead authentication setting key error

Fix aead auth setting key process error. if use soft shash function, driver
need to use digest size replace of the user input key length.
Signed-off-by: default avatarKai Ye <yekai13@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c4fc6328
...@@ -857,7 +857,7 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx, ...@@ -857,7 +857,7 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx,
struct crypto_authenc_keys *keys) struct crypto_authenc_keys *keys)
{ {
struct crypto_shash *hash_tfm = ctx->hash_tfm; struct crypto_shash *hash_tfm = ctx->hash_tfm;
int blocksize, ret; int blocksize, digestsize, ret;
if (!keys->authkeylen) { if (!keys->authkeylen) {
pr_err("hisi_sec2: aead auth key error!\n"); pr_err("hisi_sec2: aead auth key error!\n");
...@@ -865,6 +865,7 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx, ...@@ -865,6 +865,7 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx,
} }
blocksize = crypto_shash_blocksize(hash_tfm); blocksize = crypto_shash_blocksize(hash_tfm);
digestsize = crypto_shash_digestsize(hash_tfm);
if (keys->authkeylen > blocksize) { if (keys->authkeylen > blocksize) {
ret = crypto_shash_tfm_digest(hash_tfm, keys->authkey, ret = crypto_shash_tfm_digest(hash_tfm, keys->authkey,
keys->authkeylen, ctx->a_key); keys->authkeylen, ctx->a_key);
...@@ -872,7 +873,7 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx, ...@@ -872,7 +873,7 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx,
pr_err("hisi_sec2: aead auth digest error!\n"); pr_err("hisi_sec2: aead auth digest error!\n");
return -EINVAL; return -EINVAL;
} }
ctx->a_key_len = blocksize; ctx->a_key_len = digestsize;
} else { } else {
memcpy(ctx->a_key, keys->authkey, keys->authkeylen); memcpy(ctx->a_key, keys->authkey, keys->authkeylen);
ctx->a_key_len = keys->authkeylen; ctx->a_key_len = keys->authkeylen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment