[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230110135042.2940847-4-vincent.whitchurch@axis.com>
Date: Tue, 10 Jan 2023 14:50:33 +0100
From: Vincent Whitchurch <vincent.whitchurch@...s.com>
To: <herbert@...dor.apana.org.au>, <davem@...emloft.net>,
<jesper.nilsson@...s.com>, <lars.persson@...s.com>
CC: <kernel@...s.com>,
Vincent Whitchurch <vincent.whitchurch@...s.com>,
<linux-crypto@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH 03/12] crypto: axis - fix CTR output IV
Write the updated counter value to the IV with software since the
hardware does not do it. Fixes this self test:
alg: skcipher: artpec6-ctr-aes encryption test failed (wrong output IV)
on test vector 0, cfg="in-place (one sglist)"
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@...s.com>
---
drivers/crypto/axis/artpec6_crypto.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
index d3b6ee065a81..67f510c497f2 100644
--- a/drivers/crypto/axis/artpec6_crypto.c
+++ b/drivers/crypto/axis/artpec6_crypto.c
@@ -370,6 +370,8 @@ artpec6_crypto_complete_cbc_encrypt(struct crypto_async_request *req);
static void
artpec6_crypto_complete_cbc_decrypt(struct crypto_async_request *req);
static void
+artpec6_crypto_complete_ctr(struct crypto_async_request *req);
+static void
artpec6_crypto_complete_aead(struct crypto_async_request *req);
static void
artpec6_crypto_complete_hash(struct crypto_async_request *req);
@@ -1109,6 +1111,9 @@ static int artpec6_crypto_encrypt(struct skcipher_request *req)
case ARTPEC6_CRYPTO_CIPHER_AES_CBC:
complete = artpec6_crypto_complete_cbc_encrypt;
break;
+ case ARTPEC6_CRYPTO_CIPHER_AES_CTR:
+ complete = artpec6_crypto_complete_ctr;
+ break;
default:
complete = artpec6_crypto_complete_crypto;
break;
@@ -1155,6 +1160,9 @@ static int artpec6_crypto_decrypt(struct skcipher_request *req)
case ARTPEC6_CRYPTO_CIPHER_AES_CBC:
complete = artpec6_crypto_complete_cbc_decrypt;
break;
+ case ARTPEC6_CRYPTO_CIPHER_AES_CTR:
+ complete = artpec6_crypto_complete_ctr;
+ break;
default:
complete = artpec6_crypto_complete_crypto;
break;
@@ -2158,6 +2166,20 @@ static void artpec6_crypto_complete_crypto(struct crypto_async_request *req)
req->complete(req, 0);
}
+static void artpec6_crypto_complete_ctr(struct crypto_async_request *req)
+{
+ struct skcipher_request *cipher_req = container_of(req,
+ struct skcipher_request, base);
+ unsigned int nblks = ALIGN(cipher_req->cryptlen, AES_BLOCK_SIZE) /
+ AES_BLOCK_SIZE;
+ __be32 *iv = (void *)cipher_req->iv;
+ unsigned int counter = be32_to_cpu(iv[3]);
+
+ iv[3] = cpu_to_be32(counter + nblks);
+
+ req->complete(req, 0);
+}
+
static void
artpec6_crypto_complete_cbc_decrypt(struct crypto_async_request *req)
{
--
2.34.1
Powered by blists - more mailing lists