Commit 5761498c4d074560b38a203000afc6e971ffaa7f
Committed by
Herbert Xu
1 parent
c4fc6328d6
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: Kai Ye <yekai13@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 1 changed file with 3 additions and 2 deletions Side-by-side Diff
drivers/crypto/hisilicon/sec2/sec_crypto.c
... | ... | @@ -857,7 +857,7 @@ |
857 | 857 | struct crypto_authenc_keys *keys) |
858 | 858 | { |
859 | 859 | struct crypto_shash *hash_tfm = ctx->hash_tfm; |
860 | - int blocksize, ret; | |
860 | + int blocksize, digestsize, ret; | |
861 | 861 | |
862 | 862 | if (!keys->authkeylen) { |
863 | 863 | pr_err("hisi_sec2: aead auth key error!\n"); |
... | ... | @@ -865,6 +865,7 @@ |
865 | 865 | } |
866 | 866 | |
867 | 867 | blocksize = crypto_shash_blocksize(hash_tfm); |
868 | + digestsize = crypto_shash_digestsize(hash_tfm); | |
868 | 869 | if (keys->authkeylen > blocksize) { |
869 | 870 | ret = crypto_shash_tfm_digest(hash_tfm, keys->authkey, |
870 | 871 | keys->authkeylen, ctx->a_key); |
... | ... | @@ -872,7 +873,7 @@ |
872 | 873 | pr_err("hisi_sec2: aead auth digest error!\n"); |
873 | 874 | return -EINVAL; |
874 | 875 | } |
875 | - ctx->a_key_len = blocksize; | |
876 | + ctx->a_key_len = digestsize; | |
876 | 877 | } else { |
877 | 878 | memcpy(ctx->a_key, keys->authkey, keys->authkeylen); |
878 | 879 | ctx->a_key_len = keys->authkeylen; |