diff mbox series

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

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

Commit Message

Github ODP bot Nov. 7, 2017, 2 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: 17e6f7bd8c2da61bad27d90c4b530c0f5a80fb0d
 **/
 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..9341e2c78 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -51,6 +51,11 @@  static const odp_crypto_cipher_capability_t cipher_capa_aes_cbc[] = {
 {.key_len = 24, .iv_len = 16},
 {.key_len = 32, .iv_len = 16} };
 
+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} };
+
 static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = {
 {.key_len = 16, .iv_len = 12},
 {.key_len = 24, .iv_len = 12},
@@ -592,6 +597,7 @@  int odp_crypto_capability(odp_crypto_capability_t *capa)
 	capa->ciphers.bit.des        = 1;
 	capa->ciphers.bit.trides_cbc = 1;
 	capa->ciphers.bit.aes_cbc    = 1;
+	capa->ciphers.bit.aes_ctr    = 1;
 	capa->ciphers.bit.aes_gcm    = 1;
 
 	capa->auths.bit.null         = 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