Fix code style and clarify issue comment

* remove unneeded constants
* clarify comment reference to issue 183
* add additional reference comment
* fix brace spacing issues
This commit is contained in:
Nir Sonnenschein 2018-11-01 12:27:20 +02:00
parent dd69d8b7ff
commit 1caf6d24f2

View File

@ -3091,9 +3091,9 @@ void test_derive_invalid_generator_state( )
psa_key_slot_t base_key = 1;
size_t key_type = PSA_KEY_TYPE_DERIVE;
psa_crypto_generator_t generator = PSA_CRYPTO_GENERATOR_INIT;
psa_algorithm_t alg = PSA_ALG_HKDF(PSA_ALG_SHA_256);
size_t capacity = 42;
psa_algorithm_t alg = PSA_ALG_HKDF( PSA_ALG_SHA_256 );
uint8_t buffer[42];
size_t capacity = sizeof( buffer );
const uint8_t key_data[22] = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b};
@ -3107,7 +3107,7 @@ void test_derive_invalid_generator_state( )
TEST_ASSERT( psa_import_key( base_key, key_type,
key_data,
sizeof(key_data) ) == PSA_SUCCESS );
sizeof( key_data ) ) == PSA_SUCCESS );
/* valid key derivation */
TEST_ASSERT( psa_key_derivation( &generator, base_key, alg,
@ -3145,18 +3145,18 @@ void test_derive_invalid_generator_tests( )
psa_crypto_generator_t generator = PSA_CRYPTO_GENERATOR_INIT;
TEST_ASSERT( psa_generator_read( &generator, output_buffer, buffer_size )
== PSA_ERROR_INSUFFICIENT_CAPACITY );
== PSA_ERROR_INSUFFICIENT_CAPACITY ); // should be PSA_ERROR_BAD_STATE:#183
TEST_ASSERT( psa_get_generator_capacity( &generator, &capacity )
== PSA_SUCCESS ); // should be PSA_ERROR_BAD_STATE:issue opened
== PSA_SUCCESS ); // should be PSA_ERROR_BAD_STATE:#183
TEST_ASSERT( psa_generator_abort( &generator ) == PSA_SUCCESS );
TEST_ASSERT( psa_generator_read( &generator, output_buffer, buffer_size )
== PSA_ERROR_INSUFFICIENT_CAPACITY );
== PSA_ERROR_INSUFFICIENT_CAPACITY ); // should be PSA_ERROR_BAD_STATE:#183
TEST_ASSERT( psa_get_generator_capacity( &generator, &capacity )
== PSA_SUCCESS );// should be PSA_ERROR_BAD_STATE:issue opened
== PSA_SUCCESS );// should be PSA_ERROR_BAD_STATE:#183
exit:
psa_generator_abort( &generator );