From: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org>

Print all capability variants that were not covered by reference tests.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org>
---
/** Email created from pull request 379 (lumag:crypto-untested)
 ** https://github.com/Linaro/odp/pull/379
 ** Patch: https://github.com/Linaro/odp/pull/379.patch
 ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea
 ** Merge commit sha: 36b032fa07bb9b29a0c8f774c2ce76da96b4d653
 **/
 test/validation/api/crypto/odp_crypto_test_inp.c | 712 ++++++++++-------------
 1 file changed, 317 insertions(+), 395 deletions(-)

diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c 
b/test/validation/api/crypto/odp_crypto_test_inp.c
index 821bdc7e4..ddbad3097 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.c
@@ -299,14 +299,11 @@ static void alg_test(odp_crypto_op_t op,
                     odp_bool_t ovr_iv)
 {
        odp_crypto_session_t session;
-       odp_crypto_capability_t capa;
        int rc;
        odp_crypto_ses_create_err_t status;
        odp_bool_t ok = false;
        int iteration;
        odp_crypto_session_param_t ses_params;
-       odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA];
-       odp_crypto_auth_capability_t   auth_capa[MAX_ALG_CAPA];
        odp_packet_data_range_t cipher_range;
        odp_packet_data_range_t auth_range;
        odp_crypto_key_t cipher_key = {
@@ -321,111 +318,6 @@ static void alg_test(odp_crypto_op_t op,
                .data = ovr_iv ? NULL : ref->iv,
                .length = ref->iv_length
        };
-       int num, i;
-       int found;
-
-       rc = odp_crypto_capability(&capa);
-       CU_ASSERT(!rc);
-
-       if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
-           !(capa.ciphers.bit.trides_cbc))
-               rc = -1;
-       if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
-           !(capa.ciphers.bit.aes_cbc))
-               rc = -1;
-       if (cipher_alg == ODP_CIPHER_ALG_AES_CTR &&
-           !(capa.ciphers.bit.aes_ctr))
-               rc = -1;
-       if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
-           !(capa.ciphers.bit.aes_gcm))
-               rc = -1;
-       if (cipher_alg == ODP_CIPHER_ALG_DES &&
-           !(capa.ciphers.bit.des))
-               rc = -1;
-       if (cipher_alg == ODP_CIPHER_ALG_NULL &&
-           !(capa.ciphers.bit.null))
-               rc = -1;
-
-       CU_ASSERT(!rc);
-       CU_ASSERT((~capa.ciphers.all_bits & capa.hw_ciphers.all_bits) == 0);
-
-       if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
-           !(capa.auths.bit.aes_gcm))
-               rc = -1;
-       if (auth_alg == ODP_AUTH_ALG_AES_GMAC &&
-           !(capa.auths.bit.aes_gmac))
-               rc = -1;
-       if (auth_alg == ODP_AUTH_ALG_MD5_HMAC &&
-           !(capa.auths.bit.md5_hmac))
-               rc = -1;
-       if (auth_alg == ODP_AUTH_ALG_NULL &&
-           !(capa.auths.bit.null))
-               rc = -1;
-       if (auth_alg == ODP_AUTH_ALG_SHA1_HMAC &&
-           !(capa.auths.bit.sha1_hmac))
-               rc = -1;
-       if (auth_alg == ODP_AUTH_ALG_SHA256_HMAC &&
-           !(capa.auths.bit.sha256_hmac))
-               rc = -1;
-       if (auth_alg == ODP_AUTH_ALG_SHA512_HMAC &&
-           !(capa.auths.bit.sha512_hmac))
-               rc = -1;
-
-       CU_ASSERT(!rc);
-       CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0);
-
-       num = odp_crypto_cipher_capability(cipher_alg, cipher_capa,
-                                          MAX_ALG_CAPA);
-
-       CU_ASSERT(num > 0);
-       found = 0;
-
-       CU_ASSERT(num <= MAX_ALG_CAPA);
-
-       if (num > MAX_ALG_CAPA)
-               num = MAX_ALG_CAPA;
-
-       /* Search for the test case */
-       for (i = 0; i < num; i++) {
-               if (cipher_capa[i].key_len == cipher_key.length &&
-                   cipher_capa[i].iv_len  == iv.length) {
-                       found = 1;
-                       break;
-               }
-       }
-
-       if (!found) {
-               printf("\n    Unsupported: alg=%s, key_len=%" PRIu32 ", "
-                      "iv_len=%" PRIu32 "\n", cipher_alg_name(cipher_alg),
-                      cipher_key.length, iv.length);
-               return;
-       }
-
-       num = odp_crypto_auth_capability(auth_alg, auth_capa, MAX_ALG_CAPA);
-
-       CU_ASSERT(num > 0);
-       found = 0;
-
-       CU_ASSERT(num <= MAX_ALG_CAPA);
-
-       if (num > MAX_ALG_CAPA)
-               num = MAX_ALG_CAPA;
-
-       /* Search for the test case */
-       for (i = 0; i < num; i++) {
-               if (auth_capa[i].digest_len == ref->digest_length &&
-                   auth_capa[i].key_len    == auth_key.length) {
-                       found = 1;
-                       break;
-               }
-       }
-
-       if (!found) {
-               printf("\n    Unsupported: alg=%s, key_len=%" PRIu32 ", "
-                      "digest_len=%" PRIu32 "\n", auth_alg_name(auth_alg),
-                      auth_key.length, ref->digest_length);
-               return;
-       }
 
        /* Create a crypto session */
        odp_crypto_session_param_init(&ses_params);
@@ -532,6 +424,154 @@ static void alg_test(odp_crypto_op_t op,
        CU_ASSERT(!rc);
 }
 
+static void check_alg(odp_crypto_op_t op,
+                     odp_cipher_alg_t cipher_alg,
+                     odp_auth_alg_t auth_alg,
+                     crypto_test_reference_t *ref,
+                     size_t count,
+                     odp_bool_t ovr_iv)
+{
+       odp_crypto_capability_t capa;
+       odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA];
+       odp_crypto_auth_capability_t   auth_capa[MAX_ALG_CAPA];
+       int rc, cipher_num, auth_num, i;
+       odp_bool_t cipher_tested[MAX_ALG_CAPA];
+       odp_bool_t auth_tested[MAX_ALG_CAPA];
+       size_t idx;
+
+       rc = odp_crypto_capability(&capa);
+       CU_ASSERT(!rc);
+
+       if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
+           !(capa.ciphers.bit.trides_cbc))
+               rc = -1;
+       if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
+           !(capa.ciphers.bit.aes_cbc))
+               rc = -1;
+       if (cipher_alg == ODP_CIPHER_ALG_AES_CTR &&
+           !(capa.ciphers.bit.aes_ctr))
+               rc = -1;
+       if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
+           !(capa.ciphers.bit.aes_gcm))
+               rc = -1;
+       if (cipher_alg == ODP_CIPHER_ALG_DES &&
+           !(capa.ciphers.bit.des))
+               rc = -1;
+       if (cipher_alg == ODP_CIPHER_ALG_NULL &&
+           !(capa.ciphers.bit.null))
+               rc = -1;
+
+       CU_ASSERT(!rc);
+       CU_ASSERT((~capa.ciphers.all_bits & capa.hw_ciphers.all_bits) == 0);
+
+       if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
+           !(capa.auths.bit.aes_gcm))
+               rc = -1;
+       if (auth_alg == ODP_AUTH_ALG_AES_GMAC &&
+           !(capa.auths.bit.aes_gmac))
+               rc = -1;
+       if (auth_alg == ODP_AUTH_ALG_MD5_HMAC &&
+           !(capa.auths.bit.md5_hmac))
+               rc = -1;
+       if (auth_alg == ODP_AUTH_ALG_NULL &&
+           !(capa.auths.bit.null))
+               rc = -1;
+       if (auth_alg == ODP_AUTH_ALG_SHA1_HMAC &&
+           !(capa.auths.bit.sha1_hmac))
+               rc = -1;
+       if (auth_alg == ODP_AUTH_ALG_SHA256_HMAC &&
+           !(capa.auths.bit.sha256_hmac))
+               rc = -1;
+       if (auth_alg == ODP_AUTH_ALG_SHA512_HMAC &&
+           !(capa.auths.bit.sha512_hmac))
+               rc = -1;
+
+       CU_ASSERT(!rc);
+       CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0);
+
+       cipher_num = odp_crypto_cipher_capability(cipher_alg, cipher_capa,
+                                                 MAX_ALG_CAPA);
+
+       CU_ASSERT(cipher_num > 0);
+       CU_ASSERT(cipher_num <= MAX_ALG_CAPA);
+       if (cipher_num > MAX_ALG_CAPA)
+               cipher_num = MAX_ALG_CAPA;
+
+       auth_num = odp_crypto_auth_capability(auth_alg, auth_capa,
+                                             MAX_ALG_CAPA);
+
+       CU_ASSERT(auth_num > 0);
+       CU_ASSERT(auth_num <= MAX_ALG_CAPA);
+       if (auth_num > MAX_ALG_CAPA)
+               auth_num = MAX_ALG_CAPA;
+
+       memset(cipher_tested, 0, sizeof(cipher_tested));
+       memset(auth_tested, 0, sizeof(auth_tested));
+
+       for (idx = 0; idx < count; idx++) {
+               int cipher_idx = -1, auth_idx = -1;
+
+               for (i = 0; i < cipher_num; i++) {
+                       if (cipher_capa[i].key_len ==
+                           ref[idx].cipher_key_length &&
+                           cipher_capa[i].iv_len ==
+                           ref[idx].iv_length) {
+                               cipher_idx = i;
+                               break;
+                       }
+               }
+
+               if (cipher_idx < 0) {
+                       printf("\n    Unsupported: alg=%s, key_len=%" PRIu32
+                              ", iv_len=%" PRIu32 "\n",
+                              cipher_alg_name(cipher_alg),
+                              ref[idx].cipher_key_length,
+                              ref[idx].iv_length);
+                       continue;
+               }
+
+               for (i = 0; i < auth_num; i++) {
+                       if (auth_capa[i].digest_len ==
+                           ref[idx].digest_length &&
+                           auth_capa[i].key_len ==
+                           ref[idx].auth_key_length) {
+                               auth_idx = i;
+                               break;
+                       }
+               }
+
+               if (auth_idx < 0) {
+                       printf("\n    Unsupported: alg=%s, key_len=%" PRIu32
+                              ", digest_len=%" PRIu32 "\n",
+                              auth_alg_name(auth_alg),
+                              ref[idx].auth_key_length,
+                              ref[idx].digest_length);
+                       continue;
+               }
+
+               alg_test(op, cipher_alg, auth_alg, &ref[idx], ovr_iv);
+
+               cipher_tested[cipher_idx] = true;
+               auth_tested[auth_idx] = true;
+       }
+
+       for (i = 0; i < cipher_num; i++)
+               if (!cipher_tested[i])
+                       printf("\n    Untested: alg=%s, key_len=%" PRIu32 ", "
+                              "iv_len=%" PRIu32 "\n",
+                              cipher_alg_name(cipher_alg),
+                              cipher_capa[i].key_len,
+                              cipher_capa[i].iv_len);
+
+       for (i = 0; i < auth_num; i++)
+               if (!auth_tested[i])
+                       printf("\n    Untested: alg=%s, key_len=%" PRIu32 ", "
+                              "digest_len=%" PRIu32 "\n",
+                              auth_alg_name(auth_alg),
+                              auth_capa[i].key_len,
+                              auth_capa[i].digest_len);
+}
+
 /**
  * Check if given cipher and authentication algorithms are supported
  *
@@ -631,32 +671,25 @@ static int check_alg_null(void)
        return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_NULL);
 }
 
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
 void crypto_test_enc_alg_null(void)
 {
-       unsigned int test_vec_num = (sizeof(null_reference) /
-                                    sizeof(null_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_NULL,
-                        &null_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_NULL,
+                 null_reference,
+                 ARRAY_SIZE(null_reference),
+                 false);
 }
 
 void crypto_test_dec_alg_null(void)
 {
-       unsigned int test_vec_num = (sizeof(null_reference) /
-                                    sizeof(null_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_NULL,
-                        &null_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_NULL,
+                 null_reference,
+                 ARRAY_SIZE(null_reference),
+                 false);
 }
 
 static int check_alg_3des_cbc(void)
@@ -670,16 +703,12 @@ static int check_alg_3des_cbc(void)
  * packet buffer as completion event buffer.*/
 void crypto_test_enc_alg_3des_cbc(void)
 {
-       unsigned int test_vec_num = (sizeof(tdes_cbc_reference) /
-                                    sizeof(tdes_cbc_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_3DES_CBC,
-                        ODP_AUTH_ALG_NULL,
-                        &tdes_cbc_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_3DES_CBC,
+                 ODP_AUTH_ALG_NULL,
+                 tdes_cbc_reference,
+                 ARRAY_SIZE(tdes_cbc_reference),
+                 false);
 }
 
 /* This test verifies the correctness of encode (plaintext -> ciphertext)
@@ -687,16 +716,12 @@ void crypto_test_enc_alg_3des_cbc(void)
  * */
 void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
 {
-       unsigned int test_vec_num = (sizeof(tdes_cbc_reference) /
-                                    sizeof(tdes_cbc_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_3DES_CBC,
-                        ODP_AUTH_ALG_NULL,
-                        &tdes_cbc_reference[i],
-                        true);
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_3DES_CBC,
+                 ODP_AUTH_ALG_NULL,
+                 tdes_cbc_reference,
+                 ARRAY_SIZE(tdes_cbc_reference),
+                 true);
 }
 
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
@@ -706,16 +731,12 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
  * */
 void crypto_test_dec_alg_3des_cbc(void)
 {
-       unsigned int test_vec_num = (sizeof(tdes_cbc_reference) /
-                                    sizeof(tdes_cbc_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_3DES_CBC,
-                        ODP_AUTH_ALG_NULL,
-                        &tdes_cbc_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_3DES_CBC,
+                 ODP_AUTH_ALG_NULL,
+                 tdes_cbc_reference,
+                 ARRAY_SIZE(tdes_cbc_reference),
+                 false);
 }
 
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
@@ -725,16 +746,12 @@ void crypto_test_dec_alg_3des_cbc(void)
  * */
 void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
 {
-       unsigned int test_vec_num = (sizeof(tdes_cbc_reference) /
-                                    sizeof(tdes_cbc_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_3DES_CBC,
-                        ODP_AUTH_ALG_NULL,
-                        &tdes_cbc_reference[i],
-                        true);
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_3DES_CBC,
+                 ODP_AUTH_ALG_NULL,
+                 tdes_cbc_reference,
+                 ARRAY_SIZE(tdes_cbc_reference),
+                 true);
 }
 
 static int check_alg_aes_gcm(void)
@@ -748,17 +765,12 @@ static int check_alg_aes_gcm(void)
  * packet buffer as completion event buffer.*/
 void crypto_test_enc_alg_aes_gcm(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_gcm_reference) /
-                                    sizeof(aes_gcm_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_AES_GCM,
-                        ODP_AUTH_ALG_AES_GCM,
-                        &aes_gcm_reference[i],
-                        false);
-       }
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_AES_GCM,
+                 ODP_AUTH_ALG_AES_GCM,
+                 aes_gcm_reference,
+                 ARRAY_SIZE(aes_gcm_reference),
+                 false);
 }
 
 /* This test verifies the correctness of encode (plaintext -> ciphertext)
@@ -767,17 +779,12 @@ void crypto_test_enc_alg_aes_gcm(void)
  * packet buffer as completion event buffer.*/
 void crypto_test_enc_alg_aes_gcm_ovr_iv(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_gcm_reference) /
-                                    sizeof(aes_gcm_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_AES_GCM,
-                        ODP_AUTH_ALG_AES_GCM,
-                        &aes_gcm_reference[i],
-                        true);
-       }
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_AES_GCM,
+                 ODP_AUTH_ALG_AES_GCM,
+                 aes_gcm_reference,
+                 ARRAY_SIZE(aes_gcm_reference),
+                 true);
 }
 
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
@@ -787,17 +794,12 @@ void crypto_test_enc_alg_aes_gcm_ovr_iv(void)
  * */
 void crypto_test_dec_alg_aes_gcm(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_gcm_reference) /
-                                    sizeof(aes_gcm_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_AES_GCM,
-                        ODP_AUTH_ALG_AES_GCM,
-                        &aes_gcm_reference[i],
-                        false);
-       }
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_AES_GCM,
+                 ODP_AUTH_ALG_AES_GCM,
+                 aes_gcm_reference,
+                 ARRAY_SIZE(aes_gcm_reference),
+                 false);
 }
 
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
@@ -807,17 +809,12 @@ void crypto_test_dec_alg_aes_gcm(void)
  * */
 void crypto_test_dec_alg_aes_gcm_ovr_iv(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_gcm_reference) /
-                                    sizeof(aes_gcm_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_AES_GCM,
-                        ODP_AUTH_ALG_AES_GCM,
-                        &aes_gcm_reference[i],
-                        true);
-       }
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_AES_GCM,
+                 ODP_AUTH_ALG_AES_GCM,
+                 aes_gcm_reference,
+                 ARRAY_SIZE(aes_gcm_reference),
+                 true);
 }
 
 static int check_alg_aes_cbc(void)
@@ -831,17 +828,12 @@ static int check_alg_aes_cbc(void)
  * packet buffer as completion event buffer.*/
 void crypto_test_enc_alg_aes_cbc(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_cbc_reference) /
-                                    sizeof(aes_cbc_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_AES_CBC,
-                        ODP_AUTH_ALG_NULL,
-                        &aes_cbc_reference[i],
-                        false);
-       }
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_AES_CBC,
+                 ODP_AUTH_ALG_NULL,
+                 aes_cbc_reference,
+                 ARRAY_SIZE(aes_cbc_reference),
+                 false);
 }
 
 /* This test verifies the correctness of encode (plaintext -> ciphertext)
@@ -849,17 +841,12 @@ void crypto_test_enc_alg_aes_cbc(void)
  * */
 void crypto_test_enc_alg_aes_cbc_ovr_iv(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_cbc_reference) /
-                                    sizeof(aes_cbc_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_AES_CBC,
-                        ODP_AUTH_ALG_NULL,
-                        &aes_cbc_reference[i],
-                        true);
-       }
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_AES_CBC,
+                 ODP_AUTH_ALG_NULL,
+                 aes_cbc_reference,
+                 ARRAY_SIZE(aes_cbc_reference),
+                 true);
 }
 
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
@@ -869,17 +856,12 @@ void crypto_test_enc_alg_aes_cbc_ovr_iv(void)
  * */
 void crypto_test_dec_alg_aes_cbc(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_cbc_reference) /
-                                    sizeof(aes_cbc_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_AES_CBC,
-                        ODP_AUTH_ALG_NULL,
-                        &aes_cbc_reference[i],
-                        false);
-       }
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_AES_CBC,
+                 ODP_AUTH_ALG_NULL,
+                 aes_cbc_reference,
+                 ARRAY_SIZE(aes_cbc_reference),
+                 false);
 }
 
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
@@ -889,17 +871,12 @@ void crypto_test_dec_alg_aes_cbc(void)
  * */
 void crypto_test_dec_alg_aes_cbc_ovr_iv(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_cbc_reference) /
-                                    sizeof(aes_cbc_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_AES_CBC,
-                        ODP_AUTH_ALG_NULL,
-                        &aes_cbc_reference[i],
-                        true);
-       }
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_AES_CBC,
+                 ODP_AUTH_ALG_NULL,
+                 aes_cbc_reference,
+                 ARRAY_SIZE(aes_cbc_reference),
+                 true);
 }
 
 static int check_alg_aes_ctr(void)
@@ -913,17 +890,12 @@ static int check_alg_aes_ctr(void)
  * packet buffer as completion event buffer.*/
 void crypto_test_enc_alg_aes_ctr(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_ctr_reference) /
-                                    sizeof(aes_ctr_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_AES_CTR,
-                        ODP_AUTH_ALG_NULL,
-                        &aes_ctr_reference[i],
-                        false);
-       }
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_AES_CTR,
+                 ODP_AUTH_ALG_NULL,
+                 aes_ctr_reference,
+                 ARRAY_SIZE(aes_ctr_reference),
+                 false);
 }
 
 /* This test verifies the correctness of encode (plaintext -> ciphertext)
@@ -931,17 +903,12 @@ void crypto_test_enc_alg_aes_ctr(void)
  * */
 void crypto_test_enc_alg_aes_ctr_ovr_iv(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_ctr_reference) /
-                                    sizeof(aes_ctr_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_AES_CTR,
-                        ODP_AUTH_ALG_NULL,
-                        &aes_ctr_reference[i],
-                        true);
-       }
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_AES_CTR,
+                 ODP_AUTH_ALG_NULL,
+                 aes_ctr_reference,
+                 ARRAY_SIZE(aes_ctr_reference),
+                 true);
 }
 
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
@@ -951,17 +918,12 @@ void crypto_test_enc_alg_aes_ctr_ovr_iv(void)
  * */
 void crypto_test_dec_alg_aes_ctr(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_ctr_reference) /
-                                    sizeof(aes_ctr_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_AES_CTR,
-                        ODP_AUTH_ALG_NULL,
-                        &aes_ctr_reference[i],
-                        false);
-       }
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_AES_CTR,
+                 ODP_AUTH_ALG_NULL,
+                 aes_ctr_reference,
+                 ARRAY_SIZE(aes_ctr_reference),
+                 false);
 }
 
 /* This test verifies the correctness of decode (ciphertext -> plaintext)
@@ -971,17 +933,12 @@ void crypto_test_dec_alg_aes_ctr(void)
  * */
 void crypto_test_dec_alg_aes_ctr_ovr_iv(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_ctr_reference) /
-                                    sizeof(aes_ctr_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++) {
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_AES_CTR,
-                        ODP_AUTH_ALG_NULL,
-                        &aes_ctr_reference[i],
-                        true);
-       }
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_AES_CTR,
+                 ODP_AUTH_ALG_NULL,
+                 aes_ctr_reference,
+                 ARRAY_SIZE(aes_ctr_reference),
+                 true);
 }
 
 static int check_alg_hmac_md5(void)
@@ -998,30 +955,22 @@ static int check_alg_hmac_md5(void)
  * */
 void crypto_test_gen_alg_hmac_md5(void)
 {
-       unsigned int test_vec_num = (sizeof(hmac_md5_reference) /
-                                    sizeof(hmac_md5_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_MD5_HMAC,
-                        &hmac_md5_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_MD5_HMAC,
+                 hmac_md5_reference,
+                 ARRAY_SIZE(hmac_md5_reference),
+                 false);
 }
 
 void crypto_test_check_alg_hmac_md5(void)
 {
-       unsigned int test_vec_num = (sizeof(hmac_md5_reference) /
-                                    sizeof(hmac_md5_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_MD5_HMAC,
-                        &hmac_md5_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_MD5_HMAC,
+                 hmac_md5_reference,
+                 ARRAY_SIZE(hmac_md5_reference),
+                 false);
 }
 
 static int check_alg_hmac_sha1(void)
@@ -1038,30 +987,22 @@ static int check_alg_hmac_sha1(void)
  * */
 void crypto_test_gen_alg_hmac_sha1(void)
 {
-       unsigned int test_vec_num = (sizeof(hmac_sha1_reference) /
-                                    sizeof(hmac_sha1_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_SHA1_HMAC,
-                        &hmac_sha1_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_SHA1_HMAC,
+                 hmac_sha1_reference,
+                 ARRAY_SIZE(hmac_sha1_reference),
+                 false);
 }
 
 void crypto_test_check_alg_hmac_sha1(void)
 {
-       unsigned int test_vec_num = (sizeof(hmac_sha1_reference) /
-                                    sizeof(hmac_sha1_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_SHA1_HMAC,
-                        &hmac_sha1_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_SHA1_HMAC,
+                 hmac_sha1_reference,
+                 ARRAY_SIZE(hmac_sha1_reference),
+                 false);
 }
 
 static int check_alg_hmac_sha256(void)
@@ -1078,30 +1019,22 @@ static int check_alg_hmac_sha256(void)
  * */
 void crypto_test_gen_alg_hmac_sha256(void)
 {
-       unsigned int test_vec_num = (sizeof(hmac_sha256_reference) /
-                                    sizeof(hmac_sha256_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_SHA256_HMAC,
-                        &hmac_sha256_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_SHA256_HMAC,
+                 hmac_sha256_reference,
+                 ARRAY_SIZE(hmac_sha256_reference),
+                 false);
 }
 
 void crypto_test_check_alg_hmac_sha256(void)
 {
-       unsigned int test_vec_num = (sizeof(hmac_sha256_reference) /
-                                    sizeof(hmac_sha256_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_SHA256_HMAC,
-                        &hmac_sha256_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_SHA256_HMAC,
+                 hmac_sha256_reference,
+                 ARRAY_SIZE(hmac_sha256_reference),
+                 false);
 }
 
 static int check_alg_hmac_sha512(void)
@@ -1118,30 +1051,22 @@ static int check_alg_hmac_sha512(void)
  * */
 void crypto_test_gen_alg_hmac_sha512(void)
 {
-       unsigned int test_vec_num = (sizeof(hmac_sha512_reference) /
-                                    sizeof(hmac_sha512_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_SHA512_HMAC,
-                        &hmac_sha512_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_ENCODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_SHA512_HMAC,
+                 hmac_sha512_reference,
+                 ARRAY_SIZE(hmac_sha512_reference),
+                 false);
 }
 
 void crypto_test_check_alg_hmac_sha512(void)
 {
-       unsigned int test_vec_num = (sizeof(hmac_sha512_reference) /
-                                    sizeof(hmac_sha512_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_SHA512_HMAC,
-                        &hmac_sha512_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_SHA512_HMAC,
+                 hmac_sha512_reference,
+                 ARRAY_SIZE(hmac_sha512_reference),
+                 false);
 }
 
 static int check_alg_aes_gmac(void)
@@ -1156,25 +1081,22 @@ void crypto_test_gen_alg_aes_gmac(void)
        unsigned int i;
 
        for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_ENCODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_AES_GMAC,
-                        &aes_gmac_reference[i],
-                        false);
+               check_alg(ODP_CRYPTO_OP_ENCODE,
+                         ODP_CIPHER_ALG_NULL,
+                         ODP_AUTH_ALG_AES_GMAC,
+                         aes_gmac_reference,
+                         ARRAY_SIZE(aes_gmac_reference),
+                         false);
 }
 
 void crypto_test_check_alg_aes_gmac(void)
 {
-       unsigned int test_vec_num = (sizeof(aes_gmac_reference) /
-                                    sizeof(aes_gmac_reference[0]));
-       unsigned int i;
-
-       for (i = 0; i < test_vec_num; i++)
-               alg_test(ODP_CRYPTO_OP_DECODE,
-                        ODP_CIPHER_ALG_NULL,
-                        ODP_AUTH_ALG_AES_GMAC,
-                        &aes_gmac_reference[i],
-                        false);
+       check_alg(ODP_CRYPTO_OP_DECODE,
+                 ODP_CIPHER_ALG_NULL,
+                 ODP_AUTH_ALG_AES_GMAC,
+                 aes_gmac_reference,
+                 ARRAY_SIZE(aes_gmac_reference),
+                 false);
 }
 
 int crypto_suite_sync_init(void)

Reply via email to