Skip to content

Commit 6d6e71f

Browse files
larperaxisherbertx
authored andcommitted
crypto: artpec6 - set correct iv size for gcm(aes)
The IV size should not include the 32 bit counter. Because we had the IV size set as 16 the transform only worked when the IV input was zero padded. Fixes: a21eb94 ("crypto: axis - add ARTPEC-6/7 crypto accelerator driver") Signed-off-by: Lars Persson <larper@axis.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent f5c421d commit 6d6e71f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/crypto/axis/artpec6_crypto.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/slab.h>
2323

2424
#include <crypto/aes.h>
25+
#include <crypto/gcm.h>
2526
#include <crypto/internal/aead.h>
2627
#include <crypto/internal/hash.h>
2728
#include <crypto/internal/skcipher.h>
@@ -1934,7 +1935,7 @@ static int artpec6_crypto_prepare_aead(struct aead_request *areq)
19341935

19351936
memcpy(req_ctx->hw_ctx.J0, areq->iv, crypto_aead_ivsize(cipher));
19361937
// The HW omits the initial increment of the counter field.
1937-
crypto_inc(req_ctx->hw_ctx.J0+12, 4);
1938+
memcpy(req_ctx->hw_ctx.J0 + GCM_AES_IV_SIZE, "\x00\x00\x00\x01", 4);
19381939

19391940
ret = artpec6_crypto_setup_out_descr(common, &req_ctx->hw_ctx,
19401941
sizeof(struct artpec6_crypto_aead_hw_ctx), false, false);
@@ -2956,7 +2957,7 @@ static struct aead_alg aead_algos[] = {
29562957
.setkey = artpec6_crypto_aead_set_key,
29572958
.encrypt = artpec6_crypto_aead_encrypt,
29582959
.decrypt = artpec6_crypto_aead_decrypt,
2959-
.ivsize = AES_BLOCK_SIZE,
2960+
.ivsize = GCM_AES_IV_SIZE,
29602961
.maxauthsize = AES_BLOCK_SIZE,
29612962

29622963
.base = {

0 commit comments

Comments
 (0)