@@ -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)
{
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@axis.com> --- drivers/crypto/axis/artpec6_crypto.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)