diff mbox series

[API-NEXT,v2,3/3] linux-gen: crypto: add AES-CTR support

Message ID 1509642008-6978-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v2,1/3] api: crypto: add AES-CTR declarations | expand

Commit Message

Github ODP bot Nov. 2, 2017, 5 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Add implementation for AES-CTR cryptographic mode.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 271 (lumag:aes-ctr)
 ** https://github.com/Linaro/odp/pull/271
 ** Patch: https://github.com/Linaro/odp/pull/271.patch
 ** Base sha: d22c949cc466bf28de559855a1cb525740578137
 ** Merge commit sha: b976868759b2e8ee4ff32d3749e1df5cbd844ef7
 **/
 platform/linux-generic/odp_crypto.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 3174feee0..2fbf91f28 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -56,6 +56,11 @@  static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = {
 {.key_len = 24, .iv_len = 12},
 {.key_len = 32, .iv_len = 12} };
 
+static const odp_crypto_cipher_capability_t cipher_capa_aes_ctr[] = {
+{.key_len = 16, .iv_len = 16},
+{.key_len = 24, .iv_len = 16},
+{.key_len = 32, .iv_len = 16} };
+
 /*
  * Authentication algorithm capabilities
  *
@@ -593,6 +598,7 @@  int odp_crypto_capability(odp_crypto_capability_t *capa)
 	capa->ciphers.bit.trides_cbc = 1;
 	capa->ciphers.bit.aes_cbc    = 1;
 	capa->ciphers.bit.aes_gcm    = 1;
+	capa->ciphers.bit.aes_ctr    = 1;
 
 	capa->auths.bit.null         = 1;
 	capa->auths.bit.md5_hmac     = 1;
@@ -639,6 +645,10 @@  int odp_crypto_cipher_capability(odp_cipher_alg_t cipher,
 		src = cipher_capa_aes_cbc;
 		num = sizeof(cipher_capa_aes_cbc) / size;
 		break;
+	case ODP_CIPHER_ALG_AES_CTR:
+		src = cipher_capa_aes_ctr;
+		num = sizeof(cipher_capa_aes_ctr) / size;
+		break;
 	case ODP_CIPHER_ALG_AES_GCM:
 		src = cipher_capa_aes_gcm;
 		num = sizeof(cipher_capa_aes_gcm) / size;
@@ -763,6 +773,16 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 		else
 			rc = -1;
 		break;
+	case ODP_CIPHER_ALG_AES_CTR:
+		if (param->cipher_key.length == 16)
+			rc = process_cipher_param(session, EVP_aes_128_ctr());
+		else if (param->cipher_key.length == 24)
+			rc = process_cipher_param(session, EVP_aes_192_ctr());
+		else if (param->cipher_key.length == 32)
+			rc = process_cipher_param(session, EVP_aes_256_ctr());
+		else
+			rc = -1;
+		break;
 #if ODP_DEPRECATED_API
 	case ODP_CIPHER_ALG_AES128_GCM:
 		/* AES-GCM requires to do both auth and