diff mbox series

[API-NEXT,v1,6/16] crypto: linux-generic: add capabilities for CIPHER_NULL and AUTH_NULL

Message ID 1495450806-27703-7-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v1,1/16] test: crypto: explicitly pass auth_digest_len to crypto subsystem | expand

Commit Message

Github ODP bot May 22, 2017, 10:59 a.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


There is no point in having separate cases for NULL algorithms. Add
capabilities returning 0 key/digest/iv length.

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

---
/** Email created from pull request 34 (lumag:crypto-update-main-new)
 ** https://github.com/Linaro/odp/pull/34
 ** Patch: https://github.com/Linaro/odp/pull/34.patch
 ** Base sha: 826ee894aa0ebd09d42a17e1de077c46bc5b366a
 ** Merge commit sha: 225ede5cef6eb46fc9e1d1d385ac8be0b57c64f5
 **/
 platform/linux-generic/odp_crypto.c                    | 14 ++++++++++----
 .../validation/api/crypto/odp_crypto_test_inp.c        | 18 ++++--------------
 2 files changed, 14 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 0ca3e110..156aab30 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -34,6 +34,9 @@ 
  *
  * Keep sorted: first by key length, then by IV length
  */
+static const odp_crypto_cipher_capability_t cipher_capa_null[] = {
+{.key_len = 0, .iv_len = 0} };
+
 static const odp_crypto_cipher_capability_t cipher_capa_des[] = {
 {.key_len = 24, .iv_len = 8} };
 
@@ -51,6 +54,9 @@  static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = {
  *
  * Keep sorted: first by digest length, then by key length
  */
+static const odp_crypto_auth_capability_t auth_capa_null[] = {
+{.digest_len = 0, .key_len = 0, .aad_len = {.min = 0, .max = 0, .inc = 0} } };
+
 static const odp_crypto_auth_capability_t auth_capa_md5_hmac[] = {
 {.digest_len = 12, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0} },
 {.digest_len = 16, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0} } };
@@ -562,8 +568,8 @@  int odp_crypto_cipher_capability(odp_cipher_alg_t cipher,
 
 	switch (cipher) {
 	case ODP_CIPHER_ALG_NULL:
-		src = NULL;
-		num = 0;
+		src = cipher_capa_null;
+		num = sizeof(cipher_capa_null) / size;
 		break;
 	case ODP_CIPHER_ALG_DES:
 		src = cipher_capa_des;
@@ -602,8 +608,8 @@  int odp_crypto_auth_capability(odp_auth_alg_t auth,
 
 	switch (auth) {
 	case ODP_AUTH_ALG_NULL:
-		src = NULL;
-		num = 0;
+		src = auth_capa_null;
+		num = sizeof(auth_capa_null) / size;
 		break;
 	case ODP_AUTH_ALG_MD5_HMAC:
 		src = auth_capa_md5_hmac;
diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
index 3f57a907..a7d8727b 100644
--- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
@@ -141,13 +141,8 @@  static void alg_test(odp_crypto_op_t op,
 	num = odp_crypto_cipher_capability(cipher_alg, cipher_capa,
 					   MAX_ALG_CAPA);
 
-	if (cipher_alg != ODP_CIPHER_ALG_NULL) {
-		CU_ASSERT(num > 0);
-		found = 0;
-	} else {
-		CU_ASSERT(num == 0);
-		found = 1;
-	}
+	CU_ASSERT(num > 0);
+	found = 0;
 
 	CU_ASSERT(num <= MAX_ALG_CAPA);
 
@@ -167,13 +162,8 @@  static void alg_test(odp_crypto_op_t op,
 
 	num = odp_crypto_auth_capability(auth_alg, auth_capa, MAX_ALG_CAPA);
 
-	if (auth_alg != ODP_AUTH_ALG_NULL) {
-		CU_ASSERT(num > 0);
-		found = 0;
-	} else {
-		CU_ASSERT(num == 0);
-		found = 1;
-	}
+	CU_ASSERT(num > 0);
+	found = 0;
 
 	CU_ASSERT(num <= MAX_ALG_CAPA);