On 25 November 2014 at 15:10, Taras Kondratiuk <[email protected]>
wrote:
> On 11/25/2014 12:21 PM, Alexandru Badicioiu wrote:
>
> > +
>> > +/*
>> > + * 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,
>>
>> Size of test_rng is defined as a size of one in the header but is size
>> of two elements here.
>>
>> [Alex] CUnit does not use the declared size of the array - I guess this
>> is the purpose of the end marker (CU_TEST_INFO_NULL). Declaring a
>> pointer only it will not compile :
>> odp_crypto.c:23:2: error: initializer element is not constant
>> odp_crypto.c:23:2: error: (near initialization for 'suites[2].pTests')
>> odp_crypto.c:23:2: error: missing initializer
>> [-Werror=missing-field-initializers]
>> odp_crypto.c:23:2: error: (near initialization for 'suites[2].pTests')
>> [-Werror=missing-field-initializers]
>> Trying to declare the array as flexible will not work either
>> (CU_TestInfo test_rng[];):
>> In file included from odp_crypto.c:12:0:
>> ./crypto/odp_crypto_test_rng.h:15:13: error: array 'test_rng' assumed to
>> have one element [-Werror]
>> cc1: all warnings being treated as errors
>> This is the reason I used 1 as the declared size of the array.
>>
>
> This should work:
> extern CU_TestInfo test_rng[];
[Alex] Thanks. It seems I missed that the array is an extern and it should
be declared as such.
>
>
> > +
>> > +#endif
>> > +
>> > diff --git a/test/validation/crypto/test_vectors.h
>> b/test/validation/crypto/test_vectors.h
>> > index c151952..aaf0103 100644
>> > --- a/test/validation/crypto/test_vectors.h
>> > +++ b/test/validation/crypto/test_vectors.h
>> > @@ -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]
>> ODP_UNUSED
>>
>> Not sure why this is flagged unused it appears to be used in
>> crypto/odp_crypto_test_async_inp.c and
>> crypto/odp_crypto_test_sync_inp.c
>>
>> [Alex] These are static declaration, as such they are reported unused in
>> test_rng.c file where they are unused. To avoid unused, they should be
>> moved to a .c file and only be declared in test_vectors.h.
>>
>
> That's a hacky solution. You can split these structures into a separate
> .h and not include them in RNG tests.
>
[Alex] Following this approach we may end up with an unpractical amount of
files. The present test uses only TDES_CBC_IV_LEN and it would mean to
have a .h file only with definitions for IV lengths.
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp