On 2 December 2014 at 05:02, <[email protected]> wrote:

> From: Alexandru Badicioiu <[email protected]>
>
> Signed-off-by: Alexandru Badicioiu <[email protected]>
>

Reviewed-by: Mike Holmes <[email protected]>


> ---
>  test/validation/Makefile.am                  |    1 +
>  test/validation/crypto/odp_crypto_test_rng.c |   30
> ++++++++++++++++++++++++++
>  test/validation/crypto/odp_crypto_test_rng.h |   17 ++++++++++++++
>  test/validation/crypto/test_vectors.h        |   23 ++++++-------------
>  test/validation/crypto/test_vectors_len.h    |   21 ++++++++++++++++++
>  test/validation/odp_crypto.c                 |    2 +
>  6 files changed, 78 insertions(+), 16 deletions(-)
>  create mode 100644 test/validation/crypto/odp_crypto_test_rng.c
>  create mode 100644 test/validation/crypto/odp_crypto_test_rng.h
>  create mode 100644 test/validation/crypto/test_vectors_len.h
>
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index 0b831d0..52dbd50 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -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
> diff --git a/test/validation/crypto/odp_crypto_test_rng.c
> b/test/validation/crypto/odp_crypto_test_rng.c
> new file mode 100644
> index 0000000..2898cb1
> --- /dev/null
> +++ b/test/validation/crypto/odp_crypto_test_rng.c
> @@ -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_len.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,
> +};
> diff --git a/test/validation/crypto/odp_crypto_test_rng.h
> b/test/validation/crypto/odp_crypto_test_rng.h
> new file mode 100644
> index 0000000..16909b3
> --- /dev/null
> +++ b/test/validation/crypto/odp_crypto_test_rng.h
> @@ -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
> diff --git a/test/validation/crypto/test_vectors.h
> b/test/validation/crypto/test_vectors.h
> index c151952..369fc16 100644
> --- a/test/validation/crypto/test_vectors.h
> +++ b/test/validation/crypto/test_vectors.h
> @@ -4,15 +4,10 @@
>   * SPDX-License-Identifier:    BSD-3-Clause
>   */
>
> -
> +#include "test_vectors_len.h"
>  /* TDES-CBC reference vectors, according to
>   * "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf";
>   */
> -
> -#define TDES_CBC_KEY_LEN       24      /* key length(in bytes) for
> tdes-cbc */
> -#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] = {
>         {0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10, 0x43, 0xcd, 0x26,
> 0x5d,
>          0x58, 0x40, 0xea, 0xf1, 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a,
> 0x8c,
> @@ -31,27 +26,22 @@ static uint8_t
> tdes_cbc_reference_iv[][TDES_CBC_IV_LEN] = {
>  /** length in bytes */
>  static uint32_t tdes_cbc_reference_length[] = { 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] = {
>         {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] = {
>         {0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92},
>
>         {0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e, 0xbd, 0x04, 0xa7,
> 0x5f,
>          0xfb, 0xa7, 0xd2, 0xf5}
>  };
>
> -
> -/* HMAC-MD5 test vectors  - RFC2104 */
> -#define HMAC_MD5_KEY_LEN       16
> -#define HMAC_MD5_MAX_DATA_LEN  128
> -#define HMAC_MD5_DIGEST_LEN    16
> -#define HMAC_MD5_96_CHECK_LEN  12
> -
>  static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = {
>         { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
>           0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b } ,
> @@ -65,7 +55,8 @@ static uint8_t
> hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = {
>
>  static uint32_t hmac_md5_reference_length[] = { 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] = {
>         /* "Hi There" */
>         { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
>
> diff --git a/test/validation/crypto/test_vectors_len.h
> b/test/validation/crypto/test_vectors_len.h
> new file mode 100644
> index 0000000..8c83ba1
> --- /dev/null
> +++ b/test/validation/crypto/test_vectors_len.h
> @@ -0,0 +1,21 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +#ifndef TEST_VECTORS_LEN_
> +#define TEST_VECTORS_LEN_
> +
> +/* TDES-CBC */
> +#define TDES_CBC_KEY_LEN        24
> +#define TDES_CBC_IV_LEN         8
> +#define TDES_CBC_MAX_DATA_LEN   16
> +
> +
> +/* HMAC-MD5 */
> +#define HMAC_MD5_KEY_LEN        16
> +#define HMAC_MD5_MAX_DATA_LEN   128
> +#define HMAC_MD5_DIGEST_LEN     16
> +#define HMAC_MD5_96_CHECK_LEN   12
> +
> +#endif
> diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c
> index 9342aca..81343a9 100644
> --- a/test/validation/odp_crypto.c
> +++ b/test/validation/odp_crypto.c
> @@ -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,
>  };
>
> --
> 1.7.3.4
>
>
> _______________________________________________
> lng-odp mailing list
> [email protected]
> http://lists.linaro.org/mailman/listinfo/lng-odp
>



-- 
*Mike Holmes*
Linaro  Sr Technical Manager
LNG - ODP
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to