@@ -10,6 +10,8 @@
#include "odp_cunit_common.h"
/* test functions: */
+void crypto_test_enc_alg_null(void);
+void crypto_test_dec_alg_null(void);
void crypto_test_enc_alg_3des_cbc(void);
void crypto_test_enc_alg_3des_cbc_ovr_iv(void);
void crypto_test_dec_alg_3des_cbc(void);
@@ -430,6 +430,73 @@ static int check_auth_options(odp_auth_alg_t auth, uint32_t key_len,
return 1;
}
+static int check_alg_null(void)
+{
+ return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_NULL);
+}
+
+void crypto_test_enc_alg_null(void)
+{
+ odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+ auth_key = { .data = NULL, .length = 0 };
+ odp_crypto_iv_t iv;
+ unsigned int test_vec_num = (sizeof(null_reference_length) /
+ sizeof(null_reference_length[0]));
+ unsigned int i;
+
+ for (i = 0; i < test_vec_num; i++) {
+ if (!check_cipher_options(ODP_CIPHER_ALG_NULL,
+ cipher_key.length, iv.length))
+ continue;
+
+ alg_test(ODP_CRYPTO_OP_ENCODE,
+ 0,
+ ODP_CIPHER_ALG_NULL,
+ iv,
+ NULL,
+ cipher_key,
+ ODP_AUTH_ALG_NULL,
+ auth_key,
+ NULL, NULL,
+ NULL, 0,
+ null_reference_plaintext[i],
+ null_reference_length[i],
+ null_reference_plaintext[i],
+ null_reference_length[i], NULL, 0);
+ }
+}
+
+void crypto_test_dec_alg_null(void)
+{
+ odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
+ auth_key = { .data = NULL, .length = 0 };
+ odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
+ unsigned int test_vec_num = (sizeof(null_reference_length) /
+ sizeof(null_reference_length[0]));
+ unsigned int i;
+
+ for (i = 0; i < test_vec_num; i++) {
+ if (!check_cipher_options(ODP_CIPHER_ALG_NULL,
+ cipher_key.length, iv.length))
+ continue;
+
+ alg_test(ODP_CRYPTO_OP_DECODE,
+ 0,
+ ODP_CIPHER_ALG_NULL,
+ iv,
+ NULL,
+ cipher_key,
+ ODP_AUTH_ALG_NULL,
+ auth_key,
+ NULL, NULL,
+ NULL, 0,
+ null_reference_plaintext[i],
+ null_reference_length[i],
+ null_reference_plaintext[i],
+ null_reference_length[i], NULL, 0);
+ }
+}
+
static int check_alg_3des_cbc(void)
{
return check_alg_support(ODP_CIPHER_ALG_3DES_CBC, ODP_AUTH_ALG_NULL);
@@ -1252,6 +1319,10 @@ int crypto_suite_async_init(void)
}
odp_testinfo_t crypto_suite[] = {
+ ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_null,
+ check_alg_null),
+ ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_null,
+ check_alg_null),
ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_3des_cbc,
check_alg_3des_cbc),
ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_3des_cbc,
@@ -8,6 +8,18 @@
#define _ODP_TEST_CRYPTO_VECTORS_H_
#include "test_vectors_len.h"
+
+/** length in bytes */
+static uint32_t null_reference_length[] = { 8, 16 };
+
+static uint8_t
+null_reference_plaintext[][NULL_MAX_DATA_LEN] = {
+ {0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56},
+
+ {0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, 0x6d, 0x8e, 0xa2, 0x30,
+ 0x94, 0xea, 0x53, 0x09}
+};
+
/* TDES-CBC reference vectors, according to
* "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf"
*/
@@ -6,6 +6,9 @@
#ifndef TEST_VECTORS_LEN_
#define TEST_VECTORS_LEN_
+/* NULL */
+#define NULL_MAX_DATA_LEN 16
+
/* TDES-CBC */
#define TDES_CBC_KEY_LEN 24
#define TDES_CBC_IV_LEN 8
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org> --- test/common_plat/validation/api/crypto/crypto.h | 2 + .../validation/api/crypto/odp_crypto_test_inp.c | 71 ++++++++++++++++++++++ .../validation/api/crypto/test_vectors.h | 12 ++++ .../validation/api/crypto/test_vectors_len.h | 3 + 4 files changed, 88 insertions(+) -- 2.11.0