@@ -17,4 +17,5 @@ dist_odp_init_SOURCES = odp_init.c
dist_odp_queue_SOURCES = odp_queue.c
dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
crypto/odp_crypto_test_sync_inp.c \
+ crypto/odp_crypto_test_rng.c \
odp_crypto.c
new file mode 100644
@@ -0,0 +1,30 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include <odp.h>
+#include "CUnit/Basic.h"
+#include "CUnit/TestDB.h"
+#include "test_vectors.h"
+
+/*
+ * This test verifies that HW random number generator is able
+ * to produce an IV for TDES_CBC cipher algorithm.
+ * */
+#define RNG_GET_SIZE "RNG_GET_SIZE"
+static void rng_get_size(void)
+{
+ int ret;
+ size_t len = TDES_CBC_IV_LEN;
+ uint8_t buf[TDES_CBC_IV_LEN];
+
+ ret = odp_hw_random_get(buf, &len, false);
+ CU_ASSERT(!ret);
+ CU_ASSERT(len == TDES_CBC_IV_LEN);
+}
+
+CU_TestInfo test_rng[] = {
+ { RNG_GET_SIZE, rng_get_size },
+ CU_TEST_INFO_NULL,
+};
new file mode 100644
@@ -0,0 +1,17 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#ifndef ODP_CRYPTO_TEST_RNG_
+#define ODP_CRYPTO_TEST_RNG_
+
+#include "CUnit/TestDB.h"
+
+/* Suite name */
+#define ODP_CRYPTO_RNG "ODP_CRYPTO_RNG"
+
+/* Suite test array */
+extern CU_TestInfo test_rng[];
+
+#endif
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-
+#define TEST_UNUSED __attribute__((unused))
/* TDES-CBC reference vectors, according to
* "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf"
*/
@@ -13,7 +13,7 @@
#define TDES_CBC_IV_LEN 8 /* IV length(in bytes) for tdes-cbc */
#define TDES_CBC_MAX_DATA_LEN 16 /* max. plain text length(in bytes) */
-static uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] = {
+static uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] TEST_UNUSED = {
{0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10, 0x43, 0xcd, 0x26, 0x5d,
0x58, 0x40, 0xea, 0xf1, 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c,
},
@@ -22,23 +22,25 @@ static uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] = {
0x31, 0xcb, 0xb3, 0x85, 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae}
};
-static uint8_t tdes_cbc_reference_iv[][TDES_CBC_IV_LEN] = {
+static uint8_t tdes_cbc_reference_iv[][TDES_CBC_IV_LEN] TEST_UNUSED = {
{0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75},
{0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65}
};
/** length in bytes */
-static uint32_t tdes_cbc_reference_length[] = { 8, 16 };
+static uint32_t tdes_cbc_reference_length[] TEST_UNUSED = { 8, 16 };
-static uint8_t tdes_cbc_reference_plaintext[][TDES_CBC_MAX_DATA_LEN] = {
+static uint8_t
+tdes_cbc_reference_plaintext[][TDES_CBC_MAX_DATA_LEN] TEST_UNUSED = {
{0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56},
{0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, 0x6d, 0x8e, 0xa2, 0x30,
0x94, 0xea, 0x53, 0x09}
};
-static uint8_t tdes_cbc_reference_ciphertext[][TDES_CBC_MAX_DATA_LEN] = {
+static uint8_t
+tdes_cbc_reference_ciphertext[][TDES_CBC_MAX_DATA_LEN] TEST_UNUSED = {
{0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92},
{0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e, 0xbd, 0x04, 0xa7, 0x5f,
@@ -52,7 +54,7 @@ static uint8_t tdes_cbc_reference_ciphertext[][TDES_CBC_MAX_DATA_LEN] = {
#define HMAC_MD5_DIGEST_LEN 16
#define HMAC_MD5_96_CHECK_LEN 12
-static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = {
+static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] TEST_UNUSED = {
{ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b } ,
@@ -63,9 +65,10 @@ static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = {
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }
};
-static uint32_t hmac_md5_reference_length[] = { 8, 28, 50 };
+static uint32_t hmac_md5_reference_length[] TEST_UNUSED = { 8, 28, 50 };
-static uint8_t hmac_md5_reference_plaintext[][HMAC_MD5_MAX_DATA_LEN] = {
+static uint8_t
+hmac_md5_reference_plaintext[][HMAC_MD5_MAX_DATA_LEN] TEST_UNUSED = {
/* "Hi There" */
{ 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
@@ -82,7 +85,7 @@ static uint8_t hmac_md5_reference_plaintext[][HMAC_MD5_MAX_DATA_LEN] = {
0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd }
};
-static uint8_t hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = {
+static uint8_t hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] TEST_UNUSED = {
{ 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d },
@@ -9,6 +9,7 @@
#include "CUnit/TestDB.h"
#include "odp_crypto_test_async_inp.h"
#include "odp_crypto_test_sync_inp.h"
+#include "odp_crypto_test_rng.h"
#define SHM_PKT_POOL_SIZE (512*2048*2)
#define SHM_PKT_POOL_BUF_SIZE (1024 * 32)
@@ -26,6 +27,7 @@ static int init_suite(void)
CU_SuiteInfo suites[] = {
{ODP_CRYPTO_SYNC_INP, init_suite, NULL, NULL, NULL, test_array_sync },
{ODP_CRYPTO_ASYNC_INP, init_suite, NULL, NULL, NULL, test_array_async },
+ {ODP_CRYPTO_RNG, init_suite, NULL, NULL, NULL, test_rng },
CU_SUITE_INFO_NULL,
};