mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-26 03:35:35 +00:00
Add tests for the newly created ad-hoc EC J-PAKE KDF
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
08d34b8693
commit
d8705bc7b7
@ -4824,6 +4824,10 @@ PSA key derivation setup: TLS 1.2 PRF SHA-256, good case
|
||||
depends_on:PSA_WANT_ALG_SHA_256:PSA_WANT_ALG_TLS12_PRF
|
||||
derive_setup:PSA_ALG_TLS12_PRF(PSA_ALG_SHA_256):PSA_SUCCESS
|
||||
|
||||
PSA key derivation setup: TLS 1.2 ECJPAKE to PMS
|
||||
depends_on:PSA_WANT_ALG_SHA_256:PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS
|
||||
derive_setup:PSA_ALG_TLS12_ECJPAKE_TO_PMS:PSA_SUCCESS
|
||||
|
||||
PSA key derivation setup: not a key derivation algorithm (HMAC)
|
||||
depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256
|
||||
derive_setup:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_INVALID_ARGUMENT
|
||||
@ -5793,6 +5797,35 @@ PSA key derivation: over capacity 42: output 43+1
|
||||
depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_256
|
||||
derive_output:PSA_ALG_HKDF(PSA_ALG_SHA_256):PSA_KEY_DERIVATION_INPUT_SALT:"000102030405060708090a0b0c":PSA_SUCCESS:PSA_KEY_DERIVATION_INPUT_SECRET:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":PSA_SUCCESS:PSA_KEY_DERIVATION_INPUT_INFO:"f0f1f2f3f4f5f6f7f8f9":PSA_SUCCESS:0:"":PSA_SUCCESS:"":42:"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865ff":"ff":0:1:0
|
||||
|
||||
PSA key derivation: ECJPAKE to PMS, no input
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
derive_ecjpake_to_pms:"":PSA_ERROR_INVALID_ARGUMENT:"":PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
PSA key derivation: ECJPAKE to PMS, input too short
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
derive_ecjpake_to_pms:"deadbeef":PSA_ERROR_INVALID_ARGUMENT:"":PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
PSA key derivation: ECJPAKE to PMS, input too long
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
derive_ecjpake_to_pms:"0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de":PSA_ERROR_INVALID_ARGUMENT:"":PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
PSA key derivation: ECJPAKE to PMS, bad input format
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
derive_ecjpake_to_pms:"0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000":PSA_ERROR_INVALID_ARGUMENT:"":PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
#NIST CAVS 11.0 SHA-256 ShortMSG vector for L=256
|
||||
PSA key derivation: ECJPAKE to PMS, good case
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
derive_ecjpake_to_pms:"0409fc1accc230a205e4a208e64a8f204291f581a12756392da4b8c0cf5ef02b950000000000000000000000000000000000000000000000000000000000000000":PSA_SUCCESS:"4f44c1c7fbebb6f9601829f3897bfd650c56fa07844be76489076356ac1886a4":PSA_SUCCESS
|
||||
|
||||
PSA key derivation: ECJPAKE to PMS, output too short
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
derive_ecjpake_to_pms:"0409fc1accc230a205e4a208e64a8f204291f581a12756392da4b8c0cf5ef02b950000000000000000000000000000000000000000000000000000000000000000":PSA_SUCCESS:"4f":PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
PSA key derivation: ECJPAKE to PMS, output too long
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
derive_ecjpake_to_pms:"0409fc1accc230a205e4a208e64a8f204291f581a12756392da4b8c0cf5ef02b950000000000000000000000000000000000000000000000000000000000000000":PSA_SUCCESS:"4f44c1c7fbebb6f9601829f3897bfd650c56fa07844be76489076356ac1886a400":PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
PSA key derivation: HKDF SHA-256, read maximum capacity minus 1
|
||||
depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_256
|
||||
derive_full:PSA_ALG_HKDF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":255 * PSA_HASH_LENGTH(PSA_ALG_SHA_256) - 1
|
||||
|
@ -7233,6 +7233,45 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS:MBEDTLS_SHA256_C */
|
||||
void derive_ecjpake_to_pms( data_t *input, int expected_input_status,
|
||||
data_t *expected_output, int expected_output_status )
|
||||
{
|
||||
psa_algorithm_t alg = PSA_ALG_TLS12_ECJPAKE_TO_PMS;
|
||||
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
|
||||
|
||||
uint8_t *output_buffer = NULL;
|
||||
psa_status_t status;
|
||||
|
||||
ASSERT_ALLOC( output_buffer, expected_output->len );
|
||||
PSA_ASSERT( psa_crypto_init() );
|
||||
|
||||
PSA_ASSERT( psa_key_derivation_setup( &operation, alg ) );
|
||||
PSA_ASSERT( psa_key_derivation_set_capacity( &operation,
|
||||
expected_output->len ) );
|
||||
|
||||
TEST_EQUAL( psa_key_derivation_input_bytes( &operation,
|
||||
PSA_KEY_DERIVATION_INPUT_SECRET, input->x, input->len ),
|
||||
(psa_status_t) expected_input_status );
|
||||
|
||||
if( ( (psa_status_t) expected_input_status ) != PSA_SUCCESS )
|
||||
goto exit;
|
||||
|
||||
status = psa_key_derivation_output_bytes( &operation, output_buffer,
|
||||
expected_output->len );
|
||||
|
||||
TEST_EQUAL( status, (psa_status_t) expected_output_status );
|
||||
if( expected_output->len != 0 && expected_output_status == PSA_SUCCESS )
|
||||
ASSERT_COMPARE( output_buffer, expected_output->len, expected_output->x,
|
||||
expected_output->len );
|
||||
|
||||
exit:
|
||||
mbedtls_free( output_buffer );
|
||||
psa_key_derivation_abort( &operation );
|
||||
PSA_DONE();
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void derive_key_exercise( int alg_arg,
|
||||
data_t *key_data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user