From 07a30c4c009e192e35d63b22088ad65516beaee7 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 20 Apr 2021 14:13:23 +0100 Subject: [PATCH 001/966] Convert oneshot AEAD over to multipart struct Multipart AEAD operation struct has to be public as it's allocated by the caller, so to save duplication of code, switch oneshot AEAD over to using the multipart operation struct. Signed-off-by: Paul Elliott --- include/psa/crypto_struct.h | 22 +++++++++++++---- library/psa_crypto_aead.c | 48 +++++++++++-------------------------- 2 files changed, 31 insertions(+), 39 deletions(-) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 47012fdd00..a1182c48db 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -75,6 +75,8 @@ extern "C" { #include "mbedtls/cmac.h" #include "mbedtls/gcm.h" +#include "mbedtls/ccm.h" +#include "mbedtls/chachapoly.h" /* Include the context definition for the compiled-in drivers for the primitive * algorithms. */ @@ -153,17 +155,27 @@ struct psa_aead_operation_s { psa_algorithm_t alg; unsigned int key_set : 1; - unsigned int iv_set : 1; - uint8_t iv_size; - uint8_t block_size; + unsigned int nonce_set : 1; + + uint8_t tag_length; + union { unsigned dummy; /* Enable easier initializing of the union. */ - mbedtls_cipher_context_t cipher; +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + mbedtls_ccm_context ccm; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + mbedtls_gcm_context gcm; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + mbedtls_chachapoly_context chachapoly; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + } ctx; }; -#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, {0}} +#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, {0}} static inline struct psa_aead_operation_s psa_aead_operation_init( void ) { const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT; diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 356679c38f..07c52d433a 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -30,30 +30,10 @@ #include "mbedtls/cipher.h" #include "mbedtls/gcm.h" -typedef struct -{ - union - { - unsigned dummy; /* Make the union non-empty even with no supported algorithms. */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - mbedtls_ccm_context ccm; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - mbedtls_gcm_context gcm; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - mbedtls_chachapoly_context chachapoly; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ - } ctx; - psa_algorithm_t core_alg; - uint8_t tag_length; -} aead_operation_t; -#define AEAD_OPERATION_INIT {{0}, 0, 0} - -static void psa_aead_abort_internal( aead_operation_t *operation ) +static void psa_aead_abort_internal( psa_aead_operation_t *operation ) { - switch( operation->core_alg ) + switch( operation->alg ) { #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) case PSA_ALG_CCM: @@ -74,7 +54,7 @@ static void psa_aead_abort_internal( aead_operation_t *operation ) } static psa_status_t psa_aead_setup( - aead_operation_t *operation, + psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, psa_algorithm_t alg ) @@ -97,7 +77,7 @@ static psa_status_t psa_aead_setup( { #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 0 ): - operation->core_alg = PSA_ALG_CCM; + operation->alg = PSA_ALG_CCM; full_tag_length = 16; /* CCM allows the following tag lengths: 4, 6, 8, 10, 12, 14, 16. * The call to mbedtls_ccm_encrypt_and_tag or @@ -116,7 +96,7 @@ static psa_status_t psa_aead_setup( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ): - operation->core_alg = PSA_ALG_GCM; + operation->alg = PSA_ALG_GCM; full_tag_length = 16; /* GCM allows the following tag lengths: 4, 8, 12, 13, 14, 15, 16. * The call to mbedtls_gcm_crypt_and_tag or @@ -135,7 +115,7 @@ static psa_status_t psa_aead_setup( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CHACHA20_POLY1305, 0 ): - operation->core_alg = PSA_ALG_CHACHA20_POLY1305; + operation->alg = PSA_ALG_CHACHA20_POLY1305; full_tag_length = 16; /* We only support the default tag length. */ if( alg != PSA_ALG_CHACHA20_POLY1305 ) @@ -176,7 +156,7 @@ psa_status_t mbedtls_psa_aead_encrypt( uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - aead_operation_t operation = AEAD_OPERATION_INIT; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; uint8_t *tag; (void) key_buffer_size; @@ -194,7 +174,7 @@ psa_status_t mbedtls_psa_aead_encrypt( tag = ciphertext + plaintext_length; #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation.core_alg == PSA_ALG_CCM ) + if( operation.alg == PSA_ALG_CCM ) { status = mbedtls_to_psa_error( mbedtls_ccm_encrypt_and_tag( &operation.ctx.ccm, @@ -208,7 +188,7 @@ psa_status_t mbedtls_psa_aead_encrypt( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.core_alg == PSA_ALG_GCM ) + if( operation.alg == PSA_ALG_GCM ) { status = mbedtls_to_psa_error( mbedtls_gcm_crypt_and_tag( &operation.ctx.gcm, @@ -222,7 +202,7 @@ psa_status_t mbedtls_psa_aead_encrypt( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - if( operation.core_alg == PSA_ALG_CHACHA20_POLY1305 ) + if( operation.alg == PSA_ALG_CHACHA20_POLY1305 ) { if( nonce_length != 12 || operation.tag_length != 16 ) { @@ -286,7 +266,7 @@ psa_status_t mbedtls_psa_aead_decrypt( uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - aead_operation_t operation = AEAD_OPERATION_INIT; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; const uint8_t *tag = NULL; (void) key_buffer_size; @@ -301,7 +281,7 @@ psa_status_t mbedtls_psa_aead_decrypt( goto exit; #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation.core_alg == PSA_ALG_CCM ) + if( operation.alg == PSA_ALG_CCM ) { status = mbedtls_to_psa_error( mbedtls_ccm_auth_decrypt( &operation.ctx.ccm, @@ -315,7 +295,7 @@ psa_status_t mbedtls_psa_aead_decrypt( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.core_alg == PSA_ALG_GCM ) + if( operation.alg == PSA_ALG_GCM ) { status = mbedtls_to_psa_error( mbedtls_gcm_auth_decrypt( &operation.ctx.gcm, @@ -329,7 +309,7 @@ psa_status_t mbedtls_psa_aead_decrypt( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - if( operation.core_alg == PSA_ALG_CHACHA20_POLY1305 ) + if( operation.alg == PSA_ALG_CHACHA20_POLY1305 ) { if( nonce_length != 12 || operation.tag_length != 16 ) { From adb8b16b16091187d17b4a29de74dc3cc37c3502 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 20 Apr 2021 16:06:57 +0100 Subject: [PATCH 002/966] Add internal implementation of multipart AEAD For the time being CCM and GCM are not entirely implemented correctly due to issues with their underlying implentations, which would be difficult to fix in 2.x, and thus require all the AD and data to be passed in in one go. Signed-off-by: Paul Elliott --- include/psa/crypto_struct.h | 24 +- library/psa_crypto_aead.c | 756 ++++++++++++++++++++++++++++++++++-- library/psa_crypto_aead.h | 640 ++++++++++++++++++++++++++++++ 3 files changed, 1397 insertions(+), 23 deletions(-) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index a1182c48db..6c93814be3 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -154,10 +154,32 @@ static inline struct psa_mac_operation_s psa_mac_operation_init( void ) struct psa_aead_operation_s { psa_algorithm_t alg; + psa_key_type_t key_type; + unsigned int key_set : 1; unsigned int nonce_set : 1; + unsigned int lengths_set : 1; + unsigned int is_encrypt : 1; + unsigned int ad_started : 1; + unsigned int body_started : 1; uint8_t tag_length; + uint8_t nonce_length; + + size_t ad_remaining; + size_t body_remaining; + + /* Buffers for AD/data - only required until CCM gets proper multipart + support. */ + uint8_t* ad_buffer; + size_t ad_length; + + uint8_t* data_buffer; + size_t data_length; + + /* buffer to store Nonce - only required until CCM and GCM get proper + multipart support. */ + uint8_t nonce[PSA_AEAD_NONCE_MAX_SIZE]; union { @@ -175,7 +197,7 @@ struct psa_aead_operation_s } ctx; }; -#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, {0}} +#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} static inline struct psa_aead_operation_s psa_aead_operation_init( void ) { const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT; diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 07c52d433a..47b0e7b3e2 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -20,39 +20,40 @@ #include "common.h" + #if defined(MBEDTLS_PSA_CRYPTO_C) #include "psa_crypto_aead.h" #include "psa_crypto_core.h" +#include +#include "mbedtls/platform.h" +#if !defined(MBEDTLS_PLATFORM_C) +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + #include "mbedtls/ccm.h" #include "mbedtls/chachapoly.h" #include "mbedtls/cipher.h" #include "mbedtls/gcm.h" +#include "mbedtls/error.h" - -static void psa_aead_abort_internal( psa_aead_operation_t *operation ) +/* Constant-time buffer comparison. This is duplication of code from + * psa_crypto.c, but has nowhere private I can put it for the minute. Really + belongs in the constant time module, when that gets implemented */ +static inline int safer_memcmp( const uint8_t *a, const uint8_t *b, size_t n ) { - switch( operation->alg ) - { -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - case PSA_ALG_CCM: - mbedtls_ccm_free( &operation->ctx.ccm ); - break; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - case PSA_ALG_GCM: - mbedtls_gcm_free( &operation->ctx.gcm ); - break; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - case PSA_ALG_CHACHA20_POLY1305: - mbedtls_chachapoly_free( &operation->ctx.chachapoly ); - break; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ - } + size_t i; + unsigned char diff = 0; + + for( i = 0; i < n; i++ ) + diff |= a[i] ^ b[i]; + + return( diff ); } + static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, @@ -65,6 +66,12 @@ static psa_status_t psa_aead_setup( mbedtls_cipher_id_t cipher_id; size_t full_tag_length = 0; + if( operation->key_set || operation->nonce_set || + operation->ad_started || operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + key_bits = attributes->core.bits; cipher_info = mbedtls_cipher_info_from_psa( alg, @@ -143,6 +150,8 @@ static psa_status_t psa_aead_setup( key_bits, alg ); + operation->key_set = 1; + return( PSA_SUCCESS ); } @@ -230,7 +239,7 @@ psa_status_t mbedtls_psa_aead_encrypt( *ciphertext_length = plaintext_length + operation.tag_length; exit: - psa_aead_abort_internal( &operation ); + mbedtls_psa_aead_abort( &operation ); return( status ); } @@ -336,12 +345,715 @@ psa_status_t mbedtls_psa_aead_decrypt( *plaintext_length = ciphertext_length - operation.tag_length; exit: - psa_aead_abort_internal( &operation ); + mbedtls_psa_aead_abort( &operation ); if( status == PSA_SUCCESS ) *plaintext_length = ciphertext_length - operation.tag_length; return( status ); } +/* Set the key and algorithm for a multipart authenticated encryption + * operation. */ +psa_status_t mbedtls_psa_aead_encrypt_setup( psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ) +{ + psa_status_t status; + + (void) key_buffer_size; + + status = psa_aead_setup( operation, attributes, key_buffer, alg ); + + if( status == PSA_SUCCESS ) + { + operation->is_encrypt = 1; + } + + return ( status ); +} + +/* Set the key and algorithm for a multipart authenticated decryption + * operation. */ +psa_status_t mbedtls_psa_aead_decrypt_setup( psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ) +{ + psa_status_t status; + + (void) key_buffer_size; + + status = psa_aead_setup( operation, attributes, key_buffer, alg ); + + if( status == PSA_SUCCESS ) + { + operation->is_encrypt = 0; + } + + return ( status ); +} + +/* Generate a random nonce / IV for multipart AEAD operation */ +psa_status_t mbedtls_psa_aead_generate_nonce( psa_aead_operation_t *operation, + uint8_t *nonce, + size_t nonce_size, + size_t *nonce_length ) +{ + psa_status_t status; + size_t required_nonce_size = nonce_size; + + if( !operation->key_set || operation->nonce_set || + operation->ad_started || operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type, operation->alg); + + if( nonce_size == 0 || nonce_size < required_nonce_size ) + { + return( PSA_ERROR_BUFFER_TOO_SMALL ); + } + + status = psa_generate_random( nonce, required_nonce_size ); + + if( status != PSA_SUCCESS ) + { + return status; + } + + status = mbedtls_psa_aead_set_nonce( operation, nonce, required_nonce_size ); + + if( status == PSA_SUCCESS ) + { + *nonce_length = required_nonce_size; + } + + return status; +} + +/* Set a nonce for the multipart AEAD operation*/ +psa_status_t mbedtls_psa_aead_set_nonce( psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length ) +{ + psa_status_t status; + + if( !operation->key_set || operation->nonce_set || + operation->ad_started || operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + /* Restricting to a nominal safe length for nonces even though some + algorithms can handle longer nonces, but not without collision */ + if( nonce_length > PSA_AEAD_NONCE_MAX_SIZE ) + { + return( PSA_ERROR_INVALID_ARGUMENT ); + } + + #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { + /* GCM sets nonce once additional data has been supplied */ + memcpy(operation->nonce, nonce, nonce_length); + + /* We know that nonce size cannot exceed the uint8_t size */ + operation->nonce_length = ( uint8_t ) nonce_length; + status = PSA_SUCCESS; + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + /* Multipart CCM not supported as yet, so CCM is basically operating + in oneshot mode. Store the nonce as we need this later */ + memcpy(operation->nonce, nonce, nonce_length); + + /* We know that nonce size cannot exceed the uint8_t size */ + operation->nonce_length = ( uint8_t ) nonce_length; + status = PSA_SUCCESS; + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + if( nonce_length != 12 && nonce_length != 8) + { + return( PSA_ERROR_INVALID_ARGUMENT ); + } + + status = mbedtls_to_psa_error(mbedtls_chachapoly_starts( &operation->ctx.chachapoly, + nonce, + operation->is_encrypt ? + MBEDTLS_CHACHAPOLY_ENCRYPT : + MBEDTLS_CHACHAPOLY_DECRYPT ) ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + { + ( void ) nonce; + ( void ) nonce_length; + + return ( PSA_ERROR_NOT_SUPPORTED ); + } + + if( status == PSA_SUCCESS ) + { + operation->nonce_set = 1; + } + + return( status ); +} + /* Declare the lengths of the message and additional data for AEAD. */ +psa_status_t mbedtls_psa_aead_set_lengths( psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ) +{ + + if( !operation->key_set || operation->lengths_set ) + { + return( PSA_ERROR_BAD_STATE ); + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { +#if SIZE_MAX > UINT32_MAX + if( ( (uint64_t) ad_length ) >> 61 != 0 || + ( (uint64_t) plaintext_length ) > 0xFFFFFFFE0ull ) + { + return ( PSA_ERROR_INVALID_ARGUMENT ); + } +#endif + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + if( ad_length > 0xFF00 ) + { + return ( PSA_ERROR_INVALID_ARGUMENT ); + } + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + /* No length restrictions for ChaChaPoly. */ + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + { + ( void ) ad_length; + ( void ) plaintext_length; + + return ( PSA_ERROR_NOT_SUPPORTED ); + } + + operation->ad_remaining = ad_length; + operation->body_remaining = plaintext_length; + operation->lengths_set = 1; + + return ( PSA_SUCCESS ); +} + +/* Pass additional data to an active multipart AEAD operation. */ +psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length ) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + + if( !operation->nonce_set || !operation->key_set ) + { + return( PSA_ERROR_BAD_STATE ); + } + + if( operation->lengths_set ) + { + if ( operation->ad_remaining < input_length ) + { + return( PSA_ERROR_INVALID_ARGUMENT ); + } + + operation->ad_remaining -= input_length; + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { + if( !operation->lengths_set || operation->ad_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + /* GCM currently requires all the additional data to be passed in in + * one contigious buffer, so until that is re-done, we have to enforce + * this, as we cannot allocate a buffer to collate multiple calls into. + */ + if( input_length != operation->ad_remaining ) + { + return ( PSA_ERROR_INVALID_ARGUMENT ); + } + + status = mbedtls_to_psa_error( mbedtls_gcm_starts( &operation->ctx.gcm, + operation->is_encrypt ? + MBEDTLS_GCM_ENCRYPT : MBEDTLS_GCM_DECRYPT, + operation->nonce, + operation->nonce_length, + input, + input_length ) ); + + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + /* CCM requires all additional data to be passed in in one go at the + minute, as we are basically operating in oneshot mode. */ + if( !operation->lengths_set || operation->ad_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + /* Save the additional data for later, this will be passed in + when we have the body. */ + operation->ad_buffer = ( uint8_t * ) mbedtls_calloc(1, input_length ); + + if( operation->ad_buffer ) + { + memcpy( operation->ad_buffer, input, input_length ); + operation->ad_length = input_length; + } + else + { + return ( PSA_ERROR_INSUFFICIENT_MEMORY ); + } + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + status = mbedtls_to_psa_error( mbedtls_chachapoly_update_aad( &operation->ctx.chachapoly, + input, + input_length ) ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + { + (void) input; + (void) input_length; + + return ( PSA_ERROR_NOT_SUPPORTED ); + } + + if( status == PSA_SUCCESS ) + { + operation->ad_started = 1; + } + + return ( status ); +} + +/* Encrypt or decrypt a message fragment in an active multipart AEAD + * operation.*/ +psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length ) +{ + size_t update_output_size; + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + + if( !operation->nonce_set || !operation->key_set || !operation->ad_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + update_output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE(operation->key_type, + operation->alg, input_length); + + if(update_output_size > output_size ) + { + return ( PSA_ERROR_BUFFER_TOO_SMALL ); + } + + if( operation->lengths_set) + { + /* Additional data length was supplied, but not all the additional + data was supplied.*/ + if( operation->ad_remaining != 0 ) + { + return ( PSA_ERROR_INVALID_ARGUMENT ); + } + + /* Too much data provided. */ + if( operation->body_remaining < input_length ) + { + return ( PSA_ERROR_INVALID_ARGUMENT ); + } + + operation->body_remaining -= input_length; + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { + /* For the time being set the requirement that all of the body data + * must be passed in in one update, rather than deal with the complexity + * of non block size aligned updates. This will be fixed in 3.0 when + we can change the signature of the GCM multipart functions */ + if( !operation->lengths_set || operation->body_remaining != 0 ) + { + return( PSA_ERROR_BAD_STATE ); + } + + if( operation->ad_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + status = mbedtls_to_psa_error( mbedtls_gcm_update( &operation->ctx.gcm, + input_length, + input, + output ) ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + /* CCM dooes not support multipart yet, so all the input has to be + passed in in one go. Store the data for the final step.*/ + if( operation->ad_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + /* Save the additional data for later, this will be passed in + when we have the body. */ + operation->data_buffer = ( uint8_t * ) mbedtls_calloc(1, input_length ); + + if( operation->data_buffer ) + { + memcpy( operation->data_buffer, input, input_length ); + operation->data_length = input_length; + } + else + { + return ( PSA_ERROR_INSUFFICIENT_MEMORY ); + } + + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + status = mbedtls_to_psa_error( mbedtls_chachapoly_update( &operation->ctx.chachapoly, + input_length, + input, + output ) ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + { + (void) input; + (void) input_length; + + return ( PSA_ERROR_NOT_SUPPORTED ); + } + + if( status == PSA_SUCCESS ) + { + *output_length = update_output_size; + operation->body_started = 1; + } + + return( status ); +} + +/* Common checks for both mbedtls_psa_aead_finish() and + mbedtls_psa_aead_verify() */ +static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t *operation, + size_t output_size, + size_t tag_size, + size_t *finish_output_size, + size_t *output_tag_length ) +{ + if( !operation->key_set || !operation->nonce_set + || !operation->ad_started || !operation->body_started) + { + return( PSA_ERROR_BAD_STATE ); + } + + if( operation->lengths_set ) + { + if( operation->ad_remaining != 0 || operation->body_remaining != 0 ) + { + return( PSA_ERROR_BAD_STATE ); + } + } + + *output_tag_length = operation->tag_length; + + if( tag_size < *output_tag_length) + { + return ( PSA_ERROR_BUFFER_TOO_SMALL ); + } + + if( operation->is_encrypt ) + { + *finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE(operation->key_type, + operation->alg); + } + else + { + *finish_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE(operation->key_type, + operation->alg); + } + + if( output_size < *finish_output_size ) + { + return ( PSA_ERROR_BUFFER_TOO_SMALL ); + } + + return ( PSA_SUCCESS ); + +} + +/* Finish encrypting a message in a multipart AEAD operation. */ +psa_status_t mbedtls_psa_aead_finish( psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length ) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + size_t output_tag_length; + size_t finish_output_size; + + status = mbedtls_psa_aead_finish_checks( operation, ciphertext_size, tag_size, &finish_output_size, + &output_tag_length); + + if( status != PSA_SUCCESS ) + { + return status; + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { + /* We will need to do final GCM pass in here when multipart is done. */ + status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, + tag, + tag_size ) ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + if( !operation->ad_buffer || !operation->data_buffer ) + { + return( PSA_ERROR_BAD_STATE ); + } + + /* Perform oneshot CCM encryption with data already stored, as + CCM does not support multipart yet.*/ + status = mbedtls_to_psa_error( mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm, + operation->data_length, + operation->nonce, + operation->nonce_length, + operation->ad_buffer, + operation->ad_length, + operation->data_buffer, + ciphertext, + tag, tag_size ) ); + + /* Even if the above operation fails, we no longer need the data */ + mbedtls_free(operation->ad_buffer); + operation->ad_buffer = NULL; + operation->ad_length = 0; + + mbedtls_free(operation->data_buffer); + operation->data_buffer = NULL; + operation->data_length = 0; + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly, + tag ) ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + { + ( void ) ciphertext; + ( void ) ciphertext_size; + ( void ) ciphertext_length; + ( void ) tag; + ( void ) tag_size; + ( void ) tag_length; + + return ( PSA_ERROR_NOT_SUPPORTED ); + } + + if( status == PSA_SUCCESS ) + { + *ciphertext_length = finish_output_size; + *tag_length = output_tag_length; + } + + mbedtls_psa_aead_abort(operation); + + return ( status ); +} + +/* Finish authenticating and decrypting a message in a multipart AEAD + * operation.*/ +psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length ) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + size_t finish_output_size; + size_t output_tag_length; + + int do_tag_check = 1; + uint8_t check_tag[16]; + + status = mbedtls_psa_aead_finish_checks( operation, plaintext_size, tag_length, &finish_output_size, + &output_tag_length); + + if( status != PSA_SUCCESS ) + { + return status; + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { + /* Call finish to get the tag for comparison */ + status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, + check_tag, + 16 ) ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + if( !operation->ad_buffer || !operation->data_buffer ) + { + return( PSA_ERROR_BAD_STATE ); + } + + /* Perform oneshot CCM decryption with data already stored, as + CCM does not support multipart yet.*/ + + ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, operation->data_length, + operation->nonce, operation->nonce_length, + operation->ad_buffer, operation->ad_length, + operation->data_buffer, plaintext, + tag, tag_length ); + + if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) + { + status = PSA_ERROR_INVALID_SIGNATURE; + } + else + { + status = mbedtls_to_psa_error( ret ); + do_tag_check = 0; + } + + /* Even if the above operation fails, we no longer need the data */ + mbedtls_free(operation->ad_buffer); + operation->ad_buffer = NULL; + operation->ad_length = 0; + + mbedtls_free(operation->data_buffer); + operation->data_buffer = NULL; + operation->data_length = 0; + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + // call finish to get the tag for comparison. + status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly, + check_tag ) ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + { + ( void ) plaintext; + ( void ) plaintext_size; + ( void ) plaintext_length; + ( void ) tag; + ( void ) tag_length; + + return ( PSA_ERROR_NOT_SUPPORTED ); + } + + if( status == PSA_SUCCESS ) + { + if( do_tag_check && safer_memcmp(tag, check_tag, tag_length) != 0 ) + { + status = MBEDTLS_ERR_GCM_AUTH_FAILED; + } + } + + mbedtls_psa_aead_abort(operation); + + return ( status ); +} + +/* Abort an AEAD operation */ +psa_status_t mbedtls_psa_aead_abort( psa_aead_operation_t *operation ) +{ + switch( operation->alg ) + { +#if defined(MBEDTLS_CCM_C) + case MBEDTLS_PSA_BUILTIN_ALG_CCM: + mbedtls_ccm_free( &operation->ctx.ccm ); + break; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + case PSA_ALG_GCM: + mbedtls_gcm_free( &operation->ctx.gcm ); + break; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + case PSA_ALG_CHACHA20_POLY1305: + mbedtls_chachapoly_free( &operation->ctx.chachapoly ); + break; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + } + + return( PSA_SUCCESS ); +} + #endif /* MBEDTLS_PSA_CRYPTO_C */ diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index aab0f835c4..d7aac24ed0 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -148,4 +148,644 @@ psa_status_t mbedtls_psa_aead_decrypt( const uint8_t *ciphertext, size_t ciphertext_length, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ); +/** Set the key for a multipart authenticated encryption operation. + * + * \note The signature of this function is that of a PSA driver + * aead_encrypt_setup entry point. This function behaves as an + * aead_encrypt_setup entry point as defined in the PSA driver interface + * specification for transparent drivers. + * + * The sequence of operations to encrypt a message with authentication + * is as follows: + * -# Allocate an operation object which will be passed to all the functions + * listed here. + * -# Initialize the operation object with one of the methods described in the + * documentation for #psa_aead_operation_t, e.g. + * #PSA_AEAD_OPERATION_INIT. + * -# Call mbedtls_psa_aead_encrypt_setup() to specify the algorithm and key. + * -# If needed, call mbedtls_psa_aead_set_lengths() to specify the length of + * the inputs to the subsequent calls to mbedtls_psa_aead_update_ad() and + * mbedtls_psa_aead_update(). See the documentation of mbedtls_psa_aead_set_lengths() + * for details. + * -# Call either mbedtls_psa_aead_generate_nonce() or mbedtls_psa_aead_set_nonce() to + * generate or set the nonce. You should use + * mbedtls_psa_aead_generate_nonce() unless the protocol you are implementing + * requires a specific nonce value. + * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing a fragment + * of the non-encrypted additional authenticated data each time. + * -# Call mbedtls_psa_aead_update() zero, one or more times, passing a fragment + * of the message to encrypt each time. + * -# Call mbedtls_psa_aead_finish(). + * + * If an error occurs at any step after a call to mbedtls_psa_aead_encrypt_setup(), + * the operation will need to be reset by a call to mbedtls_psa_aead_abort(). The + * application may call mbedtls_psa_aead_abort() at any time after the operation + * has been initialized. + * + * After a successful call to mbedtls_psa_aead_encrypt_setup(), the application must + * eventually terminate the operation. The following events terminate an + * operation: + * - A successful call to mbedtls_psa_aead_finish(). + * - A call to mbedtls_psa_aead_abort(). + * + * \param[in,out] operation The operation object to set up. It must have + * been initialized as per the documentation for + * #mbedtls_psa_aead_operation_t and not yet in use. + * \param[in] attributes The attributes of the key to use for the + * operation. + * \param[in] key_buffer The buffer containing the key context. + * \param key_buffer_size Size of the \p key_buffer buffer in bytes. + * \param alg The AEAD algorithm to compute + * (\c PSA_ALG_XXX value such that + * #PSA_ALG_IS_AEAD(\p alg) is true). + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be inactive). + * \retval #PSA_ERROR_INVALID_HANDLE + * \retval #PSA_ERROR_NOT_PERMITTED + * \retval #PSA_ERROR_INVALID_ARGUMENT + * \p key is not compatible with \p alg. + * \retval #PSA_ERROR_NOT_SUPPORTED + * \p alg is not supported or is not an AEAD algorithm. + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_encrypt_setup(psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg); + +/** Set the key for a multipart authenticated decryption operation. + * + * \note The signature of this function is that of a PSA driver + * aead_decrypt_setup entry point. This function behaves as an + * aead_decrypt_setup entry point as defined in the PSA driver interface + * specification for transparent drivers. + * + * The sequence of operations to decrypt a message with authentication + * is as follows: + * -# Allocate an operation object which will be passed to all the functions + * listed here. + * -# Initialize the operation object with one of the methods described in the + * documentation for #psa_aead_operation_t, e.g. + * #PSA_AEAD_OPERATION_INIT. + * -# Call mbedtls_psa_aead_decrypt_setup() to specify the algorithm and key. + * -# If needed, call mbedtls_psa_aead_set_lengths() to specify the length of the + * inputs to the subsequent calls to mbedtls_psa_aead_update_ad() and + * mbedtls_psa_aead_update(). See the documentation of mbedtls_psa_aead_set_lengths() + * for details. + * -# Call mbedtls_psa_aead_set_nonce() with the nonce for the decryption. + * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing a fragment + * of the non-encrypted additional authenticated data each time. + * -# Call mbedtls_psa_aead_update() zero, one or more times, passing a fragment + * of the ciphertext to decrypt each time. + * -# Call mbedtls_psa_aead_verify(). + * + * If an error occurs at any step after a call to mbedtls_psa_aead_decrypt_setup(), + * the operation will need to be reset by a call to mbedtls_psa_aead_abort(). The + * application may call mbedtls_psa_aead_abort() at any time after the operation + * has been initialized. + * + * After a successful call to mbedtls_psa_aead_decrypt_setup(), the application must + * eventually terminate the operation. The following events terminate an + * operation: + * - A successful call to mbedtls_psa_aead_verify(). + * - A call to mbedtls_psa_aead_abort(). + * + * \param[in,out] operation The operation object to set up. It must have + * been initialized as per the documentation for + * #psa_aead_operation_t and not yet in use. + * \param[in] attributes The attributes of the key to use for the + * operation. + * \param[in] key_buffer The buffer containing the key context. + * \param key_buffer_size Size of the \p key_buffer buffer in bytes. + * \param alg The AEAD algorithm to compute + * (\c PSA_ALG_XXX value such that + * #PSA_ALG_IS_AEAD(\p alg) is true). + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be inactive). + * \retval #PSA_ERROR_INVALID_HANDLE + * \retval #PSA_ERROR_NOT_PERMITTED + * \retval #PSA_ERROR_INVALID_ARGUMENT + * \p key is not compatible with \p alg. + * \retval #PSA_ERROR_NOT_SUPPORTED + * \p alg is not supported or is not an AEAD algorithm. + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_decrypt_setup(psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg); + +/** Generate a random nonce for an authenticated encryption operation. + * + * \note The signature of this function is that of a PSA driver + * aead_generate_nonce entry point. This function behaves as an + * aead_generate_nonce entry point as defined in the PSA driver interface + * specification for transparent drivers. + * + * This function generates a random nonce for the authenticated encryption + * operation with an appropriate size for the chosen algorithm, key type + * and key size. + * + * The application must call mbedtls_psa_aead_encrypt_setup() before + * calling this function. + * + * If this function returns an error status, the operation enters an error + * state and must be aborted by calling mbedtls_psa_aead_abort(). + * + * \param[in,out] operation Active AEAD operation. + * \param[out] nonce Buffer where the generated nonce is to be + * written. + * \param nonce_size Size of the \p nonce buffer in bytes. + * \param[out] nonce_length On success, the number of bytes of the + * generated nonce. + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be an active aead encrypt + * operation, with no nonce set). + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * The size of the \p nonce buffer is too small. + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_generate_nonce(psa_aead_operation_t *operation, + uint8_t *nonce, + size_t nonce_size, + size_t *nonce_length); + +/** Set the nonce for an authenticated encryption or decryption operation. + * + * \note The signature of this function is that of a PSA driver + * psa_aead_set_nonce entry point. This function behaves as an + * psa_aead_set_nonce entry point as defined in the PSA driver interface + * specification for transparent drivers. + * + * This function sets the nonce for the authenticated + * encryption or decryption operation. + * + * The application must call mbedtls_psa_aead_encrypt_setup() or + * mbedtls_psa_aead_decrypt_setup() before calling this function. + * + * If this function returns an error status, the operation enters an error + * state and must be aborted by calling mbedtls_psa_aead_abort(). + * + * \note When encrypting, applications should use mbedtls_psa_aead_generate_nonce() + * instead of this function, unless implementing a protocol that requires + * a non-random IV. + * + * \param[in,out] operation Active AEAD operation. + * \param[in] nonce Buffer containing the nonce to use. + * \param nonce_length Size of the nonce in bytes. + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be active, with no nonce + * set). + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The size of \p nonce is not acceptable for the chosen algorithm. + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_set_nonce(psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length); + +/** Declare the lengths of the message and additional data for AEAD. + * + * \note The signature of this function is that of a PSA driver + * psa_aead_set_lengths entry point. This function behaves as an + * psa_aead_set_lengths entry point as defined in the PSA driver interface + * specification for transparent drivers. + * + * The application must call this function before calling + * mbedtls_psa_aead_update_ad() or mbedtls_psa_aead_update() if the algorithm for + * the operation requires it. If the algorithm does not require it, + * calling this function is optional, but if this function is called + * then the implementation must enforce the lengths. + * + * You may call this function before or after setting the nonce with + * mbedtls_psa_aead_set_nonce() or mbedtls_psa_aead_generate_nonce(). + * + * - For #PSA_ALG_CCM, calling this function is required. + * - For the other AEAD algorithms defined in this specification, calling + * this function is not required. + * - For vendor-defined algorithm, refer to the vendor documentation. + * + * If this function returns an error status, the operation enters an error + * state and must be aborted by calling mbedtls_psa_aead_abort(). + * + * \param[in,out] operation Active AEAD operation. + * \param ad_length Size of the non-encrypted additional + * authenticated data in bytes. + * \param plaintext_length Size of the plaintext to encrypt in bytes. + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be active, and + * mbedtls_psa_aead_update_ad() and mbedtls_psa_aead_update() must not have been + * called yet). + * \retval #PSA_ERROR_INVALID_ARGUMENT + * At least one of the lengths is not acceptable for the chosen + * algorithm. + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_set_lengths(psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length); + +/** Pass additional data to an active AEAD operation. + * + * \note The signature of this function is that of a PSA driver + * aead_update_ad entry point. This function behaves as an aead_update_ad + * entry point as defined in the PSA driver interface specification for + * transparent drivers. + * + * Additional data is authenticated, but not encrypted. + * + * You may call this function multiple times to pass successive fragments + * of the additional data. You may not call this function after passing + * data to encrypt or decrypt with mbedtls_psa_aead_update(). + * + * Before calling this function, you must: + * 1. Call either mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup(). + * 2. Set the nonce with mbedtls_psa_aead_generate_nonce() or + * mbedtls_psa_aead_set_nonce(). + * + * If this function returns an error status, the operation enters an error + * state and must be aborted by calling mbedtls_psa_aead_abort(). + * + * \warning When decrypting, until mbedtls_psa_aead_verify() has returned #PSA_SUCCESS, + * there is no guarantee that the input is valid. Therefore, until + * you have called mbedtls_psa_aead_verify() and it has returned #PSA_SUCCESS, + * treat the input as untrusted and prepare to undo any action that + * depends on the input if mbedtls_psa_aead_verify() returns an error status. + * + * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire + * additional data to be passed in in one go, i.e. only call + * mbedtls_mbedtls_psa_aead_update_ad() once. + * + * \param[in,out] operation Active AEAD operation. + * \param[in] input Buffer containing the fragment of + * additional data. + * \param input_length Size of the \p input buffer in bytes. + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be active, have a nonce + * set, have lengths set if required by the algorithm, and + * mbedtls_psa_aead_update() must not have been called yet). + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The total input length overflows the additional data length that + * was previously specified with mbedtls_psa_aead_set_lengths(). + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_update_ad(psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length); + +/** Encrypt or decrypt a message fragment in an active AEAD operation. + * + * \note The signature of this function is that of a PSA driver + * aead_update entry point. This function behaves as an aead_update entry + * point as defined in the PSA driver interface specification for + * transparent drivers. + * + * Before calling this function, you must: + * 1. Call either mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup(). + * The choice of setup function determines whether this function + * encrypts or decrypts its input. + * 2. Set the nonce with mbedtls_psa_aead_generate_nonce() or mbedtls_psa_aead_set_nonce(). + * 3. Call mbedtls_psa_aead_update_ad() to pass all the additional data. + * + * If this function returns an error status, the operation enters an error + * state and must be aborted by calling mbedtls_psa_aead_abort(). + * + * \warning When decrypting, until mbedtls_psa_aead_verify() has returned + * #PSA_SUCCESS, there is no guarantee that the input is valid. + * Therefore, until you have called mbedtls_psa_aead_verify() and it + * has returned #PSA_SUCCESS: + * - Do not use the output in any way other than storing it in a + * confidential location. If you take any action that depends + * on the tentative decrypted data, this action will need to be + * undone if the input turns out not to be valid. Furthermore, + * if an adversary can observe that this action took place + * (for example through timing), they may be able to use this + * fact as an oracle to decrypt any message encrypted with the + * same key. + * - In particular, do not copy the output anywhere but to a + * memory or storage space that you have exclusive access to. + * + * This function does not require the input to be aligned to any + * particular block boundary. If the implementation can only process + * a whole block at a time, it must consume all the input provided, but + * it may delay the end of the corresponding output until a subsequent + * call to mbedtls_psa_aead_update(), mbedtls_psa_aead_finish() or + * mbedtls_psa_aead_verify() provides sufficient input. The amount of data that + * can be delayed in this way is bounded by #PSA_AEAD_UPDATE_OUTPUT_SIZE. + * + * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire + * data to be passed in in one go, i.e. only call + * mbedtls_mbedtls_psa_aead_update() once. + * + * \param[in,out] operation Active AEAD operation. + * \param[in] input Buffer containing the message fragment to + * encrypt or decrypt. + * \param input_length Size of the \p input buffer in bytes. + * \param[out] output Buffer where the output is to be written. + * \param output_size Size of the \p output buffer in bytes. + * This must be at least + * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c alg, + * \p input_length) where \c alg is the + * algorithm that is being calculated. + * \param[out] output_length On success, the number of bytes + * that make up the returned output. + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be active, have a nonce + * set, and have lengths set if required by the algorithm). + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * The size of the \p output buffer is too small. + * You can determine a sufficient buffer size by calling + * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c alg, \p input_length) + * where \c alg is the algorithm that is being calculated. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The total length of input to mbedtls_psa_aead_update_ad() so far is + * less than the additional data length that was previously + * specified with mbedtls_psa_aead_set_lengths(). + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The total input length overflows the plaintext length that + * was previously specified with mbedtls_psa_aead_set_lengths(). + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_update(psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length); + +/** Finish encrypting a message in an AEAD operation. + * + * \note The signature of this function is that of a PSA driver + * aead_finish entry point. This function behaves as an aead_finish entry + * point as defined in the PSA driver interface specification for + * transparent drivers. + * + * The operation must have been set up with mbedtls_psa_aead_encrypt_setup(). + * + * This function finishes the authentication of the additional data + * formed by concatenating the inputs passed to preceding calls to + * mbedtls_psa_aead_update_ad() with the plaintext formed by concatenating the + * inputs passed to preceding calls to mbedtls_psa_aead_update(). + * + * This function has two output buffers: + * - \p ciphertext contains trailing ciphertext that was buffered from + * preceding calls to mbedtls_psa_aead_update(). + * - \p tag contains the authentication tag. Its length is always + * #PSA_AEAD_TAG_LENGTH(\c alg) where \c alg is the AEAD algorithm + * that the operation performs. + * + * When this function returns successfuly, the operation becomes inactive. + * If this function returns an error status, the operation enters an error + * state and must be aborted by calling mbedtls_psa_aead_abort(). + * + * \param[in,out] operation Active AEAD operation. + * \param[out] ciphertext Buffer where the last part of the ciphertext + * is to be written. + * \param ciphertext_size Size of the \p ciphertext buffer in bytes. + * This must be at least + * #PSA_AEAD_FINISH_OUTPUT_SIZE(\c alg) where + * \c alg is the algorithm that is being + * calculated. + * \param[out] ciphertext_length On success, the number of bytes of + * returned ciphertext. + * \param[out] tag Buffer where the authentication tag is + * to be written. + * \param tag_size Size of the \p tag buffer in bytes. + * This must be at least + * #PSA_AEAD_TAG_LENGTH(\c alg) where \c alg is + * the algorithm that is being calculated. + * \param[out] tag_length On success, the number of bytes + * that make up the returned tag. + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be an active encryption + * operation with a nonce set). + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * The size of the \p ciphertext or \p tag buffer is too small. + * You can determine a sufficient buffer size for \p ciphertext by + * calling #PSA_AEAD_FINISH_OUTPUT_SIZE(\c alg) + * where \c alg is the algorithm that is being calculated. + * You can determine a sufficient buffer size for \p tag by + * calling #PSA_AEAD_TAG_LENGTH(\c alg). + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The total length of input to psa_aead_update_ad() so far is + * less than the additional data length that was previously + * specified with psa_aead_set_lengths(). + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The total length of input to mbedtls_psa_aead_update() so far is + * less than the plaintext length that was previously + * specified with mbedtls_psa_aead_set_lengths(). + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_finish(psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length); + +/** Finish authenticating and decrypting a message in an AEAD operation. + * + * \note The signature of this function is that of a PSA driver + * aead_verify entry point. This function behaves as an aead_verify entry + * point as defined in the PSA driver interface specification for + * transparent drivers. + * + * The operation must have been set up with mbedtls_psa_aead_decrypt_setup(). + * + * This function finishes the authenticated decryption of the message + * components: + * + * - The additional data consisting of the concatenation of the inputs + * passed to preceding calls to mbedtls_psa_aead_update_ad(). + * - The ciphertext consisting of the concatenation of the inputs passed to + * preceding calls to mbedtls_psa_aead_update(). + * - The tag passed to this function call. + * + * If the authentication tag is correct, this function outputs any remaining + * plaintext and reports success. If the authentication tag is not correct, + * this function returns #PSA_ERROR_INVALID_SIGNATURE. + * + * When this function returns successfuly, the operation becomes inactive. + * If this function returns an error status, the operation enters an error + * state and must be aborted by calling mbedtls_psa_aead_abort(). + * + * \note Implementations shall make the best effort to ensure that the + * comparison between the actual tag and the expected tag is performed + * in constant time. + * + * \param[in,out] operation Active AEAD operation. + * \param[out] plaintext Buffer where the last part of the plaintext + * is to be written. This is the remaining data + * from previous calls to mbedtls_psa_aead_update() + * that could not be processed until the end + * of the input. + * \param plaintext_size Size of the \p plaintext buffer in bytes. + * This must be at least + * #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c alg) where + * \c alg is the algorithm that is being + * calculated. + * \param[out] plaintext_length On success, the number of bytes of + * returned plaintext. + * \param[in] tag Buffer containing the authentication tag. + * \param tag_length Size of the \p tag buffer in bytes. + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_INVALID_SIGNATURE + * The calculations were successful, but the authentication tag is + * not correct. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid (it must be an active decryption + * operation with a nonce set). + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * The size of the \p plaintext buffer is too small. + * You can determine a sufficient buffer size for \p plaintext by + * calling #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c alg) + * where \c alg is the algorithm that is being calculated. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The total length of input to mbedtls_psa_aead_update_ad() so far is + * less than the additional data length that was previously + * specified with mbedtls_psa_aead_set_lengths(). + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The total length of input to mbedtls_psa_aead_update() so far is + * less than the plaintext length that was previously + * specified with psa_aead_set_lengths(). + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_verify(psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length); + +/** Abort an AEAD operation. + * + * \note The signature of this function is that of a PSA driver + * aead_abort entry point. This function behaves as an aead_abort entry + * point as defined in the PSA driver interface specification for + * transparent drivers. + * + * Aborting an operation frees all associated resources except for the + * \p operation structure itself. Once aborted, the operation object + * can be reused for another operation by calling + * mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup() again. + * + * You may call this function any time after the operation object has + * been initialized as described in #psa_aead_operation_t. + * + * In particular, calling mbedtls_psa_aead_abort() after the operation has been + * terminated by a call to mbedtls_psa_aead_abort(), mbedtls_psa_aead_finish() or + * mbedtls_psa_aead_verify() is safe and has no effect. + * + * \param[in,out] operation Initialized AEAD operation. + * + * \retval #PSA_SUCCESS + * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. + */ +psa_status_t mbedtls_psa_aead_abort(psa_aead_operation_t *operation); + + #endif /* PSA_CRYPTO_AEAD */ From 6504aa64517ffec5b3894119d86418223b299f6c Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 20 Apr 2021 17:09:36 +0100 Subject: [PATCH 003/966] First pass addition of driver wrappers Transparent driver test functions not yet implemented. Signed-off-by: Paul Elliott --- include/psa/crypto_struct.h | 10 +- library/psa_crypto_driver_wrappers.c | 371 +++++++++++++++++++++++++++ library/psa_crypto_driver_wrappers.h | 61 +++++ 3 files changed, 441 insertions(+), 1 deletion(-) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 6c93814be3..6f0fc01fe8 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -156,6 +156,14 @@ struct psa_aead_operation_s psa_algorithm_t alg; psa_key_type_t key_type; + /** Unique ID indicating which driver got assigned to do the + * operation. Since driver contexts are driver-specific, swapping + * drivers halfway through the operation is not supported. + * ID values are auto-generated in psa_crypto_driver_wrappers.h + * ID value zero means the context is not valid or not assigned to + * any driver (i.e. none of the driver contexts are active). */ + unsigned int id; + unsigned int key_set : 1; unsigned int nonce_set : 1; unsigned int lengths_set : 1; @@ -197,7 +205,7 @@ struct psa_aead_operation_s } ctx; }; -#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} +#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} static inline struct psa_aead_operation_s psa_aead_operation_init( void ) { const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT; diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 795e424894..59a00a6cfd 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1292,6 +1292,377 @@ psa_status_t psa_driver_wrapper_aead_decrypt( } } +psa_status_t psa_driver_wrapper_aead_encrypt_setup( + psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + psa_key_location_t location = + PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); + + switch( location ) + { + case PSA_KEY_LOCATION_LOCAL_STORAGE: + /* Key is stored in the slot in export representation, so + * cycle through all known transparent accelerators */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) +// status = test_transparent_aead_encrypt_setup( +// operation, attributes, +// key_buffer, key_buffer_size, +// alg ); + /* Declared with fallback == true */ + if( status == PSA_SUCCESS ) + operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; + + if( status != PSA_ERROR_NOT_SUPPORTED ) + return( status ); +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + + /* Fell through, meaning no accelerator supports this operation */ + status = mbedtls_psa_aead_encrypt_setup( + operation, attributes, + key_buffer, key_buffer_size, + alg ); + + if( status == PSA_SUCCESS ) + operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; + + return( status ); + + /* Add cases for opaque driver here */ + + default: + /* Key is declared with a lifetime not known to us */ + (void)status; + return( PSA_ERROR_INVALID_ARGUMENT ); + } +} + +psa_status_t psa_driver_wrapper_aead_decrypt_setup( + psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + psa_key_location_t location = + PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); + + switch( location ) + { + case PSA_KEY_LOCATION_LOCAL_STORAGE: + /* Key is stored in the slot in export representation, so + * cycle through all known transparent accelerators */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) +// status = test_transparent_aead_decrypt_setup( +// operation, attributes, +// key_buffer, key_buffer_size, +// alg ); + /* Declared with fallback == true */ + if( status == PSA_SUCCESS ) + operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; + + if( status != PSA_ERROR_NOT_SUPPORTED ) + return( status ); +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + + /* Fell through, meaning no accelerator supports this operation */ + status = mbedtls_psa_aead_decrypt_setup( + operation, attributes, + key_buffer, key_buffer_size, + alg ); + + if( status == PSA_SUCCESS ) + operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; + + return( status ); + + /* Add cases for opaque driver here */ + + default: + /* Key is declared with a lifetime not known to us */ + (void)status; + return( PSA_ERROR_INVALID_ARGUMENT ); + } +} + +psa_status_t psa_driver_wrapper_aead_generate_nonce( + psa_aead_operation_t *operation, + uint8_t *nonce, + size_t nonce_size, + size_t *nonce_length ) +{ + switch( operation->id ) + { +#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) + case PSA_CRYPTO_MBED_TLS_DRIVER_ID: + return( mbedtls_psa_aead_generate_nonce( operation, nonce, nonce_size, + nonce_length ) ); +#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: +// return( test_transparent_aead_generate_nonce( +// operation, nonce, nonce_size, nonce_length ) ); + + /* Add cases for opaque driver here */ + +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + } + + (void)nonce; + (void)nonce_size; + (void)nonce_length; + + return( PSA_ERROR_INVALID_ARGUMENT ); +} + +psa_status_t psa_driver_wrapper_aead_set_nonce( + psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length ) +{ + switch( operation->id ) + { +#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) + case PSA_CRYPTO_MBED_TLS_DRIVER_ID: + return( mbedtls_psa_aead_set_nonce( operation, nonce, nonce_length ) ); + +#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: +// return( test_transparent_aead_set_nonce( +// operation, nonce, nonce_length ) ); + + /* Add cases for opaque driver here */ + +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + } + + (void)nonce; + (void)nonce_length; + + return( PSA_ERROR_INVALID_ARGUMENT ); +} + +psa_status_t psa_driver_wrapper_aead_set_lengths( + psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ) +{ + switch( operation->id ) + { +#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) + case PSA_CRYPTO_MBED_TLS_DRIVER_ID: + return( mbedtls_psa_aead_set_lengths( operation, ad_length, plaintext_length ) ); + +#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: +// return( test_transparent_aead_set_lengths( +// operation, ad_length, plaintext_length ) ); + + /* Add cases for opaque driver here */ + +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + } + + (void)ad_length; + (void)plaintext_length; + + return( PSA_ERROR_INVALID_ARGUMENT ); +} + +psa_status_t psa_driver_wrapper_aead_update_ad( + psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length ) +{ + switch( operation->id ) + { +#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) + case PSA_CRYPTO_MBED_TLS_DRIVER_ID: + return( mbedtls_psa_aead_update_ad( operation, input, input_length ) ); + +#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: +// return( test_transparent_aead_update_ad( +// operation, input, input_length ) ); + + /* Add cases for opaque driver here */ + +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + } + + (void)input; + (void)input_length; + + return( PSA_ERROR_INVALID_ARGUMENT ); +} + +psa_status_t psa_driver_wrapper_aead_update( + psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length ) +{ + switch( operation->id ) + { +#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) + case PSA_CRYPTO_MBED_TLS_DRIVER_ID: + return( mbedtls_psa_aead_update( operation, input, input_length, output, + output_size, output_length ) ); + +#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: +// return( test_transparent_aead_update( +// operation, input, input_length, ouput, output_size, +// output_length ) ); + + /* Add cases for opaque driver here */ + +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + } + + (void)input; + (void)input_length; + (void)output; + (void)output_size; + (void)output_length; + + return( PSA_ERROR_INVALID_ARGUMENT ); +} + +psa_status_t psa_driver_wrapper_aead_finish( + psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length ) +{ + switch( operation->id ) + { +#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) + case PSA_CRYPTO_MBED_TLS_DRIVER_ID: + return( mbedtls_psa_aead_finish( operation, ciphertext, ciphertext_size, + ciphertext_length, tag, tag_size, tag_length ) ); + +#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: +// return( test_transparent_aead_finish( +// operation, ciphertext, ciphertext_size, +// ciphertext_length, tag, tag_size, tag_length ) ); + + /* Add cases for opaque driver here */ + +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + } + + (void)ciphertext; + (void)ciphertext_size; + (void)ciphertext_length; + (void)tag; + (void)tag_size; + (void)tag_length; + + return( PSA_ERROR_INVALID_ARGUMENT ); +} + +psa_status_t psa_driver_wrapper_aead_verify( + psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length ) +{ + switch( operation->id ) + { +#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) + case PSA_CRYPTO_MBED_TLS_DRIVER_ID: + return( mbedtls_psa_aead_verify( operation, plaintext, plaintext_size, + plaintext_length, tag, tag_length ) ); + +#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: +// return( test_transparent_aead_verify( +// operation, ciphertext, ciphertext_size, +// ciphertext_length, tag, tag_length ) ); + + /* Add cases for opaque driver here */ + +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + } + + (void)plaintext; + (void)plaintext_size; + (void)plaintext_length; + (void)tag; + (void)tag_length; + + return( PSA_ERROR_INVALID_ARGUMENT ); +} + +psa_status_t psa_driver_wrapper_aead_abort( + psa_aead_operation_t *operation ) +{ + switch( operation->id ) + { +#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) + case PSA_CRYPTO_MBED_TLS_DRIVER_ID: + return( mbedtls_psa_aead_abort( operation ) ); + +#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ + +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: +// return( test_transparent_aead_abort( operation ) ); + + /* Add cases for opaque driver here */ + +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + } + + return( PSA_ERROR_INVALID_ARGUMENT ); +} /* * MAC functions diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h index 37d5a9a1c0..bdb2eba16a 100644 --- a/library/psa_crypto_driver_wrappers.h +++ b/library/psa_crypto_driver_wrappers.h @@ -183,6 +183,67 @@ psa_status_t psa_driver_wrapper_aead_decrypt( const uint8_t *ciphertext, size_t ciphertext_length, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ); +psa_status_t psa_driver_wrapper_aead_encrypt_setup( + psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ); + +psa_status_t psa_driver_wrapper_aead_decrypt_setup( + psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ); + +psa_status_t psa_driver_wrapper_aead_generate_nonce( + psa_aead_operation_t *operation, + uint8_t *nonce, + size_t nonce_size, + size_t *nonce_length ); + +psa_status_t psa_driver_wrapper_aead_set_nonce( + psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length ); + +psa_status_t psa_driver_wrapper_aead_set_lengths( + psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ); + +psa_status_t psa_driver_wrapper_aead_update_ad( + psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length ); + +psa_status_t psa_driver_wrapper_aead_update( + psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length ); + +psa_status_t psa_driver_wrapper_aead_finish( + psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length ); + +psa_status_t psa_driver_wrapper_aead_verify( + psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length ); + +psa_status_t psa_driver_wrapper_aead_abort( + psa_aead_operation_t *operation ); + /* * MAC functions */ From 302ff6bdd632c61c5c50452ce1b5ac8226336a98 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 20 Apr 2021 18:10:30 +0100 Subject: [PATCH 004/966] Implement multipart AEAD PSA interface Signed-off-by: Paul Elliott --- library/psa_crypto.c | 249 +++++++++++++++++++++++++++ library/psa_crypto_aead.c | 73 -------- library/psa_crypto_aead.h | 61 +------ library/psa_crypto_driver_wrappers.c | 33 ---- library/psa_crypto_driver_wrappers.h | 6 - 5 files changed, 257 insertions(+), 165 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 2583735fe9..6598cf43a3 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3214,6 +3214,255 @@ psa_status_t psa_aead_decrypt( mbedtls_svc_key_id_t key, return( status ); } +/* Set the key for a multipart authenticated encryption operation. */ +psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, + mbedtls_svc_key_id_t key, + psa_algorithm_t alg ) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; + psa_key_slot_t *slot; + + if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) + return( PSA_ERROR_NOT_SUPPORTED ); + + status = psa_get_and_lock_key_slot_with_policy( + key, &slot, PSA_KEY_USAGE_DECRYPT, alg ); + + if( status != PSA_SUCCESS ) + { + return( status ); + } + + psa_key_attributes_t attributes = { + .core = slot->attr + }; + + status = psa_driver_wrapper_aead_encrypt_setup( operation, + &attributes, slot->key.data, + slot->key.bytes, alg ); + + + unlock_status = psa_unlock_key_slot( slot ); + + if( unlock_status != PSA_SUCCESS ) + { + return( unlock_status ); + } + + return( status ); +} + +/* Set the key for a multipart authenticated decryption operation. */ +psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, + mbedtls_svc_key_id_t key, + psa_algorithm_t alg ) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; + psa_key_slot_t *slot; + + if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) + return( PSA_ERROR_NOT_SUPPORTED ); + + status = psa_get_and_lock_key_slot_with_policy( + key, &slot, PSA_KEY_USAGE_DECRYPT, alg ); + + if( status != PSA_SUCCESS ) + { + return( status ); + } + + psa_key_attributes_t attributes = { + .core = slot->attr + }; + + status = psa_driver_wrapper_aead_decrypt_setup( operation, + &attributes, slot->key.data, + slot->key.bytes, alg ); + + + unlock_status = psa_unlock_key_slot( slot ); + + if( unlock_status != PSA_SUCCESS ) + { + return( unlock_status ); + } + + return( status ); +} + +/* Generate a random nonce / IV for multipart AEAD operation */ +psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, + uint8_t *nonce, + size_t nonce_size, + size_t *nonce_length ) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + size_t required_nonce_size = nonce_size; + + *nonce_length = 0; + + if( !operation->key_set || operation->nonce_set || + operation->ad_started || operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type, operation->alg); + + if( nonce_size == 0 || nonce_size < required_nonce_size ) + { + return( PSA_ERROR_BUFFER_TOO_SMALL ); + } + + status = psa_generate_random( nonce, required_nonce_size ); + + if( status != PSA_SUCCESS ) + { + return status; + } + + status = psa_driver_wrapper_aead_set_nonce( operation, nonce, required_nonce_size ); + + if( status == PSA_SUCCESS ) + { + *nonce_length = required_nonce_size; + } + + return status; +} + +/* Set the nonce for a multipart authenticated encryption or decryption + operation.*/ +psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length ) +{ + if( !operation->key_set || operation->nonce_set || + operation->ad_started || operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + return( psa_driver_wrapper_aead_set_nonce( operation, nonce, nonce_length ) ); +} + +/* Declare the lengths of the message and additional data for multipart AEAD. */ +psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ) +{ + if( !operation->key_set || operation->lengths_set ) + { + return( PSA_ERROR_BAD_STATE ); + } + + return( psa_driver_wrapper_aead_set_lengths( operation, ad_length, plaintext_length ) ); +} + /* Pass additional data to an active multipart AEAD operation. */ +psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length ) +{ + if( !operation->nonce_set || !operation->key_set ) + { + return( PSA_ERROR_BAD_STATE ); + } + + return( psa_driver_wrapper_aead_update_ad( operation, input, input_length ) ); +} + +/* Encrypt or decrypt a message fragment in an active multipart AEAD + operation.*/ +psa_status_t psa_aead_update( psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length ) +{ + + *output_length = 0; + + if( !operation->nonce_set || !operation->key_set || !operation->ad_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + return( psa_driver_wrapper_aead_update( operation, input, input_length, output, output_size, + output_length ) ); +} + +/* Finish encrypting a message in a multipart AEAD operation. */ +psa_status_t psa_aead_finish( psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length ) +{ + *ciphertext_length = 0; + *tag_length = 0; + + if( !operation->key_set || !operation->nonce_set || + !operation->ad_started || !operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + return( psa_driver_wrapper_aead_finish( operation, ciphertext, ciphertext_size, + ciphertext_length, tag, tag_size, tag_length ) ); +} + +/* Finish authenticating and decrypting a message in a multipart AEAD + operation.*/ +psa_status_t psa_aead_verify( psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length ) +{ + *plaintext_length = 0; + + if( !operation->key_set || !operation->nonce_set || + !operation->ad_started || !operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + return( psa_driver_wrapper_aead_verify( operation, plaintext, plaintext_size, plaintext_length, + tag, tag_length ) ); +} + +/* Abort an AEAD operation. */ +psa_status_t psa_aead_abort(psa_aead_operation_t *operation) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + + if( operation->id == 0 ) + { + /* The object has (apparently) been initialized but it is not (yet) + * in use. It's ok to call abort on such an object, and there's + * nothing to do. */ + return( PSA_SUCCESS ); + } + + status = psa_driver_wrapper_aead_abort( operation ); + + operation->id = 0; + operation->key_set = 0; + operation->nonce_set = 0; + operation->lengths_set = 0; + operation->is_encrypt = 0; + operation->ad_started = 0; + operation->body_started = 0; + + return( status ); +} + /****************************************************************/ /* Generators */ /****************************************************************/ diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 47b0e7b3e2..f8cceae8ee 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -394,45 +394,6 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( psa_aead_operation_t *operation, return ( status ); } -/* Generate a random nonce / IV for multipart AEAD operation */ -psa_status_t mbedtls_psa_aead_generate_nonce( psa_aead_operation_t *operation, - uint8_t *nonce, - size_t nonce_size, - size_t *nonce_length ) -{ - psa_status_t status; - size_t required_nonce_size = nonce_size; - - if( !operation->key_set || operation->nonce_set || - operation->ad_started || operation->body_started ) - { - return( PSA_ERROR_BAD_STATE ); - } - - required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type, operation->alg); - - if( nonce_size == 0 || nonce_size < required_nonce_size ) - { - return( PSA_ERROR_BUFFER_TOO_SMALL ); - } - - status = psa_generate_random( nonce, required_nonce_size ); - - if( status != PSA_SUCCESS ) - { - return status; - } - - status = mbedtls_psa_aead_set_nonce( operation, nonce, required_nonce_size ); - - if( status == PSA_SUCCESS ) - { - *nonce_length = required_nonce_size; - } - - return status; -} - /* Set a nonce for the multipart AEAD operation*/ psa_status_t mbedtls_psa_aead_set_nonce( psa_aead_operation_t *operation, const uint8_t *nonce, @@ -440,19 +401,6 @@ psa_status_t mbedtls_psa_aead_set_nonce( psa_aead_operation_t *operation, { psa_status_t status; - if( !operation->key_set || operation->nonce_set || - operation->ad_started || operation->body_started ) - { - return( PSA_ERROR_BAD_STATE ); - } - - /* Restricting to a nominal safe length for nonces even though some - algorithms can handle longer nonces, but not without collision */ - if( nonce_length > PSA_AEAD_NONCE_MAX_SIZE ) - { - return( PSA_ERROR_INVALID_ARGUMENT ); - } - #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { @@ -514,11 +462,6 @@ psa_status_t mbedtls_psa_aead_set_lengths( psa_aead_operation_t *operation, size_t plaintext_length ) { - if( !operation->key_set || operation->lengths_set ) - { - return( PSA_ERROR_BAD_STATE ); - } - #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { @@ -570,11 +513,6 @@ psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( !operation->nonce_set || !operation->key_set ) - { - return( PSA_ERROR_BAD_STATE ); - } - if( operation->lengths_set ) { if ( operation->ad_remaining < input_length ) @@ -675,11 +613,6 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, size_t update_output_size; psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( !operation->nonce_set || !operation->key_set || !operation->ad_started ) - { - return( PSA_ERROR_BAD_STATE ); - } - update_output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE(operation->key_type, operation->alg, input_length); @@ -791,12 +724,6 @@ static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t *operat size_t *finish_output_size, size_t *output_tag_length ) { - if( !operation->key_set || !operation->nonce_set - || !operation->ad_started || !operation->body_started) - { - return( PSA_ERROR_BAD_STATE ); - } - if( operation->lengths_set ) { if( operation->ad_remaining != 0 || operation->body_remaining != 0 ) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index d7aac24ed0..a9d268773e 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -167,9 +167,9 @@ psa_status_t mbedtls_psa_aead_decrypt( * the inputs to the subsequent calls to mbedtls_psa_aead_update_ad() and * mbedtls_psa_aead_update(). See the documentation of mbedtls_psa_aead_set_lengths() * for details. - * -# Call either mbedtls_psa_aead_generate_nonce() or mbedtls_psa_aead_set_nonce() to - * generate or set the nonce. You should use - * mbedtls_psa_aead_generate_nonce() unless the protocol you are implementing + * -# Call either psa_aead_generate_nonce() or + * mbedtls_psa_aead_set_nonce() to generate or set the nonce. You should use + * psa_aead_generate_nonce() unless the protocol you are implementing * requires a specific nonce value. * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing a fragment * of the non-encrypted additional authenticated data each time. @@ -297,52 +297,6 @@ psa_status_t mbedtls_psa_aead_decrypt_setup(psa_aead_operation_t *operation, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg); -/** Generate a random nonce for an authenticated encryption operation. - * - * \note The signature of this function is that of a PSA driver - * aead_generate_nonce entry point. This function behaves as an - * aead_generate_nonce entry point as defined in the PSA driver interface - * specification for transparent drivers. - * - * This function generates a random nonce for the authenticated encryption - * operation with an appropriate size for the chosen algorithm, key type - * and key size. - * - * The application must call mbedtls_psa_aead_encrypt_setup() before - * calling this function. - * - * If this function returns an error status, the operation enters an error - * state and must be aborted by calling mbedtls_psa_aead_abort(). - * - * \param[in,out] operation Active AEAD operation. - * \param[out] nonce Buffer where the generated nonce is to be - * written. - * \param nonce_size Size of the \p nonce buffer in bytes. - * \param[out] nonce_length On success, the number of bytes of the - * generated nonce. - * - * \retval #PSA_SUCCESS - * Success. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be an active aead encrypt - * operation, with no nonce set). - * \retval #PSA_ERROR_BUFFER_TOO_SMALL - * The size of the \p nonce buffer is too small. - * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_STORAGE_FAILURE - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. - */ -psa_status_t mbedtls_psa_aead_generate_nonce(psa_aead_operation_t *operation, - uint8_t *nonce, - size_t nonce_size, - size_t *nonce_length); - /** Set the nonce for an authenticated encryption or decryption operation. * * \note The signature of this function is that of a PSA driver @@ -402,7 +356,7 @@ psa_status_t mbedtls_psa_aead_set_nonce(psa_aead_operation_t *operation, * then the implementation must enforce the lengths. * * You may call this function before or after setting the nonce with - * mbedtls_psa_aead_set_nonce() or mbedtls_psa_aead_generate_nonce(). + * mbedtls_psa_aead_set_nonce() or psa_aead_generate_nonce(). * * - For #PSA_ALG_CCM, calling this function is required. * - For the other AEAD algorithms defined in this specification, calling @@ -454,7 +408,7 @@ psa_status_t mbedtls_psa_aead_set_lengths(psa_aead_operation_t *operation, * * Before calling this function, you must: * 1. Call either mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup(). - * 2. Set the nonce with mbedtls_psa_aead_generate_nonce() or + * 2. Set the nonce with psa_aead_generate_nonce() or * mbedtls_psa_aead_set_nonce(). * * If this function returns an error status, the operation enters an error @@ -509,8 +463,9 @@ psa_status_t mbedtls_psa_aead_update_ad(psa_aead_operation_t *operation, * 1. Call either mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup(). * The choice of setup function determines whether this function * encrypts or decrypts its input. - * 2. Set the nonce with mbedtls_psa_aead_generate_nonce() or mbedtls_psa_aead_set_nonce(). - * 3. Call mbedtls_psa_aead_update_ad() to pass all the additional data. + * 2. Set the nonce with psa_aead_generate_nonce() or + * mbedtls_psa_aead_set_nonce(). 3. Call mbedtls_psa_aead_update_ad() to pass + * all the additional data. * * If this function returns an error status, the operation enters an error * state and must be aborted by calling mbedtls_psa_aead_abort(). diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 59a00a6cfd..5e09fd231c 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1394,39 +1394,6 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( } } -psa_status_t psa_driver_wrapper_aead_generate_nonce( - psa_aead_operation_t *operation, - uint8_t *nonce, - size_t nonce_size, - size_t *nonce_length ) -{ - switch( operation->id ) - { -#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) - case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_generate_nonce( operation, nonce, nonce_size, - nonce_length ) ); -#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ - -#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) -#if defined(PSA_CRYPTO_DRIVER_TEST) - case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: -// return( test_transparent_aead_generate_nonce( -// operation, nonce, nonce_size, nonce_length ) ); - - /* Add cases for opaque driver here */ - -#endif /* PSA_CRYPTO_DRIVER_TEST */ -#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ - } - - (void)nonce; - (void)nonce_size; - (void)nonce_length; - - return( PSA_ERROR_INVALID_ARGUMENT ); -} - psa_status_t psa_driver_wrapper_aead_set_nonce( psa_aead_operation_t *operation, const uint8_t *nonce, diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h index bdb2eba16a..05adb53f74 100644 --- a/library/psa_crypto_driver_wrappers.h +++ b/library/psa_crypto_driver_wrappers.h @@ -195,12 +195,6 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ); -psa_status_t psa_driver_wrapper_aead_generate_nonce( - psa_aead_operation_t *operation, - uint8_t *nonce, - size_t nonce_size, - size_t *nonce_length ); - psa_status_t psa_driver_wrapper_aead_set_nonce( psa_aead_operation_t *operation, const uint8_t *nonce, From 5653da0201c19755fa3f2ced4d8d8eea681bfbc3 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 21 Apr 2021 12:26:21 +0100 Subject: [PATCH 005/966] Fix errors with missing tests Return not supported for the time being whilst we don't have the transparent driver tests done. Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 5e09fd231c..91ad37f80d 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1310,6 +1310,7 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) + status = PSA_ERROR_NOT_SUPPORTED; // status = test_transparent_aead_encrypt_setup( // operation, attributes, // key_buffer, key_buffer_size, @@ -1361,6 +1362,7 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) + status = PSA_ERROR_NOT_SUPPORTED; // status = test_transparent_aead_decrypt_setup( // operation, attributes, // key_buffer, key_buffer_size, @@ -1410,6 +1412,7 @@ psa_status_t psa_driver_wrapper_aead_set_nonce( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: + return( PSA_ERROR_NOT_SUPPORTED ); // return( test_transparent_aead_set_nonce( // operation, nonce, nonce_length ) ); @@ -1441,6 +1444,7 @@ psa_status_t psa_driver_wrapper_aead_set_lengths( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: + return( PSA_ERROR_NOT_SUPPORTED ); // return( test_transparent_aead_set_lengths( // operation, ad_length, plaintext_length ) ); @@ -1472,6 +1476,7 @@ psa_status_t psa_driver_wrapper_aead_update_ad( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: + return( PSA_ERROR_NOT_SUPPORTED ); // return( test_transparent_aead_update_ad( // operation, input, input_length ) ); @@ -1507,6 +1512,7 @@ psa_status_t psa_driver_wrapper_aead_update( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: + return( PSA_ERROR_NOT_SUPPORTED ); // return( test_transparent_aead_update( // operation, input, input_length, ouput, output_size, // output_length ) ); @@ -1547,6 +1553,7 @@ psa_status_t psa_driver_wrapper_aead_finish( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: + return( PSA_ERROR_NOT_SUPPORTED ); // return( test_transparent_aead_finish( // operation, ciphertext, ciphertext_size, // ciphertext_length, tag, tag_size, tag_length ) ); @@ -1587,6 +1594,7 @@ psa_status_t psa_driver_wrapper_aead_verify( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: + return( PSA_ERROR_NOT_SUPPORTED ); // return( test_transparent_aead_verify( // operation, ciphertext, ciphertext_size, // ciphertext_length, tag, tag_length ) ); @@ -1620,6 +1628,7 @@ psa_status_t psa_driver_wrapper_aead_abort( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: + return( PSA_ERROR_NOT_SUPPORTED ); // return( test_transparent_aead_abort( operation ) ); /* Add cases for opaque driver here */ From 811d8d462fed3892b11a095438d4993dc7168cd8 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 22 Apr 2021 11:31:14 +0100 Subject: [PATCH 006/966] Fix incorrect enums being used Fix memory leak due to aead_abort() using incorrect enums to identify algorithm used. Fix incorrect return on failure to check tag on aead_verify() Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index f8cceae8ee..e92dac512b 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -948,7 +948,7 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, { if( do_tag_check && safer_memcmp(tag, check_tag, tag_length) != 0 ) { - status = MBEDTLS_ERR_GCM_AUTH_FAILED; + status = PSA_ERROR_INVALID_SIGNATURE; } } @@ -960,10 +960,10 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, /* Abort an AEAD operation */ psa_status_t mbedtls_psa_aead_abort( psa_aead_operation_t *operation ) { - switch( operation->alg ) + switch( operation->alg ) { -#if defined(MBEDTLS_CCM_C) - case MBEDTLS_PSA_BUILTIN_ALG_CCM: +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + case PSA_ALG_CCM: mbedtls_ccm_free( &operation->ctx.ccm ); break; #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -973,9 +973,9 @@ psa_status_t mbedtls_psa_aead_abort( psa_aead_operation_t *operation ) break; #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - case PSA_ALG_CHACHA20_POLY1305: - mbedtls_chachapoly_free( &operation->ctx.chachapoly ); - break; + case PSA_ALG_CHACHA20_POLY1305: + mbedtls_chachapoly_free( &operation->ctx.chachapoly ); + break; #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ } From c4e1dcf006318c6c5f6d671c703bae4a65e188ae Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Apr 2021 18:59:23 +0100 Subject: [PATCH 007/966] Fix incorrect PSA key usage Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 6598cf43a3..a6d0cdb20e 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3227,7 +3227,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, return( PSA_ERROR_NOT_SUPPORTED ); status = psa_get_and_lock_key_slot_with_policy( - key, &slot, PSA_KEY_USAGE_DECRYPT, alg ); + key, &slot, PSA_KEY_USAGE_ENCRYPT, alg ); if( status != PSA_SUCCESS ) { From 72c10082ddd0c35133b32466133c7dddb7fb8194 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Apr 2021 19:02:16 +0100 Subject: [PATCH 008/966] Fix logic issues with state checks Also fix missing return values. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 48 +++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index e92dac512b..b559f7a169 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -535,7 +535,7 @@ psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, * one contigious buffer, so until that is re-done, we have to enforce * this, as we cannot allocate a buffer to collate multiple calls into. */ - if( input_length != operation->ad_remaining ) + if( operation->ad_remaining != 0 ) { return ( PSA_ERROR_INVALID_ARGUMENT ); } @@ -556,7 +556,7 @@ psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, { /* CCM requires all additional data to be passed in in one go at the minute, as we are basically operating in oneshot mode. */ - if( !operation->lengths_set || operation->ad_started ) + if( operation->ad_started ) { return( PSA_ERROR_BAD_STATE ); } @@ -569,6 +569,7 @@ psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, { memcpy( operation->ad_buffer, input, input_length ); operation->ad_length = input_length; + status = PSA_SUCCESS; } else { @@ -613,10 +614,20 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, size_t update_output_size; psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - update_output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE(operation->key_type, - operation->alg, input_length); +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + /* CCM will currently not output anything until finish. */ + update_output_size = 0; + } + else +#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) */ + { + update_output_size = input_length; + } - if(update_output_size > output_size ) + if( PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type, operation->alg, + input_length ) > output_size ) { return ( PSA_ERROR_BUFFER_TOO_SMALL ); } @@ -651,7 +662,7 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - if( operation->ad_started ) + if( !operation->ad_started ) { return( PSA_ERROR_BAD_STATE ); } @@ -668,7 +679,7 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, { /* CCM dooes not support multipart yet, so all the input has to be passed in in one go. Store the data for the final step.*/ - if( operation->ad_started ) + if( operation->body_started ) { return( PSA_ERROR_BAD_STATE ); } @@ -681,6 +692,7 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, { memcpy( operation->data_buffer, input, input_length ); operation->data_length = input_length; + status = PSA_SUCCESS; } else { @@ -739,15 +751,25 @@ static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t *operat return ( PSA_ERROR_BUFFER_TOO_SMALL ); } - if( operation->is_encrypt ) +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) { - *finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE(operation->key_type, - operation->alg); + /* CCM will output all data at this step. */ + *finish_output_size = operation->data_length; } else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ { - *finish_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE(operation->key_type, - operation->alg); + if( operation->is_encrypt ) + { + *finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, + operation->alg ); + } + else + { + *finish_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, + operation->alg ); + } } if( output_size < *finish_output_size ) @@ -946,6 +968,8 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, if( status == PSA_SUCCESS ) { + *plaintext_length = finish_output_size; + if( do_tag_check && safer_memcmp(tag, check_tag, tag_length) != 0 ) { status = PSA_ERROR_INVALID_SIGNATURE; From fd3ca24e565509693fae09a5227dfa2c6b583cff Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 25 Apr 2021 18:10:42 +0100 Subject: [PATCH 009/966] Move CCM ouput to update step. Move CCM to update all data at update step, as final step can only output at most a block length, so outputting all data at this step significantly breaks the tests. Had to add unpleasant workaround for the validate stage, but this is the only way I can do things without breaking CCM Alt implementations. Signed-off-by: Paul Elliott --- include/psa/crypto_struct.h | 10 +- library/psa_crypto_aead.c | 223 +++++++++++++++++++++--------------- 2 files changed, 135 insertions(+), 98 deletions(-) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 6f0fc01fe8..90a0c2098c 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -179,11 +179,13 @@ struct psa_aead_operation_s /* Buffers for AD/data - only required until CCM gets proper multipart support. */ - uint8_t* ad_buffer; + uint8_t *ad_buffer; size_t ad_length; - uint8_t* data_buffer; - size_t data_length; + uint8_t *body_buffer; + uint8_t body_length; + + uint8_t *tag_buffer; /* buffer to store Nonce - only required until CCM and GCM get proper multipart support. */ @@ -205,7 +207,7 @@ struct psa_aead_operation_s } ctx; }; -#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} +#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} static inline struct psa_aead_operation_s psa_aead_operation_init( void ) { const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT; diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index b559f7a169..bfa271b5a1 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -613,18 +613,9 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, { size_t update_output_size; psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - /* CCM will currently not output anything until finish. */ - update_output_size = 0; - } - else -#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) */ - { - update_output_size = input_length; - } + update_output_size = input_length; if( PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type, operation->alg, input_length ) > output_size ) @@ -678,27 +669,78 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, if( operation->alg == PSA_ALG_CCM ) { /* CCM dooes not support multipart yet, so all the input has to be - passed in in one go. Store the data for the final step.*/ + passed in in one go. */ if( operation->body_started ) { return( PSA_ERROR_BAD_STATE ); } - /* Save the additional data for later, this will be passed in - when we have the body. */ - operation->data_buffer = ( uint8_t * ) mbedtls_calloc(1, input_length ); + /* Need to store tag for Finish() / Verify() */ + operation->tag_buffer = ( uint8_t * ) mbedtls_calloc(1, operation->tag_length ); - if( operation->data_buffer ) + if( operation->tag_buffer ) { - memcpy( operation->data_buffer, input, input_length ); - operation->data_length = input_length; - status = PSA_SUCCESS; + + if( operation->is_encrypt ) + { + /* Perform oneshot CCM encryption with additional data already + stored, as CCM does not support multipart yet.*/ + status = mbedtls_to_psa_error( mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm, + input_length, + operation->nonce, + operation->nonce_length, + operation->ad_buffer, + operation->ad_length, + input, + output, + operation->tag_buffer, + operation->tag_length ) ); + + /* Even if the above operation fails, we no longer need the + additional data.*/ + mbedtls_free(operation->ad_buffer); + operation->ad_buffer = NULL; + operation->ad_length = 0; + } + else + { + /* Need to back up the body data so we can do this again + later.*/ + operation->body_buffer = ( uint8_t * ) mbedtls_calloc(1, input_length ); + + if( operation->body_buffer ) + { + memcpy( operation->body_buffer, input, input_length ); + operation->body_length = input_length; + + /* this will fail, as the tag is clearly false, but will write the + decrypted data to the output buffer. */ + ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, input_length, + operation->nonce, operation->nonce_length, + operation->ad_buffer, operation->ad_length, + input, output, + operation->tag_buffer, + operation->tag_length ); + + if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) + { + status = PSA_SUCCESS; + } + else + { + status = mbedtls_to_psa_error( ret ); + } + } + else + { + status = PSA_ERROR_INSUFFICIENT_MEMORY; + } + } } else { - return ( PSA_ERROR_INSUFFICIENT_MEMORY ); + status = PSA_ERROR_INSUFFICIENT_MEMORY; } - } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -732,10 +774,10 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, mbedtls_psa_aead_verify() */ static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t *operation, size_t output_size, - size_t tag_size, - size_t *finish_output_size, - size_t *output_tag_length ) + size_t tag_size ) { + size_t finish_output_size; + if( operation->lengths_set ) { if( operation->ad_remaining != 0 || operation->body_remaining != 0 ) @@ -744,41 +786,28 @@ static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t *operat } } - *output_tag_length = operation->tag_length; - - if( tag_size < *output_tag_length) + if( tag_size < operation->tag_length ) { return ( PSA_ERROR_BUFFER_TOO_SMALL ); } -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) + if( operation->is_encrypt ) { - /* CCM will output all data at this step. */ - *finish_output_size = operation->data_length; + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, + operation->alg ); } else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ { - if( operation->is_encrypt ) - { - *finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, - operation->alg ); - } - else - { - *finish_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, + finish_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, operation->alg ); - } } - if( output_size < *finish_output_size ) + if( output_size < finish_output_size ) { return ( PSA_ERROR_BUFFER_TOO_SMALL ); } return ( PSA_SUCCESS ); - } /* Finish encrypting a message in a multipart AEAD operation. */ @@ -791,11 +820,9 @@ psa_status_t mbedtls_psa_aead_finish( psa_aead_operation_t *operation, size_t *tag_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - size_t output_tag_length; - size_t finish_output_size; + size_t finish_output_size = 0; - status = mbedtls_psa_aead_finish_checks( operation, ciphertext_size, tag_size, &finish_output_size, - &output_tag_length); + status = mbedtls_psa_aead_finish_checks( operation, ciphertext_size, tag_size ); if( status != PSA_SUCCESS ) { @@ -815,31 +842,13 @@ psa_status_t mbedtls_psa_aead_finish( psa_aead_operation_t *operation, #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - if( !operation->ad_buffer || !operation->data_buffer ) - { - return( PSA_ERROR_BAD_STATE ); - } + /* Copy the previously generated tag into place */ + memcpy( tag, operation->tag_buffer, operation->tag_length ); - /* Perform oneshot CCM encryption with data already stored, as - CCM does not support multipart yet.*/ - status = mbedtls_to_psa_error( mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm, - operation->data_length, - operation->nonce, - operation->nonce_length, - operation->ad_buffer, - operation->ad_length, - operation->data_buffer, - ciphertext, - tag, tag_size ) ); + mbedtls_free(operation->tag_buffer); + operation->tag_buffer = NULL; - /* Even if the above operation fails, we no longer need the data */ - mbedtls_free(operation->ad_buffer); - operation->ad_buffer = NULL; - operation->ad_length = 0; - - mbedtls_free(operation->data_buffer); - operation->data_buffer = NULL; - operation->data_length = 0; + status = PSA_SUCCESS; } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -865,7 +874,7 @@ psa_status_t mbedtls_psa_aead_finish( psa_aead_operation_t *operation, if( status == PSA_SUCCESS ) { *ciphertext_length = finish_output_size; - *tag_length = output_tag_length; + *tag_length = operation->tag_length; } mbedtls_psa_aead_abort(operation); @@ -885,14 +894,15 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t finish_output_size; - size_t output_tag_length; + uint8_t * temp_buffer; + size_t temp_buffer_size; + + size_t finish_output_size = 0; int do_tag_check = 1; uint8_t check_tag[16]; - status = mbedtls_psa_aead_finish_checks( operation, plaintext_size, tag_length, &finish_output_size, - &output_tag_length); + status = mbedtls_psa_aead_finish_checks( operation, plaintext_size, tag_length ); if( status != PSA_SUCCESS ) { @@ -905,45 +915,58 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, /* Call finish to get the tag for comparison */ status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, check_tag, - 16 ) ); + operation->tag_length ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - if( !operation->ad_buffer || !operation->data_buffer ) + if( !operation->ad_buffer || !operation->body_buffer ) { return( PSA_ERROR_BAD_STATE ); } - /* Perform oneshot CCM decryption with data already stored, as - CCM does not support multipart yet.*/ + /* Perform oneshot CCM decryption *again*, as its the + * only way to get the tag, but this time throw away the + results, as verify cannot write that much data. */ + temp_buffer_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type, + operation->alg, operation->body_length ); - ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, operation->data_length, - operation->nonce, operation->nonce_length, - operation->ad_buffer, operation->ad_length, - operation->data_buffer, plaintext, - tag, tag_length ); + temp_buffer = ( uint8_t * ) mbedtls_calloc(1, temp_buffer_size ); - if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) + if( temp_buffer ) { - status = PSA_ERROR_INVALID_SIGNATURE; + ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, operation->body_length, + operation->nonce, operation->nonce_length, + operation->ad_buffer, operation->ad_length, + operation->body_buffer, temp_buffer, + tag, tag_length ); + + if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) + { + status = PSA_ERROR_INVALID_SIGNATURE; + } + else + { + status = mbedtls_to_psa_error( ret ); + do_tag_check = 0; + } } else { - status = mbedtls_to_psa_error( ret ); - do_tag_check = 0; + status = PSA_ERROR_INSUFFICIENT_MEMORY; } /* Even if the above operation fails, we no longer need the data */ - mbedtls_free(operation->ad_buffer); - operation->ad_buffer = NULL; - operation->ad_length = 0; + mbedtls_free(temp_buffer); - mbedtls_free(operation->data_buffer); - operation->data_buffer = NULL; - operation->data_length = 0; + mbedtls_free(operation->body_buffer); + operation->body_buffer = NULL; + operation->body_length = 0; + + mbedtls_free(operation->tag_buffer); + operation->tag_buffer = NULL; } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -953,6 +976,7 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, // call finish to get the tag for comparison. status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly, check_tag ) ); + } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ @@ -1003,6 +1027,17 @@ psa_status_t mbedtls_psa_aead_abort( psa_aead_operation_t *operation ) #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ } + mbedtls_free(operation->ad_buffer); + operation->ad_buffer = NULL; + operation->ad_length = 0; + + mbedtls_free(operation->body_buffer); + operation->body_buffer = NULL; + operation->body_length = 0; + + mbedtls_free(operation->tag_buffer); + operation->tag_buffer = NULL; + return( PSA_SUCCESS ); } From 0023e0a1de4f0392125c2b5f3e15e13506abbb35 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 27 Apr 2021 10:06:22 +0100 Subject: [PATCH 010/966] Add tests for multipart AEAD Just clone of one shot tests for now - all additional data and body data is passed in in one go. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 264 +++++++ tests/suites/test_suite_psa_crypto.function | 778 ++++++++++++++++++++ 2 files changed, 1042 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 7b86185b9b..fc79741dc0 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2062,6 +2062,270 @@ PSA AEAD encrypt/decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C aead_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":"":PSA_ERROR_NOT_SUPPORTED +PSA Multipart AEAD encrypt/decrypt, AES-GCM, 19 bytes #1 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":-1:"0C0D0E0F101112131415161718191A1B1C1D1E":-1:PSA_SUCCESS + +PSA Multipart AEAD encrypt/decrypt, AES GCM, 19 bytes #2 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"EC46BB63B02520C33C49FD70":-1:"B96B49E21D621741632875DB7F6C9243D2D7C2":-1:PSA_SUCCESS + +PSA Multipart AEAD encrypt/decrypt, AES-GCM, 19 bytes, 12 byte nonce , 1 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"E462C58482FE8264AEEB7231":"000102030405060708090A0B":-1:"0C0D0E0F101112131415161718191A1B1C1D1E":-1:PSA_SUCCESS + +PSA Multipart AEAD encrypt/decrypt, AES GCM, 19 bytes, 12 byte nonce , 2 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"E462C58482FE8264AEEB7231":"EC46BB63B02520C33C49FD70":-1:"B96B49E21D621741632875DB7F6C9243D2D7C2":-1:PSA_SUCCESS + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #2 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":-1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":-1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=4 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=0, TAG=16, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":-1:"":-1:"f149e2b5f0adaa9842ca5f45b768a8fc" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=16, TAG=16, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":-1:"":-1:"204bdb1bd62154bf08922aaa54eed705" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=20, TAG=16, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":-1:"":-1:"1b2d2764573e20ae640bf29d48e5fe05" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=48, TAG=15, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":-1:"":-1:"77e5682a49243d5b9016eb1adafa2d" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=16, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":-1:"d2ae38c4375954835d75b8e4c2f9bbb4":-1:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=8, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":-1:"d3f3f57033df30c22860231334b099cb":-1:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=14, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":-1:"e7fb0631eebf9bdba87045b33650c4ce":-1:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=4, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":-1:"636871d4c0aae3da7b55abd8b5f21297":-1:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=20, TAG=13, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":-1:"3d952be11deb421b56e0ce9d7ce99553":-1:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=48, TAG=15, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":-1:"fdd8a462c86d4365c8bfee0e25fc8a62":-1:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=16, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":-1:"":-1:"bdc1ac884d332457a1d2664f168c76f0" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=12, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":-1:"":-1:"2fb9c3e41fff24ef07437c47" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=16, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":-1:"":-1:"f6d47505ec96c98a42dc3ae719877b87" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=13, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":-1:"":-1:"5233f95bdcf5d666fb957acdcb" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=15, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":-1:"":-1:"d57e27914ecb4a764359d3c0f8d4d6" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=4, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":-1:"":-1:"72901467" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=15, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":-1:"722ee47da4b77424733546c2d400c4e5":-1:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=12, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":-1:"bcf48ddcfe9d011a1003973d68d2d78a":-1:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=16, TAG=14, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":-1:"c37aada3d4408e880d47e41df77da9b9":-1:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=48, TAG=15, +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":-1:"e5f410fe939e79b7ad33fbd3aaf5856f":-1:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":-1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":-1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, invalid signature +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":-1:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":-1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD decrypt, AES-GCM, T=15 but passing 16 bytes +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 0 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 2 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 18 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":-1:"db1a74ffb5f7de26f5742e0942b1b9cb":-1:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":-1:"434ff68f2436f48418fd69f52158":-1:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":-1:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":-1:"b03c2c20f758a93a8d1220232ad87098":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":-1:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":-1:"b22b2dcdcc18adc30d16297b84b459d8":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":-1:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":-1:"7e5fd8b595ddc4753676107951d900e2":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":-1:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":-1:"37245449db8f72b1ecdb420f629d3d80":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":-1:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":-1:"496909523f574b205d757659c5":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":-1:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":-1:"b6e056de521a27266dffbc0d96":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":-1:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":-1:"f6d56f8c86f27d957fa63aea22":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":-1:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":-1:"bd94b34511bc65ae47684805cb":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":-1:"15e051a5e4a5f5da6cea92e2ebee5bac":-1:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":-1:"84c8beff4b0d160ee68ac613097f51":-1:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":-1:"8d6351f18d873242204c20144e2b83":-1:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":-1:"3bfd3d99fe2063e8ef8255519fe0":-1:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":-1:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":-1:"7789b41cb3ee548814ca0b388c10b343":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":-1:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":-1:"4860116a6d2deb9bf794bfd6ac5bbbd6":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":-1:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":-1:"ff426dd751190ff826e8b4a0792d746e":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":-1:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":-1:"0a0b284515694188b6b6c15bc8a09036":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":-1:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":-1:"f386b28e7eb4c2fb8eb5dc66a2":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":-1:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":-1:"da1c61fbfcdb73445ad4c7d889":PSA_SUCCESS + +PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":-1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":-1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" + +PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (zero-length input) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":-1:"":-1:"a0784d7a4716f3feb4f64e7f4b39bf04" + +PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":-1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":-1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS + +PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, bad tag) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":-1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":-1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":-1:"a0784d7a4716f3feb4f64e7f4b39bf04":-1:"":PSA_SUCCESS + +PSA Multipart AEAD encrypt/decrypt: invalid algorithm (CTR) +depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":-1:"":-1:PSA_ERROR_NOT_SUPPORTED + +PSA Multipart AEAD encrypt/decrypt: invalid algorithm (ChaCha20) +depends_on:MBEDTLS_CHACHA20_C +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":-1:"":-1:PSA_ERROR_NOT_SUPPORTED + PSA signature size: RSA keypair, 1024 bits, PKCS#1 v1.5 raw depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR signature_size:PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:128 diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index bff0c35a04..991b10a8a9 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3152,6 +3152,784 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void aead_multipart_encrypt( int key_type_arg, data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + int ad_part_len, + data_t *input_data, + int data_part_len, + data_t *expected_result ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + unsigned char *output_data = NULL; + unsigned char *part_data = NULL; + unsigned char *final_data = NULL; + size_t output_size = 0; + size_t part_data_size = 0; + size_t output_length = 0; + size_t key_bits = 0; + size_t tag_length = 0; + size_t tag_size = 0; + size_t nonce_length = 0; + uint8_t nonce_buffer[16]; + uint8_t tag_buffer[16]; + uint32_t part_offset = 0; + size_t part_length = 0; + size_t output_part_length = 0; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + key_bits = psa_get_key_bits( &attributes ); + + tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); + + TEST_ASSERT( tag_length <= 16 ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( input_data->len + tag_length ) ); + + ASSERT_ALLOC( output_data, output_size ); + + ASSERT_ALLOC( final_data, PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + operation = psa_aead_operation_init(); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + PSA_ASSERT( status ); + + if( nonce->len == 0 ) + { + PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ), + &nonce_length ) ); + } + else + { + nonce_length = nonce->len; + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation.alg == PSA_ALG_GCM ) + { + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, input_data->len ) ); + } +#endif + + if( ad_part_len != -1 ) + { + /* Pass addtional data in parts */ + part_offset = 0; + + while( part_offset <= additional_data->len) + { + if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } + + PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x + part_offset, + part_length ) ); + + part_offset += part_length; + } + } + else + { + /* Pass additional data in one go. */ + PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, additional_data->len) ); + } + + if( data_part_len != -1 ) + { + /* Pass data in parts */ + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len ); + + ASSERT_ALLOC( part_data, part_data_size ); + + part_offset = 0; + + while( part_offset <= input_data->len) + { + if( input_data->len - part_offset < ( uint32_t ) data_part_len ) + { + part_length = input_data->len - part_offset; + } + else + { + part_length = data_part_len; + } + + PSA_ASSERT( psa_aead_update( &operation, ( input_data->x + part_offset ), + part_length, part_data, + part_data_size, &output_part_length ) ); + + memcpy( ( output_data + part_offset ), part_data, output_part_length ); + + part_offset += part_length; + output_length += output_part_length; + } + } + else + { + /* Pass whole data in one go */ + PSA_ASSERT( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ) ); + } + + PSA_ASSERT( psa_aead_finish( &operation, final_data, + PSA_AEAD_FINISH_OUTPUT_MAX_SIZE, + &output_part_length, + tag_buffer, tag_length, + &tag_size ) ); + + memcpy( ( output_data + output_length ), final_data, output_part_length ); + + TEST_EQUAL(tag_length, tag_size); + + output_length += output_part_length; + + memcpy( ( output_data + output_length ), tag_buffer, tag_length ); + + output_length += tag_length; + + /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE + * should be exact. */ + TEST_EQUAL( output_length, + PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) ); + TEST_ASSERT( output_length <= + PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); + + ASSERT_COMPARE( expected_result->x, expected_result->len, + output_data, output_length ); + +exit: + psa_destroy_key( key ); + mbedtls_free( output_data ); + mbedtls_free( part_data ); + mbedtls_free( final_data ); + PSA_DONE( ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + int ad_part_len, + data_t *input_data, + int data_part_len, + int expected_result_arg ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + unsigned char *output_data = NULL; + unsigned char *part_data = NULL; + unsigned char *final_data = NULL; + size_t part_data_size; + size_t output_size = 0; + size_t output_length = 0; + unsigned char *output_data2 = NULL; + size_t output_size2 = 0; + size_t output_length2 = 0; + size_t key_bits = 0; + size_t tag_length = 0; + size_t tag_size = 0; + size_t nonce_length = 0; + uint8_t nonce_buffer[16]; + uint8_t tag_buffer[16]; + uint32_t part_offset = 0; + size_t part_length = 0; + size_t output_part_length = 0; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + psa_status_t expected_result = expected_result_arg; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + key_bits = psa_get_key_bits( &attributes ); + + tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); + + TEST_ASSERT( tag_length <= 16 ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); + + ASSERT_ALLOC( output_data, output_size ); + ASSERT_ALLOC( final_data, PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + operation = psa_aead_operation_init(); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + if( nonce->len == 0 ) + { + status = psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ), + &nonce_length ); + } + else + { + nonce_length = nonce->len; + status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); + } + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation.alg == PSA_ALG_GCM ) + { + status = psa_aead_set_lengths( &operation, additional_data->len, input_data->len ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } +#endif + + if( ad_part_len != -1 ) + { + part_offset = 0; + + while( part_offset <= additional_data->len) + { + if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } + + status = psa_aead_update_ad( &operation, additional_data->x + part_offset, + part_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + part_offset += part_length; + } + } + else + { + status = psa_aead_update_ad(&operation, additional_data->x, additional_data->len); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } + + if( data_part_len != -1 ) + { + /* Pass data in parts */ + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( size_t ) data_part_len ); + + ASSERT_ALLOC( part_data, part_data_size ); + + part_offset = 0; + + while( part_offset <= input_data->len) + { + if( input_data->len - part_offset < ( uint32_t ) data_part_len ) + { + part_length = input_data->len - part_offset; + } + else + { + part_length = data_part_len; + } + + status = psa_aead_update( &operation, ( input_data->x + part_offset ), + part_length, part_data, + part_data_size, &output_part_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + memcpy( ( output_data + part_offset ), part_data, output_part_length ); + + part_offset += part_length; + output_length += output_part_length; + } + } + else + { + status = psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } + + status = psa_aead_finish( &operation, final_data, + PSA_AEAD_FINISH_OUTPUT_MAX_SIZE, + &output_part_length, + tag_buffer, tag_length, + &tag_size ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + memcpy( ( output_data + output_length ), final_data, output_part_length ); + + output_length += output_part_length; + + /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE + * should be exact. */ + if( expected_result != PSA_ERROR_INVALID_ARGUMENT ) + TEST_EQUAL( ( output_length + tag_length ), + PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) ); + + TEST_EQUAL(tag_length, tag_size); + + if( PSA_SUCCESS == expected_result ) + { + output_size2 = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, output_length ); + ASSERT_ALLOC( output_data2, output_size2 ); + + /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE + * should be exact. */ + TEST_EQUAL( input_data->len, + PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, + ( output_length + tag_length ) ) ); + + TEST_ASSERT( input_data->len <= + PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length + tag_length ) ); + + operation = psa_aead_operation_init(); + + status = psa_aead_decrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + TEST_EQUAL( status, expected_result ); + + if( nonce->len == 0 ) + { + /* Use previously generated nonce. */ + status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_length ); + } + else + { + nonce_length = nonce->len; + status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); + } + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation.alg == PSA_ALG_GCM ) + { + status = psa_aead_set_lengths( &operation, additional_data->len, output_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + } + } +#endif + + if( ad_part_len != -1 ) + { + part_offset = 0; + + while( part_offset <= additional_data->len) + { + if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } + + PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x + part_offset, + part_length ) ); + + part_offset += part_length; + } + } + else + { + PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, additional_data->len) ); + } + + if( data_part_len != -1 ) + { + /* Pass data in parts */ + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len ); + + ASSERT_ALLOC( part_data, part_data_size ); + + part_offset = 0; + + while( part_offset <= ( input_data->len - tag_length ) ) + { + if( ( input_data->len - tag_length - part_offset ) < ( uint32_t ) data_part_len ) + { + part_length = ( input_data->len - tag_length - part_offset ); + } + else + { + part_length = data_part_len; + } + + PSA_ASSERT( psa_aead_update( &operation, ( input_data->x + part_offset ), + part_length, part_data, + part_data_size, &output_part_length ) ); + + memcpy( ( output_data2 + part_offset ), part_data, output_part_length ); + + part_offset += part_length; + output_length2 += output_part_length; + } + } + else + { + PSA_ASSERT( psa_aead_update( &operation, output_data, + output_length, output_data2, + output_size2, &output_length2 ) ); + } + + PSA_ASSERT( psa_aead_verify( &operation, final_data, + PSA_AEAD_FINISH_OUTPUT_MAX_SIZE, + &output_part_length, + tag_buffer, tag_length ) ); + + memcpy( ( output_data2 + output_length2 ), final_data, output_part_length); + + output_length2 += output_part_length; + + ASSERT_COMPARE( input_data->x, input_data->len, + output_data2, output_length2 ); + } + +exit: + psa_destroy_key( key ); + mbedtls_free( output_data ); + mbedtls_free( output_data2 ); + mbedtls_free( part_data ); + mbedtls_free( final_data ); + PSA_DONE( ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void aead_multipart_decrypt( int key_type_arg, data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + int ad_part_len, + data_t *input_data, + int data_part_len, + data_t *expected_data, + int expected_result_arg ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + unsigned char *output_data = NULL; + unsigned char *part_data = NULL; + unsigned char *final_data = NULL; + size_t part_data_size; + size_t output_size = 0; + size_t output_length = 0; + size_t key_bits = 0; + size_t tag_length = 0; + size_t nonce_length = 0; + uint8_t nonce_buffer[16]; + uint32_t part_offset = 0; + size_t part_length = 0; + size_t output_part_length = 0; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t expected_result = expected_result_arg; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + key_bits = psa_get_key_bits( &attributes ); + + tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( input_data->len - tag_length ) ); + + ASSERT_ALLOC( output_data, output_size ); + ASSERT_ALLOC( final_data, PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); + + operation = psa_aead_operation_init(); + + status = psa_aead_decrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + if( nonce->len == 0 ) + { + status = psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ), + &nonce_length ); + } + else + { + nonce_length = nonce->len; + status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); + } + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation.alg == PSA_ALG_GCM ) + { + status = psa_aead_set_lengths( &operation, additional_data->len, + ( input_data->len - tag_length ) ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } +#endif + + if( ad_part_len != -1 ) + { + part_offset = 0; + + while( part_offset <= additional_data->len) + { + if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } + + status = psa_aead_update_ad( &operation, additional_data->x + part_offset, + part_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + part_offset += part_length; + } + } + else + { + status = psa_aead_update_ad( &operation, additional_data->x, additional_data->len ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } + + if( data_part_len != -1 ) + { + /* Pass data in parts */ + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len ); + + ASSERT_ALLOC( part_data, part_data_size ); + + part_offset = 0; + + while( part_offset <= input_data->len) + { + if( (input_data->len - tag_length - part_offset ) < ( uint32_t ) data_part_len ) + { + part_length = ( input_data->len - tag_length - part_offset ); + } + else + { + part_length = data_part_len; + } + + status = psa_aead_update( &operation, ( input_data->x + part_offset ), + part_length, part_data, + part_data_size, &output_part_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + memcpy( ( output_data + part_offset ), part_data, output_part_length ); + + part_offset += part_length; + output_length += output_part_length; + } + } + else + { + status = psa_aead_update( &operation, input_data->x, + ( input_data->len - tag_length ), output_data, + output_size, &output_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } + + status = psa_aead_verify( &operation, final_data, + PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE, + &output_part_length, + ( input_data->x + input_data->len - tag_length ), + tag_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + memcpy( ( output_data + output_length ), final_data, output_part_length ); + + output_length += output_part_length; + + if( expected_result != PSA_ERROR_INVALID_ARGUMENT ) + { + /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE + * should be exact. */ + TEST_EQUAL( output_length, + PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) ); + TEST_ASSERT( output_length <= + PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); + } + + if( expected_result == PSA_SUCCESS ) + ASSERT_COMPARE( expected_data->x, expected_data->len, + output_data, output_length ); + +exit: + psa_destroy_key( key ); + mbedtls_free( output_data ); + mbedtls_free( part_data ); + mbedtls_free( final_data ); + PSA_DONE( ); +} +/* END_CASE */ + /* BEGIN_CASE */ void signature_size( int type_arg, int bits, From 4bbe82bdcc606672bda65dc4a3bcd57b2894a185 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 27 Apr 2021 12:11:56 +0100 Subject: [PATCH 011/966] Add transparent driver tests for M-AEAD Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 48 +++---- tests/include/test/drivers/aead.h | 55 ++++++++ tests/src/drivers/test_driver_aead.c | 204 +++++++++++++++++++++++++++ 3 files changed, 283 insertions(+), 24 deletions(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 91ad37f80d..ce49a226bf 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1311,10 +1311,10 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) status = PSA_ERROR_NOT_SUPPORTED; -// status = test_transparent_aead_encrypt_setup( -// operation, attributes, -// key_buffer, key_buffer_size, -// alg ); + status = test_transparent_aead_encrypt_setup( + operation, attributes, + key_buffer, key_buffer_size, + alg ); /* Declared with fallback == true */ if( status == PSA_SUCCESS ) operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; @@ -1363,10 +1363,10 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) status = PSA_ERROR_NOT_SUPPORTED; -// status = test_transparent_aead_decrypt_setup( -// operation, attributes, -// key_buffer, key_buffer_size, -// alg ); + status = test_transparent_aead_decrypt_setup( + operation, attributes, + key_buffer, key_buffer_size, + alg ); /* Declared with fallback == true */ if( status == PSA_SUCCESS ) operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; @@ -1413,8 +1413,8 @@ psa_status_t psa_driver_wrapper_aead_set_nonce( #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( PSA_ERROR_NOT_SUPPORTED ); -// return( test_transparent_aead_set_nonce( -// operation, nonce, nonce_length ) ); + return( test_transparent_aead_set_nonce( + operation, nonce, nonce_length ) ); /* Add cases for opaque driver here */ @@ -1445,8 +1445,8 @@ psa_status_t psa_driver_wrapper_aead_set_lengths( #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( PSA_ERROR_NOT_SUPPORTED ); -// return( test_transparent_aead_set_lengths( -// operation, ad_length, plaintext_length ) ); + return( test_transparent_aead_set_lengths( + operation, ad_length, plaintext_length ) ); /* Add cases for opaque driver here */ @@ -1477,8 +1477,8 @@ psa_status_t psa_driver_wrapper_aead_update_ad( #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( PSA_ERROR_NOT_SUPPORTED ); -// return( test_transparent_aead_update_ad( -// operation, input, input_length ) ); + return( test_transparent_aead_update_ad( + operation, input, input_length ) ); /* Add cases for opaque driver here */ @@ -1513,9 +1513,9 @@ psa_status_t psa_driver_wrapper_aead_update( #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( PSA_ERROR_NOT_SUPPORTED ); -// return( test_transparent_aead_update( -// operation, input, input_length, ouput, output_size, -// output_length ) ); + return( test_transparent_aead_update( + operation, input, input_length, output, output_size, + output_length ) ); /* Add cases for opaque driver here */ @@ -1554,9 +1554,9 @@ psa_status_t psa_driver_wrapper_aead_finish( #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( PSA_ERROR_NOT_SUPPORTED ); -// return( test_transparent_aead_finish( -// operation, ciphertext, ciphertext_size, -// ciphertext_length, tag, tag_size, tag_length ) ); + return( test_transparent_aead_finish( + operation, ciphertext, ciphertext_size, + ciphertext_length, tag, tag_size, tag_length ) ); /* Add cases for opaque driver here */ @@ -1595,9 +1595,9 @@ psa_status_t psa_driver_wrapper_aead_verify( #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( PSA_ERROR_NOT_SUPPORTED ); -// return( test_transparent_aead_verify( -// operation, ciphertext, ciphertext_size, -// ciphertext_length, tag, tag_length ) ); + return( test_transparent_aead_verify( + operation, plaintext, plaintext_size, + plaintext_length, tag, tag_length ) ); /* Add cases for opaque driver here */ @@ -1629,7 +1629,7 @@ psa_status_t psa_driver_wrapper_aead_abort( #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( PSA_ERROR_NOT_SUPPORTED ); -// return( test_transparent_aead_abort( operation ) ); + return( test_transparent_aead_abort( operation ) ); /* Add cases for opaque driver here */ diff --git a/tests/include/test/drivers/aead.h b/tests/include/test/drivers/aead.h index 2207cb36fe..23f32c0a88 100644 --- a/tests/include/test/drivers/aead.h +++ b/tests/include/test/drivers/aead.h @@ -67,5 +67,60 @@ psa_status_t mbedtls_test_transparent_aead_decrypt( const uint8_t *ciphertext, size_t ciphertext_length, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ); +psa_status_t test_transparent_aead_encrypt_setup( + psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ); + +psa_status_t test_transparent_aead_decrypt_setup( + psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ); + +psa_status_t test_transparent_aead_set_nonce( + psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length ); + +psa_status_t test_transparent_aead_set_lengths( + psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ); + +psa_status_t test_transparent_aead_update_ad( + psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length ); + +psa_status_t test_transparent_aead_update( + psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length ); + +psa_status_t test_transparent_aead_finish( + psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length ); + +psa_status_t test_transparent_aead_verify( + psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length ); + +psa_status_t test_transparent_aead_abort( + psa_aead_operation_t *operation ); + #endif /* PSA_CRYPTO_DRIVER_TEST */ #endif /* PSA_CRYPTO_TEST_DRIVERS_AEAD_H */ diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index 25396c92f5..67118efcbe 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -93,4 +93,208 @@ psa_status_t mbedtls_test_transparent_aead_decrypt( return( mbedtls_test_driver_aead_hooks.driver_status ); } +psa_status_t test_transparent_aead_encrypt_setup( + psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_encrypt_setup( operation, attributes, key_buffer, + key_buffer_size, alg ); + } + + return( test_driver_aead_hooks.driver_status ); +} + +psa_status_t test_transparent_aead_decrypt_setup( + psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, size_t key_buffer_size, + psa_algorithm_t alg ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_decrypt_setup( operation, attributes, key_buffer, + key_buffer_size, alg ); + } + + return( test_driver_aead_hooks.driver_status ); +} + +psa_status_t test_transparent_aead_set_nonce( + psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_set_nonce( operation, nonce, nonce_length ); + } + + return( test_driver_aead_hooks.driver_status ); +} + +psa_status_t test_transparent_aead_set_lengths( + psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_set_lengths( operation, ad_length, plaintext_length ); + } + + return( test_driver_aead_hooks.driver_status ); +} + +psa_status_t test_transparent_aead_update_ad( + psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_update_ad( operation, input, input_length ); + } + + return( test_driver_aead_hooks.driver_status ); +} + +psa_status_t test_transparent_aead_update( + psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_update( operation, input, input_length, output, + output_size, output_length ); + } + + return( test_driver_aead_hooks.driver_status ); +} + +psa_status_t test_transparent_aead_finish( + psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_finish( operation, ciphertext, ciphertext_size, + ciphertext_length, tag, tag_size, tag_length ); + } + + return( test_driver_aead_hooks.driver_status ); +} + +psa_status_t test_transparent_aead_verify( + psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_verify( operation, plaintext, plaintext_size, + plaintext_length, tag, tag_length ); + } + + return( test_driver_aead_hooks.driver_status ); +} + +psa_status_t test_transparent_aead_abort( + psa_aead_operation_t *operation ) +{ + test_driver_aead_hooks.hits++; + + if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + { + test_driver_aead_hooks.driver_status = + test_driver_aead_hooks.forced_status; + } + else + { + test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_abort( operation ); + } + + return( test_driver_aead_hooks.driver_status ); +} + #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ From d4e99ed40cd8a043daa8a62cec96ad58e3167570 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 27 Apr 2021 16:34:31 +0100 Subject: [PATCH 012/966] Fix mistyped buffer size variable Signed-off-by: Paul Elliott --- include/psa/crypto_struct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 90a0c2098c..6c5639d1c8 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -183,7 +183,7 @@ struct psa_aead_operation_s size_t ad_length; uint8_t *body_buffer; - uint8_t body_length; + size_t body_length; uint8_t *tag_buffer; From ac3c20013cba08babf891fa6616d25cdf7df5c7c Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 27 Apr 2021 19:10:18 +0100 Subject: [PATCH 013/966] Prevent unsafe memcpy Some tests cause a zero length input or output, which can mean the allocated test output buffers can be zero length. Protect against calling memcpy blindly in these situations. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 45 ++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 991b10a8a9..a7ba675257 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3292,7 +3292,10 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, part_length, part_data, part_data_size, &output_part_length ) ); - memcpy( ( output_data + part_offset ), part_data, output_part_length ); + if( output_data && output_part_length ) + { + memcpy( ( output_data + part_offset ), part_data, output_part_length ); + } part_offset += part_length; output_length += output_part_length; @@ -3312,13 +3315,19 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, tag_buffer, tag_length, &tag_size ) ); - memcpy( ( output_data + output_length ), final_data, output_part_length ); + if( output_data && output_part_length ) + { + memcpy( ( output_data + output_length ), final_data, output_part_length ); + } TEST_EQUAL(tag_length, tag_size); output_length += output_part_length; - memcpy( ( output_data + output_length ), tag_buffer, tag_length ); + if( output_data && tag_length ) + { + memcpy( ( output_data + output_length ), tag_buffer, tag_length ); + } output_length += tag_length; @@ -3516,7 +3525,10 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, goto exit; } - memcpy( ( output_data + part_offset ), part_data, output_part_length ); + if( output_data && output_part_length ) + { + memcpy( ( output_data + part_offset ), part_data, output_part_length ); + } part_offset += part_length; output_length += output_part_length; @@ -3547,7 +3559,10 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, goto exit; } - memcpy( ( output_data + output_length ), final_data, output_part_length ); + if( output_data &&output_part_length ) + { + memcpy( ( output_data + output_length ), final_data, output_part_length ); + } output_length += output_part_length; @@ -3666,7 +3681,10 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, part_length, part_data, part_data_size, &output_part_length ) ); - memcpy( ( output_data2 + part_offset ), part_data, output_part_length ); + if( output_data2 && output_part_length ) + { + memcpy( ( output_data2 + part_offset ), part_data, output_part_length ); + } part_offset += part_length; output_length2 += output_part_length; @@ -3684,7 +3702,10 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, &output_part_length, tag_buffer, tag_length ) ); - memcpy( ( output_data2 + output_length2 ), final_data, output_part_length); + if( output_data2 && output_part_length ) + { + memcpy( ( output_data2 + output_length2 ), final_data, output_part_length); + } output_length2 += output_part_length; @@ -3872,7 +3893,10 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, goto exit; } - memcpy( ( output_data + part_offset ), part_data, output_part_length ); + if( output_data && output_part_length ) + { + memcpy( ( output_data + part_offset ), part_data, output_part_length ); + } part_offset += part_length; output_length += output_part_length; @@ -3903,7 +3927,10 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, goto exit; } - memcpy( ( output_data + output_length ), final_data, output_part_length ); + if( output_data && output_part_length ) + { + memcpy( ( output_data + output_length ), final_data, output_part_length ); + } output_length += output_part_length; From 72baf658193d97bca6e37eed1a195eec09b13bf3 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 28 Apr 2021 13:23:27 +0100 Subject: [PATCH 014/966] Ensure operation id gets set even if failure Although this deviates from the standard "auto-generated" code, the M-AEAD setup functions set the key and thus allocate memory. If the failure occurs after this (invalid tag size for example) then not having the id set to the internal drivers means that abort does not get called, and this causes the allocated data to leak. Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index ce49a226bf..1e17435015 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1330,8 +1330,7 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( key_buffer, key_buffer_size, alg ); - if( status == PSA_SUCCESS ) - operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; + operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; return( status ); @@ -1382,8 +1381,7 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( key_buffer, key_buffer_size, alg ); - if( status == PSA_SUCCESS ) - operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; + operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; return( status ); From 16e6dcd72e85ed3b56f5f9c3041cd9b98ea4c466 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 28 Apr 2021 13:27:39 +0100 Subject: [PATCH 015/966] Add missing abort call to the end of tests All tests should have an abort call in case of test failure to make sure everything is cleaned up. Also removed unused define. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index a7ba675257..6ae5030ee1 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3343,6 +3343,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, exit: psa_destroy_key( key ); + psa_aead_abort( &operation ); mbedtls_free( output_data ); mbedtls_free( part_data ); mbedtls_free( final_data ); @@ -3715,6 +3716,7 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, exit: psa_destroy_key( key ); + psa_aead_abort( &operation ); mbedtls_free( output_data ); mbedtls_free( output_data2 ); mbedtls_free( part_data ); @@ -3950,6 +3952,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, exit: psa_destroy_key( key ); + psa_aead_abort( &operation ); mbedtls_free( output_data ); mbedtls_free( part_data ); mbedtls_free( final_data ); From 7bc45ebf13d0496ea9ffd22c7e97f0678306b105 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 28 Apr 2021 13:44:46 +0100 Subject: [PATCH 016/966] Add Changelog entry Signed-off-by: Paul Elliott --- ChangeLog.d/add_psa_m_aead.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ChangeLog.d/add_psa_m_aead.txt diff --git a/ChangeLog.d/add_psa_m_aead.txt b/ChangeLog.d/add_psa_m_aead.txt new file mode 100644 index 0000000000..d5c0a48c2f --- /dev/null +++ b/ChangeLog.d/add_psa_m_aead.txt @@ -0,0 +1,3 @@ +Features + * Implemented the multipart AEAD API within the PSA Crypto API, along with + tests in the PSA Crypto test suite, and transparent driver wrappers. From fe5480a4c2a32931d4f7772b23da5935530d399d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 28 Apr 2021 16:44:37 +0100 Subject: [PATCH 017/966] Fix transparent driver wrappers Remove spurious "not supported" returns, and fix same issue that was encountered with internal implementations - operation needs to be marked as a type even if the initial call fails, otherwise cleanup won't get done. Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 1e17435015..0a7960ca7e 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1316,8 +1316,7 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( key_buffer, key_buffer_size, alg ); /* Declared with fallback == true */ - if( status == PSA_SUCCESS ) - operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; + operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; if( status != PSA_ERROR_NOT_SUPPORTED ) return( status ); @@ -1367,8 +1366,7 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( key_buffer, key_buffer_size, alg ); /* Declared with fallback == true */ - if( status == PSA_SUCCESS ) - operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; + operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; if( status != PSA_ERROR_NOT_SUPPORTED ) return( status ); @@ -1410,7 +1408,6 @@ psa_status_t psa_driver_wrapper_aead_set_nonce( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( PSA_ERROR_NOT_SUPPORTED ); return( test_transparent_aead_set_nonce( operation, nonce, nonce_length ) ); @@ -1442,7 +1439,6 @@ psa_status_t psa_driver_wrapper_aead_set_lengths( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( PSA_ERROR_NOT_SUPPORTED ); return( test_transparent_aead_set_lengths( operation, ad_length, plaintext_length ) ); @@ -1474,7 +1470,6 @@ psa_status_t psa_driver_wrapper_aead_update_ad( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( PSA_ERROR_NOT_SUPPORTED ); return( test_transparent_aead_update_ad( operation, input, input_length ) ); @@ -1510,7 +1505,6 @@ psa_status_t psa_driver_wrapper_aead_update( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( PSA_ERROR_NOT_SUPPORTED ); return( test_transparent_aead_update( operation, input, input_length, output, output_size, output_length ) ); @@ -1551,7 +1545,6 @@ psa_status_t psa_driver_wrapper_aead_finish( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( PSA_ERROR_NOT_SUPPORTED ); return( test_transparent_aead_finish( operation, ciphertext, ciphertext_size, ciphertext_length, tag, tag_size, tag_length ) ); @@ -1592,7 +1585,6 @@ psa_status_t psa_driver_wrapper_aead_verify( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( PSA_ERROR_NOT_SUPPORTED ); return( test_transparent_aead_verify( operation, plaintext, plaintext_size, plaintext_length, tag, tag_length ) ); @@ -1626,7 +1618,6 @@ psa_status_t psa_driver_wrapper_aead_abort( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( PSA_ERROR_NOT_SUPPORTED ); return( test_transparent_aead_abort( operation ) ); /* Add cases for opaque driver here */ From 5d9fa8d675da84a48d86fd1578751b67c9a2a204 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 4 May 2021 17:21:16 +0100 Subject: [PATCH 018/966] Add define to allow multipart ccm to work Add (internal only) define to config.h which allows the temporary implementation of CCM to work, by removing the buffer zeroization on tag fail when decrypting. This will obviously be removed when multipart CCM is properaly implemented Signed-off-by: Paul Elliott --- include/mbedtls/config.h | 8 ++ library/ccm.c | 2 + scripts/config.py | 1 + tests/suites/test_suite_psa_crypto.data | 112 ++++++++++++++++++++++++ 4 files changed, 123 insertions(+) diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index a4479d79ff..6cb05e4712 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -3756,6 +3756,14 @@ */ //#define MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED +/** + * Internal define that removes the zeroization of the output when decrypting + * CCM and the tag check fails. This is for internal use only, and was added so + * that PSA multipart CCM could be implmented. This option will be removed at + * some point in the future when proper CCM multipart support is implemented. + * Use at own risk. + */ +//#define MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL /* \} name SECTION: Customisation configuration options */ /* Target and application specific configurations diff --git a/library/ccm.c b/library/ccm.c index 424ee77b69..d52e7b0797 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -386,7 +386,9 @@ int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, if( diff != 0 ) { +#ifndef MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL mbedtls_platform_zeroize( output, length ); +#endif return( MBEDTLS_ERR_CCM_AUTH_FAILED ); } diff --git a/scripts/config.py b/scripts/config.py index a77ead0544..f9f06053d3 100755 --- a/scripts/config.py +++ b/scripts/config.py @@ -197,6 +197,7 @@ EXCLUDE_FROM_FULL = frozenset([ 'MBEDTLS_TEST_NULL_ENTROPY', # removes a feature 'MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION', # influences the use of X.509 in TLS 'MBEDTLS_X509_REMOVE_INFO', # removes a feature + 'MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL', # lowers security of CCM ]) def is_seamless_alt(name): diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index fc79741dc0..8a85edd10c 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2062,6 +2062,118 @@ PSA AEAD encrypt/decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C aead_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":"":PSA_ERROR_NOT_SUPPORTED +PSA Multipart AEAD encrypt/decrypt: AES-CCM, 19 bytes #1 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_CCM:"000102030405060708090A0B":"000102030405060708090A0B":-1:"0C0D0E0F101112131415161718191A1B1C1D1E":-1:PSA_SUCCESS + +PSA Multipart AEAD encrypt/decrypt: AES-CCM, 19 bytes #2 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"000102030405060708090A0B":"EC46BB63B02520C33C49FD70":-1:"B96B49E21D621741632875DB7F6C9243D2D7C2":-1:PSA_SUCCESS + +PSA Multipart AEAD encrypt/decrypt: DES-CCM not supported +depends_on:MBEDTLS_DES_C:MBEDTLS_CCM_C:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_DES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"000102030405060708090A0B":"EC46BB63B02520C33C49FD70":-1:"B96B49E21D621741632875DB7F6C9243D2D7C2":-1:PSA_ERROR_NOT_SUPPORTED + +PSA Multipart AEAD encrypt: AES-CCM, 23 bytes +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"00412B4EA9CDBE3C9696766CFA":"0BE1A88BACE018B1":-1:"08E8CF97D820EA258460E96AD9CF5289054D895CEAC47C":-1:"4CB97F86A2A4689A877947AB8091EF5386A6FFBDD080F8120333D1FCB691F3406CBF531F83A4D8" + +PSA Multipart AEAD encrypt: AES-CCM, 24 bytes +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9" + +PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=4 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 4 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6643b4f39" + +PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=6 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 6 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b63fdffcd729bc" + +PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=8 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b64cf2c3bf5f220776" + +PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=10 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 10 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b69613343621327defd18e" + +PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=12 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 12 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b69a2e5d8faee3138fa5cf9846" + +PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=14 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 14 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6c99af01cdb6aa76df73c8646c27f" + +PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=16 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 16 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9" + +PSA Multipart AEAD decrypt: AES-CCM, 39 bytes +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"00412B4EA9CDBE3C9696766CFA":"0BE1A88BACE018B1":-1:"4CB97F86A2A4689A877947AB8091EF5386A6FFBDD080F8120333D1FCB691F3406CBF531F83A4D8":-1:"08E8CF97D820EA258460E96AD9CF5289054D895CEAC47C":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-CCM, 40 bytes +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS + +PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=4 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 4 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6643b4f39":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS + +PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=6 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 6 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b63fdffcd729bc":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS + +PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=8 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b64cf2c3bf5f220776":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS + +PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=10 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 10 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b69613343621327defd18e":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS + +PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=12 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 12 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b69a2e5d8faee3138fa5cf9846":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS + +PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=14 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 14 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6c99af01cdb6aa76df73c8646c27f":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS + +PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=16 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 16 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS + +PSA Multipart AEAD decrypt: AES-CCM, invalid signature +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26d56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD decrypt: AES-CCM, invalid signature, T=4 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 4 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6643b4f38":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD decrypt: AES-CCM, T=4, tag is truncated tag for T=16 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 4 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD decrypt: AES-CCM, invalid tag length 0 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart AEAD decrypt: AES-CCM, invalid tag length 2 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart AEAD decrypt: AES-CCM, invalid tag length 15 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 15 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart AEAD decrypt: AES-CCM, invalid tag length 18 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT + PSA Multipart AEAD encrypt/decrypt, AES-GCM, 19 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":-1:"0C0D0E0F101112131415161718191A1B1C1D1E":-1:PSA_SUCCESS From f0e21de4307e1b6d5d1b385b0cc52875323bbecc Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 6 May 2021 19:23:40 +0100 Subject: [PATCH 019/966] Fix generated files after adding config option Signed-off-by: Paul Elliott --- programs/test/query_config.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/programs/test/query_config.c b/programs/test/query_config.c index 450e2fbbf0..647279d687 100644 --- a/programs/test/query_config.c +++ b/programs/test/query_config.c @@ -2723,6 +2723,14 @@ int query_config( const char *config ) } #endif /* MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED */ +#if defined(MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL) + if( strcmp( "MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL ); + return( 0 ); + } +#endif /* MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL */ + /* If the symbol is not found, return an error */ return( 1 ); } From a218ceba931d8b8f9d1db7d85b08bb853e6a5147 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 7 May 2021 15:10:31 +0100 Subject: [PATCH 020/966] Merge upstream test driver changes locally Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 43 +++++---- tests/include/test/drivers/aead.h | 18 ++-- tests/src/drivers/test_driver_aead.c | 132 ++++++++++++++------------- 3 files changed, 101 insertions(+), 92 deletions(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 0a7960ca7e..7faedb30e3 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1311,7 +1311,7 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) status = PSA_ERROR_NOT_SUPPORTED; - status = test_transparent_aead_encrypt_setup( + status = mbedtls_test_transparent_aead_encrypt_setup( operation, attributes, key_buffer, key_buffer_size, alg ); @@ -1361,7 +1361,7 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) status = PSA_ERROR_NOT_SUPPORTED; - status = test_transparent_aead_decrypt_setup( + status = mbedtls_test_transparent_aead_decrypt_setup( operation, attributes, key_buffer, key_buffer_size, alg ); @@ -1401,14 +1401,15 @@ psa_status_t psa_driver_wrapper_aead_set_nonce( { #if defined(MBEDTLS_PSA_BUILTIN_CIPHER) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_set_nonce( operation, nonce, nonce_length ) ); + return( mbedtls_psa_aead_set_nonce( operation, nonce, + nonce_length ) ); #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( test_transparent_aead_set_nonce( + return( mbedtls_test_transparent_aead_set_nonce( operation, nonce, nonce_length ) ); /* Add cases for opaque driver here */ @@ -1432,14 +1433,15 @@ psa_status_t psa_driver_wrapper_aead_set_lengths( { #if defined(MBEDTLS_PSA_BUILTIN_CIPHER) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_set_lengths( operation, ad_length, plaintext_length ) ); + return( mbedtls_psa_aead_set_lengths( operation, ad_length, + plaintext_length ) ); #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( test_transparent_aead_set_lengths( + return( mbedtls_test_transparent_aead_set_lengths( operation, ad_length, plaintext_length ) ); /* Add cases for opaque driver here */ @@ -1463,14 +1465,15 @@ psa_status_t psa_driver_wrapper_aead_update_ad( { #if defined(MBEDTLS_PSA_BUILTIN_CIPHER) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_update_ad( operation, input, input_length ) ); + return( mbedtls_psa_aead_update_ad( operation, input, + input_length ) ); #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( test_transparent_aead_update_ad( + return( mbedtls_test_transparent_aead_update_ad( operation, input, input_length ) ); /* Add cases for opaque driver here */ @@ -1497,15 +1500,16 @@ psa_status_t psa_driver_wrapper_aead_update( { #if defined(MBEDTLS_PSA_BUILTIN_CIPHER) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_update( operation, input, input_length, output, - output_size, output_length ) ); + return( mbedtls_psa_aead_update( operation, input, input_length, + output, output_size, + output_length ) ); #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( test_transparent_aead_update( + return( mbedtls_test_transparent_aead_update( operation, input, input_length, output, output_size, output_length ) ); @@ -1537,15 +1541,17 @@ psa_status_t psa_driver_wrapper_aead_finish( { #if defined(MBEDTLS_PSA_BUILTIN_CIPHER) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_finish( operation, ciphertext, ciphertext_size, - ciphertext_length, tag, tag_size, tag_length ) ); + return( mbedtls_psa_aead_finish( operation, ciphertext, + ciphertext_size, + ciphertext_length, tag, + tag_size, tag_length ) ); #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( test_transparent_aead_finish( + return( mbedtls_test_transparent_aead_finish( operation, ciphertext, ciphertext_size, ciphertext_length, tag, tag_size, tag_length ) ); @@ -1577,15 +1583,16 @@ psa_status_t psa_driver_wrapper_aead_verify( { #if defined(MBEDTLS_PSA_BUILTIN_CIPHER) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_verify( operation, plaintext, plaintext_size, - plaintext_length, tag, tag_length ) ); + return( mbedtls_psa_aead_verify( operation, plaintext, + plaintext_size, plaintext_length, + tag, tag_length ) ); #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( test_transparent_aead_verify( + return( mbedtls_test_transparent_aead_verify( operation, plaintext, plaintext_size, plaintext_length, tag, tag_length ) ); @@ -1618,7 +1625,7 @@ psa_status_t psa_driver_wrapper_aead_abort( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( test_transparent_aead_abort( operation ) ); + return( mbedtls_test_transparent_aead_abort( operation ) ); /* Add cases for opaque driver here */ diff --git a/tests/include/test/drivers/aead.h b/tests/include/test/drivers/aead.h index 23f32c0a88..e1058af8b1 100644 --- a/tests/include/test/drivers/aead.h +++ b/tests/include/test/drivers/aead.h @@ -67,34 +67,34 @@ psa_status_t mbedtls_test_transparent_aead_decrypt( const uint8_t *ciphertext, size_t ciphertext_length, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ); -psa_status_t test_transparent_aead_encrypt_setup( +psa_status_t mbedtls_test_transparent_aead_encrypt_setup( psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ); -psa_status_t test_transparent_aead_decrypt_setup( +psa_status_t mbedtls_test_transparent_aead_decrypt_setup( psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ); -psa_status_t test_transparent_aead_set_nonce( +psa_status_t mbedtls_test_transparent_aead_set_nonce( psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length ); -psa_status_t test_transparent_aead_set_lengths( +psa_status_t mbedtls_test_transparent_aead_set_lengths( psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length ); -psa_status_t test_transparent_aead_update_ad( +psa_status_t mbedtls_test_transparent_aead_update_ad( psa_aead_operation_t *operation, const uint8_t *input, size_t input_length ); -psa_status_t test_transparent_aead_update( +psa_status_t mbedtls_test_transparent_aead_update( psa_aead_operation_t *operation, const uint8_t *input, size_t input_length, @@ -102,7 +102,7 @@ psa_status_t test_transparent_aead_update( size_t output_size, size_t *output_length ); -psa_status_t test_transparent_aead_finish( +psa_status_t mbedtls_test_transparent_aead_finish( psa_aead_operation_t *operation, uint8_t *ciphertext, size_t ciphertext_size, @@ -111,7 +111,7 @@ psa_status_t test_transparent_aead_finish( size_t tag_size, size_t *tag_length ); -psa_status_t test_transparent_aead_verify( +psa_status_t mbedtls_test_transparent_aead_verify( psa_aead_operation_t *operation, uint8_t *plaintext, size_t plaintext_size, @@ -119,7 +119,7 @@ psa_status_t test_transparent_aead_verify( const uint8_t *tag, size_t tag_length ); -psa_status_t test_transparent_aead_abort( +psa_status_t mbedtls_test_transparent_aead_abort( psa_aead_operation_t *operation ); #endif /* PSA_CRYPTO_DRIVER_TEST */ diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index 67118efcbe..34bbc51ab2 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -93,116 +93,117 @@ psa_status_t mbedtls_test_transparent_aead_decrypt( return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_encrypt_setup( +psa_status_t mbedtls_test_transparent_aead_encrypt_setup( psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.driver_status = mbedtls_psa_aead_encrypt_setup( operation, attributes, key_buffer, key_buffer_size, alg ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_decrypt_setup( +psa_status_t mbedtls_test_transparent_aead_decrypt_setup( psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.driver_status = mbedtls_psa_aead_decrypt_setup( operation, attributes, key_buffer, key_buffer_size, alg ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_set_nonce( +psa_status_t mbedtls_test_transparent_aead_set_nonce( psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.driver_status = mbedtls_psa_aead_set_nonce( operation, nonce, nonce_length ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_set_lengths( +psa_status_t mbedtls_test_transparent_aead_set_lengths( psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = - mbedtls_psa_aead_set_lengths( operation, ad_length, plaintext_length ); + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_set_lengths( operation, ad_length, + plaintext_length ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_update_ad( +psa_status_t mbedtls_test_transparent_aead_update_ad( psa_aead_operation_t *operation, const uint8_t *input, size_t input_length ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.driver_status = mbedtls_psa_aead_update_ad( operation, input, input_length ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_update( +psa_status_t mbedtls_test_transparent_aead_update( psa_aead_operation_t *operation, const uint8_t *input, size_t input_length, @@ -210,24 +211,24 @@ psa_status_t test_transparent_aead_update( size_t output_size, size_t *output_length ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.driver_status = mbedtls_psa_aead_update( operation, input, input_length, output, output_size, output_length ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_finish( +psa_status_t mbedtls_test_transparent_aead_finish( psa_aead_operation_t *operation, uint8_t *ciphertext, size_t ciphertext_size, @@ -236,24 +237,25 @@ psa_status_t test_transparent_aead_finish( size_t tag_size, size_t *tag_length ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.driver_status = mbedtls_psa_aead_finish( operation, ciphertext, ciphertext_size, - ciphertext_length, tag, tag_size, tag_length ); + ciphertext_length, tag, tag_size, + tag_length ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_verify( +psa_status_t mbedtls_test_transparent_aead_verify( psa_aead_operation_t *operation, uint8_t *plaintext, size_t plaintext_size, @@ -261,40 +263,40 @@ psa_status_t test_transparent_aead_verify( const uint8_t *tag, size_t tag_length ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.driver_status = mbedtls_psa_aead_verify( operation, plaintext, plaintext_size, plaintext_length, tag, tag_length ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } -psa_status_t test_transparent_aead_abort( +psa_status_t mbedtls_test_transparent_aead_abort( psa_aead_operation_t *operation ) { - test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits++; - if( test_driver_aead_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { - test_driver_aead_hooks.driver_status = - test_driver_aead_hooks.forced_status; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.forced_status; } else { - test_driver_aead_hooks.driver_status = + mbedtls_test_driver_aead_hooks.driver_status = mbedtls_psa_aead_abort( operation ); } - return( test_driver_aead_hooks.driver_status ); + return( mbedtls_test_driver_aead_hooks.driver_status ); } #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ From 2df40057b3ce3682a4ca36a4bff4c5bd3088091c Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 7 May 2021 17:52:18 +0100 Subject: [PATCH 021/966] Fix excessive line lengths Signed-off-by: Paul Elliott --- library/psa_crypto.c | 30 ++-- library/psa_crypto_aead.c | 147 +++++++++++-------- tests/suites/test_suite_psa_crypto.function | 150 +++++++++++++------- 3 files changed, 206 insertions(+), 121 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index a6d0cdb20e..4ab0c63b36 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3309,7 +3309,8 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type, operation->alg); + required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type, + operation->alg); if( nonce_size == 0 || nonce_size < required_nonce_size ) { @@ -3323,7 +3324,8 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, return status; } - status = psa_driver_wrapper_aead_set_nonce( operation, nonce, required_nonce_size ); + status = psa_driver_wrapper_aead_set_nonce( operation, nonce, + required_nonce_size ); if( status == PSA_SUCCESS ) { @@ -3345,7 +3347,8 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_set_nonce( operation, nonce, nonce_length ) ); + return( psa_driver_wrapper_aead_set_nonce( operation, nonce, + nonce_length ) ); } /* Declare the lengths of the message and additional data for multipart AEAD. */ @@ -3358,7 +3361,8 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_set_lengths( operation, ad_length, plaintext_length ) ); + return( psa_driver_wrapper_aead_set_lengths( operation, ad_length, + plaintext_length ) ); } /* Pass additional data to an active multipart AEAD operation. */ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, @@ -3370,7 +3374,8 @@ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_update_ad( operation, input, input_length ) ); + return( psa_driver_wrapper_aead_update_ad( operation, input, + input_length ) ); } /* Encrypt or decrypt a message fragment in an active multipart AEAD @@ -3390,7 +3395,8 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_update( operation, input, input_length, output, output_size, + return( psa_driver_wrapper_aead_update( operation, input, input_length, + output, output_size, output_length ) ); } @@ -3412,8 +3418,10 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_finish( operation, ciphertext, ciphertext_size, - ciphertext_length, tag, tag_size, tag_length ) ); + return( psa_driver_wrapper_aead_finish( operation, ciphertext, + ciphertext_size, + ciphertext_length, + tag, tag_size, tag_length ) ); } /* Finish authenticating and decrypting a message in a multipart AEAD @@ -3433,8 +3441,10 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_verify( operation, plaintext, plaintext_size, plaintext_length, - tag, tag_length ) ); + return( psa_driver_wrapper_aead_verify( operation, plaintext, + plaintext_size, + plaintext_length, + tag, tag_length ) ); } /* Abort an AEAD operation. */ diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index bfa271b5a1..f5b4dc512f 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -355,8 +355,10 @@ exit: /* Set the key and algorithm for a multipart authenticated encryption * operation. */ psa_status_t mbedtls_psa_aead_encrypt_setup( psa_aead_operation_t *operation, - const psa_key_attributes_t *attributes, - const uint8_t *key_buffer, size_t key_buffer_size, + const psa_key_attributes_t + *attributes, + const uint8_t *key_buffer, + size_t key_buffer_size, psa_algorithm_t alg ) { psa_status_t status; @@ -376,8 +378,10 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( psa_aead_operation_t *operation, /* Set the key and algorithm for a multipart authenticated decryption * operation. */ psa_status_t mbedtls_psa_aead_decrypt_setup( psa_aead_operation_t *operation, - const psa_key_attributes_t *attributes, - const uint8_t *key_buffer, size_t key_buffer_size, + const psa_key_attributes_t + *attributes, + const uint8_t *key_buffer, + size_t key_buffer_size, psa_algorithm_t alg ) { psa_status_t status; @@ -434,11 +438,12 @@ psa_status_t mbedtls_psa_aead_set_nonce( psa_aead_operation_t *operation, return( PSA_ERROR_INVALID_ARGUMENT ); } - status = mbedtls_to_psa_error(mbedtls_chachapoly_starts( &operation->ctx.chachapoly, - nonce, - operation->is_encrypt ? - MBEDTLS_CHACHAPOLY_ENCRYPT : - MBEDTLS_CHACHAPOLY_DECRYPT ) ); + status = mbedtls_to_psa_error( + mbedtls_chachapoly_starts( &operation->ctx.chachapoly, + nonce, + operation->is_encrypt ? + MBEDTLS_CHACHAPOLY_ENCRYPT : + MBEDTLS_CHACHAPOLY_DECRYPT ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ @@ -540,13 +545,14 @@ psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, return ( PSA_ERROR_INVALID_ARGUMENT ); } - status = mbedtls_to_psa_error( mbedtls_gcm_starts( &operation->ctx.gcm, - operation->is_encrypt ? - MBEDTLS_GCM_ENCRYPT : MBEDTLS_GCM_DECRYPT, - operation->nonce, - operation->nonce_length, - input, - input_length ) ); + status = mbedtls_to_psa_error( + mbedtls_gcm_starts( &operation->ctx.gcm, + operation->is_encrypt ? + MBEDTLS_GCM_ENCRYPT : MBEDTLS_GCM_DECRYPT, + operation->nonce, + operation->nonce_length, + input, + input_length ) ); } else @@ -581,9 +587,10 @@ psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { - status = mbedtls_to_psa_error( mbedtls_chachapoly_update_aad( &operation->ctx.chachapoly, - input, - input_length ) ); + status = mbedtls_to_psa_error( + mbedtls_chachapoly_update_aad( &operation->ctx.chachapoly, + input, + input_length ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ @@ -676,7 +683,8 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, } /* Need to store tag for Finish() / Verify() */ - operation->tag_buffer = ( uint8_t * ) mbedtls_calloc(1, operation->tag_length ); + operation->tag_buffer = + ( uint8_t * ) mbedtls_calloc(1, operation->tag_length ); if( operation->tag_buffer ) { @@ -685,16 +693,17 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, { /* Perform oneshot CCM encryption with additional data already stored, as CCM does not support multipart yet.*/ - status = mbedtls_to_psa_error( mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm, - input_length, - operation->nonce, - operation->nonce_length, - operation->ad_buffer, - operation->ad_length, - input, - output, - operation->tag_buffer, - operation->tag_length ) ); + status = mbedtls_to_psa_error( + mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm, + input_length, + operation->nonce, + operation->nonce_length, + operation->ad_buffer, + operation->ad_length, + input, + output, + operation->tag_buffer, + operation->tag_length ) ); /* Even if the above operation fails, we no longer need the additional data.*/ @@ -706,18 +715,22 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, { /* Need to back up the body data so we can do this again later.*/ - operation->body_buffer = ( uint8_t * ) mbedtls_calloc(1, input_length ); + operation->body_buffer = + ( uint8_t * ) mbedtls_calloc(1, input_length ); if( operation->body_buffer ) { memcpy( operation->body_buffer, input, input_length ); operation->body_length = input_length; - /* this will fail, as the tag is clearly false, but will write the - decrypted data to the output buffer. */ - ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, input_length, - operation->nonce, operation->nonce_length, - operation->ad_buffer, operation->ad_length, + /* this will fail, as the tag is clearly false, but will + write the decrypted data to the output buffer.*/ + ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, + input_length, + operation->nonce, + operation->nonce_length, + operation->ad_buffer, + operation->ad_length, input, output, operation->tag_buffer, operation->tag_length ); @@ -747,10 +760,11 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { - status = mbedtls_to_psa_error( mbedtls_chachapoly_update( &operation->ctx.chachapoly, - input_length, - input, - output ) ); + status = mbedtls_to_psa_error( + mbedtls_chachapoly_update( &operation->ctx.chachapoly, + input_length, + input, + output ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ @@ -772,7 +786,8 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, /* Common checks for both mbedtls_psa_aead_finish() and mbedtls_psa_aead_verify() */ -static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t *operation, +static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t + *operation, size_t output_size, size_t tag_size ) { @@ -793,13 +808,15 @@ static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t *operat if( operation->is_encrypt ) { - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, - operation->alg ); + finish_output_size = + PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, + operation->alg ); } else { - finish_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, - operation->alg ); + finish_output_size = + PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, + operation->alg ); } if( output_size < finish_output_size ) @@ -822,7 +839,8 @@ psa_status_t mbedtls_psa_aead_finish( psa_aead_operation_t *operation, psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; size_t finish_output_size = 0; - status = mbedtls_psa_aead_finish_checks( operation, ciphertext_size, tag_size ); + status = mbedtls_psa_aead_finish_checks( operation, ciphertext_size, + tag_size ); if( status != PSA_SUCCESS ) { @@ -855,8 +873,9 @@ psa_status_t mbedtls_psa_aead_finish( psa_aead_operation_t *operation, #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { - status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly, - tag ) ); + status = mbedtls_to_psa_error( + mbedtls_chachapoly_finish( &operation->ctx.chachapoly, + tag ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ @@ -902,7 +921,8 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, int do_tag_check = 1; uint8_t check_tag[16]; - status = mbedtls_psa_aead_finish_checks( operation, plaintext_size, tag_length ); + status = mbedtls_psa_aead_finish_checks( operation, plaintext_size, + tag_length ); if( status != PSA_SUCCESS ) { @@ -913,9 +933,10 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, if( operation->alg == PSA_ALG_GCM ) { /* Call finish to get the tag for comparison */ - status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, - check_tag, - operation->tag_length ) ); + status = mbedtls_to_psa_error( + mbedtls_gcm_finish( &operation->ctx.gcm, + check_tag, + operation->tag_length ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ @@ -931,17 +952,22 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, * only way to get the tag, but this time throw away the results, as verify cannot write that much data. */ temp_buffer_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type, - operation->alg, operation->body_length ); + operation->alg, + operation->body_length + ); temp_buffer = ( uint8_t * ) mbedtls_calloc(1, temp_buffer_size ); if( temp_buffer ) { - ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, operation->body_length, - operation->nonce, operation->nonce_length, - operation->ad_buffer, operation->ad_length, - operation->body_buffer, temp_buffer, - tag, tag_length ); + ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, + operation->body_length, + operation->nonce, + operation->nonce_length, + operation->ad_buffer, + operation->ad_length, + operation->body_buffer, + temp_buffer, tag, tag_length ); if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) { @@ -974,8 +1000,9 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { // call finish to get the tag for comparison. - status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly, - check_tag ) ); + status = mbedtls_to_psa_error( + mbedtls_chachapoly_finish( &operation->ctx.chachapoly, + check_tag ) ); } else diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 6ae5030ee1..04d947f375 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3201,7 +3201,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, TEST_ASSERT( tag_length <= 16 ); output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( input_data->len + tag_length ) ); + ( input_data->len + + tag_length ) ); ASSERT_ALLOC( output_data, output_size ); @@ -3224,8 +3225,9 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, if( nonce->len == 0 ) { - PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ), - &nonce_length ) ); + PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, + sizeof( nonce_buffer ), + &nonce_length ) ); } else { @@ -3236,7 +3238,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation.alg == PSA_ALG_GCM ) { - PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, input_data->len ) ); + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); } #endif @@ -3256,7 +3259,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, part_length = ad_part_len; } - PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x + part_offset, + PSA_ASSERT( psa_aead_update_ad( &operation, + additional_data->x + part_offset, part_length ) ); part_offset += part_length; @@ -3265,13 +3269,15 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, else { /* Pass additional data in one go. */ - PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, additional_data->len) ); + PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, + additional_data->len) ); } if( data_part_len != -1 ) { /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len ); + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( size_t ) data_part_len ); ASSERT_ALLOC( part_data, part_data_size ); @@ -3288,13 +3294,16 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, part_length = data_part_len; } - PSA_ASSERT( psa_aead_update( &operation, ( input_data->x + part_offset ), + PSA_ASSERT( psa_aead_update( &operation, + ( input_data->x + part_offset ), part_length, part_data, - part_data_size, &output_part_length ) ); + part_data_size, + &output_part_length ) ); if( output_data && output_part_length ) { - memcpy( ( output_data + part_offset ), part_data, output_part_length ); + memcpy( ( output_data + part_offset ), part_data, + output_part_length ); } part_offset += part_length; @@ -3317,7 +3326,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, if( output_data && output_part_length ) { - memcpy( ( output_data + output_length ), final_data, output_part_length ); + memcpy( ( output_data + output_length ), final_data, + output_part_length ); } TEST_EQUAL(tag_length, tag_size); @@ -3334,7 +3344,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE * should be exact. */ TEST_EQUAL( output_length, - PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) ); + PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, + input_data->len ) ); TEST_ASSERT( output_length <= PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); @@ -3389,7 +3400,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_crypto_init( ) ); - psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); + psa_set_key_usage_flags( &attributes, + PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); psa_set_key_algorithm( &attributes, alg ); psa_set_key_type( &attributes, key_type ); @@ -3429,7 +3441,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, if( nonce->len == 0 ) { - status = psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ), + status = psa_aead_generate_nonce( &operation, nonce_buffer, + sizeof( nonce_buffer ), &nonce_length ); } else @@ -3447,7 +3460,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation.alg == PSA_ALG_GCM ) { - status = psa_aead_set_lengths( &operation, additional_data->len, input_data->len ); + status = psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ); if( status != PSA_SUCCESS ) { @@ -3472,7 +3486,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, part_length = ad_part_len; } - status = psa_aead_update_ad( &operation, additional_data->x + part_offset, + status = psa_aead_update_ad( &operation, + additional_data->x + part_offset, part_length ); if( status != PSA_SUCCESS ) @@ -3486,7 +3501,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, } else { - status = psa_aead_update_ad(&operation, additional_data->x, additional_data->len); + status = psa_aead_update_ad(&operation, additional_data->x, + additional_data->len); if( status != PSA_SUCCESS ) { @@ -3499,7 +3515,7 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, { /* Pass data in parts */ part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); + ( size_t ) data_part_len ); ASSERT_ALLOC( part_data, part_data_size ); @@ -3516,7 +3532,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, part_length = data_part_len; } - status = psa_aead_update( &operation, ( input_data->x + part_offset ), + status = psa_aead_update( &operation, + ( input_data->x + part_offset ), part_length, part_data, part_data_size, &output_part_length ); @@ -3528,7 +3545,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, if( output_data && output_part_length ) { - memcpy( ( output_data + part_offset ), part_data, output_part_length ); + memcpy( ( output_data + part_offset ), part_data, + output_part_length ); } part_offset += part_length; @@ -3562,7 +3580,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, if( output_data &&output_part_length ) { - memcpy( ( output_data + output_length ), final_data, output_part_length ); + memcpy( ( output_data + output_length ), final_data, + output_part_length ); } output_length += output_part_length; @@ -3571,23 +3590,27 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, * should be exact. */ if( expected_result != PSA_ERROR_INVALID_ARGUMENT ) TEST_EQUAL( ( output_length + tag_length ), - PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) ); + PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, + input_data->len ) ); TEST_EQUAL(tag_length, tag_size); if( PSA_SUCCESS == expected_result ) { - output_size2 = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, output_length ); + output_size2 = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + output_length ); ASSERT_ALLOC( output_data2, output_size2 ); /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE * should be exact. */ TEST_EQUAL( input_data->len, PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, - ( output_length + tag_length ) ) ); + ( output_length + + tag_length ) ) ); TEST_ASSERT( input_data->len <= - PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length + tag_length ) ); + PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length + + tag_length ) ); operation = psa_aead_operation_init(); @@ -3599,7 +3622,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, if( status == PSA_ERROR_NOT_SUPPORTED ) { MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, + nonce->len ); } TEST_EQUAL( status, expected_result ); @@ -3607,7 +3631,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, if( nonce->len == 0 ) { /* Use previously generated nonce. */ - status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_length ); + status = psa_aead_set_nonce( &operation, nonce_buffer, + nonce_length ); } else { @@ -3623,7 +3648,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation.alg == PSA_ALG_GCM ) { - status = psa_aead_set_lengths( &operation, additional_data->len, output_length ); + status = psa_aead_set_lengths( &operation, additional_data->len, + output_length ); if( status != PSA_SUCCESS ) { @@ -3638,7 +3664,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, while( part_offset <= additional_data->len) { - if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + if( additional_data->len - part_offset < + ( uint32_t ) ad_part_len ) { part_length = additional_data->len - part_offset; } @@ -3647,7 +3674,9 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, part_length = ad_part_len; } - PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x + part_offset, + PSA_ASSERT( psa_aead_update_ad( &operation, + additional_data->x + + part_offset, part_length ) ); part_offset += part_length; @@ -3655,13 +3684,15 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, } else { - PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, additional_data->len) ); + PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, + additional_data->len) ); } if( data_part_len != -1 ) { /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len ); + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( size_t ) data_part_len ); ASSERT_ALLOC( part_data, part_data_size ); @@ -3669,22 +3700,27 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, while( part_offset <= ( input_data->len - tag_length ) ) { - if( ( input_data->len - tag_length - part_offset ) < ( uint32_t ) data_part_len ) + if( ( input_data->len - tag_length - part_offset ) < + ( uint32_t ) data_part_len ) { - part_length = ( input_data->len - tag_length - part_offset ); + part_length = + ( input_data->len - tag_length - part_offset ); } else { part_length = data_part_len; } - PSA_ASSERT( psa_aead_update( &operation, ( input_data->x + part_offset ), + PSA_ASSERT( psa_aead_update( &operation, + ( input_data->x + part_offset ), part_length, part_data, - part_data_size, &output_part_length ) ); + part_data_size, + &output_part_length ) ); if( output_data2 && output_part_length ) { - memcpy( ( output_data2 + part_offset ), part_data, output_part_length ); + memcpy( ( output_data2 + part_offset ), + part_data, output_part_length ); } part_offset += part_length; @@ -3705,7 +3741,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, if( output_data2 && output_part_length ) { - memcpy( ( output_data2 + output_length2 ), final_data, output_part_length); + memcpy( ( output_data2 + output_length2 ), final_data, + output_part_length); } output_length2 += output_part_length; @@ -3772,7 +3809,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( input_data->len - tag_length ) ); + ( input_data->len - + tag_length ) ); ASSERT_ALLOC( output_data, output_size ); ASSERT_ALLOC( final_data, PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); @@ -3798,7 +3836,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, if( nonce->len == 0 ) { - status = psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ), + status = psa_aead_generate_nonce( &operation, nonce_buffer, + sizeof( nonce_buffer ), &nonce_length ); } else @@ -3842,7 +3881,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, part_length = ad_part_len; } - status = psa_aead_update_ad( &operation, additional_data->x + part_offset, + status = psa_aead_update_ad( &operation, + additional_data->x + part_offset, part_length ); if( status != PSA_SUCCESS ) @@ -3856,7 +3896,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, } else { - status = psa_aead_update_ad( &operation, additional_data->x, additional_data->len ); + status = psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ); if( status != PSA_SUCCESS ) { @@ -3868,7 +3909,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, if( data_part_len != -1 ) { /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len ); + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( size_t ) data_part_len ); ASSERT_ALLOC( part_data, part_data_size ); @@ -3876,7 +3918,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, while( part_offset <= input_data->len) { - if( (input_data->len - tag_length - part_offset ) < ( uint32_t ) data_part_len ) + if( (input_data->len - tag_length - part_offset ) < + ( uint32_t ) data_part_len ) { part_length = ( input_data->len - tag_length - part_offset ); } @@ -3885,9 +3928,10 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, part_length = data_part_len; } - status = psa_aead_update( &operation, ( input_data->x + part_offset ), - part_length, part_data, - part_data_size, &output_part_length ); + status = psa_aead_update( &operation, + ( input_data->x + part_offset ), + part_length, part_data, + part_data_size, &output_part_length ); if( status != PSA_SUCCESS ) { @@ -3897,7 +3941,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, if( output_data && output_part_length ) { - memcpy( ( output_data + part_offset ), part_data, output_part_length ); + memcpy( ( output_data + part_offset ), part_data, + output_part_length ); } part_offset += part_length; @@ -3920,7 +3965,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, status = psa_aead_verify( &operation, final_data, PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE, &output_part_length, - ( input_data->x + input_data->len - tag_length ), + ( input_data->x + input_data->len - + tag_length ), tag_length ); if( status != PSA_SUCCESS ) @@ -3931,7 +3977,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, if( output_data && output_part_length ) { - memcpy( ( output_data + output_length ), final_data, output_part_length ); + memcpy( ( output_data + output_length ), final_data, + output_part_length ); } output_length += output_part_length; @@ -3941,7 +3988,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE * should be exact. */ TEST_EQUAL( output_length, - PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) ); + PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, + input_data->len ) ); TEST_ASSERT( output_length <= PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); } From cbbde5f28c4241ef7b002b23b0979b35703f7606 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 10 May 2021 18:19:46 +0100 Subject: [PATCH 022/966] Split multipart AEAD contexts into two parts Split to data required for internal implementation and data required for driver implementation with data left over for the PSA layer. Signed-off-by: Paul Elliott --- include/psa/crypto_builtin_primitives.h | 59 ++++++++ .../psa/crypto_driver_contexts_primitives.h | 8 + include/psa/crypto_struct.h | 43 +----- library/psa_crypto.c | 100 +++++++++++-- library/psa_crypto_aead.c | 54 ++++--- library/psa_crypto_aead.h | 138 ++++++++++-------- library/psa_crypto_driver_wrappers.c | 84 ++++++----- tests/src/drivers/test_driver_aead.c | 18 +-- 8 files changed, 321 insertions(+), 183 deletions(-) diff --git a/include/psa/crypto_builtin_primitives.h b/include/psa/crypto_builtin_primitives.h index 75801a1789..e3903bca50 100644 --- a/include/psa/crypto_builtin_primitives.h +++ b/include/psa/crypto_builtin_primitives.h @@ -118,6 +118,62 @@ typedef struct { #define MBEDTLS_PSA_CIPHER_OPERATION_INIT {0, 0, 0, {0}} +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) || \ + defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) || \ + defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) +#define MBEDTLS_PSA_BUILTIN_AEAD 1 +#endif + +/* Context structure for the Mbed TLS cipher implementation. */ +typedef struct +{ + psa_algorithm_t alg; + psa_key_type_t key_type; + + unsigned int lengths_set : 1; + unsigned int is_encrypt : 1; + unsigned int ad_started : 1; + unsigned int body_started : 1; + + uint8_t tag_length; + uint8_t nonce_length; + + size_t ad_remaining; + size_t body_remaining; + + /* Buffers for AD/data - only required until CCM gets proper multipart + support. */ + uint8_t *ad_buffer; + size_t ad_length; + + uint8_t *body_buffer; + size_t body_length; + + uint8_t *tag_buffer; + + /* buffer to store Nonce - only required until CCM and GCM get proper + multipart support. */ + uint8_t nonce[PSA_AEAD_NONCE_MAX_SIZE]; + + union + { + unsigned dummy; /* Enable easier initializing of the union. */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + mbedtls_ccm_context ccm; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + mbedtls_gcm_context gcm; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + mbedtls_chachapoly_context chachapoly; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + + } ctx; + +} mbedtls_psa_aead_operation_t; + +#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} + /* * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY. */ @@ -130,6 +186,9 @@ typedef mbedtls_psa_hash_operation_t mbedtls_transparent_test_driver_hash_operat typedef mbedtls_psa_cipher_operation_t mbedtls_transparent_test_driver_cipher_operation_t; +typedef mbedtls_psa_aead_operation_t + mbedtls_transparent_test_driver_aead_operation_t; + typedef struct { unsigned int initialised : 1; mbedtls_transparent_test_driver_cipher_operation_t ctx; diff --git a/include/psa/crypto_driver_contexts_primitives.h b/include/psa/crypto_driver_contexts_primitives.h index 104d4bdb6d..4fba9eb030 100644 --- a/include/psa/crypto_driver_contexts_primitives.h +++ b/include/psa/crypto_driver_contexts_primitives.h @@ -65,5 +65,13 @@ typedef union { #endif } psa_driver_cipher_context_t; +typedef union { + unsigned dummy; /* Make sure this union is always non-empty */ + mbedtls_psa_aead_operation_t mbedtls_ctx; +#if defined(PSA_CRYPTO_DRIVER_TEST) + mbedtls_transparent_test_driver_aead_operation_t transparent_test_driver_ctx; +#endif +} psa_driver_aead_context_t; + #endif /* PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H */ /* End of automatically generated file. */ diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 6c5639d1c8..6bb6f421b3 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -153,8 +153,6 @@ static inline struct psa_mac_operation_s psa_mac_operation_init( void ) struct psa_aead_operation_s { - psa_algorithm_t alg; - psa_key_type_t key_type; /** Unique ID indicating which driver got assigned to do the * operation. Since driver contexts are driver-specific, swapping @@ -164,50 +162,19 @@ struct psa_aead_operation_s * any driver (i.e. none of the driver contexts are active). */ unsigned int id; + psa_algorithm_t alg; + psa_key_type_t key_type; + unsigned int key_set : 1; unsigned int nonce_set : 1; unsigned int lengths_set : 1; - unsigned int is_encrypt : 1; unsigned int ad_started : 1; unsigned int body_started : 1; - uint8_t tag_length; - uint8_t nonce_length; - - size_t ad_remaining; - size_t body_remaining; - - /* Buffers for AD/data - only required until CCM gets proper multipart - support. */ - uint8_t *ad_buffer; - size_t ad_length; - - uint8_t *body_buffer; - size_t body_length; - - uint8_t *tag_buffer; - - /* buffer to store Nonce - only required until CCM and GCM get proper - multipart support. */ - uint8_t nonce[PSA_AEAD_NONCE_MAX_SIZE]; - - union - { - unsigned dummy; /* Enable easier initializing of the union. */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - mbedtls_ccm_context ccm; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - mbedtls_gcm_context gcm; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - mbedtls_chachapoly_context chachapoly; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ - - } ctx; + psa_driver_aead_context_t ctx; }; -#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} +#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, {0}} static inline struct psa_aead_operation_s psa_aead_operation_init( void ) { const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT; diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 4ab0c63b36..7190aa4da2 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3214,6 +3214,25 @@ psa_status_t psa_aead_decrypt( mbedtls_svc_key_id_t key, return( status ); } +/* Helper function to get the base algorithm from its variants. */ +static psa_algorithm_t psa_aead_get_base_algorithm(psa_algorithm_t alg) +{ + switch( PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, 0 ) ) + { + case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 0 ): + return( PSA_ALG_CCM ); + + case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ): + return( PSA_ALG_GCM ); + + case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CHACHA20_POLY1305, 0 ): + return( PSA_ALG_CHACHA20_POLY1305 ); + + default: + return( PSA_ERROR_NOT_SUPPORTED ); + } +} + /* Set the key for a multipart authenticated encryption operation. */ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, @@ -3226,6 +3245,12 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) return( PSA_ERROR_NOT_SUPPORTED ); + if( operation->key_set || operation->nonce_set || + operation->ad_started || operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + status = psa_get_and_lock_key_slot_with_policy( key, &slot, PSA_KEY_USAGE_ENCRYPT, alg ); @@ -3242,6 +3267,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, &attributes, slot->key.data, slot->key.bytes, alg ); + operation->key_type = psa_get_key_type( &attributes ); unlock_status = psa_unlock_key_slot( slot ); @@ -3250,6 +3276,12 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, return( unlock_status ); } + if( status == PSA_SUCCESS ) + { + operation->alg = psa_aead_get_base_algorithm( alg ); + operation->key_set = 1; + } + return( status ); } @@ -3265,6 +3297,12 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) return( PSA_ERROR_NOT_SUPPORTED ); + if( operation->key_set || operation->nonce_set || + operation->ad_started || operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + status = psa_get_and_lock_key_slot_with_policy( key, &slot, PSA_KEY_USAGE_DECRYPT, alg ); @@ -3281,6 +3319,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, &attributes, slot->key.data, slot->key.bytes, alg ); + operation->key_type = psa_get_key_type( &attributes ); unlock_status = psa_unlock_key_slot( slot ); @@ -3289,6 +3328,12 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, return( unlock_status ); } + if( status == PSA_SUCCESS ) + { + operation->alg = psa_aead_get_base_algorithm( alg ); + operation->key_set = 1; + } + return( status ); } @@ -3341,14 +3386,23 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length ) { + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + if( !operation->key_set || operation->nonce_set || operation->ad_started || operation->body_started ) { return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_set_nonce( operation, nonce, - nonce_length ) ); + status = psa_driver_wrapper_aead_set_nonce( operation, nonce, + nonce_length ); + + if( status == PSA_SUCCESS ) + { + operation->nonce_set = 1; + } + + return( status ); } /* Declare the lengths of the message and additional data for multipart AEAD. */ @@ -3356,26 +3410,44 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length ) { + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + if( !operation->key_set || operation->lengths_set ) { return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_set_lengths( operation, ad_length, - plaintext_length ) ); + status = psa_driver_wrapper_aead_set_lengths( operation, ad_length, + plaintext_length ); + + if( status == PSA_SUCCESS ) + { + operation->lengths_set = 1; + } + + return status; } /* Pass additional data to an active multipart AEAD operation. */ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, const uint8_t *input, size_t input_length ) { + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + if( !operation->nonce_set || !operation->key_set ) { return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_update_ad( operation, input, - input_length ) ); + status = psa_driver_wrapper_aead_update_ad( operation, input, + input_length ); + + if( status == PSA_SUCCESS ) + { + operation->ad_started = 1; + } + + return status; } /* Encrypt or decrypt a message fragment in an active multipart AEAD @@ -3387,6 +3459,7 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, size_t output_size, size_t *output_length ) { + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; *output_length = 0; @@ -3395,9 +3468,16 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, return( PSA_ERROR_BAD_STATE ); } - return( psa_driver_wrapper_aead_update( operation, input, input_length, - output, output_size, - output_length ) ); + status = psa_driver_wrapper_aead_update( operation, input, input_length, + output, output_size, + output_length ); + + if( status == PSA_SUCCESS ) + { + operation->body_started = 1; + } + + return status; } /* Finish encrypting a message in a multipart AEAD operation. */ @@ -3422,6 +3502,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, ciphertext_size, ciphertext_length, tag, tag_size, tag_length ) ); + } /* Finish authenticating and decrypting a message in a multipart AEAD @@ -3466,7 +3547,6 @@ psa_status_t psa_aead_abort(psa_aead_operation_t *operation) operation->key_set = 0; operation->nonce_set = 0; operation->lengths_set = 0; - operation->is_encrypt = 0; operation->ad_started = 0; operation->body_started = 0; diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index f5b4dc512f..8f8b74e7e4 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -20,7 +20,6 @@ #include "common.h" - #if defined(MBEDTLS_PSA_CRYPTO_C) #include "psa_crypto_aead.h" @@ -55,7 +54,7 @@ static inline int safer_memcmp( const uint8_t *a, const uint8_t *b, size_t n ) static psa_status_t psa_aead_setup( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, psa_algorithm_t alg ) @@ -66,12 +65,6 @@ static psa_status_t psa_aead_setup( mbedtls_cipher_id_t cipher_id; size_t full_tag_length = 0; - if( operation->key_set || operation->nonce_set || - operation->ad_started || operation->body_started ) - { - return( PSA_ERROR_BAD_STATE ); - } - key_bits = attributes->core.bits; cipher_info = mbedtls_cipher_info_from_psa( alg, @@ -146,12 +139,12 @@ static psa_status_t psa_aead_setup( > full_tag_length ) return( PSA_ERROR_INVALID_ARGUMENT ); - operation->tag_length = PSA_AEAD_TAG_LENGTH( attributes->core.type, + operation->key_type = psa_get_key_type( attributes ); + + operation->tag_length = PSA_AEAD_TAG_LENGTH( operation->key_type, key_bits, alg ); - operation->key_set = 1; - return( PSA_SUCCESS ); } @@ -165,7 +158,7 @@ psa_status_t mbedtls_psa_aead_encrypt( uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; + mbedtls_psa_aead_operation_t operation = MBEDTLS_PSA_AEAD_OPERATION_INIT; uint8_t *tag; (void) key_buffer_size; @@ -275,7 +268,7 @@ psa_status_t mbedtls_psa_aead_decrypt( uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; + mbedtls_psa_aead_operation_t operation = MBEDTLS_PSA_AEAD_OPERATION_INIT; const uint8_t *tag = NULL; (void) key_buffer_size; @@ -354,7 +347,8 @@ exit: /* Set the key and algorithm for a multipart authenticated encryption * operation. */ -psa_status_t mbedtls_psa_aead_encrypt_setup( psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_encrypt_setup( mbedtls_psa_aead_operation_t + *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, @@ -377,7 +371,8 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( psa_aead_operation_t *operation, /* Set the key and algorithm for a multipart authenticated decryption * operation. */ -psa_status_t mbedtls_psa_aead_decrypt_setup( psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_decrypt_setup( mbedtls_psa_aead_operation_t + *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, @@ -399,7 +394,8 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( psa_aead_operation_t *operation, } /* Set a nonce for the multipart AEAD operation*/ -psa_status_t mbedtls_psa_aead_set_nonce( psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_set_nonce( mbedtls_psa_aead_operation_t + *operation, const uint8_t *nonce, size_t nonce_length ) { @@ -454,15 +450,11 @@ psa_status_t mbedtls_psa_aead_set_nonce( psa_aead_operation_t *operation, return ( PSA_ERROR_NOT_SUPPORTED ); } - if( status == PSA_SUCCESS ) - { - operation->nonce_set = 1; - } - return( status ); } /* Declare the lengths of the message and additional data for AEAD. */ -psa_status_t mbedtls_psa_aead_set_lengths( psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_set_lengths( mbedtls_psa_aead_operation_t + *operation, size_t ad_length, size_t plaintext_length ) { @@ -512,7 +504,8 @@ psa_status_t mbedtls_psa_aead_set_lengths( psa_aead_operation_t *operation, } /* Pass additional data to an active multipart AEAD operation. */ -psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t + *operation, const uint8_t *input, size_t input_length ) { @@ -611,7 +604,7 @@ psa_status_t mbedtls_psa_aead_update_ad( psa_aead_operation_t *operation, /* Encrypt or decrypt a message fragment in an active multipart AEAD * operation.*/ -psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, @@ -786,7 +779,7 @@ psa_status_t mbedtls_psa_aead_update( psa_aead_operation_t *operation, /* Common checks for both mbedtls_psa_aead_finish() and mbedtls_psa_aead_verify() */ -static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t +static psa_status_t mbedtls_psa_aead_finish_checks( mbedtls_psa_aead_operation_t *operation, size_t output_size, size_t tag_size ) @@ -828,7 +821,7 @@ static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t } /* Finish encrypting a message in a multipart AEAD operation. */ -psa_status_t mbedtls_psa_aead_finish( psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length, @@ -903,7 +896,7 @@ psa_status_t mbedtls_psa_aead_finish( psa_aead_operation_t *operation, /* Finish authenticating and decrypting a message in a multipart AEAD * operation.*/ -psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length, @@ -1033,7 +1026,7 @@ psa_status_t mbedtls_psa_aead_verify( psa_aead_operation_t *operation, } /* Abort an AEAD operation */ -psa_status_t mbedtls_psa_aead_abort( psa_aead_operation_t *operation ) +psa_status_t mbedtls_psa_aead_abort( mbedtls_psa_aead_operation_t *operation ) { switch( operation->alg ) { @@ -1054,6 +1047,11 @@ psa_status_t mbedtls_psa_aead_abort( psa_aead_operation_t *operation ) #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ } + operation->lengths_set = 0; + operation->is_encrypt = 0; + operation->ad_started = 0; + operation->body_started = 0; + mbedtls_free(operation->ad_buffer); operation->ad_buffer = NULL; operation->ad_length = 0; diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index a9d268773e..4b6d6cd1ba 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -160,37 +160,39 @@ psa_status_t mbedtls_psa_aead_decrypt( * -# Allocate an operation object which will be passed to all the functions * listed here. * -# Initialize the operation object with one of the methods described in the - * documentation for #psa_aead_operation_t, e.g. - * #PSA_AEAD_OPERATION_INIT. + * documentation for #mbedtls_psa_aead_operation_t, e.g. + * #MBEDTLS_PSA_AEAD_OPERATION_INIT. * -# Call mbedtls_psa_aead_encrypt_setup() to specify the algorithm and key. * -# If needed, call mbedtls_psa_aead_set_lengths() to specify the length of * the inputs to the subsequent calls to mbedtls_psa_aead_update_ad() and - * mbedtls_psa_aead_update(). See the documentation of mbedtls_psa_aead_set_lengths() - * for details. + * mbedtls_psa_aead_update(). See the documentation of + * mbedtls_psa_aead_set_lengths() for details. * -# Call either psa_aead_generate_nonce() or * mbedtls_psa_aead_set_nonce() to generate or set the nonce. You should use * psa_aead_generate_nonce() unless the protocol you are implementing * requires a specific nonce value. - * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing a fragment - * of the non-encrypted additional authenticated data each time. + * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing + * a fragment of the non-encrypted additional authenticated data each time. * -# Call mbedtls_psa_aead_update() zero, one or more times, passing a fragment * of the message to encrypt each time. * -# Call mbedtls_psa_aead_finish(). * - * If an error occurs at any step after a call to mbedtls_psa_aead_encrypt_setup(), - * the operation will need to be reset by a call to mbedtls_psa_aead_abort(). The - * application may call mbedtls_psa_aead_abort() at any time after the operation - * has been initialized. + * If an error occurs at any step after a call to + * mbedtls_psa_aead_encrypt_setup(), the operation will need to be reset by a + * call to mbedtls_psa_aead_abort(). The application may call + * mbedtls_psa_aead_abort() at any time after the operation has been + * initialized. * - * After a successful call to mbedtls_psa_aead_encrypt_setup(), the application must - * eventually terminate the operation. The following events terminate an + * After a successful call to mbedtls_psa_aead_encrypt_setup(), the application + * must eventually terminate the operation. The following events terminate an * operation: * - A successful call to mbedtls_psa_aead_finish(). * - A call to mbedtls_psa_aead_abort(). * * \param[in,out] operation The operation object to set up. It must have * been initialized as per the documentation for - * #mbedtls_psa_aead_operation_t and not yet in use. + * #mbedtls_psa_aead_operation_t and not yet in + * use. * \param[in] attributes The attributes of the key to use for the * operation. * \param[in] key_buffer The buffer containing the key context. @@ -219,9 +221,12 @@ psa_status_t mbedtls_psa_aead_decrypt( * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_encrypt_setup(psa_aead_operation_t *operation, - const psa_key_attributes_t *attributes, - const uint8_t *key_buffer, size_t key_buffer_size, +psa_status_t mbedtls_psa_aead_encrypt_setup(mbedtls_psa_aead_operation_t + *operation, + const psa_key_attributes_t + *attributes, + const uint8_t *key_buffer, + size_t key_buffer_size, psa_algorithm_t alg); /** Set the key for a multipart authenticated decryption operation. @@ -236,34 +241,36 @@ psa_status_t mbedtls_psa_aead_encrypt_setup(psa_aead_operation_t *operation, * -# Allocate an operation object which will be passed to all the functions * listed here. * -# Initialize the operation object with one of the methods described in the - * documentation for #psa_aead_operation_t, e.g. + * documentation for #mbedtls_psa_aead_operation_t, e.g. * #PSA_AEAD_OPERATION_INIT. * -# Call mbedtls_psa_aead_decrypt_setup() to specify the algorithm and key. - * -# If needed, call mbedtls_psa_aead_set_lengths() to specify the length of the - * inputs to the subsequent calls to mbedtls_psa_aead_update_ad() and - * mbedtls_psa_aead_update(). See the documentation of mbedtls_psa_aead_set_lengths() - * for details. + * -# If needed, call mbedtls_psa_aead_set_lengths() to specify the length of + * the inputs to the subsequent calls to mbedtls_psa_aead_update_ad() and + * mbedtls_psa_aead_update(). See the documentation of + * mbedtls_psa_aead_set_lengths() for details. * -# Call mbedtls_psa_aead_set_nonce() with the nonce for the decryption. - * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing a fragment - * of the non-encrypted additional authenticated data each time. + * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing a + * fragment of the non-encrypted additional authenticated data each time. * -# Call mbedtls_psa_aead_update() zero, one or more times, passing a fragment * of the ciphertext to decrypt each time. * -# Call mbedtls_psa_aead_verify(). * - * If an error occurs at any step after a call to mbedtls_psa_aead_decrypt_setup(), - * the operation will need to be reset by a call to mbedtls_psa_aead_abort(). The - * application may call mbedtls_psa_aead_abort() at any time after the operation - * has been initialized. + * If an error occurs at any step after a call to + * mbedtls_psa_aead_decrypt_setup(), the operation will need to be reset by a + * call to mbedtls_psa_aead_abort(). The application may call + * mbedtls_psa_aead_abort() at any time after the operation has been + * initialized. * - * After a successful call to mbedtls_psa_aead_decrypt_setup(), the application must - * eventually terminate the operation. The following events terminate an + * After a successful call to mbedtls_psa_aead_decrypt_setup(), the application + * must eventually terminate the operation. The following events terminate an * operation: * - A successful call to mbedtls_psa_aead_verify(). * - A call to mbedtls_psa_aead_abort(). * * \param[in,out] operation The operation object to set up. It must have * been initialized as per the documentation for - * #psa_aead_operation_t and not yet in use. + * #mbedtls_psa_aead_operation_t and not yet in + * use. * \param[in] attributes The attributes of the key to use for the * operation. * \param[in] key_buffer The buffer containing the key context. @@ -292,9 +299,12 @@ psa_status_t mbedtls_psa_aead_encrypt_setup(psa_aead_operation_t *operation, * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_decrypt_setup(psa_aead_operation_t *operation, - const psa_key_attributes_t *attributes, - const uint8_t *key_buffer, size_t key_buffer_size, +psa_status_t mbedtls_psa_aead_decrypt_setup(mbedtls_psa_aead_operation_t + *operation, + const psa_key_attributes_t + *attributes, + const uint8_t *key_buffer, + size_t key_buffer_size, psa_algorithm_t alg); /** Set the nonce for an authenticated encryption or decryption operation. @@ -313,9 +323,9 @@ psa_status_t mbedtls_psa_aead_decrypt_setup(psa_aead_operation_t *operation, * If this function returns an error status, the operation enters an error * state and must be aborted by calling mbedtls_psa_aead_abort(). * - * \note When encrypting, applications should use mbedtls_psa_aead_generate_nonce() - * instead of this function, unless implementing a protocol that requires - * a non-random IV. + * \note When encrypting, applications should use + * mbedtls_psa_aead_generate_nonce() instead of this function, unless + * implementing a protocol that requires a non-random IV. * * \param[in,out] operation Active AEAD operation. * \param[in] nonce Buffer containing the nonce to use. @@ -338,7 +348,7 @@ psa_status_t mbedtls_psa_aead_decrypt_setup(psa_aead_operation_t *operation, * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_set_nonce(psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_set_nonce(mbedtls_psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length); @@ -350,10 +360,10 @@ psa_status_t mbedtls_psa_aead_set_nonce(psa_aead_operation_t *operation, * specification for transparent drivers. * * The application must call this function before calling - * mbedtls_psa_aead_update_ad() or mbedtls_psa_aead_update() if the algorithm for - * the operation requires it. If the algorithm does not require it, - * calling this function is optional, but if this function is called - * then the implementation must enforce the lengths. + * mbedtls_psa_aead_update_ad() or mbedtls_psa_aead_update() if the algorithm + * for the operation requires it. If the algorithm does not require it, calling + * this function is optional, but if this function is called then the + * implementation must enforce the lengths. * * You may call this function before or after setting the nonce with * mbedtls_psa_aead_set_nonce() or psa_aead_generate_nonce(). @@ -375,8 +385,8 @@ psa_status_t mbedtls_psa_aead_set_nonce(psa_aead_operation_t *operation, * Success. * \retval #PSA_ERROR_BAD_STATE * The operation state is not valid (it must be active, and - * mbedtls_psa_aead_update_ad() and mbedtls_psa_aead_update() must not have been - * called yet). + * mbedtls_psa_aead_update_ad() and mbedtls_psa_aead_update() must not + * have been called yet). * \retval #PSA_ERROR_INVALID_ARGUMENT * At least one of the lengths is not acceptable for the chosen * algorithm. @@ -389,7 +399,8 @@ psa_status_t mbedtls_psa_aead_set_nonce(psa_aead_operation_t *operation, * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_set_lengths(psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t + *operation, size_t ad_length, size_t plaintext_length); @@ -407,18 +418,19 @@ psa_status_t mbedtls_psa_aead_set_lengths(psa_aead_operation_t *operation, * data to encrypt or decrypt with mbedtls_psa_aead_update(). * * Before calling this function, you must: - * 1. Call either mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup(). - * 2. Set the nonce with psa_aead_generate_nonce() or - * mbedtls_psa_aead_set_nonce(). + * 1. Call either mbedtls_psa_aead_encrypt_setup() or + * mbedtls_psa_aead_decrypt_setup(). 2. Set the nonce with + * psa_aead_generate_nonce() or mbedtls_psa_aead_set_nonce(). * * If this function returns an error status, the operation enters an error * state and must be aborted by calling mbedtls_psa_aead_abort(). * - * \warning When decrypting, until mbedtls_psa_aead_verify() has returned #PSA_SUCCESS, - * there is no guarantee that the input is valid. Therefore, until - * you have called mbedtls_psa_aead_verify() and it has returned #PSA_SUCCESS, - * treat the input as untrusted and prepare to undo any action that - * depends on the input if mbedtls_psa_aead_verify() returns an error status. + * \warning When decrypting, until mbedtls_psa_aead_verify() has returned + * #PSA_SUCCESS, there is no guarantee that the input is valid. + * Therefore, until you have called mbedtls_psa_aead_verify() and it + * has returned #PSA_SUCCESS, treat the input as untrusted and prepare + * to undo any action that depends on the input if + * mbedtls_psa_aead_verify() returns an error status. * * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire * additional data to be passed in in one go, i.e. only call @@ -448,7 +460,7 @@ psa_status_t mbedtls_psa_aead_set_lengths(psa_aead_operation_t *operation, * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_update_ad(psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, const uint8_t *input, size_t input_length); @@ -460,9 +472,9 @@ psa_status_t mbedtls_psa_aead_update_ad(psa_aead_operation_t *operation, * transparent drivers. * * Before calling this function, you must: - * 1. Call either mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup(). - * The choice of setup function determines whether this function - * encrypts or decrypts its input. + * 1. Call either mbedtls_psa_aead_encrypt_setup() or + * mbedtls_psa_aead_decrypt_setup(). The choice of setup function determines + * whether this function encrypts or decrypts its input. * 2. Set the nonce with psa_aead_generate_nonce() or * mbedtls_psa_aead_set_nonce(). 3. Call mbedtls_psa_aead_update_ad() to pass * all the additional data. @@ -537,7 +549,7 @@ psa_status_t mbedtls_psa_aead_update_ad(psa_aead_operation_t *operation, * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_update(psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, @@ -618,7 +630,7 @@ psa_status_t mbedtls_psa_aead_update(psa_aead_operation_t *operation, * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_finish(psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length, @@ -703,7 +715,7 @@ psa_status_t mbedtls_psa_aead_finish(psa_aead_operation_t *operation, * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_verify(psa_aead_operation_t *operation, +psa_status_t mbedtls_psa_aead_verify(mbedtls_psa_aead_operation_t *operation, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length, @@ -723,11 +735,11 @@ psa_status_t mbedtls_psa_aead_verify(psa_aead_operation_t *operation, * mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup() again. * * You may call this function any time after the operation object has - * been initialized as described in #psa_aead_operation_t. + * been initialized as described in #mbedtls_psa_aead_operation_t. * * In particular, calling mbedtls_psa_aead_abort() after the operation has been - * terminated by a call to mbedtls_psa_aead_abort(), mbedtls_psa_aead_finish() or - * mbedtls_psa_aead_verify() is safe and has no effect. + * terminated by a call to mbedtls_psa_aead_abort(), mbedtls_psa_aead_finish() + * or mbedtls_psa_aead_verify() is safe and has no effect. * * \param[in,out] operation Initialized AEAD operation. * @@ -740,7 +752,7 @@ psa_status_t mbedtls_psa_aead_verify(psa_aead_operation_t *operation, * It is implementation-dependent whether a failure to initialize * results in this error code. */ -psa_status_t mbedtls_psa_aead_abort(psa_aead_operation_t *operation); +psa_status_t mbedtls_psa_aead_abort(mbedtls_psa_aead_operation_t *operation); #endif /* PSA_CRYPTO_AEAD */ diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 7faedb30e3..7590800e26 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1310,10 +1310,9 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) - status = PSA_ERROR_NOT_SUPPORTED; status = mbedtls_test_transparent_aead_encrypt_setup( - operation, attributes, - key_buffer, key_buffer_size, + &operation->ctx.transparent_test_driver_ctx, + attributes, key_buffer, key_buffer_size, alg ); /* Declared with fallback == true */ operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; @@ -1325,7 +1324,7 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( /* Fell through, meaning no accelerator supports this operation */ status = mbedtls_psa_aead_encrypt_setup( - operation, attributes, + &operation->ctx.mbedtls_ctx, attributes, key_buffer, key_buffer_size, alg ); @@ -1360,9 +1359,9 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) - status = PSA_ERROR_NOT_SUPPORTED; status = mbedtls_test_transparent_aead_decrypt_setup( - operation, attributes, + &operation->ctx.transparent_test_driver_ctx, + attributes, key_buffer, key_buffer_size, alg ); /* Declared with fallback == true */ @@ -1375,7 +1374,8 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( /* Fell through, meaning no accelerator supports this operation */ status = mbedtls_psa_aead_decrypt_setup( - operation, attributes, + &operation->ctx.mbedtls_ctx, + attributes, key_buffer, key_buffer_size, alg ); @@ -1401,16 +1401,18 @@ psa_status_t psa_driver_wrapper_aead_set_nonce( { #if defined(MBEDTLS_PSA_BUILTIN_CIPHER) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_set_nonce( operation, nonce, + return( mbedtls_psa_aead_set_nonce( &operation->ctx.mbedtls_ctx, + nonce, nonce_length ) ); -#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ +#endif /* MBEDTLS_PSA_BUILTIN_AEAD */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( mbedtls_test_transparent_aead_set_nonce( - operation, nonce, nonce_length ) ); + &operation->ctx.transparent_test_driver_ctx, + nonce, nonce_length ) ); /* Add cases for opaque driver here */ @@ -1431,18 +1433,20 @@ psa_status_t psa_driver_wrapper_aead_set_lengths( { switch( operation->id ) { -#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) +#if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_set_lengths( operation, ad_length, + return( mbedtls_psa_aead_set_lengths( &operation->ctx.mbedtls_ctx, + ad_length, plaintext_length ) ); -#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ +#endif /* MBEDTLS_PSA_BUILTIN_AEAD */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( mbedtls_test_transparent_aead_set_lengths( - operation, ad_length, plaintext_length ) ); + &operation->ctx.transparent_test_driver_ctx, + ad_length, plaintext_length ) ); /* Add cases for opaque driver here */ @@ -1463,18 +1467,20 @@ psa_status_t psa_driver_wrapper_aead_update_ad( { switch( operation->id ) { -#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) +#if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_update_ad( operation, input, + return( mbedtls_psa_aead_update_ad( &operation->ctx.mbedtls_ctx, + input, input_length ) ); -#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ +#endif /* MBEDTLS_PSA_BUILTIN_AEAD */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( mbedtls_test_transparent_aead_update_ad( - operation, input, input_length ) ); + &operation->ctx.transparent_test_driver_ctx, + input, input_length ) ); /* Add cases for opaque driver here */ @@ -1498,19 +1504,21 @@ psa_status_t psa_driver_wrapper_aead_update( { switch( operation->id ) { -#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) +#if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_update( operation, input, input_length, + return( mbedtls_psa_aead_update( &operation->ctx.mbedtls_ctx, + input, input_length, output, output_size, output_length ) ); -#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ +#endif /* MBEDTLS_PSA_BUILTIN_AEAD */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( mbedtls_test_transparent_aead_update( - operation, input, input_length, output, output_size, + &operation->ctx.transparent_test_driver_ctx, + input, input_length, output, output_size, output_length ) ); /* Add cases for opaque driver here */ @@ -1539,20 +1547,22 @@ psa_status_t psa_driver_wrapper_aead_finish( { switch( operation->id ) { -#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) +#if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_finish( operation, ciphertext, + return( mbedtls_psa_aead_finish( &operation->ctx.mbedtls_ctx, + ciphertext, ciphertext_size, ciphertext_length, tag, tag_size, tag_length ) ); -#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ +#endif /* MBEDTLS_PSA_BUILTIN_AEAD */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( mbedtls_test_transparent_aead_finish( - operation, ciphertext, ciphertext_size, + &operation->ctx.transparent_test_driver_ctx, + ciphertext, ciphertext_size, ciphertext_length, tag, tag_size, tag_length ) ); /* Add cases for opaque driver here */ @@ -1581,19 +1591,22 @@ psa_status_t psa_driver_wrapper_aead_verify( { switch( operation->id ) { -#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) +#if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_verify( operation, plaintext, - plaintext_size, plaintext_length, + return( mbedtls_psa_aead_verify( &operation->ctx.mbedtls_ctx, + plaintext, + plaintext_size, + plaintext_length, tag, tag_length ) ); -#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ +#endif /* MBEDTLS_PSA_BUILTIN_AEAD */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: return( mbedtls_test_transparent_aead_verify( - operation, plaintext, plaintext_size, + &operation->ctx.transparent_test_driver_ctx, + plaintext, plaintext_size, plaintext_length, tag, tag_length ) ); /* Add cases for opaque driver here */ @@ -1616,16 +1629,17 @@ psa_status_t psa_driver_wrapper_aead_abort( { switch( operation->id ) { -#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) +#if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_abort( operation ) ); + return( mbedtls_psa_aead_abort( &operation->ctx.mbedtls_ctx ) ); -#endif /* MBEDTLS_PSA_BUILTIN_CIPHER */ +#endif /* MBEDTLS_PSA_BUILTIN_AEAD */ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID: - return( mbedtls_test_transparent_aead_abort( operation ) ); + return( mbedtls_test_transparent_aead_abort( + &operation->ctx.transparent_test_driver_ctx ) ); /* Add cases for opaque driver here */ diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index 34bbc51ab2..006d3327f5 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -94,7 +94,7 @@ psa_status_t mbedtls_test_transparent_aead_decrypt( } psa_status_t mbedtls_test_transparent_aead_encrypt_setup( - psa_aead_operation_t *operation, + mbedtls_transparent_test_driver_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ) @@ -117,7 +117,7 @@ psa_status_t mbedtls_test_transparent_aead_encrypt_setup( } psa_status_t mbedtls_test_transparent_aead_decrypt_setup( - psa_aead_operation_t *operation, + mbedtls_transparent_test_driver_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ) @@ -140,7 +140,7 @@ psa_status_t mbedtls_test_transparent_aead_decrypt_setup( } psa_status_t mbedtls_test_transparent_aead_set_nonce( - psa_aead_operation_t *operation, + mbedtls_transparent_test_driver_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length ) { @@ -161,7 +161,7 @@ psa_status_t mbedtls_test_transparent_aead_set_nonce( } psa_status_t mbedtls_test_transparent_aead_set_lengths( - psa_aead_operation_t *operation, + mbedtls_transparent_test_driver_aead_operation_t *operation, size_t ad_length, size_t plaintext_length ) { @@ -183,7 +183,7 @@ psa_status_t mbedtls_test_transparent_aead_set_lengths( } psa_status_t mbedtls_test_transparent_aead_update_ad( - psa_aead_operation_t *operation, + mbedtls_transparent_test_driver_aead_operation_t *operation, const uint8_t *input, size_t input_length ) { @@ -204,7 +204,7 @@ psa_status_t mbedtls_test_transparent_aead_update_ad( } psa_status_t mbedtls_test_transparent_aead_update( - psa_aead_operation_t *operation, + mbedtls_transparent_test_driver_aead_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, @@ -229,7 +229,7 @@ psa_status_t mbedtls_test_transparent_aead_update( } psa_status_t mbedtls_test_transparent_aead_finish( - psa_aead_operation_t *operation, + mbedtls_transparent_test_driver_aead_operation_t *operation, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length, @@ -256,7 +256,7 @@ psa_status_t mbedtls_test_transparent_aead_finish( } psa_status_t mbedtls_test_transparent_aead_verify( - psa_aead_operation_t *operation, + mbedtls_transparent_test_driver_aead_operation_t *operation, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length, @@ -281,7 +281,7 @@ psa_status_t mbedtls_test_transparent_aead_verify( } psa_status_t mbedtls_test_transparent_aead_abort( - psa_aead_operation_t *operation ) + mbedtls_transparent_test_driver_aead_operation_t *operation ) { mbedtls_test_driver_aead_hooks.hits++; From 7f0a1801078665462ba7fe13f6c6724c1f34741b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 11 May 2021 17:43:42 +0100 Subject: [PATCH 023/966] Fix missed drivers header Signed-off-by: Paul Elliott --- tests/include/test/drivers/aead.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/include/test/drivers/aead.h b/tests/include/test/drivers/aead.h index e1058af8b1..86c18d4d3a 100644 --- a/tests/include/test/drivers/aead.h +++ b/tests/include/test/drivers/aead.h @@ -68,34 +68,34 @@ psa_status_t mbedtls_test_transparent_aead_decrypt( uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ); psa_status_t mbedtls_test_transparent_aead_encrypt_setup( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ); psa_status_t mbedtls_test_transparent_aead_decrypt_setup( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ); psa_status_t mbedtls_test_transparent_aead_set_nonce( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length ); psa_status_t mbedtls_test_transparent_aead_set_lengths( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length ); psa_status_t mbedtls_test_transparent_aead_update_ad( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, const uint8_t *input, size_t input_length ); psa_status_t mbedtls_test_transparent_aead_update( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, @@ -103,7 +103,7 @@ psa_status_t mbedtls_test_transparent_aead_update( size_t *output_length ); psa_status_t mbedtls_test_transparent_aead_finish( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length, @@ -112,7 +112,7 @@ psa_status_t mbedtls_test_transparent_aead_finish( size_t *tag_length ); psa_status_t mbedtls_test_transparent_aead_verify( - psa_aead_operation_t *operation, + mbedtls_psa_aead_operation_t *operation, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length, @@ -120,7 +120,7 @@ psa_status_t mbedtls_test_transparent_aead_verify( size_t tag_length ); psa_status_t mbedtls_test_transparent_aead_abort( - psa_aead_operation_t *operation ); + mbedtls_psa_aead_operation_t *operation ); #endif /* PSA_CRYPTO_DRIVER_TEST */ #endif /* PSA_CRYPTO_TEST_DRIVERS_AEAD_H */ From 6edb7473db1e4c1ee9a8da405c25ea0c3841e06c Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 10 May 2021 19:29:35 +0100 Subject: [PATCH 024/966] Move safer_memcmp to psa_crypto_core.h Same change as made by Steven Cooreman, although not yet merged. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 8f8b74e7e4..ac4297ed40 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -38,21 +38,6 @@ #include "mbedtls/gcm.h" #include "mbedtls/error.h" -/* Constant-time buffer comparison. This is duplication of code from - * psa_crypto.c, but has nowhere private I can put it for the minute. Really - belongs in the constant time module, when that gets implemented */ -static inline int safer_memcmp( const uint8_t *a, const uint8_t *b, size_t n ) -{ - size_t i; - unsigned char diff = 0; - - for( i = 0; i < n; i++ ) - diff |= a[i] ^ b[i]; - - return( diff ); -} - - static psa_status_t psa_aead_setup( mbedtls_psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, @@ -1014,7 +999,8 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, { *plaintext_length = finish_output_size; - if( do_tag_check && safer_memcmp(tag, check_tag, tag_length) != 0 ) + if( do_tag_check && + mbedtls_psa_safer_memcmp(tag, check_tag, tag_length) != 0 ) { status = PSA_ERROR_INVALID_SIGNATURE; } From ef29e17a94b9cd0c4b6c48ada1a3e21766c9ab9b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 10 May 2021 19:33:03 +0100 Subject: [PATCH 025/966] Add comment to non-obvious code guard Ad and body lengths can only be too big on builds where size_t is bigger than 32 bits. This checking code therefore generates always true comparison warnings on 32 bit platforms, and thus had to be guarded. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index ac4297ed40..29dbedeb7b 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -447,6 +447,9 @@ psa_status_t mbedtls_psa_aead_set_lengths( mbedtls_psa_aead_operation_t #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { + /* Lengths can only be too large for GCM if size_t is bigger than 32 + * bits. Without the guard this code will generate warnings on 32bit + builds */ #if SIZE_MAX > UINT32_MAX if( ( (uint64_t) ad_length ) >> 61 != 0 || ( (uint64_t) plaintext_length ) > 0xFFFFFFFE0ull ) From 39dc6b8aa58b00b93683c975427914185ea4a67e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 11 May 2021 19:16:09 +0100 Subject: [PATCH 026/966] Add abort call to all failure points Signed-off-by: Paul Elliott --- library/psa_crypto.c | 156 ++++++++++++++++++++++++++++--------------- 1 file changed, 102 insertions(+), 54 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 7190aa4da2..ee7ac90caa 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3243,12 +3243,16 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, psa_key_slot_t *slot; if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) - return( PSA_ERROR_NOT_SUPPORTED ); + { + status = PSA_ERROR_NOT_SUPPORTED; + goto exit; + } if( operation->key_set || operation->nonce_set || operation->ad_started || operation->body_started ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } status = psa_get_and_lock_key_slot_with_policy( @@ -3256,7 +3260,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, if( status != PSA_SUCCESS ) { - return( status ); + goto exit; } psa_key_attributes_t attributes = { @@ -3267,20 +3271,29 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, &attributes, slot->key.data, slot->key.bytes, alg ); + if( status != PSA_SUCCESS ) + { + goto exit; + } + operation->key_type = psa_get_key_type( &attributes ); unlock_status = psa_unlock_key_slot( slot ); if( unlock_status != PSA_SUCCESS ) { - return( unlock_status ); + status = unlock_status; } +exit: + if( status == PSA_SUCCESS ) { operation->alg = psa_aead_get_base_algorithm( alg ); operation->key_set = 1; } + else + psa_aead_abort( operation ); return( status ); } @@ -3295,21 +3308,23 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, psa_key_slot_t *slot; if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) - return( PSA_ERROR_NOT_SUPPORTED ); + { + status = PSA_ERROR_NOT_SUPPORTED; + goto exit; + } if( operation->key_set || operation->nonce_set || operation->ad_started || operation->body_started ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } status = psa_get_and_lock_key_slot_with_policy( key, &slot, PSA_KEY_USAGE_DECRYPT, alg ); if( status != PSA_SUCCESS ) - { - return( status ); - } + goto exit; psa_key_attributes_t attributes = { .core = slot->attr @@ -3324,15 +3339,17 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, unlock_status = psa_unlock_key_slot( slot ); if( unlock_status != PSA_SUCCESS ) - { - return( unlock_status ); - } + status = unlock_status; + +exit: if( status == PSA_SUCCESS ) { operation->alg = psa_aead_get_base_algorithm( alg ); operation->key_set = 1; } + else + psa_aead_abort( operation ); return( status ); } @@ -3351,33 +3368,35 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, if( !operation->key_set || operation->nonce_set || operation->ad_started || operation->body_started ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type, operation->alg); - if( nonce_size == 0 || nonce_size < required_nonce_size ) + if( nonce_size < required_nonce_size ) { - return( PSA_ERROR_BUFFER_TOO_SMALL ); + status = PSA_ERROR_BUFFER_TOO_SMALL; + goto exit; } status = psa_generate_random( nonce, required_nonce_size ); if( status != PSA_SUCCESS ) - { - return status; - } + goto exit; status = psa_driver_wrapper_aead_set_nonce( operation, nonce, required_nonce_size ); - if( status == PSA_SUCCESS ) - { - *nonce_length = required_nonce_size; - } +exit: - return status; + if( status == PSA_SUCCESS ) + *nonce_length = required_nonce_size; + else + psa_aead_abort( operation ); + + return( status ); } /* Set the nonce for a multipart authenticated encryption or decryption @@ -3391,16 +3410,19 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, if( !operation->key_set || operation->nonce_set || operation->ad_started || operation->body_started ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } status = psa_driver_wrapper_aead_set_nonce( operation, nonce, nonce_length ); +exit: + if( status == PSA_SUCCESS ) - { operation->nonce_set = 1; - } + else + psa_aead_abort( operation ); return( status ); } @@ -3414,18 +3436,21 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, if( !operation->key_set || operation->lengths_set ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } status = psa_driver_wrapper_aead_set_lengths( operation, ad_length, plaintext_length ); - if( status == PSA_SUCCESS ) - { - operation->lengths_set = 1; - } +exit: - return status; + if( status == PSA_SUCCESS ) + operation->lengths_set = 1; + else + psa_aead_abort( operation ); + + return( status ); } /* Pass additional data to an active multipart AEAD operation. */ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, @@ -3436,18 +3461,21 @@ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, if( !operation->nonce_set || !operation->key_set ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } status = psa_driver_wrapper_aead_update_ad( operation, input, input_length ); - if( status == PSA_SUCCESS ) - { - operation->ad_started = 1; - } +exit: - return status; + if( status == PSA_SUCCESS ) + operation->ad_started = 1; + else + psa_aead_abort( operation ); + + return( status ); } /* Encrypt or decrypt a message fragment in an active multipart AEAD @@ -3465,19 +3493,22 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, if( !operation->nonce_set || !operation->key_set || !operation->ad_started ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } status = psa_driver_wrapper_aead_update( operation, input, input_length, output, output_size, output_length ); - if( status == PSA_SUCCESS ) - { - operation->body_started = 1; - } +exit: - return status; + if( status == PSA_SUCCESS ) + operation->body_started = 1; + else + psa_aead_abort( operation ); + + return( status ); } /* Finish encrypting a message in a multipart AEAD operation. */ @@ -3489,20 +3520,28 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, size_t tag_size, size_t *tag_length ) { + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + *ciphertext_length = 0; *tag_length = 0; if( !operation->key_set || !operation->nonce_set || !operation->ad_started || !operation->body_started ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } - return( psa_driver_wrapper_aead_finish( operation, ciphertext, - ciphertext_size, - ciphertext_length, - tag, tag_size, tag_length ) ); + status = psa_driver_wrapper_aead_finish( operation, ciphertext, + ciphertext_size, + ciphertext_length, + tag, tag_size, tag_length ); +exit: + + psa_aead_abort( operation ); + + return( status ); } /* Finish authenticating and decrypting a message in a multipart AEAD @@ -3514,18 +3553,27 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, const uint8_t *tag, size_t tag_length ) { + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + *plaintext_length = 0; if( !operation->key_set || !operation->nonce_set || !operation->ad_started || !operation->body_started ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } - return( psa_driver_wrapper_aead_verify( operation, plaintext, - plaintext_size, - plaintext_length, - tag, tag_length ) ); + status = psa_driver_wrapper_aead_verify( operation, plaintext, + plaintext_size, + plaintext_length, + tag, tag_length ); + +exit: + + psa_aead_abort( operation ); + + return( status ); } /* Abort an AEAD operation. */ From 81231f33f0bd31c3c8d962d54cef82a1571bd46e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 11 May 2021 19:18:28 +0100 Subject: [PATCH 027/966] Return invalid argument for unsupported algorithm Signed-off-by: Paul Elliott --- library/psa_crypto.c | 4 ++-- tests/suites/test_suite_psa_crypto.data | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ee7ac90caa..4a83b09c92 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3244,7 +3244,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) { - status = PSA_ERROR_NOT_SUPPORTED; + status = PSA_ERROR_INVALID_ARGUMENT; goto exit; } @@ -3309,7 +3309,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) { - status = PSA_ERROR_NOT_SUPPORTED; + status = PSA_ERROR_INVALID_ARGUMENT; goto exit; } diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 8a85edd10c..177d688e3e 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2432,11 +2432,11 @@ aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f90 PSA Multipart AEAD encrypt/decrypt: invalid algorithm (CTR) depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":-1:"":-1:PSA_ERROR_NOT_SUPPORTED +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":-1:"":-1:PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD encrypt/decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":-1:"":-1:PSA_ERROR_NOT_SUPPORTED +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":-1:"":-1:PSA_ERROR_INVALID_ARGUMENT PSA signature size: RSA keypair, 1024 bits, PKCS#1 v1.5 raw depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR From bbe90b5f7f6776d878c1dfd3694cd430152a0140 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 11 May 2021 22:22:42 +0100 Subject: [PATCH 028/966] Formatting fixes for psa_crypto.c Signed-off-by: Paul Elliott --- library/psa_crypto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 4a83b09c92..81673c40fb 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3372,8 +3372,8 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, goto exit; } - required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type, - operation->alg); + required_nonce_size = PSA_AEAD_NONCE_LENGTH( operation->key_type, + operation->alg ); if( nonce_size < required_nonce_size ) { @@ -3577,7 +3577,7 @@ exit: } /* Abort an AEAD operation. */ -psa_status_t psa_aead_abort(psa_aead_operation_t *operation) +psa_status_t psa_aead_abort( psa_aead_operation_t *operation ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; From a559b3ce5642480cb0433d54a7fed339de7814a6 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 12 May 2021 12:12:07 +0100 Subject: [PATCH 029/966] Remove key_set and use id instead In keeping with the other PSA multipart operations. Signed-off-by: Paul Elliott --- include/psa/crypto_struct.h | 3 +-- library/psa_crypto.c | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 6bb6f421b3..36503f91cf 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -165,7 +165,6 @@ struct psa_aead_operation_s psa_algorithm_t alg; psa_key_type_t key_type; - unsigned int key_set : 1; unsigned int nonce_set : 1; unsigned int lengths_set : 1; unsigned int ad_started : 1; @@ -174,7 +173,7 @@ struct psa_aead_operation_s psa_driver_aead_context_t ctx; }; -#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, {0}} +#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, {0}} static inline struct psa_aead_operation_s psa_aead_operation_init( void ) { const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT; diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 81673c40fb..527e44e766 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3248,7 +3248,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, goto exit; } - if( operation->key_set || operation->nonce_set || + if( operation->id || operation->nonce_set || operation->ad_started || operation->body_started ) { status = PSA_ERROR_BAD_STATE; @@ -3288,10 +3288,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, exit: if( status == PSA_SUCCESS ) - { operation->alg = psa_aead_get_base_algorithm( alg ); - operation->key_set = 1; - } else psa_aead_abort( operation ); @@ -3313,7 +3310,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, goto exit; } - if( operation->key_set || operation->nonce_set || + if( operation->id || operation->nonce_set || operation->ad_started || operation->body_started ) { status = PSA_ERROR_BAD_STATE; @@ -3344,10 +3341,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, exit: if( status == PSA_SUCCESS ) - { operation->alg = psa_aead_get_base_algorithm( alg ); - operation->key_set = 1; - } else psa_aead_abort( operation ); @@ -3365,7 +3359,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, *nonce_length = 0; - if( !operation->key_set || operation->nonce_set || + if( !operation->id || operation->nonce_set || operation->ad_started || operation->body_started ) { status = PSA_ERROR_BAD_STATE; @@ -3407,7 +3401,7 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( !operation->key_set || operation->nonce_set || + if( !operation->id || operation->nonce_set || operation->ad_started || operation->body_started ) { status = PSA_ERROR_BAD_STATE; @@ -3434,7 +3428,7 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( !operation->key_set || operation->lengths_set ) + if( !operation->id || operation->lengths_set ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3459,7 +3453,7 @@ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( !operation->nonce_set || !operation->key_set ) + if( !operation->id || !operation->nonce_set ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3491,7 +3485,7 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, *output_length = 0; - if( !operation->nonce_set || !operation->key_set || !operation->ad_started ) + if( !operation->id || !operation->nonce_set || !operation->ad_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3525,7 +3519,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, *ciphertext_length = 0; *tag_length = 0; - if( !operation->key_set || !operation->nonce_set || + if( !operation->id || !operation->nonce_set || !operation->ad_started || !operation->body_started ) { status = PSA_ERROR_BAD_STATE; @@ -3557,7 +3551,7 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, *plaintext_length = 0; - if( !operation->key_set || !operation->nonce_set || + if( !operation->id || !operation->nonce_set || !operation->ad_started || !operation->body_started ) { status = PSA_ERROR_BAD_STATE; @@ -3592,7 +3586,6 @@ psa_status_t psa_aead_abort( psa_aead_operation_t *operation ) status = psa_driver_wrapper_aead_abort( operation ); operation->id = 0; - operation->key_set = 0; operation->nonce_set = 0; operation->lengths_set = 0; operation->ad_started = 0; From cc3585973910c4318b690f372fcd220823d41c73 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 12 May 2021 12:22:28 +0100 Subject: [PATCH 030/966] Pass key buffer size into psa_aead_setup Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 29dbedeb7b..37a4545b6e 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -42,6 +42,7 @@ static psa_status_t psa_aead_setup( mbedtls_psa_aead_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, + size_t key_buffer_size, psa_algorithm_t alg ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; @@ -50,6 +51,8 @@ static psa_status_t psa_aead_setup( mbedtls_cipher_id_t cipher_id; size_t full_tag_length = 0; + ( void ) key_buffer_size; + key_bits = attributes->core.bits; cipher_info = mbedtls_cipher_info_from_psa( alg, @@ -145,9 +148,10 @@ psa_status_t mbedtls_psa_aead_encrypt( psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; mbedtls_psa_aead_operation_t operation = MBEDTLS_PSA_AEAD_OPERATION_INIT; uint8_t *tag; - (void) key_buffer_size; - status = psa_aead_setup( &operation, attributes, key_buffer, alg ); + status = psa_aead_setup( &operation, attributes, key_buffer, + key_buffer_size, alg ); + if( status != PSA_SUCCESS ) goto exit; @@ -255,9 +259,10 @@ psa_status_t mbedtls_psa_aead_decrypt( psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; mbedtls_psa_aead_operation_t operation = MBEDTLS_PSA_AEAD_OPERATION_INIT; const uint8_t *tag = NULL; - (void) key_buffer_size; - status = psa_aead_setup( &operation, attributes, key_buffer, alg ); + status = psa_aead_setup( &operation, attributes, key_buffer, + key_buffer_size, alg ); + if( status != PSA_SUCCESS ) goto exit; @@ -342,9 +347,8 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( mbedtls_psa_aead_operation_t { psa_status_t status; - (void) key_buffer_size; - - status = psa_aead_setup( operation, attributes, key_buffer, alg ); + status = psa_aead_setup( operation, attributes, key_buffer, + key_buffer_size, alg ); if( status == PSA_SUCCESS ) { @@ -368,7 +372,8 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( mbedtls_psa_aead_operation_t (void) key_buffer_size; - status = psa_aead_setup( operation, attributes, key_buffer, alg ); + status = psa_aead_setup( operation, attributes, key_buffer, + key_buffer_size, alg ); if( status == PSA_SUCCESS ) { @@ -448,8 +453,8 @@ psa_status_t mbedtls_psa_aead_set_lengths( mbedtls_psa_aead_operation_t if( operation->alg == PSA_ALG_GCM ) { /* Lengths can only be too large for GCM if size_t is bigger than 32 - * bits. Without the guard this code will generate warnings on 32bit - builds */ + * bits. Without th + e guard this code will generate warnings on 32bit builds*/ #if SIZE_MAX > UINT32_MAX if( ( (uint64_t) ad_length ) >> 61 != 0 || ( (uint64_t) plaintext_length ) > 0xFFFFFFFE0ull ) From 80acb7ee21c58df798b21dd03e3ee679f1f0c027 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 12 May 2021 12:41:33 +0100 Subject: [PATCH 031/966] Formatting fixups and spelling mistake fixes Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 98 +++++---------------------------------- 1 file changed, 11 insertions(+), 87 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 37a4545b6e..b694bfd9e6 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -351,9 +351,7 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( mbedtls_psa_aead_operation_t key_buffer_size, alg ); if( status == PSA_SUCCESS ) - { operation->is_encrypt = 1; - } return ( status ); } @@ -376,9 +374,7 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( mbedtls_psa_aead_operation_t key_buffer_size, alg ); if( status == PSA_SUCCESS ) - { operation->is_encrypt = 0; - } return ( status ); } @@ -408,7 +404,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( mbedtls_psa_aead_operation_t { /* Multipart CCM not supported as yet, so CCM is basically operating in oneshot mode. Store the nonce as we need this later */ - memcpy(operation->nonce, nonce, nonce_length); + memcpy( operation->nonce, nonce, nonce_length ); /* We know that nonce size cannot exceed the uint8_t size */ operation->nonce_length = ( uint8_t ) nonce_length; @@ -469,9 +465,7 @@ psa_status_t mbedtls_psa_aead_set_lengths( mbedtls_psa_aead_operation_t if( operation->alg == PSA_ALG_CCM ) { if( ad_length > 0xFF00 ) - { return ( PSA_ERROR_INVALID_ARGUMENT ); - } } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -507,9 +501,7 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t if( operation->lengths_set ) { if ( operation->ad_remaining < input_length ) - { return( PSA_ERROR_INVALID_ARGUMENT ); - } operation->ad_remaining -= input_length; } @@ -518,18 +510,14 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t if( operation->alg == PSA_ALG_GCM ) { if( !operation->lengths_set || operation->ad_started ) - { return( PSA_ERROR_BAD_STATE ); - } /* GCM currently requires all the additional data to be passed in in - * one contigious buffer, so until that is re-done, we have to enforce + * one contiguous buffer, so until that is re-done, we have to enforce * this, as we cannot allocate a buffer to collate multiple calls into. */ if( operation->ad_remaining != 0 ) - { return ( PSA_ERROR_INVALID_ARGUMENT ); - } status = mbedtls_to_psa_error( mbedtls_gcm_starts( &operation->ctx.gcm, @@ -549,9 +537,7 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t /* CCM requires all additional data to be passed in in one go at the minute, as we are basically operating in oneshot mode. */ if( operation->ad_started ) - { return( PSA_ERROR_BAD_STATE ); - } /* Save the additional data for later, this will be passed in when we have the body. */ @@ -564,9 +550,7 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t status = PSA_SUCCESS; } else - { return ( PSA_ERROR_INSUFFICIENT_MEMORY ); - } } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -588,9 +572,7 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t } if( status == PSA_SUCCESS ) - { operation->ad_started = 1; - } return ( status ); } @@ -612,24 +594,18 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, if( PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type, operation->alg, input_length ) > output_size ) - { return ( PSA_ERROR_BUFFER_TOO_SMALL ); - } if( operation->lengths_set) { /* Additional data length was supplied, but not all the additional data was supplied.*/ if( operation->ad_remaining != 0 ) - { return ( PSA_ERROR_INVALID_ARGUMENT ); - } /* Too much data provided. */ if( operation->body_remaining < input_length ) - { return ( PSA_ERROR_INVALID_ARGUMENT ); - } operation->body_remaining -= input_length; } @@ -642,14 +618,10 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, * of non block size aligned updates. This will be fixed in 3.0 when we can change the signature of the GCM multipart functions */ if( !operation->lengths_set || operation->body_remaining != 0 ) - { return( PSA_ERROR_BAD_STATE ); - } if( !operation->ad_started ) - { return( PSA_ERROR_BAD_STATE ); - } status = mbedtls_to_psa_error( mbedtls_gcm_update( &operation->ctx.gcm, input_length, @@ -661,20 +633,17 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - /* CCM dooes not support multipart yet, so all the input has to be + /* CCM does not support multipart yet, so all the input has to be passed in in one go. */ if( operation->body_started ) - { return( PSA_ERROR_BAD_STATE ); - } /* Need to store tag for Finish() / Verify() */ operation->tag_buffer = - ( uint8_t * ) mbedtls_calloc(1, operation->tag_length ); + ( uint8_t * ) mbedtls_calloc( 1, operation->tag_length ); if( operation->tag_buffer ) { - if( operation->is_encrypt ) { /* Perform oneshot CCM encryption with additional data already @@ -693,7 +662,7 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, /* Even if the above operation fails, we no longer need the additional data.*/ - mbedtls_free(operation->ad_buffer); + mbedtls_free( operation->ad_buffer ); operation->ad_buffer = NULL; operation->ad_length = 0; } @@ -722,24 +691,16 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, operation->tag_length ); if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) - { status = PSA_SUCCESS; - } else - { status = mbedtls_to_psa_error( ret ); - } } else - { status = PSA_ERROR_INSUFFICIENT_MEMORY; - } } } else - { status = PSA_ERROR_INSUFFICIENT_MEMORY; - } } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -780,35 +741,18 @@ static psa_status_t mbedtls_psa_aead_finish_checks( mbedtls_psa_aead_operation_t size_t finish_output_size; if( operation->lengths_set ) - { if( operation->ad_remaining != 0 || operation->body_remaining != 0 ) - { return( PSA_ERROR_BAD_STATE ); - } - } if( tag_size < operation->tag_length ) - { return ( PSA_ERROR_BUFFER_TOO_SMALL ); - } - if( operation->is_encrypt ) - { - finish_output_size = - PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, - operation->alg ); - } - else - { - finish_output_size = - PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, - operation->alg ); - } + finish_output_size = operation->is_encrypt ? + PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, operation->alg ) : + PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, operation->alg ); if( output_size < finish_output_size ) - { return ( PSA_ERROR_BUFFER_TOO_SMALL ); - } return ( PSA_SUCCESS ); } @@ -829,18 +773,14 @@ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, tag_size ); if( status != PSA_SUCCESS ) - { return status; - } #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) - { /* We will need to do final GCM pass in here when multipart is done. */ status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, tag, tag_size ) ); - } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) @@ -858,11 +798,9 @@ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) - { status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly, tag ) ); - } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { @@ -911,28 +849,22 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, tag_length ); if( status != PSA_SUCCESS ) - { return status; - } #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) - { /* Call finish to get the tag for comparison */ status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, check_tag, operation->tag_length ) ); - } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { if( !operation->ad_buffer || !operation->body_buffer ) - { return( PSA_ERROR_BAD_STATE ); - } /* Perform oneshot CCM decryption *again*, as its the * only way to get the tag, but this time throw away the @@ -956,9 +888,7 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, temp_buffer, tag, tag_length ); if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) - { status = PSA_ERROR_INVALID_SIGNATURE; - } else { status = mbedtls_to_psa_error( ret ); @@ -966,9 +896,7 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, } } else - { status = PSA_ERROR_INSUFFICIENT_MEMORY; - } /* Even if the above operation fails, we no longer need the data */ mbedtls_free(temp_buffer); @@ -984,13 +912,11 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) - { // call finish to get the tag for comparison. status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly, check_tag ) ); - } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { @@ -1009,9 +935,7 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, if( do_tag_check && mbedtls_psa_safer_memcmp(tag, check_tag, tag_length) != 0 ) - { status = PSA_ERROR_INVALID_SIGNATURE; - } } mbedtls_psa_aead_abort(operation); @@ -1046,15 +970,15 @@ psa_status_t mbedtls_psa_aead_abort( mbedtls_psa_aead_operation_t *operation ) operation->ad_started = 0; operation->body_started = 0; - mbedtls_free(operation->ad_buffer); + mbedtls_free( operation->ad_buffer ); operation->ad_buffer = NULL; operation->ad_length = 0; - mbedtls_free(operation->body_buffer); + mbedtls_free( operation->body_buffer ); operation->body_buffer = NULL; operation->body_length = 0; - mbedtls_free(operation->tag_buffer); + mbedtls_free( operation->tag_buffer ); operation->tag_buffer = NULL; return( PSA_SUCCESS ); From ccaea40023814fbb31b2d35435b0e2c8c87535ea Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 13 May 2021 14:22:52 +0100 Subject: [PATCH 032/966] Replace hard coded buffer size with define Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index b694bfd9e6..0d1cdaed45 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -843,7 +843,7 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, size_t finish_output_size = 0; int do_tag_check = 1; - uint8_t check_tag[16]; + uint8_t check_tag[PSA_AEAD_TAG_MAX_SIZE]; status = mbedtls_psa_aead_finish_checks( operation, plaintext_size, tag_length ); From 9e8ccd7e82f7546383a3e1e8ff4315441fc54506 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 13 May 2021 14:30:53 +0100 Subject: [PATCH 033/966] Make sure all statuses are initialised Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 0d1cdaed45..66798072ac 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -345,7 +345,7 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( mbedtls_psa_aead_operation_t size_t key_buffer_size, psa_algorithm_t alg ) { - psa_status_t status; + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; status = psa_aead_setup( operation, attributes, key_buffer, key_buffer_size, alg ); @@ -366,7 +366,7 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( mbedtls_psa_aead_operation_t size_t key_buffer_size, psa_algorithm_t alg ) { - psa_status_t status; + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; (void) key_buffer_size; @@ -385,7 +385,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( mbedtls_psa_aead_operation_t const uint8_t *nonce, size_t nonce_length ) { - psa_status_t status; + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) From c10ad21a1b7eed23d53d8e185673376cb226ad31 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 13 May 2021 17:08:29 +0100 Subject: [PATCH 034/966] Remove SetLengths() requirement for GCM Also return NOT_SUPPORTED, rather than BAD_STATE for our current workarounds for GCM/CCM Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 66798072ac..9a98ba533f 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -509,15 +509,12 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { - if( !operation->lengths_set || operation->ad_started ) - return( PSA_ERROR_BAD_STATE ); - - /* GCM currently requires all the additional data to be passed in in + /* GCM currently requires all the additional data to be passed in in * one contiguous buffer, so until that is re-done, we have to enforce * this, as we cannot allocate a buffer to collate multiple calls into. */ - if( operation->ad_remaining != 0 ) - return ( PSA_ERROR_INVALID_ARGUMENT ); + if( operation->ad_started ) + return( PSA_ERROR_NOT_SUPPORTED ); status = mbedtls_to_psa_error( mbedtls_gcm_starts( &operation->ctx.gcm, @@ -537,7 +534,7 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t /* CCM requires all additional data to be passed in in one go at the minute, as we are basically operating in oneshot mode. */ if( operation->ad_started ) - return( PSA_ERROR_BAD_STATE ); + return( PSA_ERROR_NOT_SUPPORTED ); /* Save the additional data for later, this will be passed in when we have the body. */ @@ -617,11 +614,9 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, * must be passed in in one update, rather than deal with the complexity * of non block size aligned updates. This will be fixed in 3.0 when we can change the signature of the GCM multipart functions */ - if( !operation->lengths_set || operation->body_remaining != 0 ) - return( PSA_ERROR_BAD_STATE ); + if( operation->body_started ) + return( PSA_ERROR_NOT_SUPPORTED ); - if( !operation->ad_started ) - return( PSA_ERROR_BAD_STATE ); status = mbedtls_to_psa_error( mbedtls_gcm_update( &operation->ctx.gcm, input_length, @@ -636,7 +631,7 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, /* CCM does not support multipart yet, so all the input has to be passed in in one go. */ if( operation->body_started ) - return( PSA_ERROR_BAD_STATE ); + return( PSA_ERROR_NOT_SUPPORTED ); /* Need to store tag for Finish() / Verify() */ operation->tag_buffer = From e2c788d4804bf4321a61aefe0133b8d12db79e7e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 13 May 2021 17:16:01 +0100 Subject: [PATCH 035/966] Rename badly named variable Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 9a98ba533f..9c31e0051e 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -583,11 +583,11 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, size_t output_size, size_t *output_length ) { - size_t update_output_size; + size_t update_output_length; psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - update_output_size = input_length; + update_output_length = input_length; if( PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type, operation->alg, input_length ) > output_size ) @@ -719,7 +719,7 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, if( status == PSA_SUCCESS ) { - *output_length = update_output_size; + *output_length = update_output_length; operation->body_started = 1; } From 6108ee7c2d289f6f48bb977bb4cc1d2f431d85a0 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 13 May 2021 18:26:41 +0100 Subject: [PATCH 036/966] Change logic to reduce indentation Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 158 +++++++++++++++++++------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 9c31e0051e..0a84888b1f 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -538,16 +538,16 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t /* Save the additional data for later, this will be passed in when we have the body. */ - operation->ad_buffer = ( uint8_t * ) mbedtls_calloc(1, input_length ); + operation->ad_buffer = ( uint8_t * ) mbedtls_calloc( 1, input_length ); - if( operation->ad_buffer ) + if( operation->ad_buffer == NULL ) { - memcpy( operation->ad_buffer, input, input_length ); - operation->ad_length = input_length; - status = PSA_SUCCESS; + return( PSA_ERROR_INSUFFICIENT_MEMORY ); } - else - return ( PSA_ERROR_INSUFFICIENT_MEMORY ); + + memcpy( operation->ad_buffer, input, input_length ); + operation->ad_length = input_length; + status = PSA_SUCCESS; } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -637,65 +637,65 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, operation->tag_buffer = ( uint8_t * ) mbedtls_calloc( 1, operation->tag_length ); - if( operation->tag_buffer ) + if( operation->tag_buffer == NULL) { - if( operation->is_encrypt ) - { - /* Perform oneshot CCM encryption with additional data already - stored, as CCM does not support multipart yet.*/ - status = mbedtls_to_psa_error( - mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm, - input_length, - operation->nonce, - operation->nonce_length, - operation->ad_buffer, - operation->ad_length, - input, - output, - operation->tag_buffer, - operation->tag_length ) ); + return( PSA_ERROR_INSUFFICIENT_MEMORY ); + } - /* Even if the above operation fails, we no longer need the - additional data.*/ - mbedtls_free( operation->ad_buffer ); - operation->ad_buffer = NULL; - operation->ad_length = 0; - } - else - { - /* Need to back up the body data so we can do this again - later.*/ - operation->body_buffer = - ( uint8_t * ) mbedtls_calloc(1, input_length ); + if( operation->is_encrypt ) + { + /* Perform oneshot CCM encryption with additional data already + stored, as CCM does not support multipart yet.*/ + status = mbedtls_to_psa_error( + mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm, + input_length, + operation->nonce, + operation->nonce_length, + operation->ad_buffer, + operation->ad_length, + input, + output, + operation->tag_buffer, + operation->tag_length ) ); - if( operation->body_buffer ) - { - memcpy( operation->body_buffer, input, input_length ); - operation->body_length = input_length; - - /* this will fail, as the tag is clearly false, but will - write the decrypted data to the output buffer.*/ - ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, - input_length, - operation->nonce, - operation->nonce_length, - operation->ad_buffer, - operation->ad_length, - input, output, - operation->tag_buffer, - operation->tag_length ); - - if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) - status = PSA_SUCCESS; - else - status = mbedtls_to_psa_error( ret ); - } - else - status = PSA_ERROR_INSUFFICIENT_MEMORY; - } + /* Even if the above operation fails, we no longer need the + additional data.*/ + mbedtls_free( operation->ad_buffer ); + operation->ad_buffer = NULL; + operation->ad_length = 0; } else - status = PSA_ERROR_INSUFFICIENT_MEMORY; + { + /* Need to back up the body data so we can do this again + later.*/ + operation->body_buffer = + ( uint8_t * ) mbedtls_calloc(1, input_length ); + + if( operation->body_buffer == NULL) + { + return( PSA_ERROR_INSUFFICIENT_MEMORY ); + } + + memcpy( operation->body_buffer, input, input_length ); + operation->body_length = input_length; + + /* this will fail, as the tag is clearly false, but will + write the decrypted data to the output buffer.*/ + ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, + input_length, + operation->nonce, + operation->nonce_length, + operation->ad_buffer, + operation->ad_length, + input, output, + operation->tag_buffer, + operation->tag_length ); + + if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) + status = PSA_SUCCESS; + else + status = mbedtls_to_psa_error( ret ); + } } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -871,27 +871,27 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, temp_buffer = ( uint8_t * ) mbedtls_calloc(1, temp_buffer_size ); - if( temp_buffer ) + if( temp_buffer == NULL) { - ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, - operation->body_length, - operation->nonce, - operation->nonce_length, - operation->ad_buffer, - operation->ad_length, - operation->body_buffer, - temp_buffer, tag, tag_length ); - - if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) - status = PSA_ERROR_INVALID_SIGNATURE; - else - { - status = mbedtls_to_psa_error( ret ); - do_tag_check = 0; - } + return( PSA_ERROR_INSUFFICIENT_MEMORY ); } + + ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, + operation->body_length, + operation->nonce, + operation->nonce_length, + operation->ad_buffer, + operation->ad_length, + operation->body_buffer, + temp_buffer, tag, tag_length ); + + if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) + status = PSA_ERROR_INVALID_SIGNATURE; else - status = PSA_ERROR_INSUFFICIENT_MEMORY; + { + status = mbedtls_to_psa_error( ret ); + do_tag_check = 0; + } /* Even if the above operation fails, we no longer need the data */ mbedtls_free(temp_buffer); From b06e1c0d68b1acd130cd1abc3056fdf589aadbb9 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 13 May 2021 18:33:43 +0100 Subject: [PATCH 037/966] Remove unnecessary code Calls to abort that are now being done by the psa_crypto layer, freeing of tempory allocations (done by abort) and a couple of checks that had already been done prior to that point Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 0a84888b1f..848889af85 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -658,11 +658,6 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, operation->tag_buffer, operation->tag_length ) ); - /* Even if the above operation fails, we no longer need the - additional data.*/ - mbedtls_free( operation->ad_buffer ); - operation->ad_buffer = NULL; - operation->ad_length = 0; } else { @@ -784,9 +779,6 @@ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, /* Copy the previously generated tag into place */ memcpy( tag, operation->tag_buffer, operation->tag_length ); - mbedtls_free(operation->tag_buffer); - operation->tag_buffer = NULL; - status = PSA_SUCCESS; } else @@ -815,8 +807,6 @@ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, *tag_length = operation->tag_length; } - mbedtls_psa_aead_abort(operation); - return ( status ); } @@ -858,9 +848,6 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - if( !operation->ad_buffer || !operation->body_buffer ) - return( PSA_ERROR_BAD_STATE ); - /* Perform oneshot CCM decryption *again*, as its the * only way to get the tag, but this time throw away the results, as verify cannot write that much data. */ @@ -895,13 +882,6 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, /* Even if the above operation fails, we no longer need the data */ mbedtls_free(temp_buffer); - - mbedtls_free(operation->body_buffer); - operation->body_buffer = NULL; - operation->body_length = 0; - - mbedtls_free(operation->tag_buffer); - operation->tag_buffer = NULL; } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -933,8 +913,6 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, status = PSA_ERROR_INVALID_SIGNATURE; } - mbedtls_psa_aead_abort(operation); - return ( status ); } From 4148a6816902d12dd9973baf807ca1e6b908ec88 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 14 May 2021 17:26:56 +0100 Subject: [PATCH 038/966] Update documentation for internal implementation Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 205 +++++++++++++------------------------- 1 file changed, 72 insertions(+), 133 deletions(-) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index 4b6d6cd1ba..4bf514796d 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -155,39 +155,14 @@ psa_status_t mbedtls_psa_aead_decrypt( * aead_encrypt_setup entry point as defined in the PSA driver interface * specification for transparent drivers. * - * The sequence of operations to encrypt a message with authentication - * is as follows: - * -# Allocate an operation object which will be passed to all the functions - * listed here. - * -# Initialize the operation object with one of the methods described in the - * documentation for #mbedtls_psa_aead_operation_t, e.g. - * #MBEDTLS_PSA_AEAD_OPERATION_INIT. - * -# Call mbedtls_psa_aead_encrypt_setup() to specify the algorithm and key. - * -# If needed, call mbedtls_psa_aead_set_lengths() to specify the length of - * the inputs to the subsequent calls to mbedtls_psa_aead_update_ad() and - * mbedtls_psa_aead_update(). See the documentation of - * mbedtls_psa_aead_set_lengths() for details. - * -# Call either psa_aead_generate_nonce() or - * mbedtls_psa_aead_set_nonce() to generate or set the nonce. You should use - * psa_aead_generate_nonce() unless the protocol you are implementing - * requires a specific nonce value. - * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing - * a fragment of the non-encrypted additional authenticated data each time. - * -# Call mbedtls_psa_aead_update() zero, one or more times, passing a fragment - * of the message to encrypt each time. - * -# Call mbedtls_psa_aead_finish(). - * * If an error occurs at any step after a call to - * mbedtls_psa_aead_encrypt_setup(), the operation will need to be reset by a - * call to mbedtls_psa_aead_abort(). The application may call + * mbedtls_psa_aead_encrypt_setup(), the operation is reset by the PSA core by a + * call to mbedtls_psa_aead_abort(). The PSA core may call * mbedtls_psa_aead_abort() at any time after the operation has been * initialized. * - * After a successful call to mbedtls_psa_aead_encrypt_setup(), the application - * must eventually terminate the operation. The following events terminate an - * operation: - * - A successful call to mbedtls_psa_aead_finish(). - * - A call to mbedtls_psa_aead_abort(). + * After a successful call to mbedtls_psa_aead_encrypt_setup(), the PSA core + * eventually terminates the operation by calling mbedtls_psa_aead_abort(). * * \param[in,out] operation The operation object to set up. It must have * been initialized as per the documentation for @@ -236,36 +211,14 @@ psa_status_t mbedtls_psa_aead_encrypt_setup(mbedtls_psa_aead_operation_t * aead_decrypt_setup entry point as defined in the PSA driver interface * specification for transparent drivers. * - * The sequence of operations to decrypt a message with authentication - * is as follows: - * -# Allocate an operation object which will be passed to all the functions - * listed here. - * -# Initialize the operation object with one of the methods described in the - * documentation for #mbedtls_psa_aead_operation_t, e.g. - * #PSA_AEAD_OPERATION_INIT. - * -# Call mbedtls_psa_aead_decrypt_setup() to specify the algorithm and key. - * -# If needed, call mbedtls_psa_aead_set_lengths() to specify the length of - * the inputs to the subsequent calls to mbedtls_psa_aead_update_ad() and - * mbedtls_psa_aead_update(). See the documentation of - * mbedtls_psa_aead_set_lengths() for details. - * -# Call mbedtls_psa_aead_set_nonce() with the nonce for the decryption. - * -# Call mbedtls_psa_aead_update_ad() zero, one or more times, passing a - * fragment of the non-encrypted additional authenticated data each time. - * -# Call mbedtls_psa_aead_update() zero, one or more times, passing a fragment - * of the ciphertext to decrypt each time. - * -# Call mbedtls_psa_aead_verify(). - * * If an error occurs at any step after a call to - * mbedtls_psa_aead_decrypt_setup(), the operation will need to be reset by a - * call to mbedtls_psa_aead_abort(). The application may call + * mbedtls_psa_aead_decrypt_setup(), the PSA core resets the operation by a + * call to mbedtls_psa_aead_abort(). The PSA core may call * mbedtls_psa_aead_abort() at any time after the operation has been * initialized. * - * After a successful call to mbedtls_psa_aead_decrypt_setup(), the application - * must eventually terminate the operation. The following events terminate an - * operation: - * - A successful call to mbedtls_psa_aead_verify(). - * - A call to mbedtls_psa_aead_abort(). + * After a successful call to mbedtls_psa_aead_decrypt_setup(), the PSA core + * eventually terminates the operation by a call to mbedtls_psa_aead_abort(). * * \param[in,out] operation The operation object to set up. It must have * been initialized as per the documentation for @@ -309,23 +262,19 @@ psa_status_t mbedtls_psa_aead_decrypt_setup(mbedtls_psa_aead_operation_t /** Set the nonce for an authenticated encryption or decryption operation. * - * \note The signature of this function is that of a PSA driver - * psa_aead_set_nonce entry point. This function behaves as an - * psa_aead_set_nonce entry point as defined in the PSA driver interface - * specification for transparent drivers. + * \note The signature of this function is that of a PSA driver aead_set_nonce + * entry point. This function behaves as an aead_set_nonce entry point as + * defined in the PSA driver interface specification for transparent + * drivers. * * This function sets the nonce for the authenticated * encryption or decryption operation. * - * The application must call mbedtls_psa_aead_encrypt_setup() or + * The PSA core calls mbedtls_psa_aead_encrypt_setup() or * mbedtls_psa_aead_decrypt_setup() before calling this function. * - * If this function returns an error status, the operation enters an error - * state and must be aborted by calling mbedtls_psa_aead_abort(). - * - * \note When encrypting, applications should use - * mbedtls_psa_aead_generate_nonce() instead of this function, unless - * implementing a protocol that requires a non-random IV. + * If this function returns an error status, the PSA core calls + * mbedtls_psa_aead_abort(). * * \param[in,out] operation Active AEAD operation. * \param[in] nonce Buffer containing the nonce to use. @@ -354,19 +303,18 @@ psa_status_t mbedtls_psa_aead_set_nonce(mbedtls_psa_aead_operation_t *operation, /** Declare the lengths of the message and additional data for AEAD. * - * \note The signature of this function is that of a PSA driver - * psa_aead_set_lengths entry point. This function behaves as an - * psa_aead_set_lengths entry point as defined in the PSA driver interface - * specification for transparent drivers. + * \note The signature of this function is that of a PSA driver aead_set_lengths + * entry point. This function behaves as an aead_set_lengths entry point + * as defined in the PSA driver interface specification for transparent + * drivers. * - * The application must call this function before calling - * mbedtls_psa_aead_update_ad() or mbedtls_psa_aead_update() if the algorithm - * for the operation requires it. If the algorithm does not require it, calling - * this function is optional, but if this function is called then the - * implementation must enforce the lengths. + * The PSA core calls this function before calling mbedtls_psa_aead_update_ad() + * or mbedtls_psa_aead_update() if the algorithm for the operation requires it. + * If the algorithm does not require it, calling this function is optional, but + * if this function is called then the implementation must enforce the lengths. * - * You may call this function before or after setting the nonce with - * mbedtls_psa_aead_set_nonce() or psa_aead_generate_nonce(). + * The PSA core may call this function before or after setting the nonce with + * mbedtls_psa_aead_set_nonce(). * * - For #PSA_ALG_CCM, calling this function is required. * - For the other AEAD algorithms defined in this specification, calling @@ -413,17 +361,17 @@ psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t * * Additional data is authenticated, but not encrypted. * - * You may call this function multiple times to pass successive fragments - * of the additional data. You may not call this function after passing - * data to encrypt or decrypt with mbedtls_psa_aead_update(). + * The PSA core can call this function multiple times to pass successive + * fragments of the additional data. It will not call this function after + * passing data to encrypt or decrypt with mbedtls_psa_aead_update(). * - * Before calling this function, you must: - * 1. Call either mbedtls_psa_aead_encrypt_setup() or - * mbedtls_psa_aead_decrypt_setup(). 2. Set the nonce with - * psa_aead_generate_nonce() or mbedtls_psa_aead_set_nonce(). + * Before calling this function, The PSA core will: + * 1. Call either mbedtls_psa_aead_encrypt_setup() or + * mbedtls_psa_aead_decrypt_setup(). + * 2. Set the nonce with mbedtls_psa_aead_set_nonce(). * - * If this function returns an error status, the operation enters an error - * state and must be aborted by calling mbedtls_psa_aead_abort(). + * If this function returns an error status, the PSA core will call + * mbedtls_psa_aead_abort(). * * \warning When decrypting, until mbedtls_psa_aead_verify() has returned * #PSA_SUCCESS, there is no guarantee that the input is valid. @@ -433,8 +381,8 @@ psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t * mbedtls_psa_aead_verify() returns an error status. * * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire - * additional data to be passed in in one go, i.e. only call - * mbedtls_mbedtls_psa_aead_update_ad() once. + * additional data to be passed in in one go, i.e. + * mbedtls_mbedtls_psa_aead_update_ad() can only be called once. * * \param[in,out] operation Active AEAD operation. * \param[in] input Buffer containing the fragment of @@ -471,31 +419,15 @@ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, * point as defined in the PSA driver interface specification for * transparent drivers. * - * Before calling this function, you must: - * 1. Call either mbedtls_psa_aead_encrypt_setup() or - * mbedtls_psa_aead_decrypt_setup(). The choice of setup function determines - * whether this function encrypts or decrypts its input. - * 2. Set the nonce with psa_aead_generate_nonce() or - * mbedtls_psa_aead_set_nonce(). 3. Call mbedtls_psa_aead_update_ad() to pass - * all the additional data. + * Before calling this function, the PSA core will: + * 1. Call either mbedtls_psa_aead_encrypt_setup() or + * mbedtls_psa_aead_decrypt_setup(). The choice of setup function + * determines whether this function encrypts or decrypts its input. + * 2. Set the nonce with mbedtls_psa_aead_set_nonce(). + * 3. Call mbedtls_psa_aead_update_ad() to pass all the additional data. * - * If this function returns an error status, the operation enters an error - * state and must be aborted by calling mbedtls_psa_aead_abort(). - * - * \warning When decrypting, until mbedtls_psa_aead_verify() has returned - * #PSA_SUCCESS, there is no guarantee that the input is valid. - * Therefore, until you have called mbedtls_psa_aead_verify() and it - * has returned #PSA_SUCCESS: - * - Do not use the output in any way other than storing it in a - * confidential location. If you take any action that depends - * on the tentative decrypted data, this action will need to be - * undone if the input turns out not to be valid. Furthermore, - * if an adversary can observe that this action took place - * (for example through timing), they may be able to use this - * fact as an oracle to decrypt any message encrypted with the - * same key. - * - In particular, do not copy the output anywhere but to a - * memory or storage space that you have exclusive access to. + * If this function returns an error status, the PSA core will call + * mbedtls_psa_aead_abort(). * * This function does not require the input to be aligned to any * particular block boundary. If the implementation can only process @@ -506,8 +438,8 @@ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, * can be delayed in this way is bounded by #PSA_AEAD_UPDATE_OUTPUT_SIZE. * * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire - * data to be passed in in one go, i.e. only call - * mbedtls_mbedtls_psa_aead_update() once. + * data to be passed in in one go, i.e. mbedtls_mbedtls_psa_aead_update() + * can only be called once. * * \param[in,out] operation Active AEAD operation. * \param[in] input Buffer containing the message fragment to @@ -563,7 +495,8 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * point as defined in the PSA driver interface specification for * transparent drivers. * - * The operation must have been set up with mbedtls_psa_aead_encrypt_setup(). + * The operation must have been set up by the PSA core with + * mbedtls_psa_aead_encrypt_setup(). * * This function finishes the authentication of the additional data * formed by concatenating the inputs passed to preceding calls to @@ -572,14 +505,11 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * * This function has two output buffers: * - \p ciphertext contains trailing ciphertext that was buffered from - * preceding calls to mbedtls_psa_aead_update(). - * - \p tag contains the authentication tag. Its length is always - * #PSA_AEAD_TAG_LENGTH(\c alg) where \c alg is the AEAD algorithm - * that the operation performs. + * preceding calls to psa_aead_update(). + * - \p tag contains the authentication tag. * - * When this function returns successfuly, the operation becomes inactive. - * If this function returns an error status, the operation enters an error - * state and must be aborted by calling mbedtls_psa_aead_abort(). + * Whether or not this function returns successfuly, the PSA core subsequently + * calls mbedtls_psa_aead_abort() to deactivate the operation. * * \param[in,out] operation Active AEAD operation. * \param[out] ciphertext Buffer where the last part of the ciphertext @@ -594,9 +524,17 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * \param[out] tag Buffer where the authentication tag is * to be written. * \param tag_size Size of the \p tag buffer in bytes. - * This must be at least - * #PSA_AEAD_TAG_LENGTH(\c alg) where \c alg is - * the algorithm that is being calculated. + * This must be appropriate for the selected + * algorithm and key: + * - The exact tag size is #PSA_AEAD_TAG_LENGTH(\c + * key_type, \c key_bits, \c alg) where + * \c key_type and \c key_bits are the type and + * bit-size of the key, and \c alg is the + * algorithm that were used in the call to + * psa_aead_encrypt_setup(). + * - #PSA_AEAD_TAG_MAX_SIZE evaluates to the + * maximum tag size of any supported AEAD + * algorithm. * \param[out] tag_length On success, the number of bytes * that make up the returned tag. * @@ -610,8 +548,9 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * You can determine a sufficient buffer size for \p ciphertext by * calling #PSA_AEAD_FINISH_OUTPUT_SIZE(\c alg) * where \c alg is the algorithm that is being calculated. - * You can determine a sufficient buffer size for \p tag by - * calling #PSA_AEAD_TAG_LENGTH(\c alg). + * #PSA_AEAD_TAG_LENGTH(\c key_type, \c key_bits, \c alg) or + * #PSA_AEAD_TAG_MAX_SIZE can be used to determine the required \p tag + * buffer size. * \retval #PSA_ERROR_INVALID_ARGUMENT * The total length of input to psa_aead_update_ad() so far is * less than the additional data length that was previously @@ -645,7 +584,8 @@ psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, * point as defined in the PSA driver interface specification for * transparent drivers. * - * The operation must have been set up with mbedtls_psa_aead_decrypt_setup(). + * The operation must have been set up by the PSA core with + * mbedtls_psa_aead_decrypt_setup(). * * This function finishes the authenticated decryption of the message * components: @@ -660,9 +600,8 @@ psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, * plaintext and reports success. If the authentication tag is not correct, * this function returns #PSA_ERROR_INVALID_SIGNATURE. * - * When this function returns successfuly, the operation becomes inactive. - * If this function returns an error status, the operation enters an error - * state and must be aborted by calling mbedtls_psa_aead_abort(). + * Whether or not this function returns successfully, the PSA core subsequently + * calls mbedtls_psa_aead_abort() to deactivate the operation. * * \note Implementations shall make the best effort to ensure that the * comparison between the actual tag and the expected tag is performed @@ -731,10 +670,10 @@ psa_status_t mbedtls_psa_aead_verify(mbedtls_psa_aead_operation_t *operation, * * Aborting an operation frees all associated resources except for the * \p operation structure itself. Once aborted, the operation object - * can be reused for another operation by calling + * can be reused for another operation by the PSA core by it calling * mbedtls_psa_aead_encrypt_setup() or mbedtls_psa_aead_decrypt_setup() again. * - * You may call this function any time after the operation object has + * The PSA core may call this function any time after the operation object has * been initialized as described in #mbedtls_psa_aead_operation_t. * * In particular, calling mbedtls_psa_aead_abort() after the operation has been From 9622c9aae098f89d8c6569b20c17de8cd2321616 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 17 May 2021 17:30:52 +0100 Subject: [PATCH 039/966] Fix updated size macros in documentation Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 68 +++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index 4bf514796d..ce8bb3a513 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -447,10 +447,18 @@ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, * \param input_length Size of the \p input buffer in bytes. * \param[out] output Buffer where the output is to be written. * \param output_size Size of the \p output buffer in bytes. - * This must be at least - * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c alg, - * \p input_length) where \c alg is the - * algorithm that is being calculated. + * This must be appropriate for the selected + * algorithm and key: + * - A sufficient output size is + * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c key_type, + * \c alg, \p input_length) where + * \c key_type is the type of key and \c alg is + * the algorithm that were used to set up the + * operation. + * - #PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(\p + * input_length) evaluates to the maximum + * output size of any supported AEAD + * algorithm. * \param[out] output_length On success, the number of bytes * that make up the returned output. * @@ -461,9 +469,10 @@ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, * set, and have lengths set if required by the algorithm). * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p output buffer is too small. - * You can determine a sufficient buffer size by calling - * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c alg, \p input_length) - * where \c alg is the algorithm that is being calculated. + * The size of the \p output buffer is too small. + * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c key_type, \c alg, \p input_length) or + * #PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(\p input_length) can be used to + * determine the required buffer size. * \retval #PSA_ERROR_INVALID_ARGUMENT * The total length of input to mbedtls_psa_aead_update_ad() so far is * less than the additional data length that was previously @@ -515,10 +524,16 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * \param[out] ciphertext Buffer where the last part of the ciphertext * is to be written. * \param ciphertext_size Size of the \p ciphertext buffer in bytes. - * This must be at least - * #PSA_AEAD_FINISH_OUTPUT_SIZE(\c alg) where - * \c alg is the algorithm that is being - * calculated. + * This must be appropriate for the selected + * algorithm and key: + * - A sufficient output size is + * #PSA_AEAD_FINISH_OUTPUT_SIZE(\c key_type, + * \c alg) where \c key_type is the type of key + * and \c alg is the algorithm that were used to + * set up the operation. + * - #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE evaluates to + * the maximum output size of any supported AEAD + * algorithm. * \param[out] ciphertext_length On success, the number of bytes of * returned ciphertext. * \param[out] tag Buffer where the authentication tag is @@ -545,12 +560,11 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * operation with a nonce set). * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p ciphertext or \p tag buffer is too small. - * You can determine a sufficient buffer size for \p ciphertext by - * calling #PSA_AEAD_FINISH_OUTPUT_SIZE(\c alg) - * where \c alg is the algorithm that is being calculated. - * #PSA_AEAD_TAG_LENGTH(\c key_type, \c key_bits, \c alg) or - * #PSA_AEAD_TAG_MAX_SIZE can be used to determine the required \p tag - * buffer size. + * #PSA_AEAD_FINISH_OUTPUT_SIZE(\c key_type, \c alg) or + * #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE can be used to determine the + * required \p ciphertext buffer size. #PSA_AEAD_TAG_LENGTH(\c key_type, + * \c key_bits, \c alg) or #PSA_AEAD_TAG_MAX_SIZE can be used to + * determine the required \p tag buffer size. * \retval #PSA_ERROR_INVALID_ARGUMENT * The total length of input to psa_aead_update_ad() so far is * less than the additional data length that was previously @@ -614,10 +628,16 @@ psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, * that could not be processed until the end * of the input. * \param plaintext_size Size of the \p plaintext buffer in bytes. - * This must be at least - * #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c alg) where - * \c alg is the algorithm that is being - * calculated. + * This must be appropriate for the selected + * algorithm and key: + * - A sufficient output size is + * #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c key_type, + * \c alg) where \c key_type is the type of key + * and \c alg is the algorithm that were used to + * set up the operation. + * - #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE evaluates to + * the maximum output size of any supported AEAD + * algorithm. * \param[out] plaintext_length On success, the number of bytes of * returned plaintext. * \param[in] tag Buffer containing the authentication tag. @@ -633,9 +653,9 @@ psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, * operation with a nonce set). * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p plaintext buffer is too small. - * You can determine a sufficient buffer size for \p plaintext by - * calling #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c alg) - * where \c alg is the algorithm that is being calculated. + * #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c key_type, \c alg) or + * #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE can be used to determine the + * required buffer size. * \retval #PSA_ERROR_INVALID_ARGUMENT * The total length of input to mbedtls_psa_aead_update_ad() so far is * less than the additional data length that was previously From 498d3503c4d9ee4dd9dd96aa26ba8301ecc75c9d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 17 May 2021 18:16:20 +0100 Subject: [PATCH 040/966] Misc documentation fixes. Misnamed function calls, typos and missed changes. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index ce8bb3a513..c111c332e5 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -273,7 +273,7 @@ psa_status_t mbedtls_psa_aead_decrypt_setup(mbedtls_psa_aead_operation_t * The PSA core calls mbedtls_psa_aead_encrypt_setup() or * mbedtls_psa_aead_decrypt_setup() before calling this function. * - * If this function returns an error status, the PSA core calls + * If this function returns an error status, the PSA core will call * mbedtls_psa_aead_abort(). * * \param[in,out] operation Active AEAD operation. @@ -321,8 +321,8 @@ psa_status_t mbedtls_psa_aead_set_nonce(mbedtls_psa_aead_operation_t *operation, * this function is not required. * - For vendor-defined algorithm, refer to the vendor documentation. * - * If this function returns an error status, the operation enters an error - * state and must be aborted by calling mbedtls_psa_aead_abort(). + * If this function returns an error status, the PSA core calls + * mbedtls_psa_aead_abort(). * * \param[in,out] operation Active AEAD operation. * \param ad_length Size of the non-encrypted additional @@ -365,7 +365,7 @@ psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t * fragments of the additional data. It will not call this function after * passing data to encrypt or decrypt with mbedtls_psa_aead_update(). * - * Before calling this function, The PSA core will: + * Before calling this function, the PSA core will: * 1. Call either mbedtls_psa_aead_encrypt_setup() or * mbedtls_psa_aead_decrypt_setup(). * 2. Set the nonce with mbedtls_psa_aead_set_nonce(). @@ -382,7 +382,7 @@ psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t * * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire * additional data to be passed in in one go, i.e. - * mbedtls_mbedtls_psa_aead_update_ad() can only be called once. + * mbedtls_psa_aead_update_ad() can only be called once. * * \param[in,out] operation Active AEAD operation. * \param[in] input Buffer containing the fragment of @@ -438,8 +438,8 @@ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, * can be delayed in this way is bounded by #PSA_AEAD_UPDATE_OUTPUT_SIZE. * * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire - * data to be passed in in one go, i.e. mbedtls_mbedtls_psa_aead_update() - * can only be called once. + * data to be passed in in one go, i.e. mbedtls_psa_aead_update() can only + * be called once. * * \param[in,out] operation Active AEAD operation. * \param[in] input Buffer containing the message fragment to @@ -514,7 +514,7 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * * This function has two output buffers: * - \p ciphertext contains trailing ciphertext that was buffered from - * preceding calls to psa_aead_update(). + * preceding calls to mbedtls_psa_aead_update(). * - \p tag contains the authentication tag. * * Whether or not this function returns successfuly, the PSA core subsequently @@ -544,9 +544,9 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * - The exact tag size is #PSA_AEAD_TAG_LENGTH(\c * key_type, \c key_bits, \c alg) where * \c key_type and \c key_bits are the type and - * bit-size of the key, and \c alg is the + * bit-size of the key, and \c alg are the * algorithm that were used in the call to - * psa_aead_encrypt_setup(). + * mbedtls_psa_aead_encrypt_setup(). * - #PSA_AEAD_TAG_MAX_SIZE evaluates to the * maximum tag size of any supported AEAD * algorithm. @@ -566,9 +566,9 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * \c key_bits, \c alg) or #PSA_AEAD_TAG_MAX_SIZE can be used to * determine the required \p tag buffer size. * \retval #PSA_ERROR_INVALID_ARGUMENT - * The total length of input to psa_aead_update_ad() so far is + * The total length of input to mbedtls_psa_aead_update_ad() so far is * less than the additional data length that was previously - * specified with psa_aead_set_lengths(). + * specified with mbedtls_psa_aead_set_lengths(). * \retval #PSA_ERROR_INVALID_ARGUMENT * The total length of input to mbedtls_psa_aead_update() so far is * less than the plaintext length that was previously @@ -663,7 +663,7 @@ psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, * \retval #PSA_ERROR_INVALID_ARGUMENT * The total length of input to mbedtls_psa_aead_update() so far is * less than the plaintext length that was previously - * specified with psa_aead_set_lengths(). + * specified with mbedtls_psa_aead_set_lengths(). * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE From b91f331fcee009e79e6f1c1a8ede672bc7fb4b6d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 19 May 2021 12:30:15 +0100 Subject: [PATCH 041/966] Correct potential return values in documentation Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 121 ++++++++------------------------------ 1 file changed, 23 insertions(+), 98 deletions(-) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index c111c332e5..cf6230149d 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -178,23 +178,12 @@ psa_status_t mbedtls_psa_aead_decrypt( * * \retval #PSA_SUCCESS * Success. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be inactive). - * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_ARGUMENT * \p key is not compatible with \p alg. * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported or is not an AEAD algorithm. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_STORAGE_FAILURE - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. + * Failed to allocate memory for key material */ psa_status_t mbedtls_psa_aead_encrypt_setup(mbedtls_psa_aead_operation_t *operation, @@ -234,23 +223,12 @@ psa_status_t mbedtls_psa_aead_encrypt_setup(mbedtls_psa_aead_operation_t * * \retval #PSA_SUCCESS * Success. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be inactive). - * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_NOT_PERMITTED - * \retval #PSA_ERROR_INVALID_ARGUMENT + * * \retval #PSA_ERROR_INVALID_ARGUMENT * \p key is not compatible with \p alg. * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported or is not an AEAD algorithm. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_STORAGE_FAILURE - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. + * Failed to allocate memory for key material */ psa_status_t mbedtls_psa_aead_decrypt_setup(mbedtls_psa_aead_operation_t *operation, @@ -282,20 +260,11 @@ psa_status_t mbedtls_psa_aead_decrypt_setup(mbedtls_psa_aead_operation_t * * \retval #PSA_SUCCESS * Success. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be active, with no nonce - * set). * \retval #PSA_ERROR_INVALID_ARGUMENT * The size of \p nonce is not acceptable for the chosen algorithm. - * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_STORAGE_FAILURE - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. + * \retval #PSA_ERROR_NOT_SUPPORTED + * Algorithm previously set is not supported in this configuration of + * the library. */ psa_status_t mbedtls_psa_aead_set_nonce(mbedtls_psa_aead_operation_t *operation, const uint8_t *nonce, @@ -331,21 +300,12 @@ psa_status_t mbedtls_psa_aead_set_nonce(mbedtls_psa_aead_operation_t *operation, * * \retval #PSA_SUCCESS * Success. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be active, and - * mbedtls_psa_aead_update_ad() and mbedtls_psa_aead_update() must not - * have been called yet). * \retval #PSA_ERROR_INVALID_ARGUMENT * At least one of the lengths is not acceptable for the chosen * algorithm. - * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. + * \retval #PSA_ERROR_NOT_SUPPORTED + * Algorithm previously set is not supported in this configuration of + * the library. */ psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t *operation, @@ -391,22 +351,15 @@ psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t * * \retval #PSA_SUCCESS * Success. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be active, have a nonce - * set, have lengths set if required by the algorithm, and - * mbedtls_psa_aead_update() must not have been called yet). * \retval #PSA_ERROR_INVALID_ARGUMENT * The total input length overflows the additional data length that * was previously specified with mbedtls_psa_aead_set_lengths(). - * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_STORAGE_FAILURE - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. + * \retval #PSA_ERROR_NOT_SUPPORTED + * (For GCM / CCM) PSA core attempted to call mbedtls_psa_update_ad() + * more than once. + * \retval #PSA_ERROR_NOT_SUPPORTED + * Algorithm previously set is not supported in this configuration of + * the library. */ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, const uint8_t *input, @@ -464,12 +417,9 @@ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, * * \retval #PSA_SUCCESS * Success. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be active, have a nonce - * set, and have lengths set if required by the algorithm). + * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p output buffer is too small. - * The size of the \p output buffer is too small. * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c key_type, \c alg, \p input_length) or * #PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(\p input_length) can be used to * determine the required buffer size. @@ -480,15 +430,12 @@ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, * \retval #PSA_ERROR_INVALID_ARGUMENT * The total input length overflows the plaintext length that * was previously specified with mbedtls_psa_aead_set_lengths(). + * \retval #PSA_ERROR_NOT_SUPPORTED + * (GCM / CCM only) PSA core attempted to call mbedtls_psa_update() more + * than once. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_STORAGE_FAILURE - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. + * (CCM only) Unable to allocate memory for the tag or the body + */ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, const uint8_t *input, @@ -573,15 +520,6 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * The total length of input to mbedtls_psa_aead_update() so far is * less than the plaintext length that was previously * specified with mbedtls_psa_aead_set_lengths(). - * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_STORAGE_FAILURE - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. */ psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, uint8_t *ciphertext, @@ -665,14 +603,7 @@ psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, * less than the plaintext length that was previously * specified with mbedtls_psa_aead_set_lengths(). * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_STORAGE_FAILURE - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. + * (CCM only) Failed to allocate temporary buffer */ psa_status_t mbedtls_psa_aead_verify(mbedtls_psa_aead_operation_t *operation, uint8_t *plaintext, @@ -703,13 +634,7 @@ psa_status_t mbedtls_psa_aead_verify(mbedtls_psa_aead_operation_t *operation, * \param[in,out] operation Initialized AEAD operation. * * \retval #PSA_SUCCESS - * \retval #PSA_ERROR_COMMUNICATION_FAILURE - * \retval #PSA_ERROR_HARDWARE_FAILURE - * \retval #PSA_ERROR_CORRUPTION_DETECTED - * \retval #PSA_ERROR_BAD_STATE - * The library has not been previously initialized by psa_crypto_init(). - * It is implementation-dependent whether a failure to initialize - * results in this error code. + * Success. */ psa_status_t mbedtls_psa_aead_abort(mbedtls_psa_aead_operation_t *operation); From 5c656cbf99fd8a6297f7c912fb1ee6362c1fc722 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 19 May 2021 14:15:01 +0100 Subject: [PATCH 042/966] Fix missed incorrect include guard Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 7590800e26..3245ff4221 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1399,7 +1399,7 @@ psa_status_t psa_driver_wrapper_aead_set_nonce( { switch( operation->id ) { -#if defined(MBEDTLS_PSA_BUILTIN_CIPHER) +#if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: return( mbedtls_psa_aead_set_nonce( &operation->ctx.mbedtls_ctx, nonce, From e9eeea32905ce2c416df21afc19c6244ac989685 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 19 May 2021 14:32:58 +0100 Subject: [PATCH 043/966] Formatting fixes Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 848889af85..4fb0e3b0f1 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -391,7 +391,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( mbedtls_psa_aead_operation_t if( operation->alg == PSA_ALG_GCM ) { /* GCM sets nonce once additional data has been supplied */ - memcpy(operation->nonce, nonce, nonce_length); + memcpy( operation->nonce, nonce, nonce_length ); /* We know that nonce size cannot exceed the uint8_t size */ operation->nonce_length = ( uint8_t ) nonce_length; @@ -449,8 +449,8 @@ psa_status_t mbedtls_psa_aead_set_lengths( mbedtls_psa_aead_operation_t if( operation->alg == PSA_ALG_GCM ) { /* Lengths can only be too large for GCM if size_t is bigger than 32 - * bits. Without th - e guard this code will generate warnings on 32bit builds*/ + * bits. Without the guard this code will generate warnings on 32bit + builds */ #if SIZE_MAX > UINT32_MAX if( ( (uint64_t) ad_length ) >> 61 != 0 || ( (uint64_t) plaintext_length ) > 0xFFFFFFFE0ull ) @@ -509,10 +509,10 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { - /* GCM currently requires all the additional data to be passed in in - * one contiguous buffer, so until that is re-done, we have to enforce - * this, as we cannot allocate a buffer to collate multiple calls into. - */ + /* GCM currently requires all the additional data to be passed in + * in one contiguous buffer, so until that is re-done, we have to + * enforce this, as we cannot allocate a buffer to collate multiple + * calls into. */ if( operation->ad_started ) return( PSA_ERROR_NOT_SUPPORTED ); @@ -541,9 +541,7 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t operation->ad_buffer = ( uint8_t * ) mbedtls_calloc( 1, input_length ); if( operation->ad_buffer == NULL ) - { return( PSA_ERROR_INSUFFICIENT_MEMORY ); - } memcpy( operation->ad_buffer, input, input_length ); operation->ad_length = input_length; @@ -667,9 +665,7 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, ( uint8_t * ) mbedtls_calloc(1, input_length ); if( operation->body_buffer == NULL) - { return( PSA_ERROR_INSUFFICIENT_MEMORY ); - } memcpy( operation->body_buffer, input, input_length ); operation->body_length = input_length; @@ -859,9 +855,7 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, temp_buffer = ( uint8_t * ) mbedtls_calloc(1, temp_buffer_size ); if( temp_buffer == NULL) - { return( PSA_ERROR_INSUFFICIENT_MEMORY ); - } ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, operation->body_length, @@ -881,7 +875,7 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, } /* Even if the above operation fails, we no longer need the data */ - mbedtls_free(temp_buffer); + mbedtls_free( temp_buffer ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ From bb8bf6649e4fd09ad044849c242ae8f7d4b266d1 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 19 May 2021 17:29:42 +0100 Subject: [PATCH 044/966] Change function signature indentation Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 102 +++++++++++++++++++------------------- library/psa_crypto_aead.h | 93 +++++++++++++++++----------------- 2 files changed, 100 insertions(+), 95 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 4fb0e3b0f1..0daa3034a1 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -337,13 +337,12 @@ exit: /* Set the key and algorithm for a multipart authenticated encryption * operation. */ -psa_status_t mbedtls_psa_aead_encrypt_setup( mbedtls_psa_aead_operation_t - *operation, - const psa_key_attributes_t - *attributes, - const uint8_t *key_buffer, - size_t key_buffer_size, - psa_algorithm_t alg ) +psa_status_t mbedtls_psa_aead_encrypt_setup( + mbedtls_psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, + size_t key_buffer_size, + psa_algorithm_t alg ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; @@ -358,13 +357,12 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( mbedtls_psa_aead_operation_t /* Set the key and algorithm for a multipart authenticated decryption * operation. */ -psa_status_t mbedtls_psa_aead_decrypt_setup( mbedtls_psa_aead_operation_t - *operation, - const psa_key_attributes_t - *attributes, - const uint8_t *key_buffer, - size_t key_buffer_size, - psa_algorithm_t alg ) +psa_status_t mbedtls_psa_aead_decrypt_setup( + mbedtls_psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, + size_t key_buffer_size, + psa_algorithm_t alg ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; @@ -380,10 +378,10 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( mbedtls_psa_aead_operation_t } /* Set a nonce for the multipart AEAD operation*/ -psa_status_t mbedtls_psa_aead_set_nonce( mbedtls_psa_aead_operation_t - *operation, - const uint8_t *nonce, - size_t nonce_length ) +psa_status_t mbedtls_psa_aead_set_nonce( + mbedtls_psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; @@ -439,10 +437,10 @@ psa_status_t mbedtls_psa_aead_set_nonce( mbedtls_psa_aead_operation_t return( status ); } /* Declare the lengths of the message and additional data for AEAD. */ -psa_status_t mbedtls_psa_aead_set_lengths( mbedtls_psa_aead_operation_t - *operation, - size_t ad_length, - size_t plaintext_length ) +psa_status_t mbedtls_psa_aead_set_lengths( + mbedtls_psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ) { #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) @@ -491,10 +489,10 @@ psa_status_t mbedtls_psa_aead_set_lengths( mbedtls_psa_aead_operation_t } /* Pass additional data to an active multipart AEAD operation. */ -psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t - *operation, - const uint8_t *input, - size_t input_length ) +psa_status_t mbedtls_psa_aead_update_ad( + mbedtls_psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; @@ -574,12 +572,13 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t /* Encrypt or decrypt a message fragment in an active multipart AEAD * operation.*/ -psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, - const uint8_t *input, - size_t input_length, - uint8_t *output, - size_t output_size, - size_t *output_length ) +psa_status_t mbedtls_psa_aead_update( + mbedtls_psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length ) { size_t update_output_length; psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; @@ -719,10 +718,10 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, /* Common checks for both mbedtls_psa_aead_finish() and mbedtls_psa_aead_verify() */ -static psa_status_t mbedtls_psa_aead_finish_checks( mbedtls_psa_aead_operation_t - *operation, - size_t output_size, - size_t tag_size ) +static psa_status_t mbedtls_psa_aead_finish_checks( + mbedtls_psa_aead_operation_t *operation, + size_t output_size, + size_t tag_size ) { size_t finish_output_size; @@ -744,13 +743,14 @@ static psa_status_t mbedtls_psa_aead_finish_checks( mbedtls_psa_aead_operation_t } /* Finish encrypting a message in a multipart AEAD operation. */ -psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, - uint8_t *ciphertext, - size_t ciphertext_size, - size_t *ciphertext_length, - uint8_t *tag, - size_t tag_size, - size_t *tag_length ) +psa_status_t mbedtls_psa_aead_finish( + mbedtls_psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; size_t finish_output_size = 0; @@ -808,12 +808,13 @@ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, /* Finish authenticating and decrypting a message in a multipart AEAD * operation.*/ -psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, - uint8_t *plaintext, - size_t plaintext_size, - size_t *plaintext_length, - const uint8_t *tag, - size_t tag_length ) +psa_status_t mbedtls_psa_aead_verify( + mbedtls_psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; @@ -911,7 +912,8 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, } /* Abort an AEAD operation */ -psa_status_t mbedtls_psa_aead_abort( mbedtls_psa_aead_operation_t *operation ) +psa_status_t mbedtls_psa_aead_abort( + mbedtls_psa_aead_operation_t *operation ) { switch( operation->alg ) { diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index cf6230149d..fcac5cac18 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -185,13 +185,12 @@ psa_status_t mbedtls_psa_aead_decrypt( * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * Failed to allocate memory for key material */ -psa_status_t mbedtls_psa_aead_encrypt_setup(mbedtls_psa_aead_operation_t - *operation, - const psa_key_attributes_t - *attributes, - const uint8_t *key_buffer, - size_t key_buffer_size, - psa_algorithm_t alg); +psa_status_t mbedtls_psa_aead_encrypt_setup( + mbedtls_psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, + size_t key_buffer_size, + psa_algorithm_t alg ); /** Set the key for a multipart authenticated decryption operation. * @@ -230,13 +229,12 @@ psa_status_t mbedtls_psa_aead_encrypt_setup(mbedtls_psa_aead_operation_t * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * Failed to allocate memory for key material */ -psa_status_t mbedtls_psa_aead_decrypt_setup(mbedtls_psa_aead_operation_t - *operation, - const psa_key_attributes_t - *attributes, - const uint8_t *key_buffer, - size_t key_buffer_size, - psa_algorithm_t alg); +psa_status_t mbedtls_psa_aead_decrypt_setup( + mbedtls_psa_aead_operation_t *operation, + const psa_key_attributes_t *attributes, + const uint8_t *key_buffer, + size_t key_buffer_size, + psa_algorithm_t alg ); /** Set the nonce for an authenticated encryption or decryption operation. * @@ -266,9 +264,10 @@ psa_status_t mbedtls_psa_aead_decrypt_setup(mbedtls_psa_aead_operation_t * Algorithm previously set is not supported in this configuration of * the library. */ -psa_status_t mbedtls_psa_aead_set_nonce(mbedtls_psa_aead_operation_t *operation, - const uint8_t *nonce, - size_t nonce_length); +psa_status_t mbedtls_psa_aead_set_nonce( + mbedtls_psa_aead_operation_t *operation, + const uint8_t *nonce, + size_t nonce_length ); /** Declare the lengths of the message and additional data for AEAD. * @@ -307,10 +306,10 @@ psa_status_t mbedtls_psa_aead_set_nonce(mbedtls_psa_aead_operation_t *operation, * Algorithm previously set is not supported in this configuration of * the library. */ -psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t - *operation, - size_t ad_length, - size_t plaintext_length); +psa_status_t mbedtls_psa_aead_set_lengths( + mbedtls_psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ); /** Pass additional data to an active AEAD operation. * @@ -361,9 +360,10 @@ psa_status_t mbedtls_psa_aead_set_lengths(mbedtls_psa_aead_operation_t * Algorithm previously set is not supported in this configuration of * the library. */ -psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, - const uint8_t *input, - size_t input_length); +psa_status_t mbedtls_psa_aead_update_ad( + mbedtls_psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length ); /** Encrypt or decrypt a message fragment in an active AEAD operation. * @@ -437,12 +437,13 @@ psa_status_t mbedtls_psa_aead_update_ad(mbedtls_psa_aead_operation_t *operation, * (CCM only) Unable to allocate memory for the tag or the body */ -psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, - const uint8_t *input, - size_t input_length, - uint8_t *output, - size_t output_size, - size_t *output_length); +psa_status_t mbedtls_psa_aead_update( + mbedtls_psa_aead_operation_t *operation, + const uint8_t *input, + size_t input_length, + uint8_t *output, + size_t output_size, + size_t *output_length ); /** Finish encrypting a message in an AEAD operation. * @@ -521,13 +522,14 @@ psa_status_t mbedtls_psa_aead_update(mbedtls_psa_aead_operation_t *operation, * less than the plaintext length that was previously * specified with mbedtls_psa_aead_set_lengths(). */ -psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, - uint8_t *ciphertext, - size_t ciphertext_size, - size_t *ciphertext_length, - uint8_t *tag, - size_t tag_size, - size_t *tag_length); +psa_status_t mbedtls_psa_aead_finish( + mbedtls_psa_aead_operation_t *operation, + uint8_t *ciphertext, + size_t ciphertext_size, + size_t *ciphertext_length, + uint8_t *tag, + size_t tag_size, + size_t *tag_length ); /** Finish authenticating and decrypting a message in an AEAD operation. * @@ -605,12 +607,13 @@ psa_status_t mbedtls_psa_aead_finish(mbedtls_psa_aead_operation_t *operation, * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * (CCM only) Failed to allocate temporary buffer */ -psa_status_t mbedtls_psa_aead_verify(mbedtls_psa_aead_operation_t *operation, - uint8_t *plaintext, - size_t plaintext_size, - size_t *plaintext_length, - const uint8_t *tag, - size_t tag_length); +psa_status_t mbedtls_psa_aead_verify( + mbedtls_psa_aead_operation_t *operation, + uint8_t *plaintext, + size_t plaintext_size, + size_t *plaintext_length, + const uint8_t *tag, + size_t tag_length ); /** Abort an AEAD operation. * @@ -636,7 +639,7 @@ psa_status_t mbedtls_psa_aead_verify(mbedtls_psa_aead_operation_t *operation, * \retval #PSA_SUCCESS * Success. */ -psa_status_t mbedtls_psa_aead_abort(mbedtls_psa_aead_operation_t *operation); - +psa_status_t mbedtls_psa_aead_abort( + mbedtls_psa_aead_operation_t *operation ); #endif /* PSA_CRYPTO_AEAD */ From cee785cd72d7163042fbf34924836efdd04cf149 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 20 May 2021 14:29:20 +0100 Subject: [PATCH 045/966] Seperate id checks from other state checks Signed-off-by: Paul Elliott --- library/psa_crypto.c | 88 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 19 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 527e44e766..9c7a380d54 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3248,8 +3248,14 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, goto exit; } - if( operation->id || operation->nonce_set || - operation->ad_started || operation->body_started ) + if( operation->id != 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( operation->nonce_set || operation->ad_started || + operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3259,9 +3265,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, key, &slot, PSA_KEY_USAGE_ENCRYPT, alg ); if( status != PSA_SUCCESS ) - { goto exit; - } psa_key_attributes_t attributes = { .core = slot->attr @@ -3272,9 +3276,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, slot->key.bytes, alg ); if( status != PSA_SUCCESS ) - { goto exit; - } operation->key_type = psa_get_key_type( &attributes ); @@ -3310,8 +3312,14 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, goto exit; } - if( operation->id || operation->nonce_set || - operation->ad_started || operation->body_started ) + if( operation->id != 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( operation->nonce_set || operation->ad_started || + operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3359,8 +3367,14 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, *nonce_length = 0; - if( !operation->id || operation->nonce_set || - operation->ad_started || operation->body_started ) + if( operation->id == 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( operation->nonce_set || operation->ad_started || + operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3401,8 +3415,14 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( !operation->id || operation->nonce_set || - operation->ad_started || operation->body_started ) + if( operation->id == 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( operation->nonce_set || operation->ad_started || + operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3428,7 +3448,13 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( !operation->id || operation->lengths_set ) + if( operation->id == 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( operation->lengths_set ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3453,7 +3479,13 @@ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( !operation->id || !operation->nonce_set ) + if( operation->id == 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( !operation->nonce_set ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3485,7 +3517,13 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, *output_length = 0; - if( !operation->id || !operation->nonce_set || !operation->ad_started ) + if( operation->id == 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( !operation->nonce_set || !operation->ad_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3519,8 +3557,14 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, *ciphertext_length = 0; *tag_length = 0; - if( !operation->id || !operation->nonce_set || - !operation->ad_started || !operation->body_started ) + if( operation->id == 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( !operation->nonce_set || !operation->ad_started || + !operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3551,8 +3595,14 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, *plaintext_length = 0; - if( !operation->id || !operation->nonce_set || - !operation->ad_started || !operation->body_started ) + if( operation->id == 0 ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + + if( !operation->nonce_set || !operation->ad_started || + !operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; From ac1b3fd5b6b12f9cf4821ecb493a700c57a696ea Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 20 May 2021 14:33:13 +0100 Subject: [PATCH 046/966] Ensure that key gets unlocked in case of error Signed-off-by: Paul Elliott --- library/psa_crypto.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9c7a380d54..adf3b2b7a8 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3280,14 +3280,12 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, operation->key_type = psa_get_key_type( &attributes ); +exit: + unlock_status = psa_unlock_key_slot( slot ); if( unlock_status != PSA_SUCCESS ) - { status = unlock_status; - } - -exit: if( status == PSA_SUCCESS ) operation->alg = psa_aead_get_base_algorithm( alg ); @@ -3339,15 +3337,18 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, &attributes, slot->key.data, slot->key.bytes, alg ); + if( status != PSA_SUCCESS ) + goto exit; + operation->key_type = psa_get_key_type( &attributes ); +exit: + unlock_status = psa_unlock_key_slot( slot ); if( unlock_status != PSA_SUCCESS ) status = unlock_status; -exit: - if( status == PSA_SUCCESS ) operation->alg = psa_aead_get_base_algorithm( alg ); else From b91da71db1ccb6a28a0a9cec7c769ab73d1d32bf Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 20 May 2021 14:43:47 +0100 Subject: [PATCH 047/966] Remove unrequired initialisation Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index adf3b2b7a8..e97cbaf987 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3364,7 +3364,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, size_t *nonce_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - size_t required_nonce_size = nonce_size; + size_t required_nonce_size; *nonce_length = 0; From ee4ffe00798af7d5364fd7543db593bca4e26cca Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 20 May 2021 17:25:06 +0100 Subject: [PATCH 048/966] Move AEAD length checks to PSA core Signed-off-by: Paul Elliott --- include/psa/crypto_builtin_primitives.h | 6 +-- include/psa/crypto_struct.h | 5 ++- library/psa_crypto.c | 49 +++++++++++++++++++++++++ library/psa_crypto_aead.c | 31 ---------------- 4 files changed, 54 insertions(+), 37 deletions(-) diff --git a/include/psa/crypto_builtin_primitives.h b/include/psa/crypto_builtin_primitives.h index e3903bca50..b28e0d7e2e 100644 --- a/include/psa/crypto_builtin_primitives.h +++ b/include/psa/crypto_builtin_primitives.h @@ -130,7 +130,6 @@ typedef struct psa_algorithm_t alg; psa_key_type_t key_type; - unsigned int lengths_set : 1; unsigned int is_encrypt : 1; unsigned int ad_started : 1; unsigned int body_started : 1; @@ -138,9 +137,6 @@ typedef struct uint8_t tag_length; uint8_t nonce_length; - size_t ad_remaining; - size_t body_remaining; - /* Buffers for AD/data - only required until CCM gets proper multipart support. */ uint8_t *ad_buffer; @@ -172,7 +168,7 @@ typedef struct } mbedtls_psa_aead_operation_t; -#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} +#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} /* * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY. diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 36503f91cf..0f74c5481d 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -165,6 +165,9 @@ struct psa_aead_operation_s psa_algorithm_t alg; psa_key_type_t key_type; + size_t ad_remaining; + size_t body_remaining; + unsigned int nonce_set : 1; unsigned int lengths_set : 1; unsigned int ad_started : 1; @@ -173,7 +176,7 @@ struct psa_aead_operation_s psa_driver_aead_context_t ctx; }; -#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, {0}} +#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} static inline struct psa_aead_operation_s psa_aead_operation_init( void ) { const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT; diff --git a/library/psa_crypto.c b/library/psa_crypto.c index e97cbaf987..c53020a2be 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3467,7 +3467,11 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, exit: if( status == PSA_SUCCESS ) + { + operation->ad_remaining = ad_length; + operation->body_remaining = plaintext_length; operation->lengths_set = 1; + } else psa_aead_abort( operation ); @@ -3492,6 +3496,17 @@ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, goto exit; } + if( operation->lengths_set ) + { + if ( operation->ad_remaining < input_length ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + + operation->ad_remaining -= input_length; + } + status = psa_driver_wrapper_aead_update_ad( operation, input, input_length ); @@ -3530,6 +3545,26 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, goto exit; } + if( operation->lengths_set ) + { + /* Additional data length was supplied, but not all the additional + data was supplied.*/ + if( operation->ad_remaining != 0 ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + + /* Too much data provided. */ + if( operation->body_remaining < input_length ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + + operation->body_remaining -= input_length; + } + status = psa_driver_wrapper_aead_update( operation, input, input_length, output, output_size, output_length ); @@ -3571,6 +3606,13 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, goto exit; } + if( operation->lengths_set && (operation->ad_remaining != 0 || + operation->body_remaining != 0 ) ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + status = psa_driver_wrapper_aead_finish( operation, ciphertext, ciphertext_size, ciphertext_length, @@ -3609,6 +3651,13 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, goto exit; } + if( operation->lengths_set && (operation->ad_remaining != 0 || + operation->body_remaining != 0 ) ) + { + status = PSA_ERROR_BAD_STATE; + goto exit; + } + status = psa_driver_wrapper_aead_verify( operation, plaintext, plaintext_size, plaintext_length, diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 0daa3034a1..bbfc9271ea 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -481,10 +481,6 @@ psa_status_t mbedtls_psa_aead_set_lengths( return ( PSA_ERROR_NOT_SUPPORTED ); } - operation->ad_remaining = ad_length; - operation->body_remaining = plaintext_length; - operation->lengths_set = 1; - return ( PSA_SUCCESS ); } @@ -496,14 +492,6 @@ psa_status_t mbedtls_psa_aead_update_ad( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( operation->lengths_set ) - { - if ( operation->ad_remaining < input_length ) - return( PSA_ERROR_INVALID_ARGUMENT ); - - operation->ad_remaining -= input_length; - } - #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { @@ -590,20 +578,6 @@ psa_status_t mbedtls_psa_aead_update( input_length ) > output_size ) return ( PSA_ERROR_BUFFER_TOO_SMALL ); - if( operation->lengths_set) - { - /* Additional data length was supplied, but not all the additional - data was supplied.*/ - if( operation->ad_remaining != 0 ) - return ( PSA_ERROR_INVALID_ARGUMENT ); - - /* Too much data provided. */ - if( operation->body_remaining < input_length ) - return ( PSA_ERROR_INVALID_ARGUMENT ); - - operation->body_remaining -= input_length; - } - #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { @@ -725,10 +699,6 @@ static psa_status_t mbedtls_psa_aead_finish_checks( { size_t finish_output_size; - if( operation->lengths_set ) - if( operation->ad_remaining != 0 || operation->body_remaining != 0 ) - return( PSA_ERROR_BAD_STATE ); - if( tag_size < operation->tag_length ) return ( PSA_ERROR_BUFFER_TOO_SMALL ); @@ -934,7 +904,6 @@ psa_status_t mbedtls_psa_aead_abort( #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ } - operation->lengths_set = 0; operation->is_encrypt = 0; operation->ad_started = 0; operation->body_started = 0; From 1a98acac1c6a31507f81164ba2b30e6357d6e44e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 20 May 2021 18:24:07 +0100 Subject: [PATCH 049/966] Properly handle GCM's range of nonce sizes Add comment to the effect that we cannot really check nonce size as the GCM spec allows almost arbitrarily large nonces. As a result of this, change the operation nonce over to an allocated buffer to avoid overflow situations. Signed-off-by: Paul Elliott --- include/psa/crypto_builtin_primitives.h | 6 +++--- library/psa_crypto.c | 6 ++++++ library/psa_crypto_aead.c | 18 ++++++++++++++++-- library/psa_crypto_aead.h | 2 ++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/include/psa/crypto_builtin_primitives.h b/include/psa/crypto_builtin_primitives.h index b28e0d7e2e..b67b23ff12 100644 --- a/include/psa/crypto_builtin_primitives.h +++ b/include/psa/crypto_builtin_primitives.h @@ -135,7 +135,6 @@ typedef struct unsigned int body_started : 1; uint8_t tag_length; - uint8_t nonce_length; /* Buffers for AD/data - only required until CCM gets proper multipart support. */ @@ -149,7 +148,8 @@ typedef struct /* buffer to store Nonce - only required until CCM and GCM get proper multipart support. */ - uint8_t nonce[PSA_AEAD_NONCE_MAX_SIZE]; + uint8_t *nonce; + size_t nonce_length; union { @@ -168,7 +168,7 @@ typedef struct } mbedtls_psa_aead_operation_t; -#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}} +#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} /* * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY. diff --git a/library/psa_crypto.c b/library/psa_crypto.c index c53020a2be..fcc22e167e 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3429,6 +3429,12 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, goto exit; } + /* Not checking nonce size here as GCM spec allows almost abitrarily large + * nonces. Please note that we do not generally recommend the usage of + * nonces of greater length than PSA_AEAD_NONCE_MAX_SIZE, as large nonces + * are hashed to a shorter size, which can then lead to collisions if you + encrypt a very large number of messages. */ + status = psa_driver_wrapper_aead_set_nonce( operation, nonce, nonce_length ); diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index bbfc9271ea..10849b2ad4 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -388,11 +388,16 @@ psa_status_t mbedtls_psa_aead_set_nonce( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { + operation->nonce = mbedtls_calloc( 1, nonce_length ); + + if( operation->nonce == NULL ) + return( PSA_ERROR_INSUFFICIENT_MEMORY ); + /* GCM sets nonce once additional data has been supplied */ memcpy( operation->nonce, nonce, nonce_length ); /* We know that nonce size cannot exceed the uint8_t size */ - operation->nonce_length = ( uint8_t ) nonce_length; + operation->nonce_length = nonce_length; status = PSA_SUCCESS; } else @@ -400,12 +405,17 @@ psa_status_t mbedtls_psa_aead_set_nonce( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { + operation->nonce = mbedtls_calloc( 1, nonce_length ); + + if( operation->nonce == NULL ) + return( PSA_ERROR_INSUFFICIENT_MEMORY ); + /* Multipart CCM not supported as yet, so CCM is basically operating in oneshot mode. Store the nonce as we need this later */ memcpy( operation->nonce, nonce, nonce_length ); /* We know that nonce size cannot exceed the uint8_t size */ - operation->nonce_length = ( uint8_t ) nonce_length; + operation->nonce_length = nonce_length; status = PSA_SUCCESS; } else @@ -919,6 +929,10 @@ psa_status_t mbedtls_psa_aead_abort( mbedtls_free( operation->tag_buffer ); operation->tag_buffer = NULL; + mbedtls_free( operation->nonce ); + operation->nonce = NULL; + operation->nonce_length = 0; + return( PSA_SUCCESS ); } diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index fcac5cac18..ef4842e355 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -263,6 +263,8 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( * \retval #PSA_ERROR_NOT_SUPPORTED * Algorithm previously set is not supported in this configuration of * the library. + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * (GCM and CCM only) Unable to allocate buffer for nonce. */ psa_status_t mbedtls_psa_aead_set_nonce( mbedtls_psa_aead_operation_t *operation, From 3dc1c242b426c0ccdd683495d8345ed2395ee976 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 20 May 2021 18:32:57 +0100 Subject: [PATCH 050/966] Move AEAD contexts from primitives to composites Signed-off-by: Paul Elliott --- include/psa/crypto_builtin_composites.h | 56 +++++++++++++++++++ include/psa/crypto_builtin_primitives.h | 55 ------------------ .../psa/crypto_driver_contexts_composites.h | 8 +++ .../psa/crypto_driver_contexts_primitives.h | 8 --- 4 files changed, 64 insertions(+), 63 deletions(-) diff --git a/include/psa/crypto_builtin_composites.h b/include/psa/crypto_builtin_composites.h index 1d11b003e4..b65922b9c2 100644 --- a/include/psa/crypto_builtin_composites.h +++ b/include/psa/crypto_builtin_composites.h @@ -76,6 +76,58 @@ typedef struct #define MBEDTLS_PSA_MAC_OPERATION_INIT {0, {0}} +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) || \ + defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) || \ + defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) +#define MBEDTLS_PSA_BUILTIN_AEAD 1 +#endif + +/* Context structure for the Mbed TLS AEAD implementation. */ +typedef struct +{ + psa_algorithm_t alg; + psa_key_type_t key_type; + + unsigned int is_encrypt : 1; + unsigned int ad_started : 1; + unsigned int body_started : 1; + + uint8_t tag_length; + + /* Buffers for AD/data - only required until CCM gets proper multipart + support. */ + uint8_t *ad_buffer; + size_t ad_length; + + uint8_t *body_buffer; + size_t body_length; + + uint8_t *tag_buffer; + + /* buffer to store Nonce - only required until CCM and GCM get proper + multipart support. */ + uint8_t *nonce; + size_t nonce_length; + + union + { + unsigned dummy; /* Enable easier initializing of the union. */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + mbedtls_ccm_context ccm; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + mbedtls_gcm_context gcm; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + mbedtls_chachapoly_context chachapoly; +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + + } ctx; + +} mbedtls_psa_aead_operation_t; + +#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} + /* * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY. */ @@ -87,6 +139,10 @@ typedef mbedtls_psa_mac_operation_t mbedtls_opaque_test_driver_mac_operation_t; #define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT MBEDTLS_PSA_MAC_OPERATION_INIT #define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT MBEDTLS_PSA_MAC_OPERATION_INIT +typedef mbedtls_psa_aead_operation_t mbedtls_transparent_test_driver_aead_operation_t; + +#define MBEDTLS_TRANSPARENT_TEST_DRIVER_AEAD_OPERATION_INIT MBEDTLS_PSA_AEAD_OPERATION_INIT + #endif /* PSA_CRYPTO_DRIVER_TEST */ #endif /* PSA_CRYPTO_BUILTIN_COMPOSITES_H */ diff --git a/include/psa/crypto_builtin_primitives.h b/include/psa/crypto_builtin_primitives.h index b67b23ff12..75801a1789 100644 --- a/include/psa/crypto_builtin_primitives.h +++ b/include/psa/crypto_builtin_primitives.h @@ -118,58 +118,6 @@ typedef struct { #define MBEDTLS_PSA_CIPHER_OPERATION_INIT {0, 0, 0, {0}} -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) || \ - defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) || \ - defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) -#define MBEDTLS_PSA_BUILTIN_AEAD 1 -#endif - -/* Context structure for the Mbed TLS cipher implementation. */ -typedef struct -{ - psa_algorithm_t alg; - psa_key_type_t key_type; - - unsigned int is_encrypt : 1; - unsigned int ad_started : 1; - unsigned int body_started : 1; - - uint8_t tag_length; - - /* Buffers for AD/data - only required until CCM gets proper multipart - support. */ - uint8_t *ad_buffer; - size_t ad_length; - - uint8_t *body_buffer; - size_t body_length; - - uint8_t *tag_buffer; - - /* buffer to store Nonce - only required until CCM and GCM get proper - multipart support. */ - uint8_t *nonce; - size_t nonce_length; - - union - { - unsigned dummy; /* Enable easier initializing of the union. */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - mbedtls_ccm_context ccm; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - mbedtls_gcm_context gcm; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - mbedtls_chachapoly_context chachapoly; -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ - - } ctx; - -} mbedtls_psa_aead_operation_t; - -#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} - /* * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY. */ @@ -182,9 +130,6 @@ typedef mbedtls_psa_hash_operation_t mbedtls_transparent_test_driver_hash_operat typedef mbedtls_psa_cipher_operation_t mbedtls_transparent_test_driver_cipher_operation_t; -typedef mbedtls_psa_aead_operation_t - mbedtls_transparent_test_driver_aead_operation_t; - typedef struct { unsigned int initialised : 1; mbedtls_transparent_test_driver_cipher_operation_t ctx; diff --git a/include/psa/crypto_driver_contexts_composites.h b/include/psa/crypto_driver_contexts_composites.h index 239fdcb337..957986c22f 100644 --- a/include/psa/crypto_driver_contexts_composites.h +++ b/include/psa/crypto_driver_contexts_composites.h @@ -58,5 +58,13 @@ typedef union { #endif } psa_driver_mac_context_t; +typedef union { + unsigned dummy; /* Make sure this union is always non-empty */ + mbedtls_psa_aead_operation_t mbedtls_ctx; +#if defined(PSA_CRYPTO_DRIVER_TEST) + mbedtls_transparent_test_driver_aead_operation_t transparent_test_driver_ctx; +#endif +} psa_driver_aead_context_t; + #endif /* PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H */ /* End of automatically generated file. */ diff --git a/include/psa/crypto_driver_contexts_primitives.h b/include/psa/crypto_driver_contexts_primitives.h index 4fba9eb030..104d4bdb6d 100644 --- a/include/psa/crypto_driver_contexts_primitives.h +++ b/include/psa/crypto_driver_contexts_primitives.h @@ -65,13 +65,5 @@ typedef union { #endif } psa_driver_cipher_context_t; -typedef union { - unsigned dummy; /* Make sure this union is always non-empty */ - mbedtls_psa_aead_operation_t mbedtls_ctx; -#if defined(PSA_CRYPTO_DRIVER_TEST) - mbedtls_transparent_test_driver_aead_operation_t transparent_test_driver_ctx; -#endif -} psa_driver_aead_context_t; - #endif /* PSA_CRYPTO_DRIVER_CONTEXTS_PRIMITIVES_H */ /* End of automatically generated file. */ From e715f88d9d30e2c2812280f5952339e9dc25b09a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 20 May 2021 21:54:19 +0100 Subject: [PATCH 051/966] Fix key slot being used uninitialised on error Signed-off-by: Paul Elliott --- library/psa_crypto.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index fcc22e167e..5d55e4543d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3240,7 +3240,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; - psa_key_slot_t *slot; + psa_key_slot_t *slot = NULL; if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) { @@ -3282,10 +3282,13 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, exit: - unlock_status = psa_unlock_key_slot( slot ); + if( slot ) + { + unlock_status = psa_unlock_key_slot( slot ); - if( unlock_status != PSA_SUCCESS ) - status = unlock_status; + if( unlock_status != PSA_SUCCESS ) + status = unlock_status; + } if( status == PSA_SUCCESS ) operation->alg = psa_aead_get_base_algorithm( alg ); @@ -3302,7 +3305,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; - psa_key_slot_t *slot; + psa_key_slot_t *slot = NULL; if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) { @@ -3344,10 +3347,13 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, exit: - unlock_status = psa_unlock_key_slot( slot ); + if( slot ) + { + unlock_status = psa_unlock_key_slot( slot ); - if( unlock_status != PSA_SUCCESS ) - status = unlock_status; + if( unlock_status != PSA_SUCCESS ) + status = unlock_status; + } if( status == PSA_SUCCESS ) operation->alg = psa_aead_get_base_algorithm( alg ); From 60aa203e30b0ae13bfe2d1aa074e396199d71fc8 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 20 May 2021 18:57:02 +0100 Subject: [PATCH 052/966] Remove temporary AEAD CCM implementation Signed-off-by: Paul Elliott --- include/mbedtls/config.h | 8 -- library/ccm.c | 2 - library/psa_crypto_aead.c | 160 ++++++------------------ programs/test/query_config.c | 8 -- scripts/config.py | 1 - tests/suites/test_suite_psa_crypto.data | 112 ----------------- 6 files changed, 35 insertions(+), 256 deletions(-) diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index 6cb05e4712..a4479d79ff 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -3756,14 +3756,6 @@ */ //#define MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED -/** - * Internal define that removes the zeroization of the output when decrypting - * CCM and the tag check fails. This is for internal use only, and was added so - * that PSA multipart CCM could be implmented. This option will be removed at - * some point in the future when proper CCM multipart support is implemented. - * Use at own risk. - */ -//#define MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL /* \} name SECTION: Customisation configuration options */ /* Target and application specific configurations diff --git a/library/ccm.c b/library/ccm.c index d52e7b0797..424ee77b69 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -386,9 +386,7 @@ int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, if( diff != 0 ) { -#ifndef MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL mbedtls_platform_zeroize( output, length ); -#endif return( MBEDTLS_ERR_CCM_AUTH_FAILED ); } diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 10849b2ad4..fb86775e51 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -346,6 +346,13 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + return ( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ + status = psa_aead_setup( operation, attributes, key_buffer, key_buffer_size, alg ); @@ -366,7 +373,12 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - (void) key_buffer_size; + #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + return ( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ status = psa_aead_setup( operation, attributes, key_buffer, key_buffer_size, alg ); @@ -405,18 +417,10 @@ psa_status_t mbedtls_psa_aead_set_nonce( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - operation->nonce = mbedtls_calloc( 1, nonce_length ); + ( void ) nonce; + ( void ) nonce_length; - if( operation->nonce == NULL ) - return( PSA_ERROR_INSUFFICIENT_MEMORY ); - - /* Multipart CCM not supported as yet, so CCM is basically operating - in oneshot mode. Store the nonce as we need this later */ - memcpy( operation->nonce, nonce, nonce_length ); - - /* We know that nonce size cannot exceed the uint8_t size */ - operation->nonce_length = nonce_length; - status = PSA_SUCCESS; + return ( PSA_ERROR_NOT_SUPPORTED ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -527,21 +531,10 @@ psa_status_t mbedtls_psa_aead_update_ad( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - /* CCM requires all additional data to be passed in in one go at the - minute, as we are basically operating in oneshot mode. */ - if( operation->ad_started ) - return( PSA_ERROR_NOT_SUPPORTED ); + (void) input; + (void) input_length; - /* Save the additional data for later, this will be passed in - when we have the body. */ - operation->ad_buffer = ( uint8_t * ) mbedtls_calloc( 1, input_length ); - - if( operation->ad_buffer == NULL ) - return( PSA_ERROR_INSUFFICIENT_MEMORY ); - - memcpy( operation->ad_buffer, input, input_length ); - operation->ad_length = input_length; - status = PSA_SUCCESS; + return ( PSA_ERROR_NOT_SUPPORTED ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -580,7 +573,6 @@ psa_status_t mbedtls_psa_aead_update( { size_t update_output_length; psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; update_output_length = input_length; @@ -609,67 +601,10 @@ psa_status_t mbedtls_psa_aead_update( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - /* CCM does not support multipart yet, so all the input has to be - passed in in one go. */ - if( operation->body_started ) - return( PSA_ERROR_NOT_SUPPORTED ); + (void) input; + (void) input_length; - /* Need to store tag for Finish() / Verify() */ - operation->tag_buffer = - ( uint8_t * ) mbedtls_calloc( 1, operation->tag_length ); - - if( operation->tag_buffer == NULL) - { - return( PSA_ERROR_INSUFFICIENT_MEMORY ); - } - - if( operation->is_encrypt ) - { - /* Perform oneshot CCM encryption with additional data already - stored, as CCM does not support multipart yet.*/ - status = mbedtls_to_psa_error( - mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm, - input_length, - operation->nonce, - operation->nonce_length, - operation->ad_buffer, - operation->ad_length, - input, - output, - operation->tag_buffer, - operation->tag_length ) ); - - } - else - { - /* Need to back up the body data so we can do this again - later.*/ - operation->body_buffer = - ( uint8_t * ) mbedtls_calloc(1, input_length ); - - if( operation->body_buffer == NULL) - return( PSA_ERROR_INSUFFICIENT_MEMORY ); - - memcpy( operation->body_buffer, input, input_length ); - operation->body_length = input_length; - - /* this will fail, as the tag is clearly false, but will - write the decrypted data to the output buffer.*/ - ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, - input_length, - operation->nonce, - operation->nonce_length, - operation->ad_buffer, - operation->ad_length, - input, output, - operation->tag_buffer, - operation->tag_length ); - - if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) - status = PSA_SUCCESS; - else - status = mbedtls_to_psa_error( ret ); - } + return ( PSA_ERROR_NOT_SUPPORTED ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -752,10 +687,14 @@ psa_status_t mbedtls_psa_aead_finish( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - /* Copy the previously generated tag into place */ - memcpy( tag, operation->tag_buffer, operation->tag_length ); + ( void ) ciphertext; + ( void ) ciphertext_size; + ( void ) ciphertext_length; + ( void ) tag; + ( void ) tag_size; + ( void ) tag_length; - status = PSA_SUCCESS; + return ( PSA_ERROR_NOT_SUPPORTED ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -797,10 +736,6 @@ psa_status_t mbedtls_psa_aead_verify( size_t tag_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - - uint8_t * temp_buffer; - size_t temp_buffer_size; size_t finish_output_size = 0; @@ -825,38 +760,13 @@ psa_status_t mbedtls_psa_aead_verify( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - /* Perform oneshot CCM decryption *again*, as its the - * only way to get the tag, but this time throw away the - results, as verify cannot write that much data. */ - temp_buffer_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type, - operation->alg, - operation->body_length - ); + ( void ) plaintext; + ( void ) plaintext_size; + ( void ) plaintext_length; + ( void ) tag; + ( void ) tag_length; - temp_buffer = ( uint8_t * ) mbedtls_calloc(1, temp_buffer_size ); - - if( temp_buffer == NULL) - return( PSA_ERROR_INSUFFICIENT_MEMORY ); - - ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, - operation->body_length, - operation->nonce, - operation->nonce_length, - operation->ad_buffer, - operation->ad_length, - operation->body_buffer, - temp_buffer, tag, tag_length ); - - if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED ) - status = PSA_ERROR_INVALID_SIGNATURE; - else - { - status = mbedtls_to_psa_error( ret ); - do_tag_check = 0; - } - - /* Even if the above operation fails, we no longer need the data */ - mbedtls_free( temp_buffer ); + return ( PSA_ERROR_NOT_SUPPORTED ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ diff --git a/programs/test/query_config.c b/programs/test/query_config.c index 647279d687..450e2fbbf0 100644 --- a/programs/test/query_config.c +++ b/programs/test/query_config.c @@ -2723,14 +2723,6 @@ int query_config( const char *config ) } #endif /* MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED */ -#if defined(MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL) - if( strcmp( "MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL", config ) == 0 ) - { - MACRO_EXPANSION_TO_STR( MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL ); - return( 0 ); - } -#endif /* MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL */ - /* If the symbol is not found, return an error */ return( 1 ); } diff --git a/scripts/config.py b/scripts/config.py index f9f06053d3..a77ead0544 100755 --- a/scripts/config.py +++ b/scripts/config.py @@ -197,7 +197,6 @@ EXCLUDE_FROM_FULL = frozenset([ 'MBEDTLS_TEST_NULL_ENTROPY', # removes a feature 'MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION', # influences the use of X.509 in TLS 'MBEDTLS_X509_REMOVE_INFO', # removes a feature - 'MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL', # lowers security of CCM ]) def is_seamless_alt(name): diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 177d688e3e..c2e80e18d5 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2062,118 +2062,6 @@ PSA AEAD encrypt/decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C aead_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":"":PSA_ERROR_NOT_SUPPORTED -PSA Multipart AEAD encrypt/decrypt: AES-CCM, 19 bytes #1 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_CCM:"000102030405060708090A0B":"000102030405060708090A0B":-1:"0C0D0E0F101112131415161718191A1B1C1D1E":-1:PSA_SUCCESS - -PSA Multipart AEAD encrypt/decrypt: AES-CCM, 19 bytes #2 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"000102030405060708090A0B":"EC46BB63B02520C33C49FD70":-1:"B96B49E21D621741632875DB7F6C9243D2D7C2":-1:PSA_SUCCESS - -PSA Multipart AEAD encrypt/decrypt: DES-CCM not supported -depends_on:MBEDTLS_DES_C:MBEDTLS_CCM_C:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_DES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"000102030405060708090A0B":"EC46BB63B02520C33C49FD70":-1:"B96B49E21D621741632875DB7F6C9243D2D7C2":-1:PSA_ERROR_NOT_SUPPORTED - -PSA Multipart AEAD encrypt: AES-CCM, 23 bytes -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"00412B4EA9CDBE3C9696766CFA":"0BE1A88BACE018B1":-1:"08E8CF97D820EA258460E96AD9CF5289054D895CEAC47C":-1:"4CB97F86A2A4689A877947AB8091EF5386A6FFBDD080F8120333D1FCB691F3406CBF531F83A4D8" - -PSA Multipart AEAD encrypt: AES-CCM, 24 bytes -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9" - -PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=4 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 4 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6643b4f39" - -PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=6 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 6 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b63fdffcd729bc" - -PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=8 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b64cf2c3bf5f220776" - -PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=10 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 10 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b69613343621327defd18e" - -PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=12 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 12 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b69a2e5d8faee3138fa5cf9846" - -PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=14 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 14 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6c99af01cdb6aa76df73c8646c27f" - -PSA Multipart AEAD encrypt: AES-CCM, 24 bytes, T=16 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 16 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9" - -PSA Multipart AEAD decrypt: AES-CCM, 39 bytes -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CCM:"00412B4EA9CDBE3C9696766CFA":"0BE1A88BACE018B1":-1:"4CB97F86A2A4689A877947AB8091EF5386A6FFBDD080F8120333D1FCB691F3406CBF531F83A4D8":-1:"08E8CF97D820EA258460E96AD9CF5289054D895CEAC47C":PSA_SUCCESS - -PSA Multipart AEAD decrypt, AES-CCM, 40 bytes -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS - -PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=4 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 4 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6643b4f39":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS - -PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=6 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 6 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b63fdffcd729bc":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS - -PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=8 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b64cf2c3bf5f220776":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS - -PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=10 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 10 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b69613343621327defd18e":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS - -PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=12 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 12 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b69a2e5d8faee3138fa5cf9846":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS - -PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=14 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 14 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6c99af01cdb6aa76df73c8646c27f":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS - -PSA Multipart AEAD decrypt: AES-CCM, 24 bytes, T=16 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 16 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_SUCCESS - -PSA Multipart AEAD decrypt: AES-CCM, invalid signature -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26d56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6d80e8bf80f4a46cab06d4313f0db9be9":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_SIGNATURE - -PSA Multipart AEAD decrypt: AES-CCM, invalid signature, T=4 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 4 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6643b4f38":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_SIGNATURE - -PSA Multipart AEAD decrypt: AES-CCM, T=4, tag is truncated tag for T=16 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 4 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_SIGNATURE - -PSA Multipart AEAD decrypt: AES-CCM, invalid tag length 0 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT - -PSA Multipart AEAD decrypt: AES-CCM, invalid tag length 2 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT - -PSA Multipart AEAD decrypt: AES-CCM, invalid tag length 15 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 15 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT - -PSA Multipart AEAD decrypt: AES-CCM, invalid tag length 18 -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_INTERNAL_CCM_NO_ZEROIZE_ON_TAG_FAIL -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT - PSA Multipart AEAD encrypt/decrypt, AES-GCM, 19 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":-1:"0C0D0E0F101112131415161718191A1B1C1D1E":-1:PSA_SUCCESS From e95259f833f9580990e6d210b5e591f7cf72d9f3 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 21 May 2021 17:09:21 +0100 Subject: [PATCH 053/966] Remove some CCM leftovers Signed-off-by: Paul Elliott --- include/psa/crypto_builtin_composites.h | 15 +---- library/psa_crypto_aead.c | 76 ++----------------------- 2 files changed, 7 insertions(+), 84 deletions(-) diff --git a/include/psa/crypto_builtin_composites.h b/include/psa/crypto_builtin_composites.h index b65922b9c2..ff8e148fdb 100644 --- a/include/psa/crypto_builtin_composites.h +++ b/include/psa/crypto_builtin_composites.h @@ -93,19 +93,10 @@ typedef struct unsigned int body_started : 1; uint8_t tag_length; - - /* Buffers for AD/data - only required until CCM gets proper multipart - support. */ - uint8_t *ad_buffer; - size_t ad_length; - - uint8_t *body_buffer; - size_t body_length; - uint8_t *tag_buffer; - /* buffer to store Nonce - only required until CCM and GCM get proper - multipart support. */ + /* Buffer to store Nonce - only required until CCM and GCM get proper + * multipart support.*/ uint8_t *nonce; size_t nonce_length; @@ -126,7 +117,7 @@ typedef struct } mbedtls_psa_aead_operation_t; -#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} +#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} /* * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY. diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index fb86775e51..d585c59f65 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -349,7 +349,7 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - return ( PSA_ERROR_NOT_SUPPORTED ); + return( PSA_ERROR_NOT_SUPPORTED ); } #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -373,10 +373,10 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - return ( PSA_ERROR_NOT_SUPPORTED ); + return( PSA_ERROR_NOT_SUPPORTED ); } #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -408,22 +408,11 @@ psa_status_t mbedtls_psa_aead_set_nonce( /* GCM sets nonce once additional data has been supplied */ memcpy( operation->nonce, nonce, nonce_length ); - /* We know that nonce size cannot exceed the uint8_t size */ operation->nonce_length = nonce_length; status = PSA_SUCCESS; } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - ( void ) nonce; - ( void ) nonce_length; - - return ( PSA_ERROR_NOT_SUPPORTED ); - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { @@ -462,7 +451,7 @@ psa_status_t mbedtls_psa_aead_set_lengths( { /* Lengths can only be too large for GCM if size_t is bigger than 32 * bits. Without the guard this code will generate warnings on 32bit - builds */ + * builds */ #if SIZE_MAX > UINT32_MAX if( ( (uint64_t) ad_length ) >> 61 != 0 || ( (uint64_t) plaintext_length ) > 0xFFFFFFFE0ull ) @@ -528,16 +517,6 @@ psa_status_t mbedtls_psa_aead_update_ad( } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - (void) input; - (void) input_length; - - return ( PSA_ERROR_NOT_SUPPORTED ); - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { @@ -598,16 +577,6 @@ psa_status_t mbedtls_psa_aead_update( } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - (void) input; - (void) input_length; - - return ( PSA_ERROR_NOT_SUPPORTED ); - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { @@ -684,20 +653,6 @@ psa_status_t mbedtls_psa_aead_finish( tag_size ) ); else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - ( void ) ciphertext; - ( void ) ciphertext_size; - ( void ) ciphertext_length; - ( void ) tag; - ( void ) tag_size; - ( void ) tag_length; - - return ( PSA_ERROR_NOT_SUPPORTED ); - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) status = mbedtls_to_psa_error( @@ -736,9 +691,7 @@ psa_status_t mbedtls_psa_aead_verify( size_t tag_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - size_t finish_output_size = 0; - int do_tag_check = 1; uint8_t check_tag[PSA_AEAD_TAG_MAX_SIZE]; @@ -757,19 +710,6 @@ psa_status_t mbedtls_psa_aead_verify( operation->tag_length ) ); else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - ( void ) plaintext; - ( void ) plaintext_size; - ( void ) plaintext_length; - ( void ) tag; - ( void ) tag_length; - - return ( PSA_ERROR_NOT_SUPPORTED ); - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) // call finish to get the tag for comparison. @@ -828,14 +768,6 @@ psa_status_t mbedtls_psa_aead_abort( operation->ad_started = 0; operation->body_started = 0; - mbedtls_free( operation->ad_buffer ); - operation->ad_buffer = NULL; - operation->ad_length = 0; - - mbedtls_free( operation->body_buffer ); - operation->body_buffer = NULL; - operation->body_length = 0; - mbedtls_free( operation->tag_buffer ); operation->tag_buffer = NULL; From 6981fbcf10010dd6018221782ca2b8b2303b6c28 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 21 May 2021 17:13:50 +0100 Subject: [PATCH 054/966] Remove unneccessary guard for key unlock Also make sure failure is not hidden by key unlock failure Signed-off-by: Paul Elliott --- library/psa_crypto.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 5d55e4543d..14ef6e576c 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3282,13 +3282,10 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, exit: - if( slot ) - { - unlock_status = psa_unlock_key_slot( slot ); + unlock_status = psa_unlock_key_slot( slot ); - if( unlock_status != PSA_SUCCESS ) - status = unlock_status; - } + if( status == PSA_SUCCESS ) + status = unlock_status; if( status == PSA_SUCCESS ) operation->alg = psa_aead_get_base_algorithm( alg ); @@ -3320,6 +3317,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, } if( operation->nonce_set || operation->ad_started || + operation->body_started ) { status = PSA_ERROR_BAD_STATE; @@ -3347,13 +3345,10 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, exit: - if( slot ) - { - unlock_status = psa_unlock_key_slot( slot ); + unlock_status = psa_unlock_key_slot( slot ); - if( unlock_status != PSA_SUCCESS ) - status = unlock_status; - } + if( status == PSA_SUCCESS ) + status = unlock_status; if( status == PSA_SUCCESS ) operation->alg = psa_aead_get_base_algorithm( alg ); From 6eb959854b4418a5b37e8e193099c34eb079b2e4 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 21 May 2021 17:41:41 +0100 Subject: [PATCH 055/966] Improve state logic Signed-off-by: Paul Elliott --- library/psa_crypto.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 14ef6e576c..fb74a0d852 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3254,8 +3254,8 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, goto exit; } - if( operation->nonce_set || operation->ad_started || - operation->body_started ) + if( operation->nonce_set || operation->lengths_set || + operation->ad_started || operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3316,9 +3316,8 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, goto exit; } - if( operation->nonce_set || operation->ad_started || - - operation->body_started ) + if( operation->nonce_set || operation->lengths_set || + operation->ad_started || operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3375,8 +3374,8 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, goto exit; } - if( operation->nonce_set || operation->ad_started || - operation->body_started ) + if( operation->nonce_set || operation->lengths_set || + operation->ad_started || operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3430,11 +3429,11 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, goto exit; } - /* Not checking nonce size here as GCM spec allows almost abitrarily large - * nonces. Please note that we do not generally recommend the usage of - * nonces of greater length than PSA_AEAD_NONCE_MAX_SIZE, as large nonces - * are hashed to a shorter size, which can then lead to collisions if you - encrypt a very large number of messages. */ + /* Not checking nonce size here as GCM spec allows almost arbitrarily + * large nonces. Please note that we do not generally recommend the usage + * of nonces of greater length than PSA_AEAD_NONCE_MAX_SIZE, as large + * nonces are hashed to a shorter size, which can then lead to collisions + * if you encrypt a very large number of messages.*/ status = psa_driver_wrapper_aead_set_nonce( operation, nonce, nonce_length ); @@ -3462,7 +3461,8 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, goto exit; } - if( operation->lengths_set ) + if( operation->lengths_set || operation->ad_started || + operation->body_started) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3497,7 +3497,7 @@ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, goto exit; } - if( !operation->nonce_set ) + if( !operation->nonce_set || operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3505,7 +3505,7 @@ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, if( operation->lengths_set ) { - if ( operation->ad_remaining < input_length ) + if( operation->ad_remaining < input_length ) { status = PSA_ERROR_INVALID_ARGUMENT; goto exit; @@ -3546,7 +3546,7 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, goto exit; } - if( !operation->nonce_set || !operation->ad_started ) + if( !operation->nonce_set ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3606,8 +3606,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, goto exit; } - if( !operation->nonce_set || !operation->ad_started || - !operation->body_started ) + if( !operation->nonce_set ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3616,7 +3615,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, if( operation->lengths_set && (operation->ad_remaining != 0 || operation->body_remaining != 0 ) ) { - status = PSA_ERROR_BAD_STATE; + status = PSA_ERROR_INVALID_ARGUMENT; goto exit; } @@ -3651,8 +3650,7 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, goto exit; } - if( !operation->nonce_set || !operation->ad_started || - !operation->body_started ) + if( !operation->nonce_set ) { status = PSA_ERROR_BAD_STATE; goto exit; From f47b0957ab71a44ebb8a3430bab7a033b2276421 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 21 May 2021 18:02:33 +0100 Subject: [PATCH 056/966] Set tag to 'impossible' value on failure to encrypt Signed-off-by: Paul Elliott --- library/psa_crypto.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index fb74a0d852..0b64781760 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3626,6 +3626,11 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, exit: + /* In case the operation fails and the user fails to check for failure or + * the zero tag size, make sure the tag is set to something impossible. */ + if( status != PSA_SUCCESS ) + memset(tag, '!', tag_size); + psa_aead_abort( operation ); return( status ); From 3a16e014f209d754586d3fac23f9856830a1a4e9 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 21 May 2021 18:03:15 +0100 Subject: [PATCH 057/966] Ensure tag lengths match in verification Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index d585c59f65..0e7ca63c5d 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -733,8 +733,8 @@ psa_status_t mbedtls_psa_aead_verify( { *plaintext_length = finish_output_size; - if( do_tag_check && - mbedtls_psa_safer_memcmp(tag, check_tag, tag_length) != 0 ) + if( do_tag_check && ( tag_length != operation->tag_length || + mbedtls_psa_safer_memcmp(tag, check_tag, tag_length) != 0 ) ) status = PSA_ERROR_INVALID_SIGNATURE; } From 741beb114781ac3ecfa753fa78d7b8106b5d1c54 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 21 May 2021 18:48:30 +0100 Subject: [PATCH 058/966] Improve Changelog Signed-off-by: Paul Elliott --- ChangeLog.d/add_psa_m_aead.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog.d/add_psa_m_aead.txt b/ChangeLog.d/add_psa_m_aead.txt index d5c0a48c2f..378e9c12d5 100644 --- a/ChangeLog.d/add_psa_m_aead.txt +++ b/ChangeLog.d/add_psa_m_aead.txt @@ -1,3 +1,4 @@ Features - * Implemented the multipart AEAD API within the PSA Crypto API, along with - tests in the PSA Crypto test suite, and transparent driver wrappers. + * Added multipart AEAD API to the PSA Crypto API + * Added MbedTLS internal implementations of the PSA Crypto multipart AEAD API + supporting PolyChaCha and GCM. CCM is not as yet supported. From c40bc1e406eb67b31752a9586e49b79e4211ce48 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 21 May 2021 18:58:12 +0100 Subject: [PATCH 059/966] Fix Changelog typo Signed-off-by: Paul Elliott --- ChangeLog.d/add_psa_m_aead.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.d/add_psa_m_aead.txt b/ChangeLog.d/add_psa_m_aead.txt index 378e9c12d5..3ae58095bd 100644 --- a/ChangeLog.d/add_psa_m_aead.txt +++ b/ChangeLog.d/add_psa_m_aead.txt @@ -1,4 +1,4 @@ Features * Added multipart AEAD API to the PSA Crypto API * Added MbedTLS internal implementations of the PSA Crypto multipart AEAD API - supporting PolyChaCha and GCM. CCM is not as yet supported. + supporting ChaChaPoly and GCM. CCM is not as yet supported. From 83f09ef056b4b21a79de0835077545ae0b0bb5c8 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 21 May 2021 19:28:26 +0100 Subject: [PATCH 060/966] Proper multipart AEAD GCM Implementation Signed-off-by: Paul Elliott --- include/psa/crypto_builtin_composites.h | 10 +--- library/psa_crypto_aead.c | 80 +++++++------------------ 2 files changed, 21 insertions(+), 69 deletions(-) diff --git a/include/psa/crypto_builtin_composites.h b/include/psa/crypto_builtin_composites.h index ff8e148fdb..7d8bc1a8fd 100644 --- a/include/psa/crypto_builtin_composites.h +++ b/include/psa/crypto_builtin_composites.h @@ -89,16 +89,8 @@ typedef struct psa_key_type_t key_type; unsigned int is_encrypt : 1; - unsigned int ad_started : 1; - unsigned int body_started : 1; uint8_t tag_length; - uint8_t *tag_buffer; - - /* Buffer to store Nonce - only required until CCM and GCM get proper - * multipart support.*/ - uint8_t *nonce; - size_t nonce_length; union { @@ -117,7 +109,7 @@ typedef struct } mbedtls_psa_aead_operation_t; -#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} +#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, {0}} /* * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY. diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 0e7ca63c5d..1491b35973 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -400,16 +400,12 @@ psa_status_t mbedtls_psa_aead_set_nonce( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { - operation->nonce = mbedtls_calloc( 1, nonce_length ); - - if( operation->nonce == NULL ) - return( PSA_ERROR_INSUFFICIENT_MEMORY ); - - /* GCM sets nonce once additional data has been supplied */ - memcpy( operation->nonce, nonce, nonce_length ); - - operation->nonce_length = nonce_length; - status = PSA_SUCCESS; + status = mbedtls_to_psa_error( + mbedtls_gcm_starts( &operation->ctx.gcm, + operation->is_encrypt ? + MBEDTLS_GCM_ENCRYPT : MBEDTLS_GCM_DECRYPT, + nonce, + nonce_length ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ @@ -498,22 +494,8 @@ psa_status_t mbedtls_psa_aead_update_ad( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { - /* GCM currently requires all the additional data to be passed in - * in one contiguous buffer, so until that is re-done, we have to - * enforce this, as we cannot allocate a buffer to collate multiple - * calls into. */ - if( operation->ad_started ) - return( PSA_ERROR_NOT_SUPPORTED ); - status = mbedtls_to_psa_error( - mbedtls_gcm_starts( &operation->ctx.gcm, - operation->is_encrypt ? - MBEDTLS_GCM_ENCRYPT : MBEDTLS_GCM_DECRYPT, - operation->nonce, - operation->nonce_length, - input, - input_length ) ); - + mbedtls_gcm_update_ad( &operation->ctx.gcm, input, input_length ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ @@ -534,9 +516,6 @@ psa_status_t mbedtls_psa_aead_update_ad( return ( PSA_ERROR_NOT_SUPPORTED ); } - if( status == PSA_SUCCESS ) - operation->ad_started = 1; - return ( status ); } @@ -562,18 +541,11 @@ psa_status_t mbedtls_psa_aead_update( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { - /* For the time being set the requirement that all of the body data - * must be passed in in one update, rather than deal with the complexity - * of non block size aligned updates. This will be fixed in 3.0 when - we can change the signature of the GCM multipart functions */ - if( operation->body_started ) - return( PSA_ERROR_NOT_SUPPORTED ); - - - status = mbedtls_to_psa_error( mbedtls_gcm_update( &operation->ctx.gcm, - input_length, - input, - output ) ); + status = mbedtls_to_psa_error( + mbedtls_gcm_update( &operation->ctx.gcm, + input, input_length, + output, output_size, + &update_output_length ) ); } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ @@ -596,10 +568,7 @@ psa_status_t mbedtls_psa_aead_update( } if( status == PSA_SUCCESS ) - { *output_length = update_output_length; - operation->body_started = 1; - } return( status ); } @@ -647,17 +616,17 @@ psa_status_t mbedtls_psa_aead_finish( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) - /* We will need to do final GCM pass in here when multipart is done. */ - status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, - tag, - tag_size ) ); + status = mbedtls_to_psa_error( + mbedtls_gcm_finish( &operation->ctx.gcm, + ciphertext, ciphertext_size, + tag, tag_size ) ); else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) status = mbedtls_to_psa_error( - mbedtls_chachapoly_finish( &operation->ctx.chachapoly, - tag ) ); + mbedtls_chachapoly_finish( &operation->ctx.chachapoly, + tag ) ); else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { @@ -706,8 +675,8 @@ psa_status_t mbedtls_psa_aead_verify( /* Call finish to get the tag for comparison */ status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, - check_tag, - operation->tag_length ) ); + plaintext, plaintext_size, + check_tag, operation->tag_length ) ); else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) @@ -765,15 +734,6 @@ psa_status_t mbedtls_psa_aead_abort( } operation->is_encrypt = 0; - operation->ad_started = 0; - operation->body_started = 0; - - mbedtls_free( operation->tag_buffer ); - operation->tag_buffer = NULL; - - mbedtls_free( operation->nonce ); - operation->nonce = NULL; - operation->nonce_length = 0; return( PSA_SUCCESS ); } From 40ef3a945490550a5abaaad546ca4c88bde592fb Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 25 May 2021 15:48:09 +0100 Subject: [PATCH 061/966] Fix state logic and return codes Signed-off-by: Paul Elliott --- library/psa_crypto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 39a6b72577..e824123466 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3555,8 +3555,8 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, goto exit; } - if( operation->nonce_set || operation->lengths_set || - operation->ad_started || operation->body_started ) + if( operation->nonce_set || operation->ad_started || + operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3845,7 +3845,7 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, if( operation->lengths_set && (operation->ad_remaining != 0 || operation->body_remaining != 0 ) ) { - status = PSA_ERROR_BAD_STATE; + status = PSA_ERROR_INVALID_ARGUMENT; goto exit; } From bc94978d8cbe0d3aa34ab6a4647fa784f973733a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 3 Jun 2021 15:29:00 +0100 Subject: [PATCH 062/966] Add missing unused arguments No algorithm defined case generally doesn't use the operation. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 1491b35973..3b8fdc8b6e 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -397,7 +397,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { status = mbedtls_to_psa_error( @@ -427,6 +427,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { + ( void ) operation; ( void ) nonce; ( void ) nonce_length; @@ -474,6 +475,7 @@ psa_status_t mbedtls_psa_aead_set_lengths( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { + ( void ) operation; ( void ) ad_length; ( void ) plaintext_length; @@ -510,8 +512,9 @@ psa_status_t mbedtls_psa_aead_update_ad( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { - (void) input; - (void) input_length; + ( void ) operation; + ( void ) input; + ( void ) input_length; return ( PSA_ERROR_NOT_SUPPORTED ); } @@ -561,8 +564,8 @@ psa_status_t mbedtls_psa_aead_update( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { - (void) input; - (void) input_length; + ( void ) input; + ( void ) input_length; return ( PSA_ERROR_NOT_SUPPORTED ); } From 1c8de15490ee0de8a27935fc0781b4df942a7b8c Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 3 Jun 2021 15:54:00 +0100 Subject: [PATCH 063/966] Update documentation to tally with recent changes Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 57 ++------------------------------------- 1 file changed, 2 insertions(+), 55 deletions(-) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index ef4842e355..50644c0999 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -181,7 +181,7 @@ psa_status_t mbedtls_psa_aead_decrypt( * \retval #PSA_ERROR_INVALID_ARGUMENT * \p key is not compatible with \p alg. * \retval #PSA_ERROR_NOT_SUPPORTED - * \p alg is not supported or is not an AEAD algorithm. + * \p alg is not supported. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * Failed to allocate memory for key material */ @@ -225,7 +225,7 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( * * \retval #PSA_ERROR_INVALID_ARGUMENT * \p key is not compatible with \p alg. * \retval #PSA_ERROR_NOT_SUPPORTED - * \p alg is not supported or is not an AEAD algorithm. + * \p alg is not supported. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * Failed to allocate memory for key material */ @@ -263,8 +263,6 @@ psa_status_t mbedtls_psa_aead_decrypt_setup( * \retval #PSA_ERROR_NOT_SUPPORTED * Algorithm previously set is not supported in this configuration of * the library. - * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * (GCM and CCM only) Unable to allocate buffer for nonce. */ psa_status_t mbedtls_psa_aead_set_nonce( mbedtls_psa_aead_operation_t *operation, @@ -289,7 +287,6 @@ psa_status_t mbedtls_psa_aead_set_nonce( * - For #PSA_ALG_CCM, calling this function is required. * - For the other AEAD algorithms defined in this specification, calling * this function is not required. - * - For vendor-defined algorithm, refer to the vendor documentation. * * If this function returns an error status, the PSA core calls * mbedtls_psa_aead_abort(). @@ -341,9 +338,6 @@ psa_status_t mbedtls_psa_aead_set_lengths( * to undo any action that depends on the input if * mbedtls_psa_aead_verify() returns an error status. * - * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire - * additional data to be passed in in one go, i.e. - * mbedtls_psa_aead_update_ad() can only be called once. * * \param[in,out] operation Active AEAD operation. * \param[in] input Buffer containing the fragment of @@ -352,12 +346,6 @@ psa_status_t mbedtls_psa_aead_set_lengths( * * \retval #PSA_SUCCESS * Success. - * \retval #PSA_ERROR_INVALID_ARGUMENT - * The total input length overflows the additional data length that - * was previously specified with mbedtls_psa_aead_set_lengths(). - * \retval #PSA_ERROR_NOT_SUPPORTED - * (For GCM / CCM) PSA core attempted to call mbedtls_psa_update_ad() - * more than once. * \retval #PSA_ERROR_NOT_SUPPORTED * Algorithm previously set is not supported in this configuration of * the library. @@ -392,10 +380,6 @@ psa_status_t mbedtls_psa_aead_update_ad( * mbedtls_psa_aead_verify() provides sufficient input. The amount of data that * can be delayed in this way is bounded by #PSA_AEAD_UPDATE_OUTPUT_SIZE. * - * \note For the time being #PSA_ALG_CCM and #PSA_ALG_GCM require the entire - * data to be passed in in one go, i.e. mbedtls_psa_aead_update() can only - * be called once. - * * \param[in,out] operation Active AEAD operation. * \param[in] input Buffer containing the message fragment to * encrypt or decrypt. @@ -425,19 +409,6 @@ psa_status_t mbedtls_psa_aead_update_ad( * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c key_type, \c alg, \p input_length) or * #PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(\p input_length) can be used to * determine the required buffer size. - * \retval #PSA_ERROR_INVALID_ARGUMENT - * The total length of input to mbedtls_psa_aead_update_ad() so far is - * less than the additional data length that was previously - * specified with mbedtls_psa_aead_set_lengths(). - * \retval #PSA_ERROR_INVALID_ARGUMENT - * The total input length overflows the plaintext length that - * was previously specified with mbedtls_psa_aead_set_lengths(). - * \retval #PSA_ERROR_NOT_SUPPORTED - * (GCM / CCM only) PSA core attempted to call mbedtls_psa_update() more - * than once. - * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * (CCM only) Unable to allocate memory for the tag or the body - */ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, @@ -505,9 +476,6 @@ psa_status_t mbedtls_psa_aead_update( * * \retval #PSA_SUCCESS * Success. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be an active encryption - * operation with a nonce set). * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p ciphertext or \p tag buffer is too small. * #PSA_AEAD_FINISH_OUTPUT_SIZE(\c key_type, \c alg) or @@ -515,14 +483,6 @@ psa_status_t mbedtls_psa_aead_update( * required \p ciphertext buffer size. #PSA_AEAD_TAG_LENGTH(\c key_type, * \c key_bits, \c alg) or #PSA_AEAD_TAG_MAX_SIZE can be used to * determine the required \p tag buffer size. - * \retval #PSA_ERROR_INVALID_ARGUMENT - * The total length of input to mbedtls_psa_aead_update_ad() so far is - * less than the additional data length that was previously - * specified with mbedtls_psa_aead_set_lengths(). - * \retval #PSA_ERROR_INVALID_ARGUMENT - * The total length of input to mbedtls_psa_aead_update() so far is - * less than the plaintext length that was previously - * specified with mbedtls_psa_aead_set_lengths(). */ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, @@ -590,24 +550,11 @@ psa_status_t mbedtls_psa_aead_finish( * \retval #PSA_ERROR_INVALID_SIGNATURE * The calculations were successful, but the authentication tag is * not correct. - * \retval #PSA_ERROR_BAD_STATE - * The operation state is not valid (it must be an active decryption - * operation with a nonce set). * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p plaintext buffer is too small. * #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c key_type, \c alg) or * #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE can be used to determine the * required buffer size. - * \retval #PSA_ERROR_INVALID_ARGUMENT - * The total length of input to mbedtls_psa_aead_update_ad() so far is - * less than the additional data length that was previously - * specified with mbedtls_psa_aead_set_lengths(). - * \retval #PSA_ERROR_INVALID_ARGUMENT - * The total length of input to mbedtls_psa_aead_update() so far is - * less than the plaintext length that was previously - * specified with mbedtls_psa_aead_set_lengths(). - * \retval #PSA_ERROR_INSUFFICIENT_MEMORY - * (CCM only) Failed to allocate temporary buffer */ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, From 388f606acd2faabeceb89c9a62d1c22a5263b00b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 3 Jun 2021 19:19:49 +0100 Subject: [PATCH 064/966] Use correct size defines for buffers Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 58 +++++++++++++-------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 0f9093c7ae..e42015833f 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3170,14 +3170,15 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, unsigned char *part_data = NULL; unsigned char *final_data = NULL; size_t output_size = 0; + size_t finish_output_size; size_t part_data_size = 0; size_t output_length = 0; size_t key_bits = 0; size_t tag_length = 0; size_t tag_size = 0; size_t nonce_length = 0; - uint8_t nonce_buffer[16]; - uint8_t tag_buffer[16]; + uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; uint32_t part_offset = 0; size_t part_length = 0; size_t output_part_length = 0; @@ -3198,7 +3199,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); - TEST_ASSERT( tag_length <= 16 ); + TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( input_data->len + @@ -3206,9 +3207,13 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, ASSERT_ALLOC( output_data, output_size ); - ASSERT_ALLOC( final_data, PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - operation = psa_aead_operation_init(); + TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, finish_output_size ); + + operation = psa_aead_operation_init( ); status = psa_aead_encrypt_setup( &operation, key, alg ); @@ -3319,7 +3324,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, } PSA_ASSERT( psa_aead_finish( &operation, final_data, - PSA_AEAD_FINISH_OUTPUT_MAX_SIZE, + finish_output_size, &output_part_length, tag_buffer, tag_length, &tag_size ) ); @@ -3381,6 +3386,7 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, unsigned char *final_data = NULL; size_t part_data_size; size_t output_size = 0; + size_t finish_output_size = 0; size_t output_length = 0; unsigned char *output_data2 = NULL; size_t output_size2 = 0; @@ -3389,8 +3395,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, size_t tag_length = 0; size_t tag_size = 0; size_t nonce_length = 0; - uint8_t nonce_buffer[16]; - uint8_t tag_buffer[16]; + uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; uint32_t part_offset = 0; size_t part_length = 0; size_t output_part_length = 0; @@ -3413,14 +3419,19 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); - TEST_ASSERT( tag_length <= 16 ); + TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); ASSERT_ALLOC( output_data, output_size ); - ASSERT_ALLOC( final_data, PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - operation = psa_aead_operation_init(); + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + + TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, finish_output_size ); + + operation = psa_aead_operation_init( ); status = psa_aead_encrypt_setup( &operation, key, alg ); @@ -3567,7 +3578,7 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, } status = psa_aead_finish( &operation, final_data, - PSA_AEAD_FINISH_OUTPUT_MAX_SIZE, + finish_output_size, &output_part_length, tag_buffer, tag_length, &tag_size ); @@ -3612,7 +3623,7 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length + tag_length ) ); - operation = psa_aead_operation_init(); + operation = psa_aead_operation_init( ); status = psa_aead_decrypt_setup( &operation, key, alg ); @@ -3735,7 +3746,7 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, } PSA_ASSERT( psa_aead_verify( &operation, final_data, - PSA_AEAD_FINISH_OUTPUT_MAX_SIZE, + finish_output_size, &output_part_length, tag_buffer, tag_length ) ); @@ -3782,11 +3793,12 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, unsigned char *final_data = NULL; size_t part_data_size; size_t output_size = 0; + size_t verify_output_size = 0; size_t output_length = 0; size_t key_bits = 0; size_t tag_length = 0; size_t nonce_length = 0; - uint8_t nonce_buffer[16]; + uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; uint32_t part_offset = 0; size_t part_length = 0; size_t output_part_length = 0; @@ -3813,9 +3825,12 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, tag_length ) ); ASSERT_ALLOC( output_data, output_size ); - ASSERT_ALLOC( final_data, PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); - operation = psa_aead_operation_init(); + verify_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( key_type, alg ); + TEST_ASSERT( verify_output_size <= PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); + ASSERT_ALLOC( final_data, verify_output_size ); + + operation = psa_aead_operation_init( ); status = psa_aead_decrypt_setup( &operation, key, alg ); @@ -3963,11 +3978,10 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, } status = psa_aead_verify( &operation, final_data, - PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE, - &output_part_length, - ( input_data->x + input_data->len - - tag_length ), - tag_length ); + verify_output_size, + &output_part_length, + ( input_data->x + input_data->len - tag_length ), + tag_length ); if( status != PSA_SUCCESS ) { From 8eb9dafda1a298ef9113e8656c83b8c59ac2e147 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 4 Jun 2021 16:42:21 +0100 Subject: [PATCH 065/966] Add generate nonce test Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- tests/suites/test_suite_psa_crypto.data | 20 +++++ tests/suites/test_suite_psa_crypto.function | 98 +++++++++++++-------- 3 files changed, 82 insertions(+), 38 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index e824123466..8dc6aad534 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3547,7 +3547,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; size_t required_nonce_size; - *nonce_length = 0; + *nonce_length = 0; if( operation->id == 0 ) { diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 5f87774bbe..f9ce85e59d 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2374,6 +2374,26 @@ PSA Multipart AEAD encrypt/decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":-1:"":-1:PSA_ERROR_INVALID_ARGUMENT +PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 12 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:PSA_SUCCESS + +PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 0 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:PSA_ERROR_BUFFER_TOO_SMALL + +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 12 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:PSA_SUCCESS + +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 8 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:PSA_ERROR_BUFFER_TOO_SMALL + +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 0 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:PSA_ERROR_BUFFER_TOO_SMALL + PSA signature size: RSA keypair, 1024 bits, PKCS#1 v1.5 raw depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR signature_size:PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:128 diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index e42015833f..35b9760697 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3176,8 +3176,6 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, size_t key_bits = 0; size_t tag_length = 0; size_t tag_size = 0; - size_t nonce_length = 0; - uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; uint32_t part_offset = 0; size_t part_length = 0; @@ -3228,17 +3226,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, PSA_ASSERT( status ); - if( nonce->len == 0 ) - { - PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, - sizeof( nonce_buffer ), - &nonce_length ) ); - } - else - { - nonce_length = nonce->len; - PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); - } + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation.alg == PSA_ALG_GCM ) @@ -3450,17 +3438,8 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, goto exit; } - if( nonce->len == 0 ) - { - status = psa_aead_generate_nonce( &operation, nonce_buffer, - sizeof( nonce_buffer ), - &nonce_length ); - } - else - { - nonce_length = nonce->len; - status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); - } + nonce_length = nonce->len; + status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); if( status != PSA_SUCCESS ) { @@ -3797,8 +3776,6 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, size_t output_length = 0; size_t key_bits = 0; size_t tag_length = 0; - size_t nonce_length = 0; - uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; uint32_t part_offset = 0; size_t part_length = 0; size_t output_part_length = 0; @@ -3849,17 +3826,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, goto exit; } - if( nonce->len == 0 ) - { - status = psa_aead_generate_nonce( &operation, nonce_buffer, - sizeof( nonce_buffer ), - &nonce_length ); - } - else - { - nonce_length = nonce->len; - status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); - } + status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); if( status != PSA_SUCCESS ) { @@ -4022,6 +3989,63 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, + int alg_arg, + int nonce_len, + int expected_result_arg ) +{ + + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + size_t nonce_generated_len = 0; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( & attributes, PSA_KEY_USAGE_ENCRYPT ); + psa_set_key_algorithm( & attributes, alg ); + psa_set_key_type( & attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_len ); + } + + PSA_ASSERT( status ); + + TEST_ASSERT( nonce_len < PSA_AEAD_NONCE_MAX_SIZE ); + + status = psa_aead_generate_nonce( &operation, nonce_buffer, + nonce_len, + &nonce_generated_len ); + + TEST_ASSERT( status == expected_result_arg ); + +exit: + psa_destroy_key( key ); + psa_aead_abort( &operation ); + PSA_DONE( ); +} +/* END_CASE */ + /* BEGIN_CASE */ void signature_size( int type_arg, int bits, From d3f824136901470cdffeb7f9ceb20646e9599169 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 16 Jun 2021 16:52:21 +0100 Subject: [PATCH 066/966] Add multipart tests Test range of multipart sizes for all tests, rather than having to define specific tests. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 132 +- tests/suites/test_suite_psa_crypto.function | 1677 ++++++++++--------- 2 files changed, 978 insertions(+), 831 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index f9ce85e59d..ea54dcc1b9 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2112,267 +2112,267 @@ aead_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f9091 PSA Multipart AEAD encrypt/decrypt, AES-GCM, 19 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":-1:"0C0D0E0F101112131415161718191A1B1C1D1E":-1:PSA_SUCCESS +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":0:"0C0D0E0F101112131415161718191A1B1C1D1E":1:PSA_SUCCESS PSA Multipart AEAD encrypt/decrypt, AES GCM, 19 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"EC46BB63B02520C33C49FD70":-1:"B96B49E21D621741632875DB7F6C9243D2D7C2":-1:PSA_SUCCESS +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"EC46BB63B02520C33C49FD70":0:"B96B49E21D621741632875DB7F6C9243D2D7C2":1:PSA_SUCCESS PSA Multipart AEAD encrypt/decrypt, AES-GCM, 19 bytes, 12 byte nonce , 1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"E462C58482FE8264AEEB7231":"000102030405060708090A0B":-1:"0C0D0E0F101112131415161718191A1B1C1D1E":-1:PSA_SUCCESS +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"E462C58482FE8264AEEB7231":"000102030405060708090A0B":0:"0C0D0E0F101112131415161718191A1B1C1D1E":1:PSA_SUCCESS PSA Multipart AEAD encrypt/decrypt, AES GCM, 19 bytes, 12 byte nonce , 2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"E462C58482FE8264AEEB7231":"EC46BB63B02520C33C49FD70":-1:"B96B49E21D621741632875DB7F6C9243D2D7C2":-1:PSA_SUCCESS +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"E462C58482FE8264AEEB7231":"EC46BB63B02520C33C49FD70":0:"B96B49E21D621741632875DB7F6C9243D2D7C2":1:PSA_SUCCESS PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":-1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":-1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":-1:"":-1:"f149e2b5f0adaa9842ca5f45b768a8fc" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":0:"":1:"f149e2b5f0adaa9842ca5f45b768a8fc" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=16, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":-1:"":-1:"204bdb1bd62154bf08922aaa54eed705" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":0:"":1:"204bdb1bd62154bf08922aaa54eed705" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=20, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":-1:"":-1:"1b2d2764573e20ae640bf29d48e5fe05" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":0:"":1:"1b2d2764573e20ae640bf29d48e5fe05" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":-1:"":-1:"77e5682a49243d5b9016eb1adafa2d" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":0:"":1:"77e5682a49243d5b9016eb1adafa2d" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":-1:"d2ae38c4375954835d75b8e4c2f9bbb4":-1:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":0:"d2ae38c4375954835d75b8e4c2f9bbb4":1:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=8, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":-1:"d3f3f57033df30c22860231334b099cb":-1:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":0:"d3f3f57033df30c22860231334b099cb":1:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=14, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":-1:"e7fb0631eebf9bdba87045b33650c4ce":-1:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":0:"e7fb0631eebf9bdba87045b33650c4ce":1:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=4, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":-1:"636871d4c0aae3da7b55abd8b5f21297":-1:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":0:"636871d4c0aae3da7b55abd8b5f21297":1:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=20, TAG=13, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":-1:"3d952be11deb421b56e0ce9d7ce99553":-1:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":0:"3d952be11deb421b56e0ce9d7ce99553":1:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":-1:"fdd8a462c86d4365c8bfee0e25fc8a62":-1:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":0:"fdd8a462c86d4365c8bfee0e25fc8a62":1:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":-1:"":-1:"bdc1ac884d332457a1d2664f168c76f0" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":0:"":1:"bdc1ac884d332457a1d2664f168c76f0" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=12, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":-1:"":-1:"2fb9c3e41fff24ef07437c47" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":0:"":1:"2fb9c3e41fff24ef07437c47" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":-1:"":-1:"f6d47505ec96c98a42dc3ae719877b87" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":0:"":1:"f6d47505ec96c98a42dc3ae719877b87" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=13, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":-1:"":-1:"5233f95bdcf5d666fb957acdcb" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":0:"":1:"5233f95bdcf5d666fb957acdcb" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":-1:"":-1:"d57e27914ecb4a764359d3c0f8d4d6" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":0:"":1:"d57e27914ecb4a764359d3c0f8d4d6" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=4, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":-1:"":-1:"72901467" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":0:"":1:"72901467" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":-1:"722ee47da4b77424733546c2d400c4e5":-1:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":0:"722ee47da4b77424733546c2d400c4e5":1:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=12, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":-1:"bcf48ddcfe9d011a1003973d68d2d78a":-1:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":0:"bcf48ddcfe9d011a1003973d68d2d78a":1:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=16, TAG=14, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":-1:"c37aada3d4408e880d47e41df77da9b9":-1:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":0:"c37aada3d4408e880d47e41df77da9b9":1:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":-1:"e5f410fe939e79b7ad33fbd3aaf5856f":-1:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":0:"e5f410fe939e79b7ad33fbd3aaf5856f":1:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":-1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":-1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, invalid signature depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":-1:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":-1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_ERROR_INVALID_SIGNATURE PSA Multipart AEAD decrypt, AES-GCM, T=15 but passing 16 bytes depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":-1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":-1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_ERROR_INVALID_SIGNATURE PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 18 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":-1:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":-1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":-1:"db1a74ffb5f7de26f5742e0942b1b9cb":-1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":-1:"434ff68f2436f48418fd69f52158":-1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":-1:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":-1:"b03c2c20f758a93a8d1220232ad87098":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:"b03c2c20f758a93a8d1220232ad87098":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":-1:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":-1:"b22b2dcdcc18adc30d16297b84b459d8":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:"b22b2dcdcc18adc30d16297b84b459d8":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":-1:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":-1:"7e5fd8b595ddc4753676107951d900e2":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:"7e5fd8b595ddc4753676107951d900e2":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":-1:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":-1:"37245449db8f72b1ecdb420f629d3d80":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:"37245449db8f72b1ecdb420f629d3d80":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":-1:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":-1:"496909523f574b205d757659c5":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:"496909523f574b205d757659c5":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":-1:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":-1:"b6e056de521a27266dffbc0d96":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:"b6e056de521a27266dffbc0d96":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":-1:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":-1:"f6d56f8c86f27d957fa63aea22":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:"f6d56f8c86f27d957fa63aea22":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":-1:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":-1:"bd94b34511bc65ae47684805cb":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:"bd94b34511bc65ae47684805cb":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":-1:"15e051a5e4a5f5da6cea92e2ebee5bac":-1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":-1:"84c8beff4b0d160ee68ac613097f51":-1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":-1:"8d6351f18d873242204c20144e2b83":-1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":-1:"3bfd3d99fe2063e8ef8255519fe0":-1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":-1:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":-1:"7789b41cb3ee548814ca0b388c10b343":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:"7789b41cb3ee548814ca0b388c10b343":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":-1:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":-1:"4860116a6d2deb9bf794bfd6ac5bbbd6":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:"4860116a6d2deb9bf794bfd6ac5bbbd6":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":-1:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":-1:"ff426dd751190ff826e8b4a0792d746e":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:"ff426dd751190ff826e8b4a0792d746e":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":-1:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":-1:"0a0b284515694188b6b6c15bc8a09036":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:"0a0b284515694188b6b6c15bc8a09036":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":-1:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":-1:"f386b28e7eb4c2fb8eb5dc66a2":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:"f386b28e7eb4c2fb8eb5dc66a2":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":-1:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":-1:"da1c61fbfcdb73445ad4c7d889":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:"da1c61fbfcdb73445ad4c7d889":PSA_SUCCESS PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":-1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":-1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":-1:"":-1:"a0784d7a4716f3feb4f64e7f4b39bf04" +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"":1:"a0784d7a4716f3feb4f64e7f4b39bf04" PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":-1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":-1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, bad tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":-1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":-1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_ERROR_INVALID_SIGNATURE PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":-1:"a0784d7a4716f3feb4f64e7f4b39bf04":-1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:"":PSA_SUCCESS PSA Multipart AEAD encrypt/decrypt: invalid algorithm (CTR) depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":-1:"":-1:PSA_ERROR_INVALID_ARGUMENT +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD encrypt/decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":-1:"":-1:PSA_ERROR_INVALID_ARGUMENT +aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:PSA_ERROR_INVALID_ARGUMENT PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 35b9760697..576d467008 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -264,6 +264,845 @@ typedef enum { DERIVE_KEY = 2 } generate_method; +static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, + data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + int ad_part_len, + data_t *input_data, + int data_part_len, + data_t *expected_result ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + unsigned char *output_data = NULL; + unsigned char *part_data = NULL; + unsigned char *final_data = NULL; + size_t output_size = 0; + size_t finish_output_size; + size_t part_data_size = 0; + size_t output_length = 0; + size_t key_bits = 0; + size_t tag_length = 0; + size_t tag_size = 0; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; + uint32_t part_offset = 0; + size_t part_length = 0; + size_t output_part_length = 0; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + key_bits = psa_get_key_bits( &attributes ); + + tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); + + TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( input_data->len + + tag_length ) ); + + ASSERT_ALLOC( output_data, output_size ); + + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + + TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, finish_output_size ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + PSA_ASSERT( status ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation.alg == PSA_ALG_GCM ) + { + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + } +#endif + + if( ad_part_len != -1 ) + { + /* Pass additional data in parts */ + part_offset = 0; + + while( part_offset < additional_data->len ) + { + if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } + + PSA_ASSERT( psa_aead_update_ad( &operation, + additional_data->x + part_offset, + part_length ) ); + + part_offset += part_length; + } + } + else + { + /* Pass additional data in one go. */ + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + } + + if( data_part_len != -1 ) + { + /* Pass data in parts */ + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( size_t ) data_part_len ); + + ASSERT_ALLOC( part_data, part_data_size ); + + part_offset = 0; + + while( part_offset < input_data->len ) + { + if( input_data->len - part_offset < ( uint32_t ) data_part_len ) + { + part_length = input_data->len - part_offset; + } + else + { + part_length = data_part_len; + } + + PSA_ASSERT( psa_aead_update( &operation, + ( input_data->x + part_offset ), + part_length, part_data, + part_data_size, + &output_part_length ) ); + + if( output_data && output_part_length ) + { + memcpy( ( output_data + part_offset ), part_data, + output_part_length ); + } + + part_offset += part_length; + output_length += output_part_length; + } + } + else + { + /* Pass whole data in one go */ + PSA_ASSERT( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ) ); + } + + PSA_ASSERT( psa_aead_finish( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, tag_length, + &tag_size ) ); + + if( output_data && output_part_length ) + { + memcpy( ( output_data + output_length ), final_data, + output_part_length ); + } + + TEST_EQUAL( tag_length, tag_size ); + + output_length += output_part_length; + + if( output_data && tag_length ) + { + memcpy( ( output_data + output_length ), tag_buffer, tag_length ); + } + + output_length += tag_length; + + /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE + * should be exact. */ + TEST_EQUAL( output_length, + PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, + input_data->len ) ); + TEST_ASSERT( output_length <= + PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); + + ASSERT_COMPARE( expected_result->x, expected_result->len, + output_data, output_length ); + +exit: + psa_destroy_key( key ); + psa_aead_abort( &operation ); + mbedtls_free( output_data ); + mbedtls_free( part_data ); + mbedtls_free( final_data ); + PSA_DONE( ); + + return( status ); +} + +void aead_multipart_decrypt_internal( int key_type_arg, data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + int ad_part_len, + data_t *input_data, + int data_part_len, + data_t *expected_data, + int expected_result_arg ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + unsigned char *output_data = NULL; + unsigned char *part_data = NULL; + unsigned char *final_data = NULL; + size_t part_data_size; + size_t output_size = 0; + size_t verify_output_size = 0; + size_t output_length = 0; + size_t key_bits = 0; + size_t tag_length = 0; + uint32_t part_offset = 0; + size_t part_length = 0; + size_t output_part_length = 0; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t expected_result = expected_result_arg; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + key_bits = psa_get_key_bits( &attributes ); + + tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( input_data->len - + tag_length ) ); + + ASSERT_ALLOC( output_data, output_size ); + + verify_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( key_type, alg ); + TEST_ASSERT( verify_output_size <= PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); + ASSERT_ALLOC( final_data, verify_output_size ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_decrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation.alg == PSA_ALG_GCM ) + { + status = psa_aead_set_lengths( &operation, additional_data->len, + ( input_data->len - tag_length ) ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } +#endif + + if( ad_part_len != -1 ) + { + part_offset = 0; + + while( part_offset < additional_data->len ) + { + if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } + + status = psa_aead_update_ad( &operation, + additional_data->x + part_offset, + part_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + part_offset += part_length; + } + } + else + { + status = psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } + + if( data_part_len != -1 ) + { + /* Pass data in parts */ + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( size_t ) data_part_len ); + + ASSERT_ALLOC( part_data, part_data_size ); + + part_offset = 0; + + while( part_offset < ( input_data->len - tag_length) ) + { + if( (input_data->len - tag_length - part_offset ) < + ( uint32_t ) data_part_len ) + { + part_length = ( input_data->len - tag_length - part_offset ); + } + else + { + part_length = data_part_len; + } + + status = psa_aead_update( &operation, + ( input_data->x + part_offset ), + part_length, part_data, + part_data_size, &output_part_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + if( output_data && output_part_length ) + { + memcpy( ( output_data + part_offset ), part_data, + output_part_length ); + } + + part_offset += part_length; + output_length += output_part_length; + } + } + else + { + status = psa_aead_update( &operation, input_data->x, + ( input_data->len - tag_length ), output_data, + output_size, &output_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + } + + status = psa_aead_verify( &operation, final_data, + verify_output_size, + &output_part_length, + ( input_data->x + input_data->len - tag_length ), + tag_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_result_arg ); + goto exit; + } + + if( output_data && output_part_length ) + { + memcpy( ( output_data + output_length ), final_data, + output_part_length ); + } + + output_length += output_part_length; + + if( expected_result != PSA_ERROR_INVALID_ARGUMENT ) + { + /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE + * should be exact. */ + TEST_EQUAL( output_length, + PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, + input_data->len ) ); + TEST_ASSERT( output_length <= + PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); + } + + if( expected_result == PSA_SUCCESS ) + { + ASSERT_COMPARE( expected_data->x, expected_data->len, + output_data, output_length ); + } + +exit: + psa_destroy_key( key ); + psa_aead_abort( &operation ); + mbedtls_free( output_data ); + mbedtls_free( part_data ); + mbedtls_free( final_data ); + PSA_DONE( ); +} + +void aead_multipart_encrypt_decrypt_internal( int key_type_arg, + data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + int ad_part_len, + data_t *input_data, + int data_part_len, + int expected_status_arg ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + unsigned char *output_data = NULL; + unsigned char *part_data = NULL; + unsigned char *final_data = NULL; + size_t part_data_size; + size_t output_size = 0; + size_t finish_output_size = 0; + size_t output_length = 0; + unsigned char *output_data2 = NULL; + size_t output_size2 = 0; + size_t output_length2 = 0; + size_t key_bits = 0; + size_t tag_length = 0; + size_t tag_size = 0; + size_t nonce_length = 0; + uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; + uint32_t part_offset = 0; + size_t part_length = 0; + size_t output_part_length = 0; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + psa_status_t expected_status = expected_status_arg; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, + PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + key_bits = psa_get_key_bits( &attributes ); + + tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); + + TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); + + ASSERT_ALLOC( output_data, output_size ); + + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + + TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, finish_output_size ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + goto exit; + } + + nonce_length = nonce->len; + status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + goto exit; + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation.alg == PSA_ALG_GCM ) + { + status = psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + goto exit; + } + } +#endif + + if( ad_part_len != -1 ) + { + part_offset = 0; + + while( part_offset < additional_data->len ) + { + if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } + + status = psa_aead_update_ad( &operation, + additional_data->x + part_offset, + part_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + goto exit; + } + + part_offset += part_length; + } + } + else + { + status = psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + goto exit; + } + } + + if( data_part_len != -1 ) + { + /* Pass data in parts */ + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( size_t ) data_part_len ); + + ASSERT_ALLOC( part_data, part_data_size ); + + part_offset = 0; + + while( part_offset < input_data->len ) + { + if( input_data->len - part_offset < ( uint32_t ) data_part_len ) + { + part_length = input_data->len - part_offset; + } + else + { + part_length = data_part_len; + } + + status = psa_aead_update( &operation, + ( input_data->x + part_offset ), + part_length, part_data, + part_data_size, &output_part_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + goto exit; + } + + if( output_data && output_part_length ) + { + memcpy( ( output_data + part_offset ), part_data, + output_part_length ); + } + + part_offset += part_length; + output_length += output_part_length; + } + } + else + { + status = psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + goto exit; + } + } + + status = psa_aead_finish( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, tag_length, + &tag_size ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + goto exit; + } + + if( output_data && output_part_length ) + { + memcpy( ( output_data + output_length ), final_data, + output_part_length ); + } + + output_length += output_part_length; + + /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE + * should be exact. */ + if( expected_status != PSA_ERROR_INVALID_ARGUMENT ) + { + TEST_EQUAL( ( output_length + tag_length ), + PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, + input_data->len ) ); + } + + TEST_EQUAL( tag_length, tag_size ); + + if( PSA_SUCCESS == expected_status ) + { + output_size2 = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + output_length ); + ASSERT_ALLOC( output_data2, output_size2 ); + + /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE + * should be exact. */ + TEST_EQUAL( input_data->len, + PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, + ( output_length + + tag_length ) ) ); + + TEST_ASSERT( input_data->len <= + PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length + + tag_length ) ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_decrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, + nonce->len ); + } + + TEST_EQUAL( status, expected_status ); + + if( nonce->len == 0 ) + { + /* Use previously generated nonce. */ + status = psa_aead_set_nonce( &operation, nonce_buffer, + nonce_length ); + } + else + { + nonce_length = nonce->len; + status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); + } + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status); + } + +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation.alg == PSA_ALG_GCM ) + { + status = psa_aead_set_lengths( &operation, additional_data->len, + output_length ); + + if( status != PSA_SUCCESS ) + { + TEST_EQUAL( status, expected_status ); + } + } +#endif + + if( ad_part_len != -1 ) + { + part_offset = 0; + + while( part_offset < additional_data->len ) + { + if( additional_data->len - part_offset < + ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } + + PSA_ASSERT( psa_aead_update_ad( &operation, + additional_data->x + + part_offset, + part_length ) ); + + part_offset += part_length; + } + } + else + { + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + } + + if( data_part_len != -1 ) + { + /* Pass data in parts */ + part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( size_t ) data_part_len ); + + part_data = NULL; + ASSERT_ALLOC( part_data, part_data_size ); + + part_offset = 0; + + while( part_offset < output_length ) + { + if( ( output_length - part_offset ) < + ( uint32_t ) data_part_len ) + { + part_length = ( output_length - part_offset ); + } + else + { + part_length = data_part_len; + } + + PSA_ASSERT( psa_aead_update( &operation, + ( output_data + part_offset ), + part_length, part_data, + part_data_size, + &output_part_length ) ); + + if( output_data2 && output_part_length ) + { + memcpy( ( output_data2 + part_offset ), + part_data, output_part_length ); + } + + part_offset += part_length; + output_length2 += output_part_length; + } + } + else + { + PSA_ASSERT( psa_aead_update( &operation, output_data, + output_length, output_data2, + output_size2, &output_length2 ) ); + } + + PSA_ASSERT( psa_aead_verify( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, tag_length ) ); + + if( output_data2 && output_part_length ) + { + memcpy( ( output_data2 + output_length2 ), final_data, + output_part_length ); + } + + output_length2 += output_part_length; + + ASSERT_COMPARE( input_data->x, input_data->len, + output_data2, output_length2 ); + } + +exit: + psa_destroy_key( key ); + psa_aead_abort( &operation ); + mbedtls_free( output_data ); + mbedtls_free( output_data2 ); + mbedtls_free( part_data ); + mbedtls_free( final_data ); + PSA_DONE( ); +} + /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -3157,201 +3996,46 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, int alg_arg, data_t *nonce, data_t *additional_data, - int ad_part_len, + int test_ad_mp_arg, data_t *input_data, - int data_part_len, - data_t *expected_result ) + int test_data_mp_arg, + data_t *expected_result_arg ) { - mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; - psa_key_type_t key_type = key_type_arg; - psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; - unsigned char *output_data = NULL; - unsigned char *part_data = NULL; - unsigned char *final_data = NULL; - size_t output_size = 0; - size_t finish_output_size; - size_t part_data_size = 0; - size_t output_length = 0; - size_t key_bits = 0; - size_t tag_length = 0; - size_t tag_size = 0; - uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; - uint32_t part_offset = 0; - size_t part_length = 0; - size_t output_part_length = 0; - psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; - psa_status_t status = PSA_ERROR_GENERIC_ERROR; + size_t ad_part_len = 0; + size_t data_part_len = 0; - PSA_ASSERT( psa_crypto_init( ) ); - - psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); - psa_set_key_algorithm( &attributes, alg ); - psa_set_key_type( &attributes, key_type ); - - PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, - &key ) ); - - PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); - key_bits = psa_get_key_bits( &attributes ); - - tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); - - TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); - - output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( input_data->len + - tag_length ) ); - - ASSERT_ALLOC( output_data, output_size ); - - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - - TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - - ASSERT_ALLOC( final_data, finish_output_size ); - - operation = psa_aead_operation_init( ); - - status = psa_aead_encrypt_setup( &operation, key, alg ); - - /* If the operation is not supported, just skip and not fail in case the - * encryption involves a common limitation of cryptography hardwares and - * an alternative implementation. */ - if( status == PSA_ERROR_NOT_SUPPORTED ) + if( test_ad_mp_arg == 1 ) { - MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); - } - - PSA_ASSERT( status ); - - PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); - -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.alg == PSA_ALG_GCM ) - { - PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, - input_data->len ) ); - } -#endif - - if( ad_part_len != -1 ) - { - /* Pass addtional data in parts */ - part_offset = 0; - - while( part_offset <= additional_data->len) + for( ad_part_len = 1; ad_part_len <= additional_data->len; + ad_part_len++ ) { - if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) - { - part_length = additional_data->len - part_offset; - } - else - { - part_length = ad_part_len; - } + mbedtls_test_set_step( ad_part_len ); - PSA_ASSERT( psa_aead_update_ad( &operation, - additional_data->x + part_offset, - part_length ) ); - - part_offset += part_length; + aead_multipart_encrypt_internal( key_type_arg, key_data, + alg_arg,nonce, + additional_data, + ad_part_len, + input_data, -1, + expected_result_arg ); } } - else + + if( test_data_mp_arg == 1 ) { - /* Pass additional data in one go. */ - PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, - additional_data->len) ); - } - - if( data_part_len != -1 ) - { - /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); - - ASSERT_ALLOC( part_data, part_data_size ); - - part_offset = 0; - - while( part_offset <= input_data->len) + for( data_part_len = 1; data_part_len <= input_data->len; + data_part_len++ ) { - if( input_data->len - part_offset < ( uint32_t ) data_part_len ) - { - part_length = input_data->len - part_offset; - } - else - { - part_length = data_part_len; - } - - PSA_ASSERT( psa_aead_update( &operation, - ( input_data->x + part_offset ), - part_length, part_data, - part_data_size, - &output_part_length ) ); - - if( output_data && output_part_length ) - { - memcpy( ( output_data + part_offset ), part_data, - output_part_length ); - } - - part_offset += part_length; - output_length += output_part_length; + aead_multipart_encrypt_internal( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + expected_result_arg ); } } - else - { - /* Pass whole data in one go */ - PSA_ASSERT( psa_aead_update( &operation, input_data->x, - input_data->len, output_data, - output_size, &output_length ) ); - } - PSA_ASSERT( psa_aead_finish( &operation, final_data, - finish_output_size, - &output_part_length, - tag_buffer, tag_length, - &tag_size ) ); - - if( output_data && output_part_length ) - { - memcpy( ( output_data + output_length ), final_data, - output_part_length ); - } - - TEST_EQUAL(tag_length, tag_size); - - output_length += output_part_length; - - if( output_data && tag_length ) - { - memcpy( ( output_data + output_length ), tag_buffer, tag_length ); - } - - output_length += tag_length; - - /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE - * should be exact. */ - TEST_EQUAL( output_length, - PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, - input_data->len ) ); - TEST_ASSERT( output_length <= - PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); - - ASSERT_COMPARE( expected_result->x, expected_result->len, - output_data, output_length ); + goto exit; exit: - psa_destroy_key( key ); - psa_aead_abort( &operation ); - mbedtls_free( output_data ); - mbedtls_free( part_data ); - mbedtls_free( final_data ); - PSA_DONE( ); } /* END_CASE */ @@ -3360,395 +4044,46 @@ void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, int alg_arg, data_t *nonce, data_t *additional_data, - int ad_part_len, + int test_ad_mp_arg, data_t *input_data, - int data_part_len, - int expected_result_arg ) + int test_data_mp_arg, + int expected_status_arg ) { - mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; - psa_key_type_t key_type = key_type_arg; - psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; - unsigned char *output_data = NULL; - unsigned char *part_data = NULL; - unsigned char *final_data = NULL; - size_t part_data_size; - size_t output_size = 0; - size_t finish_output_size = 0; - size_t output_length = 0; - unsigned char *output_data2 = NULL; - size_t output_size2 = 0; - size_t output_length2 = 0; - size_t key_bits = 0; - size_t tag_length = 0; - size_t tag_size = 0; - size_t nonce_length = 0; - uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; - uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; - uint32_t part_offset = 0; - size_t part_length = 0; - size_t output_part_length = 0; - psa_status_t status = PSA_ERROR_GENERIC_ERROR; - psa_status_t expected_result = expected_result_arg; - psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + size_t ad_part_len = 0; + size_t data_part_len = 0; - PSA_ASSERT( psa_crypto_init( ) ); - - psa_set_key_usage_flags( &attributes, - PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); - psa_set_key_algorithm( &attributes, alg ); - psa_set_key_type( &attributes, key_type ); - - PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, - &key ) ); - - PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); - key_bits = psa_get_key_bits( &attributes ); - - tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); - - TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); - - output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); - - ASSERT_ALLOC( output_data, output_size ); - - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - - TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - - ASSERT_ALLOC( final_data, finish_output_size ); - - operation = psa_aead_operation_init( ); - - status = psa_aead_encrypt_setup( &operation, key, alg ); - - /* If the operation is not supported, just skip and not fail in case the - * encryption involves a common limitation of cryptography hardwares and - * an alternative implementation. */ - if( status == PSA_ERROR_NOT_SUPPORTED ) + if( test_ad_mp_arg == 1 ) { - MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); - } - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - nonce_length = nonce->len; - status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.alg == PSA_ALG_GCM ) - { - status = psa_aead_set_lengths( &operation, additional_data->len, - input_data->len ); - - if( status != PSA_SUCCESS ) + for( ad_part_len = 1; ad_part_len <= additional_data->len; + ad_part_len++ ) { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - } -#endif + mbedtls_test_set_step( ad_part_len ); - if( ad_part_len != -1 ) - { - part_offset = 0; - - while( part_offset <= additional_data->len) - { - if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) - { - part_length = additional_data->len - part_offset; - } - else - { - part_length = ad_part_len; - } - - status = psa_aead_update_ad( &operation, - additional_data->x + part_offset, - part_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - part_offset += part_length; - } - } - else - { - status = psa_aead_update_ad(&operation, additional_data->x, - additional_data->len); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; + aead_multipart_encrypt_decrypt_internal( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + expected_status_arg ); } } - if( data_part_len != -1 ) + if( test_data_mp_arg == 1 ) { - /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); - - ASSERT_ALLOC( part_data, part_data_size ); - - part_offset = 0; - - while( part_offset <= input_data->len) + for( data_part_len = 1; data_part_len <= input_data->len; + data_part_len++ ) { - if( input_data->len - part_offset < ( uint32_t ) data_part_len ) - { - part_length = input_data->len - part_offset; - } - else - { - part_length = data_part_len; - } - - status = psa_aead_update( &operation, - ( input_data->x + part_offset ), - part_length, part_data, - part_data_size, &output_part_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - if( output_data && output_part_length ) - { - memcpy( ( output_data + part_offset ), part_data, - output_part_length ); - } - - part_offset += part_length; - output_length += output_part_length; - } - } - else - { - status = psa_aead_update( &operation, input_data->x, - input_data->len, output_data, - output_size, &output_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; + aead_multipart_encrypt_decrypt_internal( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + expected_status_arg ); } } - status = psa_aead_finish( &operation, final_data, - finish_output_size, - &output_part_length, - tag_buffer, tag_length, - &tag_size ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - if( output_data &&output_part_length ) - { - memcpy( ( output_data + output_length ), final_data, - output_part_length ); - } - - output_length += output_part_length; - - /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE - * should be exact. */ - if( expected_result != PSA_ERROR_INVALID_ARGUMENT ) - TEST_EQUAL( ( output_length + tag_length ), - PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, - input_data->len ) ); - - TEST_EQUAL(tag_length, tag_size); - - if( PSA_SUCCESS == expected_result ) - { - output_size2 = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - output_length ); - ASSERT_ALLOC( output_data2, output_size2 ); - - /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE - * should be exact. */ - TEST_EQUAL( input_data->len, - PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, - ( output_length + - tag_length ) ) ); - - TEST_ASSERT( input_data->len <= - PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length + - tag_length ) ); - - operation = psa_aead_operation_init( ); - - status = psa_aead_decrypt_setup( &operation, key, alg ); - - /* If the operation is not supported, just skip and not fail in case the - * encryption involves a common limitation of cryptography hardwares and - * an alternative implementation. */ - if( status == PSA_ERROR_NOT_SUPPORTED ) - { - MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, - nonce->len ); - } - - TEST_EQUAL( status, expected_result ); - - if( nonce->len == 0 ) - { - /* Use previously generated nonce. */ - status = psa_aead_set_nonce( &operation, nonce_buffer, - nonce_length ); - } - else - { - nonce_length = nonce->len; - status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); - } - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - } - -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.alg == PSA_ALG_GCM ) - { - status = psa_aead_set_lengths( &operation, additional_data->len, - output_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - } - } -#endif - - if( ad_part_len != -1 ) - { - part_offset = 0; - - while( part_offset <= additional_data->len) - { - if( additional_data->len - part_offset < - ( uint32_t ) ad_part_len ) - { - part_length = additional_data->len - part_offset; - } - else - { - part_length = ad_part_len; - } - - PSA_ASSERT( psa_aead_update_ad( &operation, - additional_data->x + - part_offset, - part_length ) ); - - part_offset += part_length; - } - } - else - { - PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, - additional_data->len) ); - } - - if( data_part_len != -1 ) - { - /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); - - ASSERT_ALLOC( part_data, part_data_size ); - - part_offset = 0; - - while( part_offset <= ( input_data->len - tag_length ) ) - { - if( ( input_data->len - tag_length - part_offset ) < - ( uint32_t ) data_part_len ) - { - part_length = - ( input_data->len - tag_length - part_offset ); - } - else - { - part_length = data_part_len; - } - - PSA_ASSERT( psa_aead_update( &operation, - ( input_data->x + part_offset ), - part_length, part_data, - part_data_size, - &output_part_length ) ); - - if( output_data2 && output_part_length ) - { - memcpy( ( output_data2 + part_offset ), - part_data, output_part_length ); - } - - part_offset += part_length; - output_length2 += output_part_length; - } - } - else - { - PSA_ASSERT( psa_aead_update( &operation, output_data, - output_length, output_data2, - output_size2, &output_length2 ) ); - } - - PSA_ASSERT( psa_aead_verify( &operation, final_data, - finish_output_size, - &output_part_length, - tag_buffer, tag_length ) ); - - if( output_data2 && output_part_length ) - { - memcpy( ( output_data2 + output_length2 ), final_data, - output_part_length); - } - - output_length2 += output_part_length; - - ASSERT_COMPARE( input_data->x, input_data->len, - output_data2, output_length2 ); - } + goto exit; exit: - psa_destroy_key( key ); - psa_aead_abort( &operation ); - mbedtls_free( output_data ); - mbedtls_free( output_data2 ); - mbedtls_free( part_data ); - mbedtls_free( final_data ); - PSA_DONE( ); } /* END_CASE */ @@ -3757,235 +4092,47 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, int alg_arg, data_t *nonce, data_t *additional_data, - int ad_part_len, + int test_ad_mp_arg, data_t *input_data, - int data_part_len, + int test_data_mp_arg, data_t *expected_data, - int expected_result_arg ) + int expected_status ) { - mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; - psa_key_type_t key_type = key_type_arg; - psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; - unsigned char *output_data = NULL; - unsigned char *part_data = NULL; - unsigned char *final_data = NULL; - size_t part_data_size; - size_t output_size = 0; - size_t verify_output_size = 0; - size_t output_length = 0; - size_t key_bits = 0; - size_t tag_length = 0; - uint32_t part_offset = 0; - size_t part_length = 0; - size_t output_part_length = 0; - psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; - psa_status_t expected_result = expected_result_arg; - psa_status_t status = PSA_ERROR_GENERIC_ERROR; + size_t ad_part_len = 0; + size_t data_part_len = 0; - PSA_ASSERT( psa_crypto_init( ) ); - - psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT ); - psa_set_key_algorithm( &attributes, alg ); - psa_set_key_type( &attributes, key_type ); - - PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, - &key ) ); - - PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); - key_bits = psa_get_key_bits( &attributes ); - - tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); - - output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( input_data->len - - tag_length ) ); - - ASSERT_ALLOC( output_data, output_size ); - - verify_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( key_type, alg ); - TEST_ASSERT( verify_output_size <= PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); - ASSERT_ALLOC( final_data, verify_output_size ); - - operation = psa_aead_operation_init( ); - - status = psa_aead_decrypt_setup( &operation, key, alg ); - - /* If the operation is not supported, just skip and not fail in case the - * encryption involves a common limitation of cryptography hardwares and - * an alternative implementation. */ - if( status == PSA_ERROR_NOT_SUPPORTED ) + if( test_ad_mp_arg == 1 ) { - MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); - } - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.alg == PSA_ALG_GCM ) - { - status = psa_aead_set_lengths( &operation, additional_data->len, - ( input_data->len - tag_length ) ); - - if( status != PSA_SUCCESS ) + for( ad_part_len = 1; ad_part_len <= additional_data->len; + ad_part_len++ ) { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - } -#endif + mbedtls_test_set_step( ad_part_len ); - if( ad_part_len != -1 ) - { - part_offset = 0; - - while( part_offset <= additional_data->len) - { - if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) - { - part_length = additional_data->len - part_offset; - } - else - { - part_length = ad_part_len; - } - - status = psa_aead_update_ad( &operation, - additional_data->x + part_offset, - part_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - part_offset += part_length; - } - } - else - { - status = psa_aead_update_ad( &operation, additional_data->x, - additional_data->len ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; + aead_multipart_decrypt_internal( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + expected_data, expected_status ); } } - if( data_part_len != -1 ) + if( test_data_mp_arg == 1 ) { - /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); - - ASSERT_ALLOC( part_data, part_data_size ); - - part_offset = 0; - - while( part_offset <= input_data->len) + for( data_part_len = 1; data_part_len <= input_data->len; + data_part_len++ ) { - if( (input_data->len - tag_length - part_offset ) < - ( uint32_t ) data_part_len ) - { - part_length = ( input_data->len - tag_length - part_offset ); - } - else - { - part_length = data_part_len; - } - - status = psa_aead_update( &operation, - ( input_data->x + part_offset ), - part_length, part_data, - part_data_size, &output_part_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - if( output_data && output_part_length ) - { - memcpy( ( output_data + part_offset ), part_data, - output_part_length ); - } - - part_offset += part_length; - output_length += output_part_length; - } - } - else - { - status = psa_aead_update( &operation, input_data->x, - ( input_data->len - tag_length ), output_data, - output_size, &output_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; + aead_multipart_decrypt_internal( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + expected_data, expected_status ); } } - status = psa_aead_verify( &operation, final_data, - verify_output_size, - &output_part_length, - ( input_data->x + input_data->len - tag_length ), - tag_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - if( output_data && output_part_length ) - { - memcpy( ( output_data + output_length ), final_data, - output_part_length ); - } - - output_length += output_part_length; - - if( expected_result != PSA_ERROR_INVALID_ARGUMENT ) - { - /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE - * should be exact. */ - TEST_EQUAL( output_length, - PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, - input_data->len ) ); - TEST_ASSERT( output_length <= - PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); - } - - if( expected_result == PSA_SUCCESS ) - ASSERT_COMPARE( expected_data->x, expected_data->len, - output_data, output_length ); + goto exit; exit: - psa_destroy_key( key ); - psa_aead_abort( &operation ); - mbedtls_free( output_data ); - mbedtls_free( part_data ); - mbedtls_free( final_data ); - PSA_DONE( ); } /* END_CASE */ From c23a9a07995ec09b941e7606ea0f1d3f654b63ca Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 21 Jun 2021 18:32:46 +0100 Subject: [PATCH 067/966] Add state checks for multipart AEAD Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 4 + tests/suites/test_suite_psa_crypto.function | 282 ++++++++++++++++++++ 2 files changed, 286 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index ea54dcc1b9..b74a959bbb 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2394,6 +2394,10 @@ PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:PSA_ERROR_BUFFER_TOO_SMALL +PSA Multipart State Checks, AES - GCM +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" + PSA signature size: RSA keypair, 1024 bits, PKCS#1 v1.5 raw depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR signature_size:PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:128 diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 576d467008..fdec30fb9f 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4193,6 +4193,288 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void aead_multipart_state_test( int key_type_arg, data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + data_t *input_data ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + unsigned char *output_data = NULL; + unsigned char *final_data = NULL; + size_t output_size = 0; + size_t finish_output_size = 0; + size_t output_length = 0; + size_t key_bits = 0; + size_t tag_length = 0; + size_t tag_size = 0; + size_t nonce_length = 0; + uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; + size_t output_part_length = 0; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( & attributes, + PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); + psa_set_key_algorithm( & attributes, alg ); + psa_set_key_type( & attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + key_bits = psa_get_key_bits( &attributes ); + + tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); + + TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); + + ASSERT_ALLOC( output_data, output_size ); + + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + + TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, finish_output_size ); + + /* Test all operations error without calling setup first. */ + + operation = psa_aead_operation_init( ); + + TEST_EQUAL( psa_aead_set_nonce( &operation, nonce->x, nonce->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + TEST_EQUAL( psa_aead_generate_nonce( &operation, nonce_buffer, + PSA_AEAD_NONCE_MAX_SIZE, + &nonce_length ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + TEST_EQUAL( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + TEST_EQUAL( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + TEST_EQUAL( psa_aead_finish( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, tag_length, + &tag_size ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + TEST_EQUAL( psa_aead_verify( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, + tag_length ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* Test for double setups. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_encrypt_setup( &operation, key, alg ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_decrypt_setup( &operation, key, alg ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* Test for not setting a nonce. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* Test for double setting nonce. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + TEST_EQUAL( psa_aead_set_nonce( &operation, nonce->x, nonce->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* Test for setting lengths twice. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* Test for setting lengths after already starting data. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ) ); + + TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* Test for not sending any additional data or data (encrypt) */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + TEST_EQUAL( psa_aead_finish( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, tag_length, + &tag_size ), + PSA_ERROR_INVALID_ARGUMENT ); + + psa_aead_abort( &operation ); + + /* Test for not sending any additional data or data (decrypt) */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + TEST_EQUAL( psa_aead_verify( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, + tag_length ), + PSA_ERROR_INVALID_ARGUMENT ); + + psa_aead_abort( &operation ); + + /* Test for not sending any additional data. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + TEST_EQUAL( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ), + PSA_ERROR_INVALID_ARGUMENT ); + + psa_aead_abort( &operation ); + + /* Test sending additional data after data. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ) ); + + TEST_EQUAL( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + +exit: + psa_destroy_key( key ); + psa_aead_abort( &operation ); + mbedtls_free( output_data ); + mbedtls_free( final_data ); + PSA_DONE( ); +} +/* END_CASE */ + /* BEGIN_CASE */ void signature_size( int type_arg, int bits, From 1c96429282399ace521d3762ab81b5958e88b835 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 21 Jun 2021 18:36:42 +0100 Subject: [PATCH 068/966] Remove encrypt/decrypt tests Tests were not really providing any more coverage than already provided. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 24 +- tests/suites/test_suite_psa_crypto.function | 446 -------------------- 2 files changed, 4 insertions(+), 466 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index b74a959bbb..49685b4f4e 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2110,22 +2110,6 @@ PSA AEAD encrypt/decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C aead_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":"":PSA_ERROR_NOT_SUPPORTED -PSA Multipart AEAD encrypt/decrypt, AES-GCM, 19 bytes #1 -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":0:"0C0D0E0F101112131415161718191A1B1C1D1E":1:PSA_SUCCESS - -PSA Multipart AEAD encrypt/decrypt, AES GCM, 19 bytes #2 -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"EC46BB63B02520C33C49FD70":0:"B96B49E21D621741632875DB7F6C9243D2D7C2":1:PSA_SUCCESS - -PSA Multipart AEAD encrypt/decrypt, AES-GCM, 19 bytes, 12 byte nonce , 1 -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"E462C58482FE8264AEEB7231":"000102030405060708090A0B":0:"0C0D0E0F101112131415161718191A1B1C1D1E":1:PSA_SUCCESS - -PSA Multipart AEAD encrypt/decrypt, AES GCM, 19 bytes, 12 byte nonce , 2 -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_GCM:"E462C58482FE8264AEEB7231":"EC46BB63B02520C33C49FD70":0:"B96B49E21D621741632875DB7F6C9243D2D7C2":1:PSA_SUCCESS - PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" @@ -2366,13 +2350,13 @@ PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:"":PSA_SUCCESS -PSA Multipart AEAD encrypt/decrypt: invalid algorithm (CTR) +PSA Multipart AEAD decrypt: invalid algorithm (CTR) depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart AEAD encrypt/decrypt: invalid algorithm (ChaCha20) +PSA Multipart AEAD decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C -aead_multipart_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index fdec30fb9f..1a5c23e8e0 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -705,404 +705,6 @@ exit: PSA_DONE( ); } -void aead_multipart_encrypt_decrypt_internal( int key_type_arg, - data_t *key_data, - int alg_arg, - data_t *nonce, - data_t *additional_data, - int ad_part_len, - data_t *input_data, - int data_part_len, - int expected_status_arg ) -{ - mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; - psa_key_type_t key_type = key_type_arg; - psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; - unsigned char *output_data = NULL; - unsigned char *part_data = NULL; - unsigned char *final_data = NULL; - size_t part_data_size; - size_t output_size = 0; - size_t finish_output_size = 0; - size_t output_length = 0; - unsigned char *output_data2 = NULL; - size_t output_size2 = 0; - size_t output_length2 = 0; - size_t key_bits = 0; - size_t tag_length = 0; - size_t tag_size = 0; - size_t nonce_length = 0; - uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; - uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; - uint32_t part_offset = 0; - size_t part_length = 0; - size_t output_part_length = 0; - psa_status_t status = PSA_ERROR_GENERIC_ERROR; - psa_status_t expected_status = expected_status_arg; - psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; - - PSA_ASSERT( psa_crypto_init( ) ); - - psa_set_key_usage_flags( &attributes, - PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); - psa_set_key_algorithm( &attributes, alg ); - psa_set_key_type( &attributes, key_type ); - - PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, - &key ) ); - - PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); - key_bits = psa_get_key_bits( &attributes ); - - tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); - - TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); - - output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); - - ASSERT_ALLOC( output_data, output_size ); - - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - - TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - - ASSERT_ALLOC( final_data, finish_output_size ); - - operation = psa_aead_operation_init( ); - - status = psa_aead_encrypt_setup( &operation, key, alg ); - - /* If the operation is not supported, just skip and not fail in case the - * encryption involves a common limitation of cryptography hardwares and - * an alternative implementation. */ - if( status == PSA_ERROR_NOT_SUPPORTED ) - { - MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); - } - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - goto exit; - } - - nonce_length = nonce->len; - status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - goto exit; - } - -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.alg == PSA_ALG_GCM ) - { - status = psa_aead_set_lengths( &operation, additional_data->len, - input_data->len ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - goto exit; - } - } -#endif - - if( ad_part_len != -1 ) - { - part_offset = 0; - - while( part_offset < additional_data->len ) - { - if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) - { - part_length = additional_data->len - part_offset; - } - else - { - part_length = ad_part_len; - } - - status = psa_aead_update_ad( &operation, - additional_data->x + part_offset, - part_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - goto exit; - } - - part_offset += part_length; - } - } - else - { - status = psa_aead_update_ad( &operation, additional_data->x, - additional_data->len ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - goto exit; - } - } - - if( data_part_len != -1 ) - { - /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); - - ASSERT_ALLOC( part_data, part_data_size ); - - part_offset = 0; - - while( part_offset < input_data->len ) - { - if( input_data->len - part_offset < ( uint32_t ) data_part_len ) - { - part_length = input_data->len - part_offset; - } - else - { - part_length = data_part_len; - } - - status = psa_aead_update( &operation, - ( input_data->x + part_offset ), - part_length, part_data, - part_data_size, &output_part_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - goto exit; - } - - if( output_data && output_part_length ) - { - memcpy( ( output_data + part_offset ), part_data, - output_part_length ); - } - - part_offset += part_length; - output_length += output_part_length; - } - } - else - { - status = psa_aead_update( &operation, input_data->x, - input_data->len, output_data, - output_size, &output_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - goto exit; - } - } - - status = psa_aead_finish( &operation, final_data, - finish_output_size, - &output_part_length, - tag_buffer, tag_length, - &tag_size ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - goto exit; - } - - if( output_data && output_part_length ) - { - memcpy( ( output_data + output_length ), final_data, - output_part_length ); - } - - output_length += output_part_length; - - /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE - * should be exact. */ - if( expected_status != PSA_ERROR_INVALID_ARGUMENT ) - { - TEST_EQUAL( ( output_length + tag_length ), - PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, - input_data->len ) ); - } - - TEST_EQUAL( tag_length, tag_size ); - - if( PSA_SUCCESS == expected_status ) - { - output_size2 = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - output_length ); - ASSERT_ALLOC( output_data2, output_size2 ); - - /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE - * should be exact. */ - TEST_EQUAL( input_data->len, - PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, - ( output_length + - tag_length ) ) ); - - TEST_ASSERT( input_data->len <= - PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length + - tag_length ) ); - - operation = psa_aead_operation_init( ); - - status = psa_aead_decrypt_setup( &operation, key, alg ); - - /* If the operation is not supported, just skip and not fail in case the - * encryption involves a common limitation of cryptography hardwares and - * an alternative implementation. */ - if( status == PSA_ERROR_NOT_SUPPORTED ) - { - MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, - nonce->len ); - } - - TEST_EQUAL( status, expected_status ); - - if( nonce->len == 0 ) - { - /* Use previously generated nonce. */ - status = psa_aead_set_nonce( &operation, nonce_buffer, - nonce_length ); - } - else - { - nonce_length = nonce->len; - status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); - } - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status); - } - -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.alg == PSA_ALG_GCM ) - { - status = psa_aead_set_lengths( &operation, additional_data->len, - output_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_status ); - } - } -#endif - - if( ad_part_len != -1 ) - { - part_offset = 0; - - while( part_offset < additional_data->len ) - { - if( additional_data->len - part_offset < - ( uint32_t ) ad_part_len ) - { - part_length = additional_data->len - part_offset; - } - else - { - part_length = ad_part_len; - } - - PSA_ASSERT( psa_aead_update_ad( &operation, - additional_data->x + - part_offset, - part_length ) ); - - part_offset += part_length; - } - } - else - { - PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, - additional_data->len ) ); - } - - if( data_part_len != -1 ) - { - /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); - - part_data = NULL; - ASSERT_ALLOC( part_data, part_data_size ); - - part_offset = 0; - - while( part_offset < output_length ) - { - if( ( output_length - part_offset ) < - ( uint32_t ) data_part_len ) - { - part_length = ( output_length - part_offset ); - } - else - { - part_length = data_part_len; - } - - PSA_ASSERT( psa_aead_update( &operation, - ( output_data + part_offset ), - part_length, part_data, - part_data_size, - &output_part_length ) ); - - if( output_data2 && output_part_length ) - { - memcpy( ( output_data2 + part_offset ), - part_data, output_part_length ); - } - - part_offset += part_length; - output_length2 += output_part_length; - } - } - else - { - PSA_ASSERT( psa_aead_update( &operation, output_data, - output_length, output_data2, - output_size2, &output_length2 ) ); - } - - PSA_ASSERT( psa_aead_verify( &operation, final_data, - finish_output_size, - &output_part_length, - tag_buffer, tag_length ) ); - - if( output_data2 && output_part_length ) - { - memcpy( ( output_data2 + output_length2 ), final_data, - output_part_length ); - } - - output_length2 += output_part_length; - - ASSERT_COMPARE( input_data->x, input_data->len, - output_data2, output_length2 ); - } - -exit: - psa_destroy_key( key ); - psa_aead_abort( &operation ); - mbedtls_free( output_data ); - mbedtls_free( output_data2 ); - mbedtls_free( part_data ); - mbedtls_free( final_data ); - PSA_DONE( ); -} - /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -4039,54 +3641,6 @@ exit: } /* END_CASE */ -/* BEGIN_CASE */ -void aead_multipart_encrypt_decrypt( int key_type_arg, data_t *key_data, - int alg_arg, - data_t *nonce, - data_t *additional_data, - int test_ad_mp_arg, - data_t *input_data, - int test_data_mp_arg, - int expected_status_arg ) -{ - size_t ad_part_len = 0; - size_t data_part_len = 0; - - if( test_ad_mp_arg == 1 ) - { - for( ad_part_len = 1; ad_part_len <= additional_data->len; - ad_part_len++ ) - { - mbedtls_test_set_step( ad_part_len ); - - aead_multipart_encrypt_decrypt_internal( key_type_arg, key_data, - alg_arg, nonce, - additional_data, - ad_part_len, - input_data, -1, - expected_status_arg ); - } - } - - if( test_data_mp_arg == 1 ) - { - for( data_part_len = 1; data_part_len <= input_data->len; - data_part_len++ ) - { - aead_multipart_encrypt_decrypt_internal( key_type_arg, key_data, - alg_arg, nonce, - additional_data, -1, - input_data, data_part_len, - expected_status_arg ); - } - } - - goto exit; - -exit: -} -/* END_CASE */ - /* BEGIN_CASE */ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, int alg_arg, From 5e3bb131114fd6c72794ac46c3a050395ea9a3e9 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 22 Jun 2021 16:22:13 +0100 Subject: [PATCH 069/966] Add set_lengths argument to all tests. Run all tests that do not require set_lengths with and without setting lengths. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 340 ++++++++++++++++---- tests/suites/test_suite_psa_crypto.function | 16 +- 2 files changed, 288 insertions(+), 68 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 49685b4f4e..7fe94495b5 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2112,251 +2112,467 @@ aead_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f9091 PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1:0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #2 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1:1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=4 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" + +PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=16 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":0:"":1:"f149e2b5f0adaa9842ca5f45b768a8fc" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":0:"":1:0:"f149e2b5f0adaa9842ca5f45b768a8fc" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=0, TAG=16, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":0:"":1:1:"f149e2b5f0adaa9842ca5f45b768a8fc" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=16, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":0:"":1:"204bdb1bd62154bf08922aaa54eed705" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":0:"":1:0:"204bdb1bd62154bf08922aaa54eed705" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=16, TAG=16, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":0:"":1:1:"204bdb1bd62154bf08922aaa54eed705" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=20, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":0:"":1:"1b2d2764573e20ae640bf29d48e5fe05" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":0:"":1:0:"1b2d2764573e20ae640bf29d48e5fe05" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=20, TAG=16, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":0:"":1:1:"1b2d2764573e20ae640bf29d48e5fe05" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":0:"":1:"77e5682a49243d5b9016eb1adafa2d" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":0:"":1:0:"77e5682a49243d5b9016eb1adafa2d" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=48, TAG=15, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":0:"":1:1:"77e5682a49243d5b9016eb1adafa2d" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":0:"d2ae38c4375954835d75b8e4c2f9bbb4":1:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":0:"d2ae38c4375954835d75b8e4c2f9bbb4":1:0:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=16, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":0:"d2ae38c4375954835d75b8e4c2f9bbb4":1:1:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=8, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":0:"d3f3f57033df30c22860231334b099cb":1:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":0:"d3f3f57033df30c22860231334b099cb":1:0:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=8, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":0:"d3f3f57033df30c22860231334b099cb":1:1:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=14, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":0:"e7fb0631eebf9bdba87045b33650c4ce":1:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":0:"e7fb0631eebf9bdba87045b33650c4ce":1:0:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=14, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":0:"e7fb0631eebf9bdba87045b33650c4ce":1:1:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=4, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":0:"636871d4c0aae3da7b55abd8b5f21297":1:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":0:"636871d4c0aae3da7b55abd8b5f21297":1:0:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=4, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":0:"636871d4c0aae3da7b55abd8b5f21297":1:1:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=20, TAG=13, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":0:"3d952be11deb421b56e0ce9d7ce99553":1:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":0:"3d952be11deb421b56e0ce9d7ce99553":1:0:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=20, TAG=13, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":0:"3d952be11deb421b56e0ce9d7ce99553":1:1:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":0:"fdd8a462c86d4365c8bfee0e25fc8a62":1:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":0:"fdd8a462c86d4365c8bfee0e25fc8a62":1:0:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=48, TAG=15, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":0:"fdd8a462c86d4365c8bfee0e25fc8a62":1:1:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":0:"":1:"bdc1ac884d332457a1d2664f168c76f0" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":0:"":1:0:"bdc1ac884d332457a1d2664f168c76f0" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=16, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":0:"":1:1:"bdc1ac884d332457a1d2664f168c76f0" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=12, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":0:"":1:"2fb9c3e41fff24ef07437c47" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":0:"":1:0:"2fb9c3e41fff24ef07437c47" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=12, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":0:"":1:1:"2fb9c3e41fff24ef07437c47" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":0:"":1:"f6d47505ec96c98a42dc3ae719877b87" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":0:"":1:0:"f6d47505ec96c98a42dc3ae719877b87" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=16, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":0:"":1:1:"f6d47505ec96c98a42dc3ae719877b87" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=13, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":0:"":1:"5233f95bdcf5d666fb957acdcb" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":0:"":1:0:"5233f95bdcf5d666fb957acdcb" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=13, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":0:"":1:1:"5233f95bdcf5d666fb957acdcb" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":0:"":1:"d57e27914ecb4a764359d3c0f8d4d6" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":0:"":1:0:"d57e27914ecb4a764359d3c0f8d4d6" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=15, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":0:"":1:1:"d57e27914ecb4a764359d3c0f8d4d6" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=4, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":0:"":1:"72901467" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":0:"":1:0:"72901467" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=4, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":0:"":1:1:"72901467" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":0:"722ee47da4b77424733546c2d400c4e5":1:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":0:"722ee47da4b77424733546c2d400c4e5":1:0:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=15, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":0:"722ee47da4b77424733546c2d400c4e5":1:1:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=12, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":0:"bcf48ddcfe9d011a1003973d68d2d78a":1:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":0:"bcf48ddcfe9d011a1003973d68d2d78a":1:0:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=12, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":0:"bcf48ddcfe9d011a1003973d68d2d78a":1:1:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=16, TAG=14, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":0:"c37aada3d4408e880d47e41df77da9b9":1:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":0:"c37aada3d4408e880d47e41df77da9b9":1:0:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=16, TAG=14, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":0:"c37aada3d4408e880d47e41df77da9b9":1:1:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":0:"e5f410fe939e79b7ad33fbd3aaf5856f":1:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":0:"e5f410fe939e79b7ad33fbd3aaf5856f":1:0:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" + +PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=48, TAG=15, (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":0:"e5f410fe939e79b7ad33fbd3aaf5856f":1:1:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS + +PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS PSA Multipart AEAD decrypt, AES-GCM, invalid signature depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_ERROR_INVALID_SIGNATURE PSA Multipart AEAD decrypt, AES-GCM, T=15 but passing 16 bytes depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_ERROR_INVALID_SIGNATURE PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 18 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:0:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:0:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:"b03c2c20f758a93a8d1220232ad87098":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:0:"b03c2c20f758a93a8d1220232ad87098":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:1:"b03c2c20f758a93a8d1220232ad87098":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:"b22b2dcdcc18adc30d16297b84b459d8":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:0:"b22b2dcdcc18adc30d16297b84b459d8":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:1:"b22b2dcdcc18adc30d16297b84b459d8":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:"7e5fd8b595ddc4753676107951d900e2":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:0:"7e5fd8b595ddc4753676107951d900e2":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:1:"7e5fd8b595ddc4753676107951d900e2":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:"37245449db8f72b1ecdb420f629d3d80":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:0:"37245449db8f72b1ecdb420f629d3d80":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:1:"37245449db8f72b1ecdb420f629d3d80":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:"496909523f574b205d757659c5":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:0:"496909523f574b205d757659c5":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:1:"496909523f574b205d757659c5":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:"b6e056de521a27266dffbc0d96":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:0:"b6e056de521a27266dffbc0d96":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:1:"b6e056de521a27266dffbc0d96":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:"f6d56f8c86f27d957fa63aea22":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:0:"f6d56f8c86f27d957fa63aea22":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:1:"f6d56f8c86f27d957fa63aea22":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:"bd94b34511bc65ae47684805cb":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:0:"bd94b34511bc65ae47684805cb":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:1:"bd94b34511bc65ae47684805cb":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:0:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:0:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:0:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:0:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:1:"":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:"7789b41cb3ee548814ca0b388c10b343":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:0:"7789b41cb3ee548814ca0b388c10b343":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:1:"7789b41cb3ee548814ca0b388c10b343":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:"4860116a6d2deb9bf794bfd6ac5bbbd6":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:0:"4860116a6d2deb9bf794bfd6ac5bbbd6":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:1:"4860116a6d2deb9bf794bfd6ac5bbbd6":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:"ff426dd751190ff826e8b4a0792d746e":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:0:"ff426dd751190ff826e8b4a0792d746e":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:1:"ff426dd751190ff826e8b4a0792d746e":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:"0a0b284515694188b6b6c15bc8a09036":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:0:"0a0b284515694188b6b6c15bc8a09036":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:1:"0a0b284515694188b6b6c15bc8a09036":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:"f386b28e7eb4c2fb8eb5dc66a2":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:0:"f386b28e7eb4c2fb8eb5dc66a2":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:1:"f386b28e7eb4c2fb8eb5dc66a2":PSA_SUCCESS PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:"da1c61fbfcdb73445ad4c7d889":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:0:"da1c61fbfcdb73445ad4c7d889":PSA_SUCCESS + +PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 (lengths set) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:1:"da1c61fbfcdb73445ad4c7d889":PSA_SUCCESS PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:0:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" + +PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) (lengths set) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"":1:"a0784d7a4716f3feb4f64e7f4b39bf04" +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"":1:0:"a0784d7a4716f3feb4f64e7f4b39bf04" + +PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (zero-length input) (lengths set) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"":1:1:"a0784d7a4716f3feb4f64e7f4b39bf04" PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS + +PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) (lengths set) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, bad tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_ERROR_INVALID_SIGNATURE PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:"":PSA_SUCCESS +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:0:"":PSA_SUCCESS + +PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) (lengths set) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:1:"":PSA_SUCCESS PSA Multipart AEAD decrypt: invalid algorithm (CTR) depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:0:"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:0:"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 1a5c23e8e0..2a2f2e61c4 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -272,6 +272,7 @@ static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, int ad_part_len, data_t *input_data, int data_part_len, + int test_set_lengths_arg, data_t *expected_result ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; @@ -340,13 +341,11 @@ static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.alg == PSA_ALG_GCM ) + if( test_set_lengths_arg ) { PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, input_data->len ) ); } -#endif if( ad_part_len != -1 ) { @@ -475,6 +474,7 @@ void aead_multipart_decrypt_internal( int key_type_arg, data_t *key_data, int ad_part_len, data_t *input_data, int data_part_len, + int test_set_lengths_arg, data_t *expected_data, int expected_result_arg ) { @@ -549,8 +549,7 @@ void aead_multipart_decrypt_internal( int key_type_arg, data_t *key_data, goto exit; } -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation.alg == PSA_ALG_GCM ) + if( test_set_lengths_arg ) { status = psa_aead_set_lengths( &operation, additional_data->len, ( input_data->len - tag_length ) ); @@ -561,7 +560,6 @@ void aead_multipart_decrypt_internal( int key_type_arg, data_t *key_data, goto exit; } } -#endif if( ad_part_len != -1 ) { @@ -3601,6 +3599,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, int test_ad_mp_arg, data_t *input_data, int test_data_mp_arg, + int test_set_lengths_arg, data_t *expected_result_arg ) { size_t ad_part_len = 0; @@ -3618,6 +3617,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, additional_data, ad_part_len, input_data, -1, + test_set_lengths_arg, expected_result_arg ); } } @@ -3631,6 +3631,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, alg_arg, nonce, additional_data, -1, input_data, data_part_len, + test_set_lengths_arg, expected_result_arg ); } } @@ -3649,6 +3650,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, int test_ad_mp_arg, data_t *input_data, int test_data_mp_arg, + int test_set_lengths_arg, data_t *expected_data, int expected_status ) { @@ -3667,6 +3669,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, additional_data, ad_part_len, input_data, -1, + test_set_lengths_arg, expected_data, expected_status ); } } @@ -3680,6 +3683,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, alg_arg, nonce, additional_data, -1, input_data, data_part_len, + test_set_lengths_arg, expected_data, expected_status ); } } From 7220cae93c9dc5a820c18e1a9a2329f97c6256ec Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 22 Jun 2021 17:25:57 +0100 Subject: [PATCH 070/966] Ensure generate nonce unavailable in decrypt Signed-off-by: Paul Elliott --- include/psa/crypto_struct.h | 3 ++- library/psa_crypto.c | 9 ++++++++- tests/suites/test_suite_psa_crypto.function | 13 +++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 0f74c5481d..e05c846ff8 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -172,11 +172,12 @@ struct psa_aead_operation_s unsigned int lengths_set : 1; unsigned int ad_started : 1; unsigned int body_started : 1; + unsigned int is_encrypt : 1; psa_driver_aead_context_t ctx; }; -#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} +#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}} static inline struct psa_aead_operation_s psa_aead_operation_init( void ) { const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT; diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 8dc6aad534..aec22c79cf 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3469,7 +3469,10 @@ exit: status = unlock_status; if( status == PSA_SUCCESS ) + { operation->alg = psa_aead_get_base_algorithm( alg ); + operation->is_encrypt = 1; + } else psa_aead_abort( operation ); @@ -3531,7 +3534,10 @@ exit: status = unlock_status; if( status == PSA_SUCCESS ) + { operation->alg = psa_aead_get_base_algorithm( alg ); + operation->is_encrypt = 0; + } else psa_aead_abort( operation ); @@ -3556,7 +3562,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, } if( operation->nonce_set || operation->ad_started || - operation->body_started ) + operation->body_started || operation->is_encrypt == 0 ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3881,6 +3887,7 @@ psa_status_t psa_aead_abort( psa_aead_operation_t *operation ) operation->lengths_set = 0; operation->ad_started = 0; operation->body_started = 0; + operation->is_encrypt = 0; return( status ); } diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 2a2f2e61c4..38545bccc6 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3913,6 +3913,19 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* Test for generating nonce in decrypt setup. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_generate_nonce( &operation, nonce_buffer, + PSA_AEAD_NONCE_MAX_SIZE, + &nonce_length ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + /* Test for setting lengths twice. */ operation = psa_aead_operation_init( ); From e4030f2cd181bd9885dd437d0aef419b5a3fb1be Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 22 Jun 2021 17:36:55 +0100 Subject: [PATCH 071/966] Replace function with macro that already exists I wrote a function to determine the base algorithm given a variant, however this is already implemented by PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG Signed-off-by: Paul Elliott --- library/psa_crypto.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index aec22c79cf..9254f36e7d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3398,20 +3398,7 @@ psa_status_t psa_aead_decrypt( mbedtls_svc_key_id_t key, /* Helper function to get the base algorithm from its variants. */ static psa_algorithm_t psa_aead_get_base_algorithm(psa_algorithm_t alg) { - switch( PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, 0 ) ) - { - case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 0 ): - return( PSA_ALG_CCM ); - - case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ): - return( PSA_ALG_GCM ); - - case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CHACHA20_POLY1305, 0 ): - return( PSA_ALG_CHACHA20_POLY1305 ); - - default: - return( PSA_ERROR_NOT_SUPPORTED ); - } + return PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( alg ); } /* Set the key for a multipart authenticated encryption operation. */ From d89304ebb7f8ee28cf56adfa523cdbafcc48df26 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 22 Jun 2021 17:47:09 +0100 Subject: [PATCH 072/966] Fix formatting issues Signed-off-by: Paul Elliott --- library/psa_crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9254f36e7d..056d5515dc 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3396,7 +3396,7 @@ psa_status_t psa_aead_decrypt( mbedtls_svc_key_id_t key, } /* Helper function to get the base algorithm from its variants. */ -static psa_algorithm_t psa_aead_get_base_algorithm(psa_algorithm_t alg) +static psa_algorithm_t psa_aead_get_base_algorithm( psa_algorithm_t alg ) { return PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( alg ); } @@ -3487,7 +3487,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, goto exit; } - if( operation->nonce_set || operation->lengths_set || + if( operation->nonce_set || operation->lengths_set || operation->ad_started || operation->body_started ) { status = PSA_ERROR_BAD_STATE; From f88a565f183a8f24feff070115f46f1100e6971c Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 22 Jun 2021 17:53:45 +0100 Subject: [PATCH 073/966] Better tag size default for m-aead finish Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 056d5515dc..7a7238cc6d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3772,7 +3772,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; *ciphertext_length = 0; - *tag_length = 0; + *tag_length = tag_size; if( operation->id == 0 ) { From 534d0b44847967fa82c2a25f2d87cfdc853d504b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 22 Jun 2021 19:15:20 +0100 Subject: [PATCH 074/966] Finish / Verify state checks Ensure finish only called when encrypting and verify only called for decrypting, and add tests to ensure this. Signed-off-by: Paul Elliott --- library/psa_crypto.c | 4 +-- tests/suites/test_suite_psa_crypto.function | 35 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 7a7238cc6d..c1071b0f37 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3780,7 +3780,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, goto exit; } - if( !operation->nonce_set ) + if( !operation->nonce_set || operation->is_encrypt == 0 ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3829,7 +3829,7 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, goto exit; } - if( !operation->nonce_set ) + if( !operation->nonce_set || operation->is_encrypt == 1 ) { status = PSA_ERROR_BAD_STATE; goto exit; diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 38545bccc6..67f2395230 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4037,6 +4037,41 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* Test calling finish on decryption. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + TEST_EQUAL( psa_aead_finish( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, tag_length, + &tag_size ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* Test calling verify on encryption. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + TEST_EQUAL( psa_aead_verify( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, + tag_length ), + PSA_ERROR_BAD_STATEcd ); + + psa_aead_abort( &operation ); + + exit: psa_destroy_key( key ); psa_aead_abort( &operation ); From 5b065cb8cd5386ccafd50b3de15ff022a9f25bd0 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 08:33:22 +0100 Subject: [PATCH 075/966] Fix typo Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 67f2395230..5c5c4572b2 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4067,7 +4067,7 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, &output_part_length, tag_buffer, tag_length ), - PSA_ERROR_BAD_STATEcd ); + PSA_ERROR_BAD_STATE ); psa_aead_abort( &operation ); From ad53dcc9752d3af49d9601445326b3a35f88b12f Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 08:50:14 +0100 Subject: [PATCH 076/966] Move common final checks to function Signed-off-by: Paul Elliott --- library/psa_crypto.c | 51 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index c1071b0f37..714e556b5a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3760,6 +3760,18 @@ exit: return( status ); } +static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation ) +{ + if( operation->id == 0 || operation->nonce_set == 0 ) + return( PSA_ERROR_BAD_STATE ); + + if( operation->lengths_set && (operation->ad_remaining != 0 || + operation->body_remaining != 0 ) ) + return( PSA_ERROR_INVALID_ARGUMENT ); + + return( PSA_SUCCESS ); +} + /* Finish encrypting a message in a multipart AEAD operation. */ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, uint8_t *ciphertext, @@ -3774,25 +3786,17 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, *ciphertext_length = 0; *tag_length = tag_size; - if( operation->id == 0 ) + status = psa_aead_final_checks( operation ); + + if( status != PSA_SUCCESS ) + goto exit; + + if( operation->is_encrypt == 0 ) { status = PSA_ERROR_BAD_STATE; goto exit; } - if( !operation->nonce_set || operation->is_encrypt == 0 ) - { - status = PSA_ERROR_BAD_STATE; - goto exit; - } - - if( operation->lengths_set && (operation->ad_remaining != 0 || - operation->body_remaining != 0 ) ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } - status = psa_driver_wrapper_aead_finish( operation, ciphertext, ciphertext_size, ciphertext_length, @@ -3823,24 +3827,21 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, *plaintext_length = 0; - if( operation->id == 0 ) + status = psa_aead_final_checks( operation ); + + if( status != PSA_SUCCESS ) + goto exit; + + if( operation->is_encrypt == 1 ) { status = PSA_ERROR_BAD_STATE; goto exit; } - if( !operation->nonce_set || operation->is_encrypt == 1 ) - { - status = PSA_ERROR_BAD_STATE; - goto exit; - } + status = psa_aead_final_checks( operation ); - if( operation->lengths_set && (operation->ad_remaining != 0 || - operation->body_remaining != 0 ) ) - { - status = PSA_ERROR_INVALID_ARGUMENT; + if( status != PSA_SUCCESS ) goto exit; - } status = psa_driver_wrapper_aead_verify( operation, plaintext, plaintext_size, From fcb5cdc954f4841cef7fb1840e51fad52e52f1ca Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 09:40:12 +0100 Subject: [PATCH 077/966] Add per function hits to driver wrappers Signed-off-by: Paul Elliott --- tests/include/test/drivers/aead.h | 15 +++++++++++++-- tests/src/drivers/test_driver_aead.c | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/include/test/drivers/aead.h b/tests/include/test/drivers/aead.h index 86c18d4d3a..5eabf17de4 100644 --- a/tests/include/test/drivers/aead.h +++ b/tests/include/test/drivers/aead.h @@ -34,12 +34,23 @@ typedef struct { * function call. */ psa_status_t forced_status; /* Count the amount of times AEAD driver functions are called. */ - unsigned long hits; + unsigned long hits_encrypt; + unsigned long hits_decrypt; + unsigned long hits_encrypt_setup; + unsigned long hits_decrypt_setup; + unsigned long hits_set_nonce; + unsigned long hits_set_lengths; + unsigned long hits_update_ad; + unsigned long hits_update; + unsigned long hits_finish; + unsigned long hits_verify; + unsigned long hits_abort; + /* Status returned by the last AEAD driver function call. */ psa_status_t driver_status; } mbedtls_test_driver_aead_hooks_t; -#define MBEDTLS_TEST_DRIVER_AEAD_INIT { 0, 0, 0 } +#define MBEDTLS_TEST_DRIVER_AEAD_INIT { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } static inline mbedtls_test_driver_aead_hooks_t mbedtls_test_driver_aead_hooks_init( void ) { diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index 006d3327f5..698353c5d6 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -40,7 +40,7 @@ psa_status_t mbedtls_test_transparent_aead_encrypt( const uint8_t *plaintext, size_t plaintext_length, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_encrypt++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -71,7 +71,7 @@ psa_status_t mbedtls_test_transparent_aead_decrypt( const uint8_t *ciphertext, size_t ciphertext_length, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_decrypt++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -99,7 +99,7 @@ psa_status_t mbedtls_test_transparent_aead_encrypt_setup( const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_encrypt_setup++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -122,7 +122,7 @@ psa_status_t mbedtls_test_transparent_aead_decrypt_setup( const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_decrypt_setup++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -144,7 +144,7 @@ psa_status_t mbedtls_test_transparent_aead_set_nonce( const uint8_t *nonce, size_t nonce_length ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_set_nonce++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -165,7 +165,7 @@ psa_status_t mbedtls_test_transparent_aead_set_lengths( size_t ad_length, size_t plaintext_length ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_set_lengths++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -187,7 +187,7 @@ psa_status_t mbedtls_test_transparent_aead_update_ad( const uint8_t *input, size_t input_length ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_update_ad++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -211,7 +211,7 @@ psa_status_t mbedtls_test_transparent_aead_update( size_t output_size, size_t *output_length ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_update++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -237,7 +237,7 @@ psa_status_t mbedtls_test_transparent_aead_finish( size_t tag_size, size_t *tag_length ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_finish++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -263,7 +263,7 @@ psa_status_t mbedtls_test_transparent_aead_verify( const uint8_t *tag, size_t tag_length ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_verify++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { @@ -283,7 +283,7 @@ psa_status_t mbedtls_test_transparent_aead_verify( psa_status_t mbedtls_test_transparent_aead_abort( mbedtls_transparent_test_driver_aead_operation_t *operation ) { - mbedtls_test_driver_aead_hooks.hits++; + mbedtls_test_driver_aead_hooks.hits_abort++; if( mbedtls_test_driver_aead_hooks.forced_status != PSA_SUCCESS ) { From d7ab9f1260dc7419203f0153b12524a27afb2f32 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 09:52:19 +0100 Subject: [PATCH 078/966] Move the setting of id in driver wrappers Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 354477a9e1..48410c0e1e 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1458,26 +1458,25 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) + operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; status = mbedtls_test_transparent_aead_encrypt_setup( &operation->ctx.transparent_test_driver_ctx, attributes, key_buffer, key_buffer_size, alg ); - /* Declared with fallback == true */ - operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; + /* Declared with fallback == true */ if( status != PSA_ERROR_NOT_SUPPORTED ) return( status ); #endif /* PSA_CRYPTO_DRIVER_TEST */ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ /* Fell through, meaning no accelerator supports this operation */ + operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; status = mbedtls_psa_aead_encrypt_setup( &operation->ctx.mbedtls_ctx, attributes, key_buffer, key_buffer_size, alg ); - operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; - return( status ); /* Add cases for opaque driver here */ @@ -1507,28 +1506,27 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) + operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; status = mbedtls_test_transparent_aead_decrypt_setup( &operation->ctx.transparent_test_driver_ctx, attributes, key_buffer, key_buffer_size, alg ); - /* Declared with fallback == true */ - operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; + /* Declared with fallback == true */ if( status != PSA_ERROR_NOT_SUPPORTED ) return( status ); #endif /* PSA_CRYPTO_DRIVER_TEST */ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ /* Fell through, meaning no accelerator supports this operation */ + operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; status = mbedtls_psa_aead_decrypt_setup( &operation->ctx.mbedtls_ctx, attributes, key_buffer, key_buffer_size, alg ); - operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; - return( status ); /* Add cases for opaque driver here */ From 2007d70a5ae56e69306632752d14f6af544dfaf8 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 09:56:55 +0100 Subject: [PATCH 079/966] Improve changelog Signed-off-by: Paul Elliott --- ChangeLog.d/add_psa_m_aead.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ChangeLog.d/add_psa_m_aead.txt b/ChangeLog.d/add_psa_m_aead.txt index 3ae58095bd..fa4e7ac61b 100644 --- a/ChangeLog.d/add_psa_m_aead.txt +++ b/ChangeLog.d/add_psa_m_aead.txt @@ -1,4 +1,3 @@ Features - * Added multipart AEAD API to the PSA Crypto API - * Added MbedTLS internal implementations of the PSA Crypto multipart AEAD API - supporting ChaChaPoly and GCM. CCM is not as yet supported. + * Implement the PSA multipart AEAD interface, currently supporting + ChaChaPoly and GCM. From 8fc45169f1b3c8ea54cb70bc33e67da665bcd1f3 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 16:06:01 +0100 Subject: [PATCH 080/966] Fix compiler errors on many platforms. Also added comment to explain why I added a seemingly pointless goto Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 5c5c4572b2..fa5556e50c 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3636,9 +3636,10 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, } } - goto exit; -exit: + /* Goto is required to silence warnings about unused labels, as we + * don't actually do any test assertions in this function. */ + goto exit; } /* END_CASE */ @@ -3688,9 +3689,9 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, } } + /* Goto is required to silence warnings about unused labels, as we + * don't actually do any test assertions in this function. */ goto exit; - -exit: } /* END_CASE */ From 95271f10c372c1a805cbc875aec429bead7ef3c9 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 16:50:45 +0100 Subject: [PATCH 081/966] Call set_nonce direct rather than by wrapper Signed-off-by: Paul Elliott --- library/psa_crypto.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 714e556b5a..9fb3a20941 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3569,8 +3569,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, if( status != PSA_SUCCESS ) goto exit; - status = psa_driver_wrapper_aead_set_nonce( operation, nonce, - required_nonce_size ); + status = psa_aead_set_nonce( operation, nonce, required_nonce_size ); exit: From 3bd5dbacc1fffdaf1d99cd8b431e98b75e04a7b4 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 17:14:40 +0100 Subject: [PATCH 082/966] Improve generate nonce test Make sure the generated nonce works to encrypt test data if the generated nonce is valid. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 10 +++--- tests/suites/test_suite_psa_crypto.function | 39 +++++++++++++++++++-- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 7fe94495b5..f55deb022f 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2576,23 +2576,23 @@ aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f90 PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:PSA_SUCCESS +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"":"":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 12 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:PSA_SUCCESS +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 8 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:"":"":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index fa5556e50c..577b8c6e8e 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3699,7 +3699,9 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, int alg_arg, int nonce_len, - int expected_result_arg ) + data_t *additional_data, + data_t *input_data, + int expected_status_arg ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; @@ -3710,6 +3712,13 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; size_t nonce_generated_len = 0; + unsigned char *output_data = NULL; + unsigned char *final_data = NULL; + size_t output_size = 0; + size_t finish_output_size = 0; + size_t output_length = 0; + size_t tag_length = 0; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; PSA_ASSERT( psa_crypto_init( ) ); @@ -3722,6 +3731,16 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); + + ASSERT_ALLOC( output_data, output_size ); + + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + + TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, finish_output_size ); + operation = psa_aead_operation_init( ); status = psa_aead_encrypt_setup( &operation, key, alg ); @@ -3743,7 +3762,23 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, nonce_len, &nonce_generated_len ); - TEST_ASSERT( status == expected_result_arg ); + TEST_ASSERT( status == expected_status_arg ); + + if( expected_status_arg == PSA_SUCCESS ) + { + + /* Ensure we can still complete operation. */ + + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len, + output_data, output_size, &output_length ) ); + + PSA_ASSERT( psa_aead_finish( &operation, final_data, finish_output_size, + &output_length, tag_buffer, + PSA_AEAD_TAG_MAX_SIZE, &tag_length ) ); + } exit: psa_destroy_key( key ); From 018765164762ecf2110a21994f87043af0081df4 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 18:13:04 +0100 Subject: [PATCH 083/966] Test all set lengths and set/generate nonce orders Test that the two are completely interchangeable in order. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 577b8c6e8e..bb4d7e6119 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3979,6 +3979,46 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* Test that generate/set nonce and set lengths are interchangeable (we + * already tested set nonce followed by set lengths above). */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, + PSA_AEAD_NONCE_MAX_SIZE, + &nonce_length ) ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, + PSA_AEAD_NONCE_MAX_SIZE, + &nonce_length ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + psa_aead_abort( &operation ); + /* Test for setting lengths after already starting data. */ operation = psa_aead_operation_init( ); From cf2d66e022ff9241866f19e49789030e76266e9e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 23 Jun 2021 18:49:56 +0100 Subject: [PATCH 084/966] Remove permitting of 8 byte nonce with PolyChaCha Also unify nonce length checking Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 3b8fdc8b6e..1a515a14af 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -247,6 +247,21 @@ static psa_status_t psa_aead_unpadded_locate_tag( size_t tag_length, return( PSA_SUCCESS ); } +static psa_status_t mbedtls_aead_check_nonce_length( + mbedtls_psa_aead_operation_t *operation, + size_t nonce_length ) +{ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + if( nonce_length != 12 ) + return( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + + return PSA_SUCCESS; +} + psa_status_t mbedtls_psa_aead_decrypt( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, @@ -272,6 +287,13 @@ psa_status_t mbedtls_psa_aead_decrypt( if( status != PSA_SUCCESS ) goto exit; + if( mbedtls_aead_check_nonce_length( &operation, nonce_length ) + != PSA_SUCCESS) + { + status = PSA_ERROR_NOT_SUPPORTED; + goto exit; + } + #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation.alg == PSA_ALG_CCM ) { @@ -303,7 +325,7 @@ psa_status_t mbedtls_psa_aead_decrypt( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation.alg == PSA_ALG_CHACHA20_POLY1305 ) { - if( nonce_length != 12 || operation.tag_length != 16 ) + if( operation.tag_length != 16 ) { status = PSA_ERROR_NOT_SUPPORTED; goto exit; @@ -397,6 +419,12 @@ psa_status_t mbedtls_psa_aead_set_nonce( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + if( mbedtls_aead_check_nonce_length( operation, nonce_length ) + != PSA_SUCCESS) + { + return( PSA_ERROR_INVALID_ARGUMENT ); + } + #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { @@ -412,11 +440,6 @@ psa_status_t mbedtls_psa_aead_set_nonce( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { - if( nonce_length != 12 && nonce_length != 8) - { - return( PSA_ERROR_INVALID_ARGUMENT ); - } - status = mbedtls_to_psa_error( mbedtls_chachapoly_starts( &operation->ctx.chachapoly, nonce, From 16906f9011da64a32e20d80cf2b3571148ad87ac Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 24 Jun 2021 09:57:01 +0100 Subject: [PATCH 085/966] Add missing frees to generate nonce test Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index bb4d7e6119..819c61b52a 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3782,6 +3782,8 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, exit: psa_destroy_key( key ); + mbedtls_free( output_data ); + mbedtls_free( final_data ); psa_aead_abort( &operation ); PSA_DONE( ); } From e24f1a1a9d123fea12a86d65b5cb9d1f0ff1b594 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 24 Jun 2021 14:37:53 +0100 Subject: [PATCH 086/966] Fix missed driver wrapper tests Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto_driver_wrappers.function | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_driver_wrappers.function b/tests/suites/test_suite_psa_crypto_driver_wrappers.function index e86309b065..fb92d34589 100644 --- a/tests/suites/test_suite_psa_crypto_driver_wrappers.function +++ b/tests/suites/test_suite_psa_crypto_driver_wrappers.function @@ -997,7 +997,7 @@ void aead_encrypt( int key_type_arg, data_t *key_data, input_data->x, input_data->len, output_data, output_size, &output_length ); - TEST_EQUAL( mbedtls_test_driver_aead_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_aead_hooks.hits_encrypt, 1 ); TEST_EQUAL( mbedtls_test_driver_aead_hooks.driver_status, forced_status ); TEST_EQUAL( status, ( forced_status == PSA_ERROR_NOT_SUPPORTED ) ? @@ -1061,7 +1061,7 @@ void aead_decrypt( int key_type_arg, data_t *key_data, input_data->x, input_data->len, output_data, output_size, &output_length ); - TEST_EQUAL( mbedtls_test_driver_aead_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_aead_hooks.hits_decrypt, 1 ); TEST_EQUAL( mbedtls_test_driver_aead_hooks.driver_status, forced_status ); TEST_EQUAL( status, ( forced_status == PSA_ERROR_NOT_SUPPORTED ) ? From a8940ed876997c9f0f051c099f769988b27b452a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 24 Jun 2021 16:57:52 +0100 Subject: [PATCH 087/966] Fix documented error codes Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index 50644c0999..57b1b74bf5 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -179,7 +179,7 @@ psa_status_t mbedtls_psa_aead_decrypt( * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_ARGUMENT - * \p key is not compatible with \p alg. + * An invalid block length was supplied. * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY @@ -222,8 +222,8 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( * * \retval #PSA_SUCCESS * Success. - * * \retval #PSA_ERROR_INVALID_ARGUMENT - * \p key is not compatible with \p alg. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * An invalid block length was supplied. * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY @@ -403,7 +403,7 @@ psa_status_t mbedtls_psa_aead_update_ad( * * \retval #PSA_SUCCESS * Success. - + * * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p output buffer is too small. * #PSA_AEAD_UPDATE_OUTPUT_SIZE(\c key_type, \c alg, \p input_length) or From 87c909a8c598c98fb58593d71fff00fb18f46942 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 24 Jun 2021 18:07:39 +0100 Subject: [PATCH 088/966] Make auxiliary function static Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 819c61b52a..502515f2a4 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -467,16 +467,16 @@ exit: return( status ); } -void aead_multipart_decrypt_internal( int key_type_arg, data_t *key_data, - int alg_arg, - data_t *nonce, - data_t *additional_data, - int ad_part_len, - data_t *input_data, - int data_part_len, - int test_set_lengths_arg, - data_t *expected_data, - int expected_result_arg ) +static void aead_multipart_decrypt_internal( int key_type_arg, data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + int ad_part_len, + data_t *input_data, + int data_part_len, + int test_set_lengths_arg, + data_t *expected_data, + int expected_result_arg ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; From 7f429b747b8086781d32eb3db4d48e46a58e8ec7 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 24 Jun 2021 18:08:54 +0100 Subject: [PATCH 089/966] Remove code duplication and fix formatting Signed-off-by: Paul Elliott --- library/psa_crypto.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9fb3a20941..64c05ea6ed 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3549,7 +3549,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, } if( operation->nonce_set || operation->ad_started || - operation->body_started || operation->is_encrypt == 0 ) + operation->body_started || !operation->is_encrypt ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3635,7 +3635,7 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, } if( operation->lengths_set || operation->ad_started || - operation->body_started) + operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3761,7 +3761,7 @@ exit: static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation ) { - if( operation->id == 0 || operation->nonce_set == 0 ) + if( operation->id == 0 || !operation->nonce_set ) return( PSA_ERROR_BAD_STATE ); if( operation->lengths_set && (operation->ad_remaining != 0 || @@ -3790,7 +3790,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, if( status != PSA_SUCCESS ) goto exit; - if( operation->is_encrypt == 0 ) + if( !operation->is_encrypt ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3831,17 +3831,12 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, if( status != PSA_SUCCESS ) goto exit; - if( operation->is_encrypt == 1 ) + if( operation->is_encrypt ) { status = PSA_ERROR_BAD_STATE; goto exit; } - status = psa_aead_final_checks( operation ); - - if( status != PSA_SUCCESS ) - goto exit; - status = psa_driver_wrapper_aead_verify( operation, plaintext, plaintext_size, plaintext_length, From c2b7144da0f807e2ae1b2c64ab2b5184cd41ac53 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 24 Jun 2021 18:17:52 +0100 Subject: [PATCH 090/966] Simplify logic and factor out initial checks Signed-off-by: Paul Elliott --- library/psa_crypto.c | 66 +++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 64c05ea6ed..a9026e4bb5 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3401,6 +3401,28 @@ static psa_algorithm_t psa_aead_get_base_algorithm( psa_algorithm_t alg ) return PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( alg ); } +static psa_status_t psa_aead_setup_checks( psa_aead_operation_t *operation, + psa_algorithm_t alg ) +{ + if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) + { + return( PSA_ERROR_INVALID_ARGUMENT ); + } + + if( operation->id != 0 ) + { + return( PSA_ERROR_BAD_STATE ); + } + + if( operation->nonce_set || operation->lengths_set || + operation->ad_started || operation->body_started ) + { + return( PSA_ERROR_BAD_STATE ); + } + + return( PSA_SUCCESS ); +} + /* Set the key for a multipart authenticated encryption operation. */ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, @@ -3410,24 +3432,10 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; psa_key_slot_t *slot = NULL; - if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } + status = psa_aead_setup_checks( operation, alg ); - if( operation->id != 0 ) - { - status = PSA_ERROR_BAD_STATE; + if( status != PSA_SUCCESS ) goto exit; - } - - if( operation->nonce_set || operation->lengths_set || - operation->ad_started || operation->body_started ) - { - status = PSA_ERROR_BAD_STATE; - goto exit; - } status = psa_get_and_lock_key_slot_with_policy( key, &slot, PSA_KEY_USAGE_ENCRYPT, alg ); @@ -3452,11 +3460,9 @@ exit: unlock_status = psa_unlock_key_slot( slot ); - if( status == PSA_SUCCESS ) - status = unlock_status; - if( status == PSA_SUCCESS ) { + status = unlock_status; operation->alg = psa_aead_get_base_algorithm( alg ); operation->is_encrypt = 1; } @@ -3475,24 +3481,10 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; psa_key_slot_t *slot = NULL; - if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } + status = psa_aead_setup_checks( operation, alg ); - if( operation->id != 0 ) - { - status = PSA_ERROR_BAD_STATE; + if( status != PSA_SUCCESS ) goto exit; - } - - if( operation->nonce_set || operation->lengths_set || - operation->ad_started || operation->body_started ) - { - status = PSA_ERROR_BAD_STATE; - goto exit; - } status = psa_get_and_lock_key_slot_with_policy( key, &slot, PSA_KEY_USAGE_DECRYPT, alg ); @@ -3517,11 +3509,9 @@ exit: unlock_status = psa_unlock_key_slot( slot ); - if( status == PSA_SUCCESS ) - status = unlock_status; - if( status == PSA_SUCCESS ) { + status = unlock_status; operation->alg = psa_aead_get_base_algorithm( alg ); operation->is_encrypt = 0; } From ed68d7464d3444f6627b5a8137f708abe197256d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 24 Jun 2021 20:37:32 +0100 Subject: [PATCH 091/966] Move buffer size checks up to psa_crypto layer Signed-off-by: Paul Elliott --- library/psa_crypto.c | 16 +++++++++++++--- library/psa_crypto_aead.c | 16 ++-------------- library/psa_crypto_aead.h | 18 ++++++++---------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index a9026e4bb5..a5027f386f 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3749,8 +3749,11 @@ exit: return( status ); } -static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation ) +static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation, + size_t output_size ) { + size_t finish_output_size; + if( operation->id == 0 || !operation->nonce_set ) return( PSA_ERROR_BAD_STATE ); @@ -3758,6 +3761,13 @@ static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation ) operation->body_remaining != 0 ) ) return( PSA_ERROR_INVALID_ARGUMENT ); + finish_output_size = operation->is_encrypt ? + PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, operation->alg ) : + PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, operation->alg ); + + if( output_size < finish_output_size ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + return( PSA_SUCCESS ); } @@ -3775,7 +3785,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, *ciphertext_length = 0; *tag_length = tag_size; - status = psa_aead_final_checks( operation ); + status = psa_aead_final_checks( operation, ciphertext_size ); if( status != PSA_SUCCESS ) goto exit; @@ -3816,7 +3826,7 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, *plaintext_length = 0; - status = psa_aead_final_checks( operation ); + status = psa_aead_final_checks( operation, plaintext_size ); if( status != PSA_SUCCESS ) goto exit; diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 1a515a14af..f2096ce3f2 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -603,21 +603,11 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_verify() */ static psa_status_t mbedtls_psa_aead_finish_checks( mbedtls_psa_aead_operation_t *operation, - size_t output_size, size_t tag_size ) { - size_t finish_output_size; - if( tag_size < operation->tag_length ) return ( PSA_ERROR_BUFFER_TOO_SMALL ); - finish_output_size = operation->is_encrypt ? - PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, operation->alg ) : - PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, operation->alg ); - - if( output_size < finish_output_size ) - return ( PSA_ERROR_BUFFER_TOO_SMALL ); - return ( PSA_SUCCESS ); } @@ -634,8 +624,7 @@ psa_status_t mbedtls_psa_aead_finish( psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; size_t finish_output_size = 0; - status = mbedtls_psa_aead_finish_checks( operation, ciphertext_size, - tag_size ); + status = mbedtls_psa_aead_finish_checks( operation, tag_size ); if( status != PSA_SUCCESS ) return status; @@ -690,8 +679,7 @@ psa_status_t mbedtls_psa_aead_verify( int do_tag_check = 1; uint8_t check_tag[PSA_AEAD_TAG_MAX_SIZE]; - status = mbedtls_psa_aead_finish_checks( operation, plaintext_size, - tag_length ); + status = mbedtls_psa_aead_finish_checks( operation, tag_length ); if( status != PSA_SUCCESS ) return status; diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index 57b1b74bf5..c664f9f2bb 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -477,12 +477,10 @@ psa_status_t mbedtls_psa_aead_update( * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_BUFFER_TOO_SMALL - * The size of the \p ciphertext or \p tag buffer is too small. - * #PSA_AEAD_FINISH_OUTPUT_SIZE(\c key_type, \c alg) or - * #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE can be used to determine the - * required \p ciphertext buffer size. #PSA_AEAD_TAG_LENGTH(\c key_type, - * \c key_bits, \c alg) or #PSA_AEAD_TAG_MAX_SIZE can be used to - * determine the required \p tag buffer size. + * The size of the \p tag buffer is too small. + * #PSA_AEAD_TAG_LENGTH(\c key_type, key_bits, \c alg) or + * #PSA_AEAD_TAG_MAX_SIZE can be used to determine the required \p tag + * buffer size. */ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, @@ -551,10 +549,10 @@ psa_status_t mbedtls_psa_aead_finish( * The calculations were successful, but the authentication tag is * not correct. * \retval #PSA_ERROR_BUFFER_TOO_SMALL - * The size of the \p plaintext buffer is too small. - * #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c key_type, \c alg) or - * #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE can be used to determine the - * required buffer size. + * The size of the \p tag buffer is too small. + * #PSA_AEAD_TAG_LENGTH(\c key_type, key_bits, \c alg) or + * #PSA_AEAD_TAG_MAX_SIZE can be used to determine the required \p tag + * buffer size. */ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, From 62cf2e8e9f62db18514da3392a04cd842515990b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 27 Mar 2020 16:35:23 +0100 Subject: [PATCH 092/966] Switch all.sh to bash This will let us use bash features that are not found in some other sh implementations, such as DEBUG and ERR traps, "set -o pipefail", etc. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f8e43c8714..b6f39e96fa 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env sh +#! /usr/bin/env bash # all.sh # @@ -175,8 +175,8 @@ pre_initialize_variables () { # Gather the list of available components. These are the functions # defined in this script whose name starts with "component_". - # Parse the script with sed, because in sh there is no way to list - # defined functions. + # Parse the script with sed. This way we get the functions in the order + # they are defined. ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") # Exclude components that are not supported on this platform. From 5d99682a8c701cff581ee3f33e4e7fbb541010f3 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 28 Mar 2020 21:09:21 +0100 Subject: [PATCH 093/966] Add --error-test option to test error detection and reporting Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index b6f39e96fa..20a20a3151 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -231,6 +231,8 @@ General options: Prefix for a cross-compiler for arm-none-eabi (default: "${ARM_NONE_EABI_GCC_PREFIX}") --armcc Run ARM Compiler builds (on by default). + --error-test Error test mode: run a failing function in addition + to any specified component. --except Exclude the COMPONENTs listed on the command line, instead of running only those. --no-append-outcome Write a new outcome file and analyze it (default). @@ -378,6 +380,7 @@ check_headers_in_cpp () { pre_parse_command_line () { COMMAND_LINE_COMPONENTS= all_except=0 + error_test=0 no_armcc= # Note that legacy options are ignored instead of being omitted from this @@ -390,6 +393,7 @@ pre_parse_command_line () { --armcc) no_armcc=;; --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; + --error-test) error_test=$((error_test + 1));; --except) all_except=1;; --force|-f) FORCE=1;; --gnutls-cli) shift; GNUTLS_CLI="$1";; @@ -2636,6 +2640,19 @@ post_report () { #### Run all the things ################################################################ +# Function invoked by --error-test to test error reporting. +pseudo_component_error_test () { + msg "Testing error reporting $error_test" + if [ $KEEP_GOING -ne 0 ]; then + echo "Expect three failing commands." + fi + error_test='this should not be used since the component runs in a subshell' + grep non_existent /dev/null + not grep -q . "$0" + make unknown_target + false "this should not be executed" +} + # Run one component and clean up afterwards. run_component () { # Back up the configuration in case the component modifies it. @@ -2685,6 +2702,10 @@ cleanup pre_generate_files # Run the requested tests. +while [ $error_test -gt 0 ]; do + run_component pseudo_component_error_test + error_test=$((error_test - 1)) +done for component in $RUN_COMPONENTS; do run_component "component_$component" done From ce266c48bb8214a061c906392b8fbcdf53ac6617 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 28 Mar 2020 18:50:43 +0100 Subject: [PATCH 094/966] Run each component in a subshell and handle errors more robustly This commit completely rewrites keep-going mode. Instead of relying solely on "set -e", which has some subtle limitations (such as being off anywhere inside a conditional), use an ERR trap to record errors. Run each component in a subshell. This way a component can set environment variables, change the current directory, etc., without affecting other components. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 151 ++++++++++++++++++++++++++----------------- 1 file changed, 93 insertions(+), 58 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 20a20a3151..f3494bdd97 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -59,6 +59,15 @@ # This script must be invoked from the toplevel directory of a git # working copy of Mbed TLS. # +# The behavior on an error depends on whether --keep-going (alias -k) +# is in effect. +# * Without --keep-going: the script stops on the first error without +# cleaning up. This lets you work in the configuration of the failing +# component. +# * With --keep-going: the script runs all requested components and +# reports failures at the end. In particular the script always cleans +# up on exit. +# # Note that the output is not saved. You may want to run # script -c tests/scripts/all.sh # or @@ -81,6 +90,9 @@ # # Each component must start by invoking `msg` with a short informative message. # +# Each component is executed in a separate shell process. The component +# fails if any command in it returns a non-zero status. +# # The framework performs some cleanup tasks after each component. This # means that components can assume that the working directory is in a # cleaned-up state, and don't need to perform the cleanup themselves. @@ -91,19 +103,6 @@ # `tests/Makefile` and `programs/fuzz/Makefile` from git. # This cleans up after an in-tree use of CMake. # -# Any command that is expected to fail must be protected so that the -# script keeps running in --keep-going mode despite `set -e`. In keep-going -# mode, if a protected command fails, this is logged as a failure and the -# script will exit with a failure status once it has run all components. -# Commands can be protected in any of the following ways: -# * `make` is a function which runs the `make` command with protection. -# Note that you must write `make VAR=value`, not `VAR=value make`, -# because the `VAR=value make` syntax doesn't work with functions. -# * Put `report_status` before the command to protect it. -# * Put `if_build_successful` before a command. This protects it, and -# additionally skips it if a prior invocation of `make` in the same -# component failed. -# # The tests are roughly in order from fastest to slowest. This doesn't # have to be exact, but in general you should add slower tests towards # the end and fast checks near the beginning. @@ -477,8 +476,9 @@ pre_check_git () { } pre_setup_keep_going () { - failure_summary= - failure_count=0 + failure_count=0 # Number of failed components + last_failure_status=0 # Last failure status in this component + start_red= end_color= if [ -t 1 ]; then @@ -489,57 +489,73 @@ pre_setup_keep_going () { ;; esac fi - record_status () { - if "$@"; then - last_status=0 - else - last_status=$? - text="$current_section: $* -> $last_status" - failure_summary="$failure_summary -$text" - failure_count=$((failure_count + 1)) - echo "${start_red}^^^^$text^^^^${end_color}" >&2 - fi - } - make () { - case "$*" in - *test|*check) - if [ $build_status -eq 0 ]; then - record_status command make "$@" - else - echo "(skipped because the build failed)" - fi - ;; - *) - record_status command make "$@" - build_status=$last_status - ;; + + # Keep a summary of failures in a file. We'll print it out at the end. + failure_summary_file=$PWD/all-sh-failures-$$.log + : >"$failure_summary_file" + + # Whether it makes sense to keep a component going after the specified + # command fails (test command) or not (configure or build). + # This doesn't have to be 100% accurate: all failures are recorded anyway. + can_keep_going_after_failure () { + case "$1" in + "msg "*) false;; + *[!A-Za-z]"test"|*[!A-Za-z]"test"[!A-Za-z]*) true;; + "tests/"*) true;; + "grep "*|"not grep "*) true;; + *) false;; esac } + + # This function runs if there is any error in a component. + # It must either exit with a nonzero status, or set + # last_failure_status to a nonzero value. + err_trap () { + # Save $? (status of the failing command). This must be the very + # first thing, before $? is overridden. + last_failure_status=$? + failed_command=$BASH_COMMAND + + text="$current_section: $failed_command -> $last_failure_status" + echo "${start_red}^^^^$text^^^^${end_color}" >&2 + echo "$text" >>"$failure_summary_file" + + # If the command is fatal (configure or build command), stop this + # component. Otherwise (test command) keep the component running + # (run more tests from the same build). + if ! can_keep_going_after_failure "$failed_command"; then + exit $last_failure_status + fi + } + final_report () { if [ $failure_count -gt 0 ]; then echo echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "${start_red}FAILED: $failure_count${end_color}$failure_summary" + echo "${start_red}FAILED: $failure_count components${end_color}" + cat "$failure_summary_file" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - exit 1 elif [ -z "${1-}" ]; then echo "SUCCESS :)" fi if [ -n "${1-}" ]; then echo "Killed by SIG$1." fi + rm -f "$failure_summary_file" + if [ $failure_count -gt 0 ]; then + exit 1 + fi } } -if_build_succeeded () { - if [ $build_status -eq 0 ]; then - record_status "$@" - fi +# These functions are kept temporarily for backward compatibility. +# Don't use them in new components. +record_status () { + "$@" +} +if_build_succeeded () { + "$@" } - -# to be used instead of ! for commands run with -# record_status or if_build_succeeded not() { ! "$@" } @@ -2667,12 +2683,35 @@ run_component () { # have messed it up or shortened it. redirect_err dd if=/dev/urandom of=./tests/seedfile bs=64 count=1 - # Run the component code. - if [ $QUIET -eq 1 ]; then - # msg() is silenced, so just print the component name here - echo "${current_component#component_}" + # Run the component in a subshell + if [ $KEEP_GOING -eq 1 ]; then + set +e + fi + ( + if [ $QUIET -eq 1 ]; then + # msg() will be silenced, so just print the component name here. + echo "${current_component#component_}" + exec >/dev/null + fi + if [ $KEEP_GOING -eq 1 ]; then + # Keep "set -e" off, and run an ERR trap instead to record failures. + set -E + trap err_trap ERR + fi + # The next line is what runs the component + "$@" + if [ $KEEP_GOING -eq 1 ]; then + trap - ERR + exit $last_failure_status + fi + ) + component_status=$? + if [ $KEEP_GOING -eq 1 ]; then + set -e + if [ $component_status -ne 0 ]; then + failure_count=$((failure_count + 1)) + fi fi - redirect_out "$@" # Restore the build tree to a clean state. cleanup @@ -2689,10 +2728,6 @@ pre_check_git build_status=0 if [ $KEEP_GOING -eq 1 ]; then pre_setup_keep_going -else - record_status () { - "$@" - } fi pre_setup_quiet_redirect pre_prepare_outcome_file From 3664780f98357b211fe6fafb4fb090c6fe630c84 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 28 Mar 2020 18:50:49 +0100 Subject: [PATCH 095/966] Detect errors on the left-hand side of a pipeline Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f3494bdd97..f80b8ff1ea 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -113,8 +113,9 @@ #### Initialization and command line parsing ################################################################ -# Abort on errors (and uninitialised variables) -set -eu +# Abort on errors (even on the left-hand side of a pipe). +# Treat uninitialised variables as errors. +set -e -o pipefail -u pre_check_environment () { if [ -d library -a -d include -a -d tests ]; then :; else From f7e956c85c5204d253db043128ea4260040e158d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 28 Mar 2020 18:56:09 +0100 Subject: [PATCH 096/966] component_test_cmake_out_of_source: simplify and fix error handling Remove ssl-opt.err even if it's empty. Call cat unconditionally: it'll have no visible effect if the file is empty. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f80b8ff1ea..5a0ae4b0fa 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2548,11 +2548,10 @@ component_test_cmake_out_of_source () { # file is missing (ssl-opt.sh tolerates the absence of some files so # may exit with status 0 but emit errors). if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err - if [ -s ssl-opt.err ]; then - cat ssl-opt.err >&2 - record_status [ ! -s ssl-opt.err ] - rm ssl-opt.err - fi + cat ssl-opt.err >&2 + # If ssl-opt.err is non-empty, record an error and keep going. + record_status [ ! -s ssl-opt.err ] + rm ssl-opt.err cd "$MBEDTLS_ROOT_DIR" rm -rf "$OUT_OF_SOURCE_DIR" unset MBEDTLS_ROOT_DIR From 1f0cdaf3af3dbedeb0ae9dd7094df375472d129f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 8 Jul 2021 18:41:16 +0200 Subject: [PATCH 097/966] Stop dispatching through obsolete functions Remove the obsolete functions record_status and if_build_succeeded. They didn't affect error detection, but they made error reporting worse since $BASH_COMMAND would be the unexpanded "$@". Keep the function definitions for the sake of pull requests using them that may still be in flight. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 209 ++++++++++++++++++++++--------------------- 1 file changed, 105 insertions(+), 104 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 5a0ae4b0fa..8b8e3dd590 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -549,14 +549,15 @@ pre_setup_keep_going () { } } -# These functions are kept temporarily for backward compatibility. -# Don't use them in new components. +# record_status() and if_build_succeeded() are kept temporarily for backward +# compatibility. Don't use them in new components. record_status () { "$@" } if_build_succeeded () { "$@" } + not() { ! "$@" } @@ -707,24 +708,24 @@ pre_generate_files() { component_check_recursion () { msg "Check: recursion.pl" # < 1s - record_status tests/scripts/recursion.pl library/*.c + tests/scripts/recursion.pl library/*.c } component_check_generated_files () { msg "Check: check-generated-files, files generated with make" # 2s make generated_files - record_status tests/scripts/check-generated-files.sh + tests/scripts/check-generated-files.sh msg "Check: check-generated-files -u, files present" # 2s - record_status tests/scripts/check-generated-files.sh -u + tests/scripts/check-generated-files.sh -u # Check that the generated files are considered up to date. - record_status tests/scripts/check-generated-files.sh + tests/scripts/check-generated-files.sh msg "Check: check-generated-files -u, files absent" # 2s command make neat - record_status tests/scripts/check-generated-files.sh -u + tests/scripts/check-generated-files.sh -u # Check that the generated files are considered up to date. - record_status tests/scripts/check-generated-files.sh + tests/scripts/check-generated-files.sh # This component ends with the generated files present in the source tree. # This is necessary for subsequent components! @@ -732,18 +733,18 @@ component_check_generated_files () { component_check_doxy_blocks () { msg "Check: doxygen markup outside doxygen blocks" # < 1s - record_status tests/scripts/check-doxy-blocks.pl + tests/scripts/check-doxy-blocks.pl } component_check_files () { msg "Check: file sanity checks (permissions, encodings)" # < 1s - record_status tests/scripts/check_files.py + tests/scripts/check_files.py } component_check_changelog () { msg "Check: changelog entries" # < 1s rm -f ChangeLog.new - record_status scripts/assemble_changelog.py -o ChangeLog.new + scripts/assemble_changelog.py -o ChangeLog.new if [ -e ChangeLog.new ]; then # Show the diff for information. It isn't an error if the diff is # non-empty. @@ -754,7 +755,7 @@ component_check_changelog () { component_check_names () { msg "Check: declared and exported names (builds the library)" # < 3s - record_status tests/scripts/check-names.sh -v + tests/scripts/check-names.sh -v } component_check_test_cases () { @@ -764,13 +765,13 @@ component_check_test_cases () { else opt='' fi - record_status tests/scripts/check_test_cases.py $opt + tests/scripts/check_test_cases.py $opt unset opt } component_check_doxygen_warnings () { msg "Check: doxygen warnings (builds the documentation)" # ~ 3s - record_status tests/scripts/doxygen.sh + tests/scripts/doxygen.sh } @@ -790,7 +791,7 @@ component_test_default_out_of_box () { make test msg "selftest: make, default config (out-of-box)" # ~10s - if_build_succeeded programs/test/selftest + programs/test/selftest export MBEDTLS_TEST_OUTCOME_FILE="$SAVE_MBEDTLS_TEST_OUTCOME_FILE" unset SAVE_MBEDTLS_TEST_OUTCOME_FILE @@ -805,16 +806,16 @@ component_test_default_cmake_gcc_asan () { make test msg "test: selftest (ASan build)" # ~ 10s - if_build_succeeded programs/test/selftest + programs/test/selftest msg "test: ssl-opt.sh (ASan build)" # ~ 1 min - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh msg "test: compat.sh (ASan build)" # ~ 6 min - if_build_succeeded tests/compat.sh + tests/compat.sh msg "test: context-info.sh (ASan build)" # ~ 15 sec - if_build_succeeded tests/context-info.sh + tests/context-info.sh } component_test_full_cmake_gcc_asan () { @@ -827,16 +828,16 @@ component_test_full_cmake_gcc_asan () { make test msg "test: selftest (ASan build)" # ~ 10s - if_build_succeeded programs/test/selftest + programs/test/selftest msg "test: ssl-opt.sh (full config, ASan build)" - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh msg "test: compat.sh (full config, ASan build)" - if_build_succeeded tests/compat.sh + tests/compat.sh msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec - if_build_succeeded tests/context-info.sh + tests/context-info.sh } component_test_psa_crypto_key_id_encodes_owner () { @@ -874,7 +875,7 @@ component_build_psa_crypto_spm () { # Check that if a symbol is renamed by crypto_spe.h, the non-renamed # version is not present. echo "Checking for renamed symbols in the library" - if_build_succeeded check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a + check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a } component_test_psa_crypto_client () { @@ -900,7 +901,7 @@ component_test_psa_crypto_rsa_no_genprime() { component_test_ref_configs () { msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . - record_status tests/scripts/test-ref-configs.pl + tests/scripts/test-ref-configs.pl } component_test_no_renegotiation () { @@ -913,7 +914,7 @@ component_test_no_renegotiation () { make test msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh } component_test_no_pem_no_fs () { @@ -929,7 +930,7 @@ component_test_no_pem_no_fs () { make test msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh } component_test_rsa_no_crt () { @@ -942,13 +943,13 @@ component_test_rsa_no_crt () { make test msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s - if_build_succeeded tests/ssl-opt.sh -f RSA + tests/ssl-opt.sh -f RSA msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min - if_build_succeeded tests/compat.sh -t RSA + tests/compat.sh -t RSA msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec - if_build_succeeded tests/context-info.sh + tests/context-info.sh } component_test_no_ctr_drbg_classic () { @@ -967,10 +968,10 @@ component_test_no_ctr_drbg_classic () { # The SSL tests are slow, so run a small subset, just enough to get # confidence that the SSL code copes with HMAC_DRBG. msg "test: Full minus CTR_DRBG, classic crypto - ssl-opt.sh (subset)" - if_build_succeeded tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server' + tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server' msg "test: Full minus CTR_DRBG, classic crypto - compat.sh (subset)" - if_build_succeeded tests/compat.sh -m tls1_2 -t 'ECDSA PSK' -V NO -p OpenSSL + tests/compat.sh -m tls1_2 -t 'ECDSA PSK' -V NO -p OpenSSL } component_test_no_ctr_drbg_use_psa () { @@ -989,10 +990,10 @@ component_test_no_ctr_drbg_use_psa () { # The SSL tests are slow, so run a small subset, just enough to get # confidence that the SSL code copes with HMAC_DRBG. msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)" - if_build_succeeded tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server' + tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server' msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - compat.sh (subset)" - if_build_succeeded tests/compat.sh -m tls1_2 -t 'ECDSA PSK' -V NO -p OpenSSL + tests/compat.sh -m tls1_2 -t 'ECDSA PSK' -V NO -p OpenSSL } component_test_no_hmac_drbg_classic () { @@ -1014,12 +1015,12 @@ component_test_no_hmac_drbg_classic () { # Test SSL with non-deterministic ECDSA. Only test features that # might be affected by how ECDSA signature is performed. msg "test: Full minus HMAC_DRBG, classic crypto - ssl-opt.sh (subset)" - if_build_succeeded tests/ssl-opt.sh -f 'Default\|SSL async private: sign' + tests/ssl-opt.sh -f 'Default\|SSL async private: sign' # To save time, only test one protocol version, since this part of # the protocol is identical in (D)TLS up to 1.2. msg "test: Full minus HMAC_DRBG, classic crypto - compat.sh (ECDSA)" - if_build_succeeded tests/compat.sh -m tls1_2 -t 'ECDSA' + tests/compat.sh -m tls1_2 -t 'ECDSA' } component_test_no_hmac_drbg_use_psa () { @@ -1041,12 +1042,12 @@ component_test_no_hmac_drbg_use_psa () { # Test SSL with non-deterministic ECDSA. Only test features that # might be affected by how ECDSA signature is performed. msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)" - if_build_succeeded tests/ssl-opt.sh -f 'Default\|SSL async private: sign' + tests/ssl-opt.sh -f 'Default\|SSL async private: sign' # To save time, only test one protocol version, since this part of # the protocol is identical in (D)TLS up to 1.2. msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - compat.sh (ECDSA)" - if_build_succeeded tests/compat.sh -m tls1_2 -t 'ECDSA' + tests/compat.sh -m tls1_2 -t 'ECDSA' } component_test_psa_external_rng_no_drbg_classic () { @@ -1069,7 +1070,7 @@ component_test_psa_external_rng_no_drbg_classic () { make test msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - ssl-opt.sh (subset)" - if_build_succeeded tests/ssl-opt.sh -f 'Default' + tests/ssl-opt.sh -f 'Default' } component_test_psa_external_rng_no_drbg_use_psa () { @@ -1088,7 +1089,7 @@ component_test_psa_external_rng_no_drbg_use_psa () { make test msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - ssl-opt.sh (subset)" - if_build_succeeded tests/ssl-opt.sh -f 'Default\|opaque' + tests/ssl-opt.sh -f 'Default\|opaque' } component_test_psa_external_rng_use_psa_crypto () { @@ -1103,7 +1104,7 @@ component_test_psa_external_rng_use_psa_crypto () { make test msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG" - if_build_succeeded tests/ssl-opt.sh -f 'Default\|opaque' + tests/ssl-opt.sh -f 'Default\|opaque' } component_test_everest () { @@ -1116,11 +1117,11 @@ component_test_everest () { make test msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s - if_build_succeeded tests/ssl-opt.sh -f ECDH + tests/ssl-opt.sh -f ECDH msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min # Exclude some symmetric ciphers that are redundant here to gain time. - if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA\|DES' + tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA\|DES' } component_test_everest_curve25519_only () { @@ -1150,7 +1151,7 @@ component_test_small_ssl_out_content_len () { make msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" - if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet" + tests/ssl-opt.sh -f "Max fragment\|Large packet" } component_test_small_ssl_in_content_len () { @@ -1161,7 +1162,7 @@ component_test_small_ssl_in_content_len () { make msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" - if_build_succeeded tests/ssl-opt.sh -f "Max fragment" + tests/ssl-opt.sh -f "Max fragment" } component_test_small_ssl_dtls_max_buffering () { @@ -1171,7 +1172,7 @@ component_test_small_ssl_dtls_max_buffering () { make msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" - if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" + tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" } component_test_small_mbedtls_ssl_dtls_max_buffering () { @@ -1181,15 +1182,15 @@ component_test_small_mbedtls_ssl_dtls_max_buffering () { make msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" - if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" + tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" } component_test_psa_collect_statuses () { msg "build+test: psa_collect_statuses" # ~30s scripts/config.py full - record_status tests/scripts/psa_collect_statuses.py + tests/scripts/psa_collect_statuses.py # Check that psa_crypto_init() succeeded at least once - record_status grep -q '^0:psa_crypto_init:' tests/statuses.log + grep -q '^0:psa_crypto_init:' tests/statuses.log rm -f tests/statuses.log } @@ -1203,16 +1204,16 @@ component_test_full_cmake_clang () { make test msg "test: psa_constant_names (full config, clang)" # ~ 1s - record_status tests/scripts/test_psa_constant_names.py + tests/scripts/test_psa_constant_names.py msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s - if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private' + tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private' msg "test: compat.sh DES, 3DES & NULL (full config)" # ~ 2 min - if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES' + env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES' msg "test: compat.sh ARIA + ChachaPoly" - if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' + env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' } component_test_memsan_constant_flow () { @@ -1319,59 +1320,59 @@ component_build_crypto_default () { msg "build: make, crypto only" scripts/config.py crypto make CFLAGS='-O1 -Werror' - if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* + are_empty_libraries library/libmbedx509.* library/libmbedtls.* } component_build_crypto_full () { msg "build: make, crypto only, full config" scripts/config.py crypto_full make CFLAGS='-O1 -Werror' - if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* + are_empty_libraries library/libmbedx509.* library/libmbedtls.* } component_build_crypto_baremetal () { msg "build: make, crypto only, baremetal config" scripts/config.py crypto_baremetal make CFLAGS='-O1 -Werror' - if_build_succeeded are_empty_libraries library/libmbedx509.* library/libmbedtls.* + are_empty_libraries library/libmbedx509.* library/libmbedtls.* } component_test_depends_curves () { msg "test/build: curves.pl (gcc)" # ~ 4 min - record_status tests/scripts/curves.pl + tests/scripts/curves.pl } component_test_depends_curves_psa () { msg "test/build: curves.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)" scripts/config.py set MBEDTLS_USE_PSA_CRYPTO - record_status tests/scripts/curves.pl + tests/scripts/curves.pl } component_test_depends_hashes () { msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min - record_status tests/scripts/depends-hashes.pl + tests/scripts/depends-hashes.pl } component_test_depends_hashes_psa () { msg "test/build: depends-hashes.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)" scripts/config.py set MBEDTLS_USE_PSA_CRYPTO - record_status tests/scripts/depends-hashes.pl + tests/scripts/depends-hashes.pl } component_test_depends_pkalgs () { msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min - record_status tests/scripts/depends-pkalgs.pl + tests/scripts/depends-pkalgs.pl } component_test_depends_pkalgs_psa () { msg "test/build: depends-pkalgs.pl with MBEDTLS_USE_PSA_CRYPTO defined (gcc)" scripts/config.py set MBEDTLS_USE_PSA_CRYPTO - record_status tests/scripts/depends-pkalgs.pl + tests/scripts/depends-pkalgs.pl } component_build_key_exchanges () { msg "test/build: key-exchanges (gcc)" # ~ 1 min - record_status tests/scripts/key-exchanges.pl + tests/scripts/key-exchanges.pl } component_build_default_make_gcc_and_cxx () { @@ -1379,7 +1380,7 @@ component_build_default_make_gcc_and_cxx () { make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' msg "test: verify header list in cpp_dummy_build.cpp" - record_status check_headers_in_cpp + check_headers_in_cpp msg "build: Unix make, incremental g++" make TEST_CPP=1 @@ -1434,16 +1435,16 @@ component_test_no_use_psa_crypto_full_cmake_asan() { make test msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)" - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)" - if_build_succeeded tests/compat.sh + tests/compat.sh msg "test: compat.sh DES & NULL (full minus MBEDTLS_USE_PSA_CRYPTO)" - if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES' + env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES' msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)" - if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' + env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' } component_test_psa_crypto_config_basic() { @@ -1916,7 +1917,7 @@ component_test_memory_buffer_allocator () { msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. - if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy' + tests/ssl-opt.sh -e '^DTLS proxy' } component_test_no_max_fragment_length () { @@ -1927,7 +1928,7 @@ component_test_no_max_fragment_length () { make msg "test: ssl-opt.sh, MFL-related tests" - if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" + tests/ssl-opt.sh -f "Max fragment length" } component_test_asan_remove_peer_certificate () { @@ -1940,13 +1941,13 @@ component_test_asan_remove_peer_certificate () { make test msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" - if_build_succeeded tests/compat.sh + tests/compat.sh msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" - if_build_succeeded tests/context-info.sh + tests/context-info.sh } component_test_no_max_fragment_length_small_ssl_out_content_len () { @@ -1958,10 +1959,10 @@ component_test_no_max_fragment_length_small_ssl_out_content_len () { make msg "test: MFL tests (disabled MFL extension case) & large packet tests" - if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer" + tests/ssl-opt.sh -f "Max fragment length\|Large buffer" msg "test: context-info.sh (disabled MFL extension case)" - if_build_succeeded tests/context-info.sh + tests/context-info.sh } component_test_variable_ssl_in_out_buffer_len () { @@ -1974,10 +1975,10 @@ component_test_variable_ssl_in_out_buffer_len () { make test msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" - if_build_succeeded tests/compat.sh + tests/compat.sh } component_test_variable_ssl_in_out_buffer_len_CID () { @@ -1992,10 +1993,10 @@ component_test_variable_ssl_in_out_buffer_len_CID () { make test msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled" - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled" - if_build_succeeded tests/compat.sh + tests/compat.sh } component_test_ssl_alloc_buffer_and_mfl () { @@ -2012,7 +2013,7 @@ component_test_ssl_alloc_buffer_and_mfl () { make test msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" - if_build_succeeded tests/ssl-opt.sh -f "Handshake memory usage" + tests/ssl-opt.sh -f "Handshake memory usage" } component_test_when_no_ciphersuites_have_mac () { @@ -2026,7 +2027,7 @@ component_test_when_no_ciphersuites_have_mac () { make test msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC" - if_build_succeeded tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM' + tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM' } component_test_no_date_time () { @@ -2062,7 +2063,7 @@ component_test_malloc_0_null () { msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" # Just the calloc selftest. "make test" ran the others as part of the # test suites. - if_build_succeeded programs/test/selftest calloc + programs/test/selftest calloc msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)" # Run a subset of the tests. The choice is a balance between coverage @@ -2070,7 +2071,7 @@ component_test_malloc_0_null () { # The current choice is to skip tests whose description includes # "proxy", which is an approximation of skipping tests that use the # UDP proxy, which tend to be slower and flakier. - if_build_succeeded tests/ssl-opt.sh -e 'proxy' + tests/ssl-opt.sh -e 'proxy' } component_test_aes_fewer_tables () { @@ -2261,7 +2262,7 @@ component_test_m32_o1 () { make test msg "test ssl-opt.sh, i386, make, gcc-O1" - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh } support_test_m32_o1 () { support_test_m32_o0 "$@" @@ -2276,11 +2277,11 @@ component_test_m32_everest () { make test msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s - if_build_succeeded tests/ssl-opt.sh -f ECDH + tests/ssl-opt.sh -f ECDH msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min # Exclude some symmetric ciphers that are redundant here to gain time. - if_build_succeeded tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA\|DES' + tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA\|DES' } support_test_m32_everest () { support_test_m32_o0 "$@" @@ -2378,7 +2379,7 @@ component_test_no_x509_info () { make test msg "test: ssl-opt.sh, full + MBEDTLS_X509_REMOVE_INFO" # ~ 1 min - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh } component_build_arm_none_eabi_gcc () { @@ -2419,7 +2420,7 @@ component_build_arm_none_eabi_gcc_no_udbl_division () { scripts/config.py set MBEDTLS_NO_UDBL_DIVISION make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra' lib echo "Checking that software 64-bit division is not required" - if_build_succeeded not grep __aeabi_uldiv library/*.o + not grep __aeabi_uldiv library/*.o } component_build_arm_none_eabi_gcc_no_64bit_multiplication () { @@ -2428,7 +2429,7 @@ component_build_arm_none_eabi_gcc_no_64bit_multiplication () { scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -O1 -march=armv6-m -mthumb' lib echo "Checking that software 64-bit multiplication is not required" - if_build_succeeded not grep __aeabi_lmul library/*.o + not grep __aeabi_lmul library/*.o } component_build_armcc () { @@ -2496,13 +2497,13 @@ component_test_memsan () { make test msg "test: ssl-opt.sh (MSan)" # ~ 1 min - if_build_succeeded tests/ssl-opt.sh + tests/ssl-opt.sh # Optional part(s) if [ "$MEMORY" -gt 0 ]; then msg "test: compat.sh (MSan)" # ~ 6 min 20s - if_build_succeeded tests/compat.sh + tests/compat.sh fi } @@ -2518,17 +2519,17 @@ component_test_valgrind () { # seem to receive signals under valgrind on OS X). if [ "$MEMORY" -gt 0 ]; then msg "test: ssl-opt.sh --memcheck (Release)" - if_build_succeeded tests/ssl-opt.sh --memcheck + tests/ssl-opt.sh --memcheck fi if [ "$MEMORY" -gt 1 ]; then msg "test: compat.sh --memcheck (Release)" - if_build_succeeded tests/compat.sh --memcheck + tests/compat.sh --memcheck fi if [ "$MEMORY" -gt 0 ]; then msg "test: context-info.sh --memcheck (Release)" - if_build_succeeded tests/context-info.sh --memcheck + tests/context-info.sh --memcheck fi } @@ -2547,10 +2548,10 @@ component_test_cmake_out_of_source () { # "No such file or directory", which would indicate that some required # file is missing (ssl-opt.sh tolerates the absence of some files so # may exit with status 0 but emit errors). - if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err + ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err cat ssl-opt.err >&2 # If ssl-opt.err is non-empty, record an error and keep going. - record_status [ ! -s ssl-opt.err ] + [ ! -s ssl-opt.err ] rm ssl-opt.err cd "$MBEDTLS_ROOT_DIR" rm -rf "$OUT_OF_SOURCE_DIR" @@ -2564,7 +2565,7 @@ component_test_cmake_as_subdirectory () { cd programs/test/cmake_subproject cmake . make - if_build_succeeded ./cmake_subproject + ./cmake_subproject cd "$MBEDTLS_ROOT_DIR" unset MBEDTLS_ROOT_DIR @@ -2577,7 +2578,7 @@ component_test_cmake_as_package () { cd programs/test/cmake_package cmake . make - if_build_succeeded ./cmake_package + ./cmake_package cd "$MBEDTLS_ROOT_DIR" unset MBEDTLS_ROOT_DIR @@ -2590,7 +2591,7 @@ component_test_cmake_as_package_install () { cd programs/test/cmake_package_install cmake . make - if_build_succeeded ./cmake_package_install + ./cmake_package_install cd "$MBEDTLS_ROOT_DIR" unset MBEDTLS_ROOT_DIR @@ -2615,9 +2616,9 @@ component_test_zeroize () { for compiler in clang gcc; do msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" - if_build_succeeded gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log - if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log - if_build_succeeded not grep -i "error" test_zeroize.log + gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log + grep "The buffer was correctly zeroized" test_zeroize.log + not grep -i "error" test_zeroize.log rm -f test_zeroize.log make clean done @@ -2628,7 +2629,7 @@ component_test_zeroize () { component_check_python_files () { msg "Lint: Python scripts" - record_status tests/scripts/check-python-files.sh + tests/scripts/check-python-files.sh } component_check_generate_test_code () { @@ -2636,7 +2637,7 @@ component_check_generate_test_code () { # unittest writes out mundane stuff like number or tests run on stderr. # Our convention is to reserve stderr for actual errors, and write # harmless info on stdout so it can be suppress with --quiet. - record_status ./tests/scripts/test_generate_test_code.py 2>&1 + ./tests/scripts/test_generate_test_code.py 2>&1 } ################################################################ From fec30cbe8c800dcc3615601eb2d6859de8d78da5 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 28 Mar 2020 19:34:23 +0100 Subject: [PATCH 098/966] Fix double reporting when the last command of a function fails Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 8b8e3dd590..cb3c8f2fb9 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -480,6 +480,11 @@ pre_setup_keep_going () { failure_count=0 # Number of failed components last_failure_status=0 # Last failure status in this component + # See err_trap + previous_failure_status=0 + previous_failed_command= + previous_failure_funcall_depth=0 + start_red= end_color= if [ -t 1 ]; then @@ -517,6 +522,21 @@ pre_setup_keep_going () { last_failure_status=$? failed_command=$BASH_COMMAND + if [[ $last_failure_status -eq $previous_failure_status && + "$failed_command" == "$previous_failed_command" && + ${#FUNCNAME[@]} == $((previous_failure_funcall_depth - 1)) ]] + then + # The same command failed twice in a row, but this time one level + # less deep in the function call stack. This happens when the last + # command of a function returns a nonzero status, and the function + # returns that same status. Ignore the second failure. + previous_failure_funcall_depth=${#FUNCNAME[@]} + return + fi + previous_failure_status=$last_failure_status + previous_failed_command=$failed_command + previous_failure_funcall_depth=${#FUNCNAME[@]} + text="$current_section: $failed_command -> $last_failure_status" echo "${start_red}^^^^$text^^^^${end_color}" >&2 echo "$text" >>"$failure_summary_file" From a681c59d348f362bd18fcff72c694fc8ede98546 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 28 Mar 2020 21:27:40 +0100 Subject: [PATCH 099/966] Better not function In the `not` function, in keep-going mode, arrange to report the failing command (rather than `"$@"`). Note that the `!` keyword should not be used, because failures with `!` are not reported properly. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index cb3c8f2fb9..d95ca7b897 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -90,6 +90,9 @@ # # Each component must start by invoking `msg` with a short informative message. # +# Warning: due to the way bash detects errors, the failure of a command +# inside 'if' or '!' is not detected. Use the 'not' function instead of '!'. +# # Each component is executed in a separate shell process. The component # fails if any command in it returns a non-zero status. # @@ -484,6 +487,7 @@ pre_setup_keep_going () { previous_failure_status=0 previous_failed_command= previous_failure_funcall_depth=0 + unset report_failed_command start_red= end_color= @@ -508,7 +512,7 @@ pre_setup_keep_going () { "msg "*) false;; *[!A-Za-z]"test"|*[!A-Za-z]"test"[!A-Za-z]*) true;; "tests/"*) true;; - "grep "*|"not grep "*) true;; + "grep "*|"! grep "*) true;; *) false;; esac } @@ -520,7 +524,7 @@ pre_setup_keep_going () { # Save $? (status of the failing command). This must be the very # first thing, before $? is overridden. last_failure_status=$? - failed_command=$BASH_COMMAND + failed_command=${report_failed_command-$BASH_COMMAND} if [[ $last_failure_status -eq $previous_failure_status && "$failed_command" == "$previous_failed_command" && @@ -578,8 +582,14 @@ if_build_succeeded () { "$@" } -not() { - ! "$@" +# '! true' does not trigger the ERR trap. Arrange to trigger it, with +# a reasonably informative error message (not just "$@"). +not () { + if "$@"; then + report_failed_command="! $*" + false + unset report_failed_command + fi } pre_setup_quiet_redirect () { From b80f0d20ea063ff0a87ac52e58c8155faf53f8bd Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 28 Mar 2020 21:37:59 +0100 Subject: [PATCH 100/966] Complain if an unsupported component is explicitly requested In all.sh, when an explicit list of components is specified, error out if one of the components is not known or not supported. Patterns that happen to match zero components are still effectively ignored. Fix #2783 Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index d95ca7b897..61b17e1022 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -444,6 +444,24 @@ pre_parse_command_line () { COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" fi + if [ $all_except -eq 0 ]; then + unsupported=0 + for component in $COMMAND_LINE_COMPONENTS; do + case $component in + *[*?\[]*) continue;; + esac + case " $SUPPORTED_COMPONENTS " in + *" $component "*) :;; + *) + echo >&2 "Component $component was explicitly requested, but is not known or not supported." + unsupported=$((unsupported + 1));; + esac + done + if [ $unsupported -ne 0 ]; then + exit 2 + fi + fi + # Build the list of components to run. RUN_COMPONENTS= for component in $SUPPORTED_COMPONENTS; do From c2e22ee27177c2041cdb047325db20df500796d4 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 28 Mar 2020 22:02:50 +0100 Subject: [PATCH 101/966] Remove code that is useless now that components run in a subshell Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 61b17e1022..6249977c82 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -267,10 +267,6 @@ EOF # remove built files as well as the cmake cache/config cleanup() { - if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then - cd "$MBEDTLS_ROOT_DIR" - fi - command make clean # Remove CMake artefacts @@ -2603,7 +2599,6 @@ component_test_cmake_out_of_source () { rm ssl-opt.err cd "$MBEDTLS_ROOT_DIR" rm -rf "$OUT_OF_SOURCE_DIR" - unset MBEDTLS_ROOT_DIR } component_test_cmake_as_subdirectory () { From aca0b32132533acec4cbb9c64b5e64338bb04145 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 20 Apr 2020 13:21:27 +0200 Subject: [PATCH 102/966] Keep going after a shell "[" a.k.a. "test" fails This is necessary to actually keep going and finish the component-specific cleanup in component_test_cmake_out_of_source if ssl-opt.err is non-empty. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 6249977c82..afc1a49185 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -527,6 +527,7 @@ pre_setup_keep_going () { *[!A-Za-z]"test"|*[!A-Za-z]"test"[!A-Za-z]*) true;; "tests/"*) true;; "grep "*|"! grep "*) true;; + "test "*|"[ "*) true;; *) false;; esac } From 88a07457c7e6dbe0c170a75110f84bad39f156c6 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 8 Jul 2021 19:03:50 +0200 Subject: [PATCH 103/966] Remove barely-used redirect functions redirect_out was no longer used and redirect_err was only used to quiet dd. Change the dd invocation to only print diagnostics on error (on platforms where this is possible). Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index afc1a49185..4614029ad0 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -607,24 +607,6 @@ not () { fi } -pre_setup_quiet_redirect () { - if [ $QUIET -ne 1 ]; then - redirect_out () { - "$@" - } - redirect_err () { - "$@" - } - else - redirect_out () { - "$@" >/dev/null - } - redirect_err () { - "$@" 2>/dev/null - } - fi -} - pre_prepare_outcome_file () { case "$MBEDTLS_TEST_OUTCOME_FILE" in [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";; @@ -2726,7 +2708,12 @@ run_component () { # Unconditionally create a seedfile that's sufficiently long. # Do this before each component, because a previous component may # have messed it up or shortened it. - redirect_err dd if=/dev/urandom of=./tests/seedfile bs=64 count=1 + local dd_cmd + dd_cmd=(dd if=/dev/urandom of=./tests/seedfile bs=64 count=1) + case $OSTYPE in + linux*|freebsd*|openbsd*|darwin*) dd_cmd+=(status=none) + esac + "${dd_cmd[@]}" # Run the component in a subshell if [ $KEEP_GOING -eq 1 ]; then @@ -2774,7 +2761,6 @@ build_status=0 if [ $KEEP_GOING -eq 1 ]; then pre_setup_keep_going fi -pre_setup_quiet_redirect pre_prepare_outcome_file pre_print_configuration pre_check_tools From 72385036420e9a072c0588ccd685f8f72cf6458d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 8 Jul 2021 19:07:07 +0200 Subject: [PATCH 104/966] Heed --quiet when running make generated_files Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 4614029ad0..c3df05b724 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -713,7 +713,11 @@ pre_generate_files() { # since make doesn't have proper dependencies, remove any possibly outdate # file that might be around before generating fresh ones make neat - make generated_files + if [ $QUIET -eq 1 ]; then + make -s generated_files + else + make generated_files + fi } From 03ab544832fceeb1d618fef1d4f2e44641a9eadc Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 9 Jul 2021 15:19:28 +0200 Subject: [PATCH 105/966] Generate cpp_cummy_build.cpp dynamically Generate programs/test/cpp_dummy_build.cpp dynamically instead of maintaining it manually. This removes the need to update it when the list of headers changes. Include all the headers unconditionally except for the ones that cannot be included directly. Support this dynamic generation both with make and with cmake. Adapt all.sh accordingly. Remove the redundant C build from component_build_default_make_gcc_and_cxx (it was also done in component_test_default_out_of_box), leaving a component_test_make_cxx. Also run the C++ program, because why not. Do this in the full configuration which may catch a bit more problems in headers. Fixes #2570 for good. Signed-off-by: Gilles Peskine --- programs/.gitignore | 1 + programs/Makefile | 7 +- programs/test/CMakeLists.txt | 12 ++- programs/test/cpp_dummy_build.cpp | 98 ----------------------- programs/test/generate_cpp_dummy_build.sh | 85 ++++++++++++++++++++ tests/scripts/all.sh | 22 ++--- 6 files changed, 109 insertions(+), 116 deletions(-) delete mode 100644 programs/test/cpp_dummy_build.cpp create mode 100755 programs/test/generate_cpp_dummy_build.sh diff --git a/programs/.gitignore b/programs/.gitignore index 83521a792b..d8eb6baa03 100644 --- a/programs/.gitignore +++ b/programs/.gitignore @@ -56,6 +56,7 @@ ssl/ssl_server ssl/ssl_server2 test/benchmark test/cpp_dummy_build +test/cpp_dummy_build.cpp test/ecp-bench test/query_compile_time_config test/selftest diff --git a/programs/Makefile b/programs/Makefile index 997c198716..977ae7e8b4 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -331,6 +331,10 @@ test/benchmark$(EXEXT): test/benchmark.c $(DEP) echo " CC test/benchmark.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/benchmark.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ +test/cpp_dummy_build.cpp: test/generate_cpp_dummy_build.sh + echo " Gen test/cpp_dummy_build.cpp" + test/generate_cpp_dummy_build.sh + test/cpp_dummy_build$(EXEXT): test/cpp_dummy_build.cpp $(DEP) echo " CXX test/cpp_dummy_build.cpp" $(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) test/cpp_dummy_build.cpp $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ @@ -391,10 +395,11 @@ clean: ifndef WINDOWS rm -f $(EXES) -rm -f ssl/ssl_pthread_server$(EXEXT) - -rm -f test/cpp_dummy_build$(EXEXT) + -rm -f test/cpp_dummy_build.cpp test/cpp_dummy_build$(EXEXT) else if exist *.o del /Q /F *.o if exist *.exe del /Q /F *.exe + if exist test\cpp_dummy_build.cpp del /Q /F test\cpp_dummy_build.cpp endif $(MAKE) -C fuzz clean diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 807d1bc10b..a0a1b763cc 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -14,7 +14,17 @@ set(executables_mbedcrypto ) if(TEST_CPP) - list(APPEND executables_mbedcrypto cpp_dummy_build) + set(cpp_dummy_build_cpp "${CMAKE_CURRENT_BINARY_DIR}/cpp_dummy_build.cpp") + set(generate_cpp_dummy_build "${CMAKE_CURRENT_SOURCE_DIR}/generate_cpp_dummy_build.sh") + add_custom_command( + OUTPUT "${cpp_dummy_build_cpp}" + COMMAND "${generate_cpp_dummy_build}" "${cpp_dummy_build_cpp}" + DEPENDS "${generate_cpp_dummy_build}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + ) + add_executable(cpp_dummy_build "${cpp_dummy_build_cpp}") + target_include_directories(cpp_dummy_build PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) + target_link_libraries(cpp_dummy_build ${mbedcrypto_target}) endif() foreach(exe IN LISTS executables_libs executables_mbedcrypto) diff --git a/programs/test/cpp_dummy_build.cpp b/programs/test/cpp_dummy_build.cpp deleted file mode 100644 index 7f1efe8dba..0000000000 --- a/programs/test/cpp_dummy_build.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This program is a dummy C++ program to ensure Mbed TLS library header files - * can be included and built with a C++ compiler. - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mbedtls/build_info.h" - -#include "mbedtls/aes.h" -#include "mbedtls/aria.h" -#include "mbedtls/asn1.h" -#include "mbedtls/asn1write.h" -#include "mbedtls/base64.h" -#include "mbedtls/bignum.h" -#include "mbedtls/camellia.h" -#include "mbedtls/ccm.h" -#include "mbedtls/chacha20.h" -#include "mbedtls/chachapoly.h" -#include "mbedtls/check_config.h" -#include "mbedtls/cipher.h" -#include "mbedtls/cmac.h" -#include "mbedtls/config_psa.h" -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/debug.h" -#include "mbedtls/des.h" -#include "mbedtls/dhm.h" -#include "mbedtls/ecdh.h" -#include "mbedtls/ecdsa.h" -#include "mbedtls/ecjpake.h" -#include "mbedtls/ecp.h" -#include "mbedtls/entropy.h" -#include "mbedtls/error.h" -#include "mbedtls/gcm.h" -#include "mbedtls/hkdf.h" -#include "mbedtls/hmac_drbg.h" -#include "mbedtls/md.h" -#include "mbedtls/md5.h" -#include "mbedtls/net_sockets.h" -#include "mbedtls/nist_kw.h" -#include "mbedtls/oid.h" -#include "mbedtls/pem.h" -#include "mbedtls/pk.h" -#include "mbedtls/pkcs12.h" -#include "mbedtls/pkcs5.h" -#include "mbedtls/platform_time.h" -#include "mbedtls/platform_util.h" -#include "mbedtls/poly1305.h" -#include "mbedtls/psa_util.h" -#include "mbedtls/ripemd160.h" -#include "mbedtls/rsa.h" -#include "mbedtls/sha1.h" -#include "mbedtls/sha256.h" -#include "mbedtls/sha512.h" -#include "mbedtls/ssl.h" -#include "mbedtls/ssl_cache.h" -#include "mbedtls/ssl_ciphersuites.h" -#include "mbedtls/ssl_cookie.h" -#include "mbedtls/ssl_ticket.h" -#include "mbedtls/threading.h" -#include "mbedtls/timing.h" -#include "mbedtls/version.h" -#include "mbedtls/x509.h" -#include "mbedtls/x509_crl.h" -#include "mbedtls/x509_crt.h" -#include "mbedtls/x509_csr.h" - -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#endif - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) -#include "mbedtls/memory_buffer_alloc.h" -#endif - -#include "psa/crypto.h" -#include "psa/crypto_se_driver.h" - -int main() -{ - mbedtls_platform_context *ctx = NULL; - mbedtls_platform_setup(ctx); - mbedtls_printf("CPP Build test\n"); - mbedtls_platform_teardown(ctx); -} diff --git a/programs/test/generate_cpp_dummy_build.sh b/programs/test/generate_cpp_dummy_build.sh new file mode 100755 index 0000000000..41adf149eb --- /dev/null +++ b/programs/test/generate_cpp_dummy_build.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +# Ensure a reproducible order for *.h +export LC_ALL=C + +print_cpp () { + cat <<'EOF' +/* Automatically generated file. Do not edit. + * + * This program is a dummy C++ program to ensure Mbed TLS library header files + * can be included and built with a C++ compiler. + * + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mbedtls/build_info.h" + +EOF + + for header in include/mbedtls/*.h include/psa/*.h; do + case ${header#include/} in + mbedtls/mbedtls_config.h) :;; # not meant for direct inclusion + psa/crypto_config.h) :;; # not meant for direct inclusion + # Some of the psa/crypto_*.h headers are not meant to be included directly. + # They do have include guards that make them no-ops if psa/crypto.h + # has been included before. Since psa/crypto.h comes before psa/crypto_*.h + # in the wildcard enumeration, we don't need to skip those headers. + *) echo "#include \"${header#include/}\"";; + esac + done + + cat <<'EOF' + +int main() +{ + mbedtls_platform_context *ctx = NULL; + mbedtls_platform_setup(ctx); + mbedtls_printf("CPP Build test passed\n"); + mbedtls_platform_teardown(ctx); +} +EOF +} + +if [ -d include/mbedtls ]; then + : +elif [ -d ../include/mbedtls ]; then + cd .. +elif [ -d ../../include/mbedtls ]; then + cd ../.. +else + echo >&2 "This script must be run from an Mbed TLS source tree." + exit 3 +fi + +print_cpp >"${1:-programs/test/cpp_dummy_build.cpp}" diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index c3df05b724..8c75c9f052 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -368,14 +368,6 @@ check_tools() done } -check_headers_in_cpp () { - ls include/mbedtls | grep "\.h$" >headers.txt - Date: Mon, 30 Mar 2020 20:11:39 +0200 Subject: [PATCH 106/966] Don't restore *config.h before backing it up Back up the config files at the beginning of all.sh, rather than before each component. In particular, create the backup before running cleanup for the first time. This fixes #3139 (all.sh using a config.h.bak from a previous job), and makes all.sh more robust against accidentally using a modified config.h midway through because a component messed with the backup. Use a different extension (*.all.bak rather than *.bak) for the backups. This is necessary to ensure that auxiliary scripts such as depends*.pl that make their own backup don't remove all.sh's backup, which the code from this commit does not support. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 8c75c9f052..5c2ab2778d 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -129,9 +129,14 @@ pre_check_environment () { pre_initialize_variables () { CONFIG_H='include/mbedtls/mbedtls_config.h' - CONFIG_BAK="$CONFIG_H.bak" CRYPTO_CONFIG_H='include/psa/crypto_config.h' - CRYPTO_CONFIG_BAK="$CRYPTO_CONFIG_H.bak" + + # Files that are clobbered by some jobs will be backed up. Use a different + # suffix from auxiliary scripts so that all.sh and auxiliary scripts can + # independently decide when to remove the backup file. + backup_suffix='.all.bak' + # Files clobbered by config.py + files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H" append_outcome=0 MEMORY=0 @@ -295,13 +300,18 @@ cleanup() rm -f programs/test/cmake_package_install/Makefile rm -f programs/test/cmake_package_install/cmake_package_install - if [ -f "$CONFIG_BAK" ]; then - mv "$CONFIG_BAK" "$CONFIG_H" - fi + # Restore files that may have been clobbered by the job + for x in $files_to_back_up; do + cp -p "$x$backup_suffix" "$x" + done +} - if [ -f "$CRYPTO_CONFIG_BAK" ]; then - mv "$CRYPTO_CONFIG_BAK" "$CRYPTO_CONFIG_H" - fi +final_cleanup () { + cleanup + + for x in $files_to_back_up; do + rm -f "$x$backup_suffix" + done } # Executed on exit. May be redefined depending on command line options. @@ -310,7 +320,7 @@ final_report () { } fatal_signal () { - cleanup + final_cleanup final_report $1 trap - $1 kill -$1 $$ @@ -485,6 +495,12 @@ pre_check_git () { fi } +pre_back_up () { + for x in $files_to_back_up; do + cp -p "$x" "$x$backup_suffix" + done +} + pre_setup_keep_going () { failure_count=0 # Number of failed components last_failure_status=0 # Last failure status in this component @@ -2666,7 +2682,7 @@ component_check_generate_test_code () { post_report () { msg "Done, cleaning up" - cleanup + final_cleanup final_report } @@ -2692,10 +2708,6 @@ pseudo_component_error_test () { # Run one component and clean up afterwards. run_component () { - # Back up the configuration in case the component modifies it. - # The cleanup function will restore it. - cp -p "$CONFIG_H" "$CONFIG_BAK" - cp -p "$CRYPTO_CONFIG_H" "$CRYPTO_CONFIG_BAK" current_component="$1" export MBEDTLS_TEST_CONFIGURATION="$current_component" @@ -2750,6 +2762,7 @@ pre_initialize_variables pre_parse_command_line "$@" pre_check_git +pre_back_up build_status=0 if [ $KEEP_GOING -eq 1 ]; then From 568f53a9d8734f8dc28f2a9c8fe86ef5267df0af Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 12 Jul 2021 18:16:01 +0200 Subject: [PATCH 107/966] Don't unconditionally restore **/Makefile all.sh restores **/Makefile from git in case the version in the worktree was from doing a cmake in-tree build. Instead of doing this unconditionally, do it only if the toplevel Makefile seems to have been automatically generated (by cmake or otherwise, e.g. by mbedtls-prepare-build). This way all.sh no longer silently wipes changes made to Makefile but not committed yet. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 5c2ab2778d..7db9488eee 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -137,6 +137,8 @@ pre_initialize_variables () { backup_suffix='.all.bak' # Files clobbered by config.py files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H" + # Files clobbered by in-tree cmake + files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile" append_outcome=0 MEMORY=0 @@ -282,8 +284,6 @@ cleanup() -iname CMakeCache.txt \) -exec rm -f {} \+ # Recover files overwritten by in-tree CMake builds rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile - git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile - git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile # Remove any artifacts from the component_test_cmake_as_subdirectory test. rm -rf programs/test/cmake_subproject/build @@ -495,6 +495,20 @@ pre_check_git () { fi } +pre_restore_files () { + # If the makefiles have been generated by a framework such as cmake, + # restore them from git. If the makefiles look like modifications from + # the ones checked into git, take care not to modify them. Whatever + # this function leaves behind is what the script will restore before + # each component. + case "$(head -n1 Makefile)" in + *[Gg]enerated*) + git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile + git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile + ;; + esac +} + pre_back_up () { for x in $files_to_back_up; do cp -p "$x" "$x$backup_suffix" @@ -2762,6 +2776,7 @@ pre_initialize_variables pre_parse_command_line "$@" pre_check_git +pre_restore_files pre_back_up build_status=0 From a561444561dec2313a99c3a6d6b560d0828f05c3 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 14 Jul 2021 14:54:11 +0100 Subject: [PATCH 108/966] Add missing space Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index a5027f386f..e14508353d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3757,7 +3757,7 @@ static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation, if( operation->id == 0 || !operation->nonce_set ) return( PSA_ERROR_BAD_STATE ); - if( operation->lengths_set && (operation->ad_remaining != 0 || + if( operation->lengths_set && ( operation->ad_remaining != 0 || operation->body_remaining != 0 ) ) return( PSA_ERROR_INVALID_ARGUMENT ); From 96b0173cec455571d89bb57d2c8b7c47500d9277 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 16 Jul 2021 17:00:26 +0100 Subject: [PATCH 109/966] Add common nonce checking to oneshot encrypt Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 40 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index f2096ce3f2..9ac26467f1 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -136,6 +136,22 @@ static psa_status_t psa_aead_setup( return( PSA_SUCCESS ); } +/* Perform common nonce length checks */ +static psa_status_t mbedtls_aead_check_nonce_length( + mbedtls_psa_aead_operation_t *operation, + size_t nonce_length ) +{ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + if( nonce_length != 12 ) + return( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + + return PSA_SUCCESS; +} + psa_status_t mbedtls_psa_aead_encrypt( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, @@ -164,6 +180,13 @@ psa_status_t mbedtls_psa_aead_encrypt( } tag = ciphertext + plaintext_length; + if( mbedtls_aead_check_nonce_length( &operation, nonce_length ) + != PSA_SUCCESS ) + { + status = PSA_ERROR_NOT_SUPPORTED; + goto exit; + } + #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation.alg == PSA_ALG_CCM ) { @@ -195,7 +218,7 @@ psa_status_t mbedtls_psa_aead_encrypt( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation.alg == PSA_ALG_CHACHA20_POLY1305 ) { - if( nonce_length != 12 || operation.tag_length != 16 ) + if( operation.tag_length != 16 ) { status = PSA_ERROR_NOT_SUPPORTED; goto exit; @@ -247,21 +270,6 @@ static psa_status_t psa_aead_unpadded_locate_tag( size_t tag_length, return( PSA_SUCCESS ); } -static psa_status_t mbedtls_aead_check_nonce_length( - mbedtls_psa_aead_operation_t *operation, - size_t nonce_length ) -{ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) - { - if( nonce_length != 12 ) - return( PSA_ERROR_NOT_SUPPORTED ); - } -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ - - return PSA_SUCCESS; -} - psa_status_t mbedtls_psa_aead_decrypt( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, From 481be341ef1bee3a1a71bfb35b40dcfb72ca403e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 16 Jul 2021 17:38:47 +0100 Subject: [PATCH 110/966] Make state tests more readable Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 502515f2a4..dfd0cfde47 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3859,6 +3859,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + operation = psa_aead_operation_init( ); TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len, @@ -3867,6 +3869,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + operation = psa_aead_operation_init( ); TEST_EQUAL( psa_aead_update_ad( &operation, additional_data->x, @@ -3875,6 +3879,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + operation = psa_aead_operation_init( ); TEST_EQUAL( psa_aead_update( &operation, input_data->x, @@ -3884,6 +3890,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + operation = psa_aead_operation_init( ); TEST_EQUAL( psa_aead_finish( &operation, final_data, @@ -3895,6 +3903,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + operation = psa_aead_operation_init( ); TEST_EQUAL( psa_aead_verify( &operation, final_data, @@ -3917,6 +3927,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + operation = psa_aead_operation_init( ); PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); @@ -3995,6 +4007,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + operation = psa_aead_operation_init( ); PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); @@ -4008,6 +4022,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + operation = psa_aead_operation_init( ); PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); From 374a2be58805d1e28f9493a20dc649ad69b8a621 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 16 Jul 2021 17:53:40 +0100 Subject: [PATCH 111/966] Add missing state test coverage Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 70 +++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index dfd0cfde47..5f36230bfd 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3938,6 +3938,28 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_decrypt_setup( &operation, key, alg ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* ------------------------------------------------------- */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_encrypt_setup( &operation, key, alg ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + /* Test for not setting a nonce. */ operation = psa_aead_operation_init( ); @@ -3963,6 +3985,54 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* Test for double generating nonce. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, + PSA_AEAD_NONCE_MAX_SIZE, + &nonce_length ) ); + + TEST_EQUAL( psa_aead_generate_nonce( &operation, nonce_buffer, + PSA_AEAD_NONCE_MAX_SIZE, + &nonce_length ), + PSA_ERROR_BAD_STATE ); + + + psa_aead_abort( &operation ); + + /* Test for generate nonce then set and vice versa */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, + PSA_AEAD_NONCE_MAX_SIZE, + &nonce_length ) ); + + TEST_EQUAL( psa_aead_set_nonce( &operation, nonce->x, nonce->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* ------------------------------------------------------- */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + TEST_EQUAL( psa_aead_generate_nonce( &operation, nonce_buffer, + PSA_AEAD_NONCE_MAX_SIZE, + &nonce_length ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + /* Test for generating nonce in decrypt setup. */ operation = psa_aead_operation_init( ); From d85f547b65b177d786598890742b48d3fd8b0987 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 16 Jul 2021 18:20:16 +0100 Subject: [PATCH 112/966] Add expected size to nonce generation test Also add unneeded copy-paste in the test descriptions. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 14 +++++++------- tests/suites/test_suite_psa_crypto.function | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index f55deb022f..db94f53b35 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2574,25 +2574,25 @@ PSA Multipart AEAD decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:0:"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 12 +PSA Multipart Nonce Generation, AES - GCM, IV = 12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS -PSA Multipart Nonce Generation, AES - GCM, CAVS 14.0, IV = 0 +PSA Multipart Nonce Generation, AES - GCM, IV = 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"":"":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 12 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 8 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:"":"":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 5f36230bfd..b5fe5e74a6 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3699,6 +3699,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, int alg_arg, int nonce_len, + int expected_generated_len_arg, data_t *additional_data, data_t *input_data, int expected_status_arg ) @@ -3712,6 +3713,7 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; size_t nonce_generated_len = 0; + size_t expected_generated_len = expected_generated_len_arg; unsigned char *output_data = NULL; unsigned char *final_data = NULL; size_t output_size = 0; @@ -3764,6 +3766,8 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, TEST_ASSERT( status == expected_status_arg ); + TEST_EQUAL( nonce_generated_len, expected_generated_len ); + if( expected_status_arg == PSA_SUCCESS ) { From e0fcb3b99efc500f792d9fcdecc08af30d8e9e8c Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 16 Jul 2021 18:52:03 +0100 Subject: [PATCH 113/966] Add 'too big' tests for nonce generation Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 8 ++++++++ tests/suites/test_suite_psa_crypto.function | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index db94f53b35..5e16c8c079 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2582,6 +2582,10 @@ PSA Multipart Nonce Generation, AES - GCM, IV = 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL +PSA Multipart Nonce Generation, AES - GCM, IV = 16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS + PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 12 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS @@ -2594,6 +2598,10 @@ PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 16 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:12:"":"":PSA_SUCCESS + PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index b5fe5e74a6..ac58b6edf3 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3758,8 +3758,6 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, PSA_ASSERT( status ); - TEST_ASSERT( nonce_len < PSA_AEAD_NONCE_MAX_SIZE ); - status = psa_aead_generate_nonce( &operation, nonce_buffer, nonce_len, &nonce_generated_len ); @@ -3768,6 +3766,8 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, TEST_EQUAL( nonce_generated_len, expected_generated_len ); + TEST_ASSERT( nonce_generated_len < PSA_AEAD_NONCE_MAX_SIZE ); + if( expected_status_arg == PSA_SUCCESS ) { From 32925b9e5b3c67c754ca7f8fcb34abf56c5fe480 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 16 Jul 2021 18:56:12 +0100 Subject: [PATCH 114/966] Make sure unused parts of tag buffer are cleared We already did this on failure, but make sure the buffer does not leak what was in it previously on success Signed-off-by: Paul Elliott --- library/psa_crypto.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index e14508353d..95f9740633 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3804,9 +3804,14 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, exit: /* In case the operation fails and the user fails to check for failure or - * the zero tag size, make sure the tag is set to something impossible. */ + * the zero tag size, make sure the tag is set to something impossible. + * Even if the operation succeeds, make sure we set the rest of the + * buffer to something impossible to prevent potential leakage of + * anything previously placed in the same buffer.*/ if( status != PSA_SUCCESS ) - memset(tag, '!', tag_size); + memset( tag, '!', tag_size ); + else if( *tag_length < tag_size ) + memset( tag + *tag_length, '!', ( tag_size - *tag_length ) ); psa_aead_abort( operation ); From 315628d91ab1f07327655cfc1aebe3b433078046 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 20 Jul 2021 18:25:54 +0100 Subject: [PATCH 115/966] Remove internal aead_verify endpoint The internal verify endpoint was only calling the finish endpoint to get a tag to compare against the tag passed in. Moved this logic to the driver wrapper (still allowing a driver to call verify if required) and removed the internal implementation endpoint. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 78 +--------------------------- library/psa_crypto_aead.h | 71 ------------------------- library/psa_crypto_driver_wrappers.c | 28 ++++++++-- 3 files changed, 25 insertions(+), 152 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 9ac26467f1..9f673596fd 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -607,18 +607,6 @@ psa_status_t mbedtls_psa_aead_update( return( status ); } -/* Common checks for both mbedtls_psa_aead_finish() and - mbedtls_psa_aead_verify() */ -static psa_status_t mbedtls_psa_aead_finish_checks( - mbedtls_psa_aead_operation_t *operation, - size_t tag_size ) -{ - if( tag_size < operation->tag_length ) - return ( PSA_ERROR_BUFFER_TOO_SMALL ); - - return ( PSA_SUCCESS ); -} - /* Finish encrypting a message in a multipart AEAD operation. */ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, @@ -632,10 +620,8 @@ psa_status_t mbedtls_psa_aead_finish( psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; size_t finish_output_size = 0; - status = mbedtls_psa_aead_finish_checks( operation, tag_size ); - - if( status != PSA_SUCCESS ) - return status; + if( tag_size < operation->tag_length ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) @@ -672,66 +658,6 @@ psa_status_t mbedtls_psa_aead_finish( return ( status ); } -/* Finish authenticating and decrypting a message in a multipart AEAD - * operation.*/ -psa_status_t mbedtls_psa_aead_verify( - mbedtls_psa_aead_operation_t *operation, - uint8_t *plaintext, - size_t plaintext_size, - size_t *plaintext_length, - const uint8_t *tag, - size_t tag_length ) -{ - psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - size_t finish_output_size = 0; - int do_tag_check = 1; - uint8_t check_tag[PSA_AEAD_TAG_MAX_SIZE]; - - status = mbedtls_psa_aead_finish_checks( operation, tag_length ); - - if( status != PSA_SUCCESS ) - return status; - -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation->alg == PSA_ALG_GCM ) - /* Call finish to get the tag for comparison */ - status = mbedtls_to_psa_error( - mbedtls_gcm_finish( &operation->ctx.gcm, - plaintext, plaintext_size, - check_tag, operation->tag_length ) ); - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) - // call finish to get the tag for comparison. - status = mbedtls_to_psa_error( - mbedtls_chachapoly_finish( &operation->ctx.chachapoly, - check_tag ) ); - - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ - { - ( void ) plaintext; - ( void ) plaintext_size; - ( void ) plaintext_length; - ( void ) tag; - ( void ) tag_length; - - return ( PSA_ERROR_NOT_SUPPORTED ); - } - - if( status == PSA_SUCCESS ) - { - *plaintext_length = finish_output_size; - - if( do_tag_check && ( tag_length != operation->tag_length || - mbedtls_psa_safer_memcmp(tag, check_tag, tag_length) != 0 ) ) - status = PSA_ERROR_INVALID_SIGNATURE; - } - - return ( status ); -} - /* Abort an AEAD operation */ psa_status_t mbedtls_psa_aead_abort( mbedtls_psa_aead_operation_t *operation ) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index c664f9f2bb..38202b6fb4 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -491,77 +491,6 @@ psa_status_t mbedtls_psa_aead_finish( size_t tag_size, size_t *tag_length ); -/** Finish authenticating and decrypting a message in an AEAD operation. - * - * \note The signature of this function is that of a PSA driver - * aead_verify entry point. This function behaves as an aead_verify entry - * point as defined in the PSA driver interface specification for - * transparent drivers. - * - * The operation must have been set up by the PSA core with - * mbedtls_psa_aead_decrypt_setup(). - * - * This function finishes the authenticated decryption of the message - * components: - * - * - The additional data consisting of the concatenation of the inputs - * passed to preceding calls to mbedtls_psa_aead_update_ad(). - * - The ciphertext consisting of the concatenation of the inputs passed to - * preceding calls to mbedtls_psa_aead_update(). - * - The tag passed to this function call. - * - * If the authentication tag is correct, this function outputs any remaining - * plaintext and reports success. If the authentication tag is not correct, - * this function returns #PSA_ERROR_INVALID_SIGNATURE. - * - * Whether or not this function returns successfully, the PSA core subsequently - * calls mbedtls_psa_aead_abort() to deactivate the operation. - * - * \note Implementations shall make the best effort to ensure that the - * comparison between the actual tag and the expected tag is performed - * in constant time. - * - * \param[in,out] operation Active AEAD operation. - * \param[out] plaintext Buffer where the last part of the plaintext - * is to be written. This is the remaining data - * from previous calls to mbedtls_psa_aead_update() - * that could not be processed until the end - * of the input. - * \param plaintext_size Size of the \p plaintext buffer in bytes. - * This must be appropriate for the selected - * algorithm and key: - * - A sufficient output size is - * #PSA_AEAD_VERIFY_OUTPUT_SIZE(\c key_type, - * \c alg) where \c key_type is the type of key - * and \c alg is the algorithm that were used to - * set up the operation. - * - #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE evaluates to - * the maximum output size of any supported AEAD - * algorithm. - * \param[out] plaintext_length On success, the number of bytes of - * returned plaintext. - * \param[in] tag Buffer containing the authentication tag. - * \param tag_length Size of the \p tag buffer in bytes. - * - * \retval #PSA_SUCCESS - * Success. - * \retval #PSA_ERROR_INVALID_SIGNATURE - * The calculations were successful, but the authentication tag is - * not correct. - * \retval #PSA_ERROR_BUFFER_TOO_SMALL - * The size of the \p tag buffer is too small. - * #PSA_AEAD_TAG_LENGTH(\c key_type, key_bits, \c alg) or - * #PSA_AEAD_TAG_MAX_SIZE can be used to determine the required \p tag - * buffer size. - */ -psa_status_t mbedtls_psa_aead_verify( - mbedtls_psa_aead_operation_t *operation, - uint8_t *plaintext, - size_t plaintext_size, - size_t *plaintext_length, - const uint8_t *tag, - size_t tag_length ); - /** Abort an AEAD operation. * * \note The signature of this function is that of a PSA driver diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 48410c0e1e..09fff0c6bd 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1739,11 +1739,29 @@ psa_status_t psa_driver_wrapper_aead_verify( { #if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_verify( &operation->ctx.mbedtls_ctx, - plaintext, - plaintext_size, - plaintext_length, - tag, tag_length ) ); + { + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + uint8_t check_tag[PSA_AEAD_TAG_MAX_SIZE]; + size_t check_tag_length; + + status = mbedtls_psa_aead_finish( &operation->ctx.mbedtls_ctx, + plaintext, + plaintext_size, + plaintext_length, + check_tag, + tag_length, + &check_tag_length ); + + if( status == PSA_SUCCESS ) + { + if( tag_length != check_tag_length || + mbedtls_psa_safer_memcmp( tag, check_tag, tag_length ) + != 0 ) + status = PSA_ERROR_INVALID_SIGNATURE; + } + + return( status ); + } #endif /* MBEDTLS_PSA_BUILTIN_AEAD */ From 97fd1bad8375d96a7901f828ef62799c8e7d64bc Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 21 Jul 2021 18:46:06 +0100 Subject: [PATCH 116/966] Convert over to using a single internal test func Make all encrypt/decrypt tests use the same function. Cleanup arguments that were poorly named and document internal function. Removed one test as I didn't want to write another test purely for it, when its already tested in one shot. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 187 +++---- tests/suites/test_suite_psa_crypto.function | 531 ++++++++------------ 2 files changed, 263 insertions(+), 455 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 5e16c8c079..8f9d6c4d6b 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2312,224 +2312,166 @@ aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a0 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 PSA Multipart AEAD decrypt, AES-GCM, invalid signature depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":PSA_ERROR_INVALID_SIGNATURE - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":0 PSA Multipart AEAD decrypt, AES-GCM, T=15 but passing 16 bytes depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":PSA_ERROR_INVALID_SIGNATURE - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":0 PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":0 PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT - -PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 18 -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":0 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:0:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:0:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:1:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:1:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:0:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:0:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:1:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:1:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:0:"b03c2c20f758a93a8d1220232ad87098":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:0:"b03c2c20f758a93a8d1220232ad87098":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:1:"b03c2c20f758a93a8d1220232ad87098":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:1:"b03c2c20f758a93a8d1220232ad87098":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:0:"b22b2dcdcc18adc30d16297b84b459d8":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:0:"b22b2dcdcc18adc30d16297b84b459d8":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:1:"b22b2dcdcc18adc30d16297b84b459d8":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:1:"b22b2dcdcc18adc30d16297b84b459d8":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:0:"7e5fd8b595ddc4753676107951d900e2":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:0:"7e5fd8b595ddc4753676107951d900e2":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:1:"7e5fd8b595ddc4753676107951d900e2":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:1:"7e5fd8b595ddc4753676107951d900e2":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:0:"37245449db8f72b1ecdb420f629d3d80":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:0:"37245449db8f72b1ecdb420f629d3d80":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:1:"37245449db8f72b1ecdb420f629d3d80":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:1:"37245449db8f72b1ecdb420f629d3d80":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:0:"496909523f574b205d757659c5":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:0:"496909523f574b205d757659c5":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:1:"496909523f574b205d757659c5":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:1:"496909523f574b205d757659c5":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:0:"b6e056de521a27266dffbc0d96":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:0:"b6e056de521a27266dffbc0d96":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:1:"b6e056de521a27266dffbc0d96":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:1:"b6e056de521a27266dffbc0d96":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:0:"f6d56f8c86f27d957fa63aea22":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:0:"f6d56f8c86f27d957fa63aea22":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:1:"f6d56f8c86f27d957fa63aea22":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:1:"f6d56f8c86f27d957fa63aea22":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:0:"bd94b34511bc65ae47684805cb":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:0:"bd94b34511bc65ae47684805cb":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:1:"bd94b34511bc65ae47684805cb":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:1:"bd94b34511bc65ae47684805cb":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:0:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:0:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:1:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:1:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:0:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:0:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:1:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:1:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:0:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:0:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:1:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:1:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:0:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:0:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:1:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:1:"":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:0:"7789b41cb3ee548814ca0b388c10b343":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:0:"7789b41cb3ee548814ca0b388c10b343":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:1:"7789b41cb3ee548814ca0b388c10b343":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:1:"7789b41cb3ee548814ca0b388c10b343":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:0:"4860116a6d2deb9bf794bfd6ac5bbbd6":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:0:"4860116a6d2deb9bf794bfd6ac5bbbd6":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:1:"4860116a6d2deb9bf794bfd6ac5bbbd6":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:1:"4860116a6d2deb9bf794bfd6ac5bbbd6":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:0:"ff426dd751190ff826e8b4a0792d746e":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:0:"ff426dd751190ff826e8b4a0792d746e":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:1:"ff426dd751190ff826e8b4a0792d746e":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:1:"ff426dd751190ff826e8b4a0792d746e":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:0:"0a0b284515694188b6b6c15bc8a09036":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:0:"0a0b284515694188b6b6c15bc8a09036":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:1:"0a0b284515694188b6b6c15bc8a09036":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:1:"0a0b284515694188b6b6c15bc8a09036":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:0:"f386b28e7eb4c2fb8eb5dc66a2":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:0:"f386b28e7eb4c2fb8eb5dc66a2":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:1:"f386b28e7eb4c2fb8eb5dc66a2":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:1:"f386b28e7eb4c2fb8eb5dc66a2":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:0:"da1c61fbfcdb73445ad4c7d889":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:0:"da1c61fbfcdb73445ad4c7d889":1 PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:1:"da1c61fbfcdb73445ad4c7d889":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:1:"da1c61fbfcdb73445ad4c7d889":1 PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:0:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" @@ -2548,32 +2490,25 @@ aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f90 PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1 PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1 PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, bad tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_ERROR_INVALID_SIGNATURE - +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":0 PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:0:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:0:"":1 PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:1:"":PSA_SUCCESS - +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:1:"":1 PSA Multipart AEAD decrypt: invalid algorithm (CTR) depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:0:"":PSA_ERROR_INVALID_ARGUMENT - +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:0:"":0 PSA Multipart AEAD decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:0:"":PSA_ERROR_INVALID_ARGUMENT - +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:0:"":0 PSA Multipart Nonce Generation, AES - GCM, IV = 12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index ac58b6edf3..fe9e0014db 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -264,16 +264,41 @@ typedef enum { DERIVE_KEY = 2 } generate_method; -static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, - data_t *key_data, - int alg_arg, - data_t *nonce, - data_t *additional_data, - int ad_part_len, - data_t *input_data, - int data_part_len, - int test_set_lengths_arg, - data_t *expected_result ) +/*! + * \brief Internal Function for AEAD multipart tests. + * + * \param key_type_arg Type of key passed in + * \param key_data The encryption / decryption key data + * \param alg_arg The type of algorithm used + * \param nonce Nonce data + * \param additional_data Additional data + * \param ad_part_len If not -1, the length of chunks to + * feed additional data in to be encrypted / + * decrypted. If -1, no chunking. + * \param input_data Data to encrypt / decrypt + * \param data_part_len If not -1, the length of chunks to feed the + * data in to be encrypted / decrypted. If -1, + * no chunking + * \param do_set_lengths If non-zero, then set lengths prior to + * calling encryption / decryption. + * \param expected_output Expected output + * \param expected_status_arg Expected status + * \param is_encrypt If non-zero this is an encryption operation. + * + * \return int Zero on failure, non-zero on success. + * + */ +static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + int ad_part_len, + data_t *input_data, + int data_part_len, + int do_set_lengths, + data_t *expected_output, + int expect_valid_signature, + int is_encrypt ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; @@ -282,23 +307,30 @@ static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, unsigned char *output_data = NULL; unsigned char *part_data = NULL; unsigned char *final_data = NULL; - size_t output_size = 0; - size_t finish_output_size; + size_t data_true_size = 0; size_t part_data_size = 0; + size_t output_size = 0; + size_t final_output_size = 0; size_t output_length = 0; size_t key_bits = 0; size_t tag_length = 0; - size_t tag_size = 0; - uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; uint32_t part_offset = 0; size_t part_length = 0; size_t output_part_length = 0; + size_t tag_size = 0; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; + int test_ok = 0; + PSA_ASSERT( psa_crypto_init( ) ); - psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); + if( is_encrypt ) + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); + else + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT ); + psa_set_key_algorithm( &attributes, alg ); psa_set_key_type( &attributes, key_type ); @@ -310,23 +342,46 @@ static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); - TEST_ASSERT( tag_length <= PSA_AEAD_TAG_MAX_SIZE ); + if( is_encrypt ) + { + /* Tag gets written at end of buffer. */ + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( input_data->len + + tag_length ) ); + data_true_size = input_data->len; + } + else + { + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + ( input_data->len - + tag_length ) ); - output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( input_data->len + - tag_length ) ); + /* Do not want to attempt to decrypt tag. */ + data_true_size = input_data->len - tag_length; + } ASSERT_ALLOC( output_data, output_size ); - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + if( is_encrypt ) + { + final_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( key_type, alg ); + TEST_ASSERT( final_output_size <= PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); + } + else + { + final_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + TEST_ASSERT( final_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + } - TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - - ASSERT_ALLOC( final_data, finish_output_size ); + ASSERT_ALLOC( final_data, final_output_size ); operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); + + if( is_encrypt ) + status = psa_aead_encrypt_setup( &operation, key, alg ); + else + status = psa_aead_decrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the * encryption involves a common limitation of cryptography hardwares and @@ -341,10 +396,10 @@ static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); - if( test_set_lengths_arg ) + if( do_set_lengths ) { PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, - input_data->len ) ); + data_true_size ) ); } if( ad_part_len != -1 ) @@ -381,17 +436,17 @@ static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, { /* Pass data in parts */ part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); + ( size_t ) data_part_len ); ASSERT_ALLOC( part_data, part_data_size ); part_offset = 0; - while( part_offset < input_data->len ) + while( part_offset < data_true_size ) { - if( input_data->len - part_offset < ( uint32_t ) data_part_len ) + if( ( data_true_size - part_offset ) < ( uint32_t ) data_part_len ) { - part_length = input_data->len - part_offset; + part_length = ( data_true_size - part_offset ); } else { @@ -416,283 +471,79 @@ static psa_status_t aead_multipart_encrypt_internal( int key_type_arg, } else { - /* Pass whole data in one go */ + /* Pass all data in one go. */ PSA_ASSERT( psa_aead_update( &operation, input_data->x, - input_data->len, output_data, + data_true_size, output_data, output_size, &output_length ) ); } - PSA_ASSERT( psa_aead_finish( &operation, final_data, - finish_output_size, - &output_part_length, - tag_buffer, tag_length, - &tag_size ) ); - - if( output_data && output_part_length ) + if( is_encrypt ) + PSA_ASSERT( psa_aead_finish( &operation, final_data, + final_output_size, + &output_part_length, + tag_buffer, tag_length, + &tag_size ) ); + else { - memcpy( ( output_data + output_length ), final_data, - output_part_length ); + status = psa_aead_verify( &operation, final_data, + final_output_size, + &output_part_length, + ( input_data->x + data_true_size ), + tag_length ); + + if( status != PSA_SUCCESS ) + { + if( !expect_valid_signature ) + { + /* Expected failure. */ + test_ok = 1; + goto exit; + } + else + PSA_ASSERT( status ); + } } - TEST_EQUAL( tag_length, tag_size ); + if( output_data && output_part_length ) + memcpy( ( output_data + output_length ), final_data, + output_part_length ); output_length += output_part_length; - if( output_data && tag_length ) + + /* For all currently defined algorithms, PSA_AEAD_xxx_OUTPUT_SIZE + * should be exact.*/ + if( is_encrypt ) { - memcpy( ( output_data + output_length ), tag_buffer, tag_length ); + TEST_EQUAL( tag_length, tag_size ); + + if( output_data && tag_length ) + memcpy( ( output_data + output_length ), tag_buffer, + tag_length ); + + output_length += tag_length; + + TEST_EQUAL( output_length, + PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, + input_data->len ) ); + TEST_ASSERT( output_length <= + PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); + } + else + { + TEST_EQUAL( output_length, + PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, + input_data->len ) ); + TEST_ASSERT( output_length <= + PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); } - output_length += tag_length; - /* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE - * should be exact. */ - TEST_EQUAL( output_length, - PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, - input_data->len ) ); - TEST_ASSERT( output_length <= - PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); - - ASSERT_COMPARE( expected_result->x, expected_result->len, + ASSERT_COMPARE( expected_output->x, expected_output->len, output_data, output_length ); -exit: - psa_destroy_key( key ); - psa_aead_abort( &operation ); - mbedtls_free( output_data ); - mbedtls_free( part_data ); - mbedtls_free( final_data ); - PSA_DONE( ); - return( status ); -} - -static void aead_multipart_decrypt_internal( int key_type_arg, data_t *key_data, - int alg_arg, - data_t *nonce, - data_t *additional_data, - int ad_part_len, - data_t *input_data, - int data_part_len, - int test_set_lengths_arg, - data_t *expected_data, - int expected_result_arg ) -{ - mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; - psa_key_type_t key_type = key_type_arg; - psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; - unsigned char *output_data = NULL; - unsigned char *part_data = NULL; - unsigned char *final_data = NULL; - size_t part_data_size; - size_t output_size = 0; - size_t verify_output_size = 0; - size_t output_length = 0; - size_t key_bits = 0; - size_t tag_length = 0; - uint32_t part_offset = 0; - size_t part_length = 0; - size_t output_part_length = 0; - psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; - psa_status_t expected_result = expected_result_arg; - psa_status_t status = PSA_ERROR_GENERIC_ERROR; - - PSA_ASSERT( psa_crypto_init( ) ); - - psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT ); - psa_set_key_algorithm( &attributes, alg ); - psa_set_key_type( &attributes, key_type ); - - PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, - &key ) ); - - PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); - key_bits = psa_get_key_bits( &attributes ); - - tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg ); - - output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( input_data->len - - tag_length ) ); - - ASSERT_ALLOC( output_data, output_size ); - - verify_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( key_type, alg ); - TEST_ASSERT( verify_output_size <= PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); - ASSERT_ALLOC( final_data, verify_output_size ); - - operation = psa_aead_operation_init( ); - - status = psa_aead_decrypt_setup( &operation, key, alg ); - - /* If the operation is not supported, just skip and not fail in case the - * encryption involves a common limitation of cryptography hardwares and - * an alternative implementation. */ - if( status == PSA_ERROR_NOT_SUPPORTED ) - { - MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); - } - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - status = psa_aead_set_nonce( &operation, nonce->x, nonce->len ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - if( test_set_lengths_arg ) - { - status = psa_aead_set_lengths( &operation, additional_data->len, - ( input_data->len - tag_length ) ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - } - - if( ad_part_len != -1 ) - { - part_offset = 0; - - while( part_offset < additional_data->len ) - { - if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) - { - part_length = additional_data->len - part_offset; - } - else - { - part_length = ad_part_len; - } - - status = psa_aead_update_ad( &operation, - additional_data->x + part_offset, - part_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - part_offset += part_length; - } - } - else - { - status = psa_aead_update_ad( &operation, additional_data->x, - additional_data->len ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - } - - if( data_part_len != -1 ) - { - /* Pass data in parts */ - part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, - ( size_t ) data_part_len ); - - ASSERT_ALLOC( part_data, part_data_size ); - - part_offset = 0; - - while( part_offset < ( input_data->len - tag_length) ) - { - if( (input_data->len - tag_length - part_offset ) < - ( uint32_t ) data_part_len ) - { - part_length = ( input_data->len - tag_length - part_offset ); - } - else - { - part_length = data_part_len; - } - - status = psa_aead_update( &operation, - ( input_data->x + part_offset ), - part_length, part_data, - part_data_size, &output_part_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - if( output_data && output_part_length ) - { - memcpy( ( output_data + part_offset ), part_data, - output_part_length ); - } - - part_offset += part_length; - output_length += output_part_length; - } - } - else - { - status = psa_aead_update( &operation, input_data->x, - ( input_data->len - tag_length ), output_data, - output_size, &output_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - } - - status = psa_aead_verify( &operation, final_data, - verify_output_size, - &output_part_length, - ( input_data->x + input_data->len - tag_length ), - tag_length ); - - if( status != PSA_SUCCESS ) - { - TEST_EQUAL( status, expected_result_arg ); - goto exit; - } - - if( output_data && output_part_length ) - { - memcpy( ( output_data + output_length ), final_data, - output_part_length ); - } - - output_length += output_part_length; - - if( expected_result != PSA_ERROR_INVALID_ARGUMENT ) - { - /* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE - * should be exact. */ - TEST_EQUAL( output_length, - PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, - input_data->len ) ); - TEST_ASSERT( output_length <= - PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( input_data->len ) ); - } - - if( expected_result == PSA_SUCCESS ) - { - ASSERT_COMPARE( expected_data->x, expected_data->len, - output_data, output_length ); - } + test_ok = 1; exit: psa_destroy_key( key ); @@ -701,6 +552,8 @@ exit: mbedtls_free( part_data ); mbedtls_free( final_data ); PSA_DONE( ); + + return( test_ok ); } /* END_HEADER */ @@ -3596,43 +3449,53 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, int alg_arg, data_t *nonce, data_t *additional_data, - int test_ad_mp_arg, + int do_test_ad_chunked, data_t *input_data, - int test_data_mp_arg, - int test_set_lengths_arg, - data_t *expected_result_arg ) + int do_test_data_chunked, + int do_set_lengths, + data_t *expected_output ) { size_t ad_part_len = 0; size_t data_part_len = 0; - if( test_ad_mp_arg == 1 ) + TEST_ASSERT( do_test_ad_chunked || do_test_data_chunked ); + + /* Temporary whilst we have algorithms that cannot support chunking */ + if( do_test_ad_chunked == 1 ) { for( ad_part_len = 1; ad_part_len <= additional_data->len; ad_part_len++ ) { mbedtls_test_set_step( ad_part_len ); - aead_multipart_encrypt_internal( key_type_arg, key_data, - alg_arg,nonce, - additional_data, - ad_part_len, - input_data, -1, - test_set_lengths_arg, - expected_result_arg ); + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + do_set_lengths, + expected_output, + 1, 1 ) ) + break; } } - if( test_data_mp_arg == 1 ) + /* Temporary whilst we have algorithms that cannot support chunking */ + if( do_test_data_chunked == 1 ) { for( data_part_len = 1; data_part_len <= input_data->len; data_part_len++ ) { - aead_multipart_encrypt_internal( key_type_arg, key_data, - alg_arg, nonce, - additional_data, -1, - input_data, data_part_len, - test_set_lengths_arg, - expected_result_arg ); + mbedtls_test_set_step( 1000 + data_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + do_set_lengths, + expected_output, + 1, 1 ) ) + break; } } @@ -3648,44 +3511,54 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, int alg_arg, data_t *nonce, data_t *additional_data, - int test_ad_mp_arg, + int do_test_ad_chunked, data_t *input_data, - int test_data_mp_arg, - int test_set_lengths_arg, - data_t *expected_data, - int expected_status ) + int do_test_data_chunked, + int do_set_lengths, + data_t *expected_output, + int expect_valid_signature ) { size_t ad_part_len = 0; size_t data_part_len = 0; - if( test_ad_mp_arg == 1 ) + /* Temporary whilst we have algorithms that cannot support chunking */ + if( do_test_ad_chunked == 1 ) { for( ad_part_len = 1; ad_part_len <= additional_data->len; ad_part_len++ ) { mbedtls_test_set_step( ad_part_len ); - aead_multipart_decrypt_internal( key_type_arg, key_data, - alg_arg, nonce, - additional_data, - ad_part_len, - input_data, -1, - test_set_lengths_arg, - expected_data, expected_status ); + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + do_set_lengths, + expected_output, + expect_valid_signature, + 0 ) ) + break; } } - if( test_data_mp_arg == 1 ) + /* Temporary whilst we have algorithms that cannot support chunking */ + if( do_test_data_chunked == 1 ) { for( data_part_len = 1; data_part_len <= input_data->len; data_part_len++ ) { - aead_multipart_decrypt_internal( key_type_arg, key_data, - alg_arg, nonce, - additional_data, -1, - input_data, data_part_len, - test_set_lengths_arg, - expected_data, expected_status ); + mbedtls_test_set_step( 1000 + data_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + do_set_lengths, + expected_output, + expect_valid_signature, + 0 ) ) + break; } } From 243080ca7de46b576069e6285ddd0893ec055047 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 21 Jul 2021 19:01:17 +0100 Subject: [PATCH 117/966] Clarify comments on state test. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index fe9e0014db..c5567406a7 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4002,7 +4002,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); - /* Test for not sending any additional data or data (encrypt) */ + /* Test for not sending any additional data or data after setting non zero + * lengths for them. (encrypt) */ operation = psa_aead_operation_init( ); @@ -4022,7 +4023,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); - /* Test for not sending any additional data or data (decrypt) */ + /* Test for not sending any additional data or data after setting non-zero + * lengths for them. (decrypt) */ operation = psa_aead_operation_init( ); @@ -4042,7 +4044,8 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); - /* Test for not sending any additional data. */ + /* Test for not sending any additional data after setting a non-zero length + * for it. */ operation = psa_aead_operation_init( ); From 329d5381a5fd7e55892eac6e5dabdd62512b7cbe Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 22 Jul 2021 17:10:45 +0100 Subject: [PATCH 118/966] Add 0 length part tests Add tests to do zero length part, n length part until done, to exercise the zero length edge case. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 99 ++++++++++++++++++--- 1 file changed, 86 insertions(+), 13 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index c5567406a7..46f7a1d529 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -298,7 +298,8 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, int do_set_lengths, data_t *expected_output, int expect_valid_signature, - int is_encrypt ) + int is_encrypt, + int do_zero_parts ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; @@ -323,6 +324,7 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, psa_status_t status = PSA_ERROR_GENERIC_ERROR; int test_ok = 0; + uint32_t part_count = 0; PSA_ASSERT( psa_crypto_init( ) ); @@ -409,13 +411,21 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, while( part_offset < additional_data->len ) { - if( additional_data->len - part_offset < ( uint32_t ) ad_part_len ) + if( do_zero_parts && part_count++ & 0x01 ) { - part_length = additional_data->len - part_offset; + part_length = 0; } else { - part_length = ad_part_len; + if( additional_data->len - part_offset < + ( uint32_t ) ad_part_len ) + { + part_length = additional_data->len - part_offset; + } + else + { + part_length = ad_part_len; + } } PSA_ASSERT( psa_aead_update_ad( &operation, @@ -444,13 +454,20 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, while( part_offset < data_true_size ) { - if( ( data_true_size - part_offset ) < ( uint32_t ) data_part_len ) + if( do_zero_parts && part_count++ & 0x01 ) { - part_length = ( data_true_size - part_offset ); + part_length = 0; } else { - part_length = data_part_len; + if( ( data_true_size - part_offset ) < ( uint32_t ) data_part_len ) + { + part_length = ( data_true_size - part_offset ); + } + else + { + part_length = data_part_len; + } } PSA_ASSERT( psa_aead_update( &operation, @@ -3468,6 +3485,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, { mbedtls_test_set_step( ad_part_len ); + /* Split ad into length(ad_part_len) parts. */ if( !aead_multipart_internal_func( key_type_arg, key_data, alg_arg, nonce, additional_data, @@ -3475,7 +3493,20 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, -1, do_set_lengths, expected_output, - 1, 1 ) ) + 1, 1, 0 ) ) + break; + + /* length(0) part, length(ad_part_len) part, length(0) part... */ + mbedtls_test_set_step( 1000 + ad_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + do_set_lengths, + expected_output, + 1, 1, 1 ) ) break; } } @@ -3486,7 +3517,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, for( data_part_len = 1; data_part_len <= input_data->len; data_part_len++ ) { - mbedtls_test_set_step( 1000 + data_part_len ); + /* Split data into length(data_part_len) parts. */ + mbedtls_test_set_step( 2000 + data_part_len ); if( !aead_multipart_internal_func( key_type_arg, key_data, alg_arg, nonce, @@ -3494,7 +3526,19 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, data_part_len, do_set_lengths, expected_output, - 1, 1 ) ) + 1, 1, 0 ) ) + break; + + /* length(0) part, length(data_part_len) part, length(0) part... */ + mbedtls_test_set_step( 3000 + data_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + do_set_lengths, + expected_output, + 1, 1, 1 ) ) break; } } @@ -3527,6 +3571,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, for( ad_part_len = 1; ad_part_len <= additional_data->len; ad_part_len++ ) { + /* Split ad into length(ad_part_len) parts. */ mbedtls_test_set_step( ad_part_len ); if( !aead_multipart_internal_func( key_type_arg, key_data, @@ -3537,7 +3582,21 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, do_set_lengths, expected_output, expect_valid_signature, - 0 ) ) + 0, 0 ) ) + break; + + /* length(0) part, length(ad_part_len) part, length(0) part... */ + mbedtls_test_set_step( 1000 + ad_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + do_set_lengths, + expected_output, + expect_valid_signature, + 0, 1 ) ) break; } } @@ -3548,7 +3607,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, for( data_part_len = 1; data_part_len <= input_data->len; data_part_len++ ) { - mbedtls_test_set_step( 1000 + data_part_len ); + /* Split data into length(data_part_len) parts. */ + mbedtls_test_set_step( 2000 + data_part_len ); if( !aead_multipart_internal_func( key_type_arg, key_data, alg_arg, nonce, @@ -3557,7 +3617,20 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, do_set_lengths, expected_output, expect_valid_signature, - 0 ) ) + 0, 0 ) ) + break; + + /* length(0) part, length(data_part_len) part, length(0) part... */ + mbedtls_test_set_step( 3000 + data_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + do_set_lengths, + expected_output, + expect_valid_signature, + 0, 1 ) ) break; } } From ebf91638b5c6e5d53a77e0a9a12061108a6743b0 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 22 Jul 2021 17:54:42 +0100 Subject: [PATCH 119/966] Move set nonce / set length tests to positive test Previous test in state test was not actually making sure that the operatioon could be completed using set lengths / set nonce in either order, thus changed the 'normal' encrypt / decrypt tests to run in alternating order. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 94 ++++++++------------- 1 file changed, 36 insertions(+), 58 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 46f7a1d529..0e9917a432 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -299,7 +299,8 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, data_t *expected_output, int expect_valid_signature, int is_encrypt, - int do_zero_parts ) + int do_zero_parts, + int swap_set_functions ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; @@ -396,12 +397,25 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, PSA_ASSERT( status ); - PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); - - if( do_set_lengths ) + if( swap_set_functions ) { - PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, - data_true_size ) ); + if( do_set_lengths ) + { + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + data_true_size ) ); + } + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + } + else + { + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + if( do_set_lengths ) + { + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + data_true_size ) ); + } } if( ad_part_len != -1 ) @@ -3493,7 +3507,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, -1, do_set_lengths, expected_output, - 1, 1, 0 ) ) + 1, 1, 0, + ( ad_part_len & 0x01 ) ) ) break; /* length(0) part, length(ad_part_len) part, length(0) part... */ @@ -3506,7 +3521,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, -1, do_set_lengths, expected_output, - 1, 1, 1 ) ) + 1, 1, 1, + ( ad_part_len & 0x01 ) ) ) break; } } @@ -3526,7 +3542,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, data_part_len, do_set_lengths, expected_output, - 1, 1, 0 ) ) + 1, 1, 0, + ( data_part_len & 0x01 ) ) ) break; /* length(0) part, length(data_part_len) part, length(0) part... */ @@ -3538,7 +3555,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, data_part_len, do_set_lengths, expected_output, - 1, 1, 1 ) ) + 1, 1, 1, + ( data_part_len & 0x01 ) ) ) break; } } @@ -3582,7 +3600,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, do_set_lengths, expected_output, expect_valid_signature, - 0, 0 ) ) + 0, 0, + ( ad_part_len & 0x01 ) ) ) break; /* length(0) part, length(ad_part_len) part, length(0) part... */ @@ -3596,7 +3615,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, do_set_lengths, expected_output, expect_valid_signature, - 0, 1 ) ) + 0, 1, + ( ad_part_len & 0x01 ) ) ) break; } } @@ -3617,7 +3637,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, do_set_lengths, expected_output, expect_valid_signature, - 0, 0 ) ) + 0, 0, + ( data_part_len & 0x01 ) ) ) break; /* length(0) part, length(data_part_len) part, length(0) part... */ @@ -3630,7 +3651,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, do_set_lengths, expected_output, expect_valid_signature, - 0, 1 ) ) + 0, 1, + ( data_part_len & 0x01 ) ) ) break; } } @@ -4013,50 +4035,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); - /* Test that generate/set nonce and set lengths are interchangeable (we - * already tested set nonce followed by set lengths above). */ - - operation = psa_aead_operation_init( ); - - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); - - PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, - input_data->len ) ); - - PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); - - psa_aead_abort( &operation ); - - /* ------------------------------------------------------- */ - - operation = psa_aead_operation_init( ); - - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); - - PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, - input_data->len ) ); - - PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, - PSA_AEAD_NONCE_MAX_SIZE, - &nonce_length ) ); - - psa_aead_abort( &operation ); - - /* ------------------------------------------------------- */ - - operation = psa_aead_operation_init( ); - - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); - - PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, - PSA_AEAD_NONCE_MAX_SIZE, - &nonce_length ) ); - - PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, - input_data->len ) ); - - psa_aead_abort( &operation ); - /* Test for setting lengths after already starting data. */ operation = psa_aead_operation_init( ); From 99f548d974a48fcfe58aaf2666872bee146ffa30 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 22 Jul 2021 18:03:50 +0100 Subject: [PATCH 120/966] Fix format issues with check nonce size Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 9f673596fd..5310702c68 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -296,7 +296,7 @@ psa_status_t mbedtls_psa_aead_decrypt( goto exit; if( mbedtls_aead_check_nonce_length( &operation, nonce_length ) - != PSA_SUCCESS) + != PSA_SUCCESS ) { status = PSA_ERROR_NOT_SUPPORTED; goto exit; @@ -428,7 +428,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; if( mbedtls_aead_check_nonce_length( operation, nonce_length ) - != PSA_SUCCESS) + != PSA_SUCCESS ) { return( PSA_ERROR_INVALID_ARGUMENT ); } From 2fe5db87d5702a4f34f6fd28acaa0f5961584e93 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 22 Jul 2021 18:10:43 +0100 Subject: [PATCH 121/966] Fix passing wrong tag size to GCM finish Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 5310702c68..6af25ec78b 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -628,7 +628,7 @@ psa_status_t mbedtls_psa_aead_finish( status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, ciphertext, ciphertext_size, - tag, tag_size ) ); + tag, operation->tag_length ) ); else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) From ed08cf884a6a8462a577dd0ac7ad9b8c4338921d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 22 Jul 2021 18:48:24 +0100 Subject: [PATCH 122/966] Add safety check to chachapoly finish Previous code checked that the buffer was big enough for the tag size for the given algorithm, however chachapoly finish expects a 16 byte buffer passed in, no matter what. If we start supporting smaller chachapoly tags in the future, this could potentially end up in buffer overflow, so add a safety check. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 6af25ec78b..bcf3c43a5d 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -633,9 +633,18 @@ psa_status_t mbedtls_psa_aead_finish( #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + /* Belt and braces. Although the above tag_size check should have + * already done this, if we later start supporting smaller tag sizes + * for chachapoly, then passing a tag buffer smaller than 16 into here + * could cause a buffer overflow, so better safe than sorry. */ + if( tag_size < 16 ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly, tag ) ); + } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { From 26f4aef3a7f4ef0503862e199dcfe1f2ff4bf583 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 22 Jul 2021 21:47:27 +0100 Subject: [PATCH 123/966] Remove aead_verify call from test driver Function was removed, but missed this reference. Signed-off-by: Paul Elliott --- tests/src/drivers/test_driver_aead.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index 698353c5d6..5928e0e010 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -272,9 +272,26 @@ psa_status_t mbedtls_test_transparent_aead_verify( } else { - mbedtls_test_driver_aead_hooks.driver_status = - mbedtls_psa_aead_verify( operation, plaintext, plaintext_size, - plaintext_length, tag, tag_length ); + uint8_t check_tag[PSA_AEAD_TAG_MAX_SIZE]; + size_t check_tag_length; + + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_finish( operation, + plaintext, + plaintext_size, + plaintext_length, + check_tag, + tag_length, + &check_tag_length ); + + if( mbedtls_test_driver_aead_hooks.driver_status == PSA_SUCCESS ) + { + if( tag_length != check_tag_length || + mbedtls_psa_safer_memcmp( tag, check_tag, tag_length ) + != 0 ) + mbedtls_test_driver_aead_hooks.driver_status = + PSA_ERROR_INVALID_SIGNATURE; + } } return( mbedtls_test_driver_aead_hooks.driver_status ); From 41ffae17b1a1fea67a2dc925616bfa3586ad8a09 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 22 Jul 2021 21:52:01 +0100 Subject: [PATCH 124/966] Fix incorrect function documentation Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 0e9917a432..3312f674fc 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -282,8 +282,13 @@ typedef enum { * \param do_set_lengths If non-zero, then set lengths prior to * calling encryption / decryption. * \param expected_output Expected output - * \param expected_status_arg Expected status + * \param expect_valid_signature If non zero, we expect the signature to be + * valid * \param is_encrypt If non-zero this is an encryption operation. + * \param do_zero_parts If non-zero, interleave zero length chunks + * with normal length chunks + * \param swap_set_functions If non-zero, swap the order of set lengths + * and set nonce. * * \return int Zero on failure, non-zero on success. * From 218dec824e6de919f229afa00731d185651aae09 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Fri, 23 Jul 2021 07:23:47 +0100 Subject: [PATCH 125/966] Document that returning 0 from the recv callback means EOF Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 3a14a58307..bf44975c35 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -493,10 +493,11 @@ typedef int mbedtls_ssl_send_t( void *ctx, * \param buf Buffer to write the received data to * \param len Length of the receive buffer * - * \return The callback must return the number of bytes received, - * or a non-zero error code. - * If performing non-blocking I/O, \c MBEDTLS_ERR_SSL_WANT_READ + * \returns If data has been received, the positive number of bytes received. + * \returns \c 0 if the connection has been closed. + * \returns If performing non-blocking I/O, \c MBEDTLS_ERR_SSL_WANT_READ * must be returned when the operation would block. + * \returns Another negative error code on other kinds of failures. * * \note The callback may receive fewer bytes than the length of the * buffer. It must always return the number of bytes actually From 0a6a5694d94ec7df45cd776e4340210dbe0f5556 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Jul 2021 15:29:21 +0100 Subject: [PATCH 126/966] Add missing include to PSA test driver Signed-off-by: Paul Elliott --- tests/src/drivers/test_driver_aead.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index 5928e0e010..ac116ffb06 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -25,6 +25,7 @@ #if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST) #include "psa_crypto_aead.h" +#include "psa_crypto_core.h" #include "test/drivers/aead.h" From ecce901907ebdc52b382c01d905740d8995c3826 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Jul 2021 15:44:11 +0100 Subject: [PATCH 127/966] Change over to specific per algorith size checks Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index bcf3c43a5d..d877638ecf 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -568,13 +568,12 @@ psa_status_t mbedtls_psa_aead_update( update_output_length = input_length; - if( PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type, operation->alg, - input_length ) > output_size ) - return ( PSA_ERROR_BUFFER_TOO_SMALL ); - #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { + if( output_size < input_length ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + status = mbedtls_to_psa_error( mbedtls_gcm_update( &operation->ctx.gcm, input, input_length, @@ -586,6 +585,9 @@ psa_status_t mbedtls_psa_aead_update( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { + if( output_size < input_length ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + status = mbedtls_to_psa_error( mbedtls_chachapoly_update( &operation->ctx.chachapoly, input_length, @@ -625,10 +627,15 @@ psa_status_t mbedtls_psa_aead_finish( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) + { + if( ciphertext_size < 15 ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, ciphertext, ciphertext_size, tag, operation->tag_length ) ); + } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) From 863864a2f77ade5e94cca4c6afb19899debdb814 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Jul 2021 17:28:31 +0100 Subject: [PATCH 128/966] Add multipart set nonce test Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 28 ++++++ tests/suites/test_suite_psa_crypto.function | 98 +++++++++++++++++++++ 2 files changed, 126 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 8f9d6c4d6b..ad54793cd4 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2537,6 +2537,34 @@ PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:12:"":"":PSA_SUCCESS +PSA Multipart Set Nonce, AES - GCM, IV = 0 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"":"":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart Set Nonce, AES - GCM, IV = 16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS + +PSA Multipart Set Nonce, AES - GCM, IV = 20 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS + +PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 12 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS + +PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 8 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:"":"":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"":"":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 16 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:"":"":PSA_ERROR_INVALID_ARGUMENT + PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 3312f674fc..0d9543d7b1 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3766,6 +3766,104 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, + int alg_arg, + int nonce_len, + data_t *additional_data, + data_t *input_data, + int expected_status_arg ) +{ + + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + uint8_t *nonce_buffer = NULL; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + psa_status_t expected_status = expected_status_arg; + unsigned char *output_data = NULL; + unsigned char *final_data = NULL; + size_t output_size = 0; + size_t finish_output_size = 0; + size_t output_length = 0; + size_t tag_length = 0; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; + int index = 0; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); + + ASSERT_ALLOC( output_data, output_size ); + + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + + TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, finish_output_size ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_len ); + } + + PSA_ASSERT( status ); + + ASSERT_ALLOC( nonce_buffer, nonce_len ); + + for( index = 0; index < nonce_len - 1; ++index) + { + nonce_buffer[index] = 'a' + index; + } + + status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_len ); + + TEST_ASSERT( status == expected_status ); + + if( expected_status == PSA_SUCCESS ) + { + /* Ensure we can still complete operation. */ + + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len, + output_data, output_size, &output_length ) ); + + PSA_ASSERT( psa_aead_finish( &operation, final_data, finish_output_size, + &output_length, tag_buffer, + PSA_AEAD_TAG_MAX_SIZE, &tag_length ) ); + } + +exit: + psa_destroy_key( key ); + mbedtls_free( output_data ); + mbedtls_free( final_data ); + mbedtls_free( nonce_buffer ); + psa_aead_abort( &operation ); + PSA_DONE( ); +} +/* END_CASE */ + /* BEGIN_CASE */ void aead_multipart_state_test( int key_type_arg, data_t *key_data, int alg_arg, From 56e4aa6ae20deb43e59d4d4e436f5377de3ef8a2 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Jul 2021 17:36:48 +0100 Subject: [PATCH 129/966] Restore accidentally deleted blank lines Script to generate test data was missing a '\n' Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 61 +++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index ad54793cd4..5a696fd93b 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2313,165 +2313,219 @@ aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a0 PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 + PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 + PSA Multipart AEAD decrypt, AES-GCM, invalid signature depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":0 + PSA Multipart AEAD decrypt, AES-GCM, T=15 but passing 16 bytes depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":0 + PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":0 + PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":0 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:0:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:1:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:0:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:1:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:0:"b03c2c20f758a93a8d1220232ad87098":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:1:"b03c2c20f758a93a8d1220232ad87098":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:0:"b22b2dcdcc18adc30d16297b84b459d8":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:1:"b22b2dcdcc18adc30d16297b84b459d8":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:0:"7e5fd8b595ddc4753676107951d900e2":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:1:"7e5fd8b595ddc4753676107951d900e2":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:0:"37245449db8f72b1ecdb420f629d3d80":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:1:"37245449db8f72b1ecdb420f629d3d80":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:0:"496909523f574b205d757659c5":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:1:"496909523f574b205d757659c5":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:0:"b6e056de521a27266dffbc0d96":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:1:"b6e056de521a27266dffbc0d96":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:0:"f6d56f8c86f27d957fa63aea22":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:1:"f6d56f8c86f27d957fa63aea22":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:0:"bd94b34511bc65ae47684805cb":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:1:"bd94b34511bc65ae47684805cb":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:0:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:1:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:0:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:1:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:0:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:1:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:0:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:1:"":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:0:"7789b41cb3ee548814ca0b388c10b343":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:1:"7789b41cb3ee548814ca0b388c10b343":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:0:"4860116a6d2deb9bf794bfd6ac5bbbd6":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:1:"4860116a6d2deb9bf794bfd6ac5bbbd6":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:0:"ff426dd751190ff826e8b4a0792d746e":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:1:"ff426dd751190ff826e8b4a0792d746e":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:0:"0a0b284515694188b6b6c15bc8a09036":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:1:"0a0b284515694188b6b6c15bc8a09036":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:0:"f386b28e7eb4c2fb8eb5dc66a2":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:1:"f386b28e7eb4c2fb8eb5dc66a2":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:0:"da1c61fbfcdb73445ad4c7d889":1 + PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:1:"da1c61fbfcdb73445ad4c7d889":1 + PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:0:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" @@ -2491,24 +2545,31 @@ aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f90 PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1 + PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1 + PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, bad tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":0 + PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:0:"":1 + PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:1:"":1 + PSA Multipart AEAD decrypt: invalid algorithm (CTR) depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:0:"":0 + PSA Multipart AEAD decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:0:"":0 + PSA Multipart Nonce Generation, AES - GCM, IV = 12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS From 693bf312d94ad2ea364cd3902e9d944091b1c5be Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Jul 2021 17:40:41 +0100 Subject: [PATCH 130/966] Fix _arg argument not being cast to correct type Also change to TEST_EQUAL, as this is now possible. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 0d9543d7b1..5e4eaf85fa 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3685,6 +3685,7 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; + psa_status_t expected_status = expected_status_arg; size_t nonce_generated_len = 0; size_t expected_generated_len = expected_generated_len_arg; unsigned char *output_data = NULL; @@ -3735,13 +3736,13 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, nonce_len, &nonce_generated_len ); - TEST_ASSERT( status == expected_status_arg ); + TEST_EQUAL( status, expected_status ); TEST_EQUAL( nonce_generated_len, expected_generated_len ); TEST_ASSERT( nonce_generated_len < PSA_AEAD_NONCE_MAX_SIZE ); - if( expected_status_arg == PSA_SUCCESS ) + if( expected_status == PSA_SUCCESS ) { /* Ensure we can still complete operation. */ @@ -3837,7 +3838,7 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_len ); - TEST_ASSERT( status == expected_status ); + TEST_EQUAL( status, expected_status ); if( expected_status == PSA_SUCCESS ) { From 43fbda648db946113848588a4051b42df2794080 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Jul 2021 18:30:59 +0100 Subject: [PATCH 131/966] Add test for update buffer size Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 16 ++++ tests/suites/test_suite_psa_crypto.function | 86 +++++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 5a696fd93b..45d37b6c78 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2626,6 +2626,22 @@ PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:"":"":PSA_ERROR_INVALID_ARGUMENT +PSA AEAD buffer test: AES - GCM, IN = 16, BUF = 10 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):10:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL + +PSA AEAD buffer test: AES - GCM, IN = 16, BUF = 16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS + +PSA AEAD buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 10 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:10:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL + +PSA AEAD buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 130 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:130:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_SUCCESS + PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 5e4eaf85fa..32be56e068 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3865,6 +3865,92 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, + int alg_arg, + int buffer_size, + data_t *nonce, + data_t *additional_data, + data_t *input_data, + int expected_status_arg ) +{ + + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + psa_status_t expected_status = expected_status_arg; + unsigned char *output_data = NULL; + unsigned char *final_data = NULL; + size_t finish_output_size = 0; + size_t output_length = 0; + size_t tag_length = 0; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + + ASSERT_ALLOC( output_data, buffer_size ); + + finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + + TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, finish_output_size ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + PSA_ASSERT( status ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + status = psa_aead_update( &operation, input_data->x, input_data->len, + output_data, buffer_size, &output_length ); + + TEST_EQUAL( status, expected_status ); + + if( expected_status == PSA_SUCCESS ) + { + /* Ensure we can still complete operation. */ + PSA_ASSERT( psa_aead_finish( &operation, final_data, finish_output_size, + &output_length, tag_buffer, + PSA_AEAD_TAG_MAX_SIZE, &tag_length ) ); + } + +exit: + psa_destroy_key( key ); + mbedtls_free( output_data ); + mbedtls_free( final_data ); + psa_aead_abort( &operation ); + PSA_DONE( ); +} +/* END_CASE */ + + /* BEGIN_CASE */ void aead_multipart_state_test( int key_type_arg, data_t *key_data, int alg_arg, From 91b021e4c70e0ac7e9352f97d9c55cb29f4572d0 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 23 Jul 2021 18:52:31 +0100 Subject: [PATCH 132/966] Add finish buffer size test Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 21 +++++- tests/suites/test_suite_psa_crypto.function | 81 +++++++++++++++++++++ 2 files changed, 98 insertions(+), 4 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 45d37b6c78..d223537900 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2626,22 +2626,35 @@ PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:"":"":PSA_ERROR_INVALID_ARGUMENT -PSA AEAD buffer test: AES - GCM, IN = 16, BUF = 10 +PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 10 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):10:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL -PSA AEAD buffer test: AES - GCM, IN = 16, BUF = 16 +PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS -PSA AEAD buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 10 +PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 10 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:10:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL -PSA AEAD buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 130 +PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 130 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:130:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_SUCCESS +PSA AEAD finish buffer test: AES - GCM, BUF = 8 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):8:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL + +PSA AEAD finish buffer test: AES - GCM, BUF = 15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS + +PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_SUCCESS + + PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 32be56e068..b8023eeb1a 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3950,6 +3950,87 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, + int alg_arg, + int buffer_size, + data_t *nonce, + data_t *additional_data, + data_t *input_data, + int expected_status_arg ) +{ + + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + psa_status_t expected_status = expected_status_arg; + unsigned char *output_data = NULL; + unsigned char *final_data = NULL; + size_t output_size = 0; + size_t output_length = 0; + size_t tag_length = 0; + uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + + output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); + + ASSERT_ALLOC( output_data, output_size ); + + TEST_ASSERT( buffer_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + + ASSERT_ALLOC( final_data, buffer_size ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + PSA_ASSERT( status ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len, + output_data, output_size, &output_length ) ); + + /* Ensure we can still complete operation. */ + status = psa_aead_finish( &operation, final_data, buffer_size, + &output_length, tag_buffer, + PSA_AEAD_TAG_MAX_SIZE, &tag_length ); + + TEST_EQUAL( status, expected_status ); + +exit: + psa_destroy_key( key ); + mbedtls_free( output_data ); + mbedtls_free( final_data ); + psa_aead_abort( &operation ); + PSA_DONE( ); +} +/* END_CASE */ /* BEGIN_CASE */ void aead_multipart_state_test( int key_type_arg, data_t *key_data, From bd25755d2a6f72961e4dd8925e324596978c4f6a Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 22 Mar 2021 06:59:27 +0000 Subject: [PATCH 133/966] Rename ssl_populate_transform() -> ssl_tls12_populate_transform() In TLS 1.2 specific code, the internal helper functions ssl_populate_transform() builds an SSL transform structure, representing a specific record protection mechanism. In preparation for a subsequent commit which will introduce a similar helper function specific to TLS 1.3, this commmit renames ssl_populate_transform() to ssl_tls12_populate_transform(). Signed-off-by: Hanno Becker --- library/ssl_misc.h | 3 ++- library/ssl_tls.c | 48 +++++++++++++++++++++++----------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index cc19f4723b..ca92d6893e 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -740,7 +740,8 @@ struct mbedtls_ssl_transform #if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) /* We need the Hello random bytes in order to re-derive keys from the - * Master Secret and other session info, see ssl_populate_transform() */ + * Master Secret and other session info, + * see ssl_tls12_populate_transform() */ unsigned char randbytes[64]; /*!< ServerHello.random+ClientHello.random */ #endif /* MBEDTLS_SSL_CONTEXT_SERIALIZATION */ }; diff --git a/library/ssl_tls.c b/library/ssl_tls.c index fe3b5e2e64..33f4e601c3 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -665,14 +665,14 @@ typedef int ssl_tls_prf_t(const unsigned char *, size_t, const char *, * - MBEDTLS_SSL_EXPORT_KEYS: ssl->conf->{f,p}_export_keys * - MBEDTLS_DEBUG_C: ssl->conf->{f,p}_dbg */ -static int ssl_populate_transform( mbedtls_ssl_transform *transform, +static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, int ciphersuite, const unsigned char master[48], -#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC) -#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC) && \ + defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) int encrypt_then_mac, -#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ -#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */ +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC && + MBEDTLS_SSL_SOME_SUITES_USE_MAC */ ssl_tls_prf_t tls_prf, const unsigned char randbytes[64], int minor_ver, @@ -1328,22 +1328,22 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) } /* Populate transform structure */ - ret = ssl_populate_transform( ssl->transform_negotiate, - ssl->session_negotiate->ciphersuite, - ssl->session_negotiate->master, -#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC) -#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) - ssl->session_negotiate->encrypt_then_mac, -#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ -#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */ - ssl->handshake->tls_prf, - ssl->handshake->randbytes, - ssl->minor_ver, - ssl->conf->endpoint, - ssl ); + ret = ssl_tls12_populate_transform( ssl->transform_negotiate, + ssl->session_negotiate->ciphersuite, + ssl->session_negotiate->master, +#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC) && \ + defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + ssl->session_negotiate->encrypt_then_mac, +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC && + MBEDTLS_SSL_SOME_SUITES_USE_MAC */ + ssl->handshake->tls_prf, + ssl->handshake->randbytes, + ssl->minor_ver, + ssl->conf->endpoint, + ssl ); if( ret != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "ssl_populate_transform", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_tls12_populate_transform", ret ); return( ret ); } @@ -5775,14 +5775,14 @@ static int ssl_context_load( mbedtls_ssl_context *ssl, if( (size_t)( end - p ) < sizeof( ssl->transform->randbytes ) ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - ret = ssl_populate_transform( ssl->transform, + ret = ssl_tls12_populate_transform( ssl->transform, ssl->session->ciphersuite, ssl->session->master, -#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC) -#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) +#if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC) && \ + defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) ssl->session->encrypt_then_mac, -#endif -#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */ +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC && + MBEDTLS_SSL_SOME_SUITES_USE_MAC */ ssl_tls12prf_from_cs( ssl->session->ciphersuite ), p, /* currently pointing to randbytes */ MBEDTLS_SSL_MINOR_VERSION_3, /* (D)TLS 1.2 is forced */ From c94060c6417468bd0c5fd091f3a3aa4217bbb4bd Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 22 Mar 2021 07:50:44 +0000 Subject: [PATCH 134/966] Add TLS 1.3 specific key to SSL transform conversion function This commit adds the TLS 1.3 specific internal function ``` mbedtls_ssl_tls13_populate_transform() ``` which creates an instance of the SSL transform structure `mbedtls_ssl_transform` representing a TLS 1.3 record protection mechanism. It is analogous to the existing internal helper function ``` ssl_tls12_populate_transform() ``` which creates transform structures representing record protection mechanisms in TLS 1.2 and earlier. Signed-off-by: Hanno Becker --- library/ssl_tls13_keys.c | 108 +++++++++++++++++++++++++++++++++++++++ library/ssl_tls13_keys.h | 33 ++++++++++++ 2 files changed, 141 insertions(+) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index f1c8a12d86..28313130f7 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -699,4 +699,112 @@ exit: return( ret ); } +int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, + int endpoint, + int ciphersuite, + mbedtls_ssl_key_set const *traffic_keys, + mbedtls_ssl_context *ssl /* DEBUG ONLY */ ) +{ + int ret; + mbedtls_cipher_info_t const *cipher_info; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + unsigned char const *key_enc; + unsigned char const *iv_enc; + unsigned char const *key_dec; + unsigned char const *iv_dec; + +#if !defined(MBEDTLS_DEBUG_C) + ssl = NULL; /* make sure we don't use it except for those cases */ + (void) ssl; +#endif + + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuite ); + + cipher_info = mbedtls_cipher_info_from_type( ciphersuite_info->cipher ); + if( cipher_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* + * Setup cipher contexts in target transform + */ + + if( ( ret = mbedtls_cipher_setup( &transform->cipher_ctx_enc, + cipher_info ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setup", ret ); + return( ret ); + } + + if( ( ret = mbedtls_cipher_setup( &transform->cipher_ctx_dec, + cipher_info ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setup", ret ); + return( ret ); + } + +#if defined(MBEDTLS_SSL_SRV_C) + if( endpoint == MBEDTLS_SSL_IS_SERVER ) + { + key_enc = traffic_keys->server_write_key; + key_dec = traffic_keys->client_write_key; + iv_enc = traffic_keys->server_write_iv; + iv_dec = traffic_keys->client_write_iv; + } + else +#endif /* MBEDTLS_SSL_SRV_C */ +#if defined(MBEDTLS_SSL_CLI_C) + if( endpoint == MBEDTLS_SSL_IS_CLIENT ) + { + key_enc = traffic_keys->client_write_key; + key_dec = traffic_keys->server_write_key; + iv_enc = traffic_keys->client_write_iv; + iv_dec = traffic_keys->server_write_iv; + } + else +#endif /* MBEDTLS_SSL_CLI_C */ + { + /* should not happen */ + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + memcpy( transform->iv_enc, iv_enc, traffic_keys->iv_len ); + memcpy( transform->iv_dec, iv_dec, traffic_keys->iv_len ); + + if( ( ret = mbedtls_cipher_setkey( &transform->cipher_ctx_enc, + key_enc, cipher_info->key_bitlen, + MBEDTLS_ENCRYPT ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setkey", ret ); + return( ret ); + } + + if( ( ret = mbedtls_cipher_setkey( &transform->cipher_ctx_dec, + key_dec, cipher_info->key_bitlen, + MBEDTLS_DECRYPT ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setkey", ret ); + return( ret ); + } + + /* + * Setup other fields in SSL transform + */ + + if( ( ciphersuite_info->flags & MBEDTLS_CIPHERSUITE_SHORT_TAG ) != 0 ) + transform->taglen = 8; + else + transform->taglen = 16; + + transform->ivlen = traffic_keys->iv_len; + transform->maclen = 0; + transform->fixed_ivlen = transform->ivlen; + transform->minlen = transform->taglen + 1; + transform->minor_ver = MBEDTLS_SSL_MINOR_VERSION_4; + + return( 0 ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 3b96998aed..ca892b1665 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -498,4 +498,37 @@ int mbedtls_ssl_tls1_3_create_psk_binder( mbedtls_ssl_context *ssl, unsigned char const *transcript, unsigned char *result ); +/** + * \bref Setup an SSL transform structure representing the + * record protection mechanism used by TLS 1.3 + * + * \param transform The SSL transform structure to be created. This must have + * been initialized through mbedtls_ssl_transform_init() and + * not used in any other way prior to calling this function. + * In particular, this function does not clean up the + * transform structure prior to installing the new keys. + * \param endpoint Indicates whether the transform is for the client + * (value #MBEDTLS_SSL_IS_CLIENT) or the server + * (value #MBEDTLS_SSL_IS_SERVER). + * \param ciphersuite The numerical identifier for the ciphersuite to use. + * This must be one of the identifiers listed in + * ssl_ciphersuites.h. + * \param traffic_keys The key material to use. No reference is stored in + * the SSL transform being generated, and the caller + * should destroy the key material afterwards. + * \param ssl (Debug-only) The SSL context to use for debug output + * in case of failure. This parameter is only needed if + * #MBEDTLS_DEBUG_C is set, and is ignored otherwise. + * + * \return \c 0 on success. In this case, \p transform is ready to + * be used with mbedtls_ssl_transform_decrypt() and + * mbedtls_ssl_transform_encrypt(). + * \return A negative error code on failure. + */ +int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, + int endpoint, + int ciphersuite, + mbedtls_ssl_key_set const *traffic_keys, + mbedtls_ssl_context *ssl ); + #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From 79e2d1b6f6eb5c07370afe20c20af00a727a190b Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 22 Mar 2021 11:42:19 +0000 Subject: [PATCH 135/966] Fix AEAD additional data computation for TLS 1.3 The AEAD additional data (AAD) is computed differently in TLS 1.3 compared to TLS 1.2, but this change hasn't yet been reflected in the codee, rendering the current implementation of ``` mbedtls_ssl_{encrypt,decrypt}_buf() ``` not standard compliant. This commit fixes this by adjusting the AAD extraction function ssl_extract_add_data_from_record() and its call-sites. Please see the documentation of the code for an explanation of how the AAD has changed from TLS 1.2 to TLS 1.3. Signed-off-by: Hanno Becker --- library/ssl_msg.c | 53 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 76cc2b17d4..cf2eab56bf 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -384,7 +384,8 @@ static int ssl_parse_inner_plaintext( unsigned char const *content, static void ssl_extract_add_data_from_record( unsigned char* add_data, size_t *add_data_len, mbedtls_record *rec, - unsigned minor_ver ) + unsigned minor_ver, + size_t taglen ) { /* Quoting RFC 5246 (TLS 1.2): * @@ -403,15 +404,37 @@ static void ssl_extract_add_data_from_record( unsigned char* add_data, * * For TLS 1.3, the record sequence number is dropped from the AAD * and encoded within the nonce of the AEAD operation instead. + * Moreover, the additional data involves the length of the TLS + * ciphertext, not the TLS plaintext as in earlier versions. + * Quoting RFC 8446 (TLS 1.3): + * + * additional_data = TLSCiphertext.opaque_type || + * TLSCiphertext.legacy_record_version || + * TLSCiphertext.length + * + * We pass the tag length to this function in order to compute the + * ciphertext length from the inner plaintext length rec->data_len via + * + * TLSCiphertext.length = TLSInnerPlaintext.length + taglen. + * */ unsigned char *cur = add_data; + size_t ad_len_field = rec->data_len; #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - if( minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 ) + if( minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) + { + /* In TLS 1.3, the AAD contains the length of the TLSCiphertext, + * which differs from the length of the TLSInnerPlaintext + * by the length of the authentication tag. */ + ad_len_field += taglen; + } + else #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ { ((void) minor_ver); + ((void) taglen); memcpy( cur, rec->ctr, sizeof( rec->ctr ) ); cur += sizeof( rec->ctr ); } @@ -431,15 +454,15 @@ static void ssl_extract_add_data_from_record( unsigned char* add_data, *cur = rec->cid_len; cur++; - cur[0] = ( rec->data_len >> 8 ) & 0xFF; - cur[1] = ( rec->data_len >> 0 ) & 0xFF; + cur[0] = ( ad_len_field >> 8 ) & 0xFF; + cur[1] = ( ad_len_field >> 0 ) & 0xFF; cur += 2; } else #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ { - cur[0] = ( rec->data_len >> 8 ) & 0xFF; - cur[1] = ( rec->data_len >> 0 ) & 0xFF; + cur[0] = ( ad_len_field >> 8 ) & 0xFF; + cur[1] = ( ad_len_field >> 0 ) & 0xFF; cur += 2; } @@ -646,7 +669,8 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl, unsigned char mac[MBEDTLS_SSL_MAC_ADD]; ssl_extract_add_data_from_record( add_data, &add_data_len, rec, - transform->minor_ver ); + transform->minor_ver, + transform->taglen ); mbedtls_md_hmac_update( &transform->md_ctx_enc, add_data, add_data_len ); @@ -743,7 +767,8 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl, * This depends on the TLS version. */ ssl_extract_add_data_from_record( add_data, &add_data_len, rec, - transform->minor_ver ); + transform->minor_ver, + transform->taglen ); MBEDTLS_SSL_DEBUG_BUF( 4, "IV used (internal)", iv, transform->ivlen ); @@ -897,7 +922,8 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl, } ssl_extract_add_data_from_record( add_data, &add_data_len, - rec, transform->minor_ver ); + rec, transform->minor_ver, + transform->taglen ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "using encrypt then mac" ) ); MBEDTLS_SSL_DEBUG_BUF( 4, "MAC'd meta-data", add_data, @@ -1304,7 +1330,8 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl, * This depends on the TLS version. */ ssl_extract_add_data_from_record( add_data, &add_data_len, rec, - transform->minor_ver ); + transform->minor_ver, + transform->taglen ); MBEDTLS_SSL_DEBUG_BUF( 4, "additional data used for AEAD", add_data, add_data_len ); @@ -1414,7 +1441,8 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl, * Further, we still know that data_len > minlen */ rec->data_len -= transform->maclen; ssl_extract_add_data_from_record( add_data, &add_data_len, rec, - transform->minor_ver ); + transform->minor_ver, + transform->taglen ); /* Calculate expected MAC. */ MBEDTLS_SSL_DEBUG_BUF( 4, "MAC'd meta-data", add_data, @@ -1606,7 +1634,8 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl, */ rec->data_len -= transform->maclen; ssl_extract_add_data_from_record( add_data, &add_data_len, rec, - transform->minor_ver ); + transform->minor_ver, + transform->taglen ); #if defined(MBEDTLS_SSL_PROTO_TLS1_2) /* From a77d005d39e78b55231311d034f2187eae8d5929 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 22 Mar 2021 15:16:33 +0000 Subject: [PATCH 136/966] Add known answer tests for TLS 1.3 record protection This commit adds four known answer tests for TLS 1.3 record protection from the following sources: - RFC 8448 "Example Handshake Traces for TLS 1.3" - tls13.ulfheim.net "The New Illustrated TLS Connection" It extends the test coverage of the existing record protection tests in the following ways: - The existing record protection tests hand-craft record transform structures; the new tests use the function mbedtls_ssl_tls13_populate_transform() from library source to create an TLS 1.3 transform from raw key material and connection information. - The existing record protection tests only check that encryption and decryption are inverse to each other; as such, they don't catch non-compliant implementations of encryption and decryption which happen to be inverse to each other. By adding a known answer test for TLS 1.3 record protection, can gain confidence that our implementation is indeed standards-compliant. Signed-off-by: Hanno Becker --- tests/suites/test_suite_ssl.data | 55 ++++++++++++++++++ tests/suites/test_suite_ssl.function | 86 ++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) diff --git a/tests/suites/test_suite_ssl.data b/tests/suites/test_suite_ssl.data index 5d92469ad7..efedd06154 100644 --- a/tests/suites/test_suite_ssl.data +++ b/tests/suites/test_suite_ssl.data @@ -6021,6 +6021,61 @@ SSL TLS 1.3 Key schedule: Handshake secrets derivation helper # Vector from RFC 8448 ssl_tls1_3_derive_handshake_secrets:MBEDTLS_MD_SHA256:"005cb112fd8eb4ccc623bb88a07c64b3ede1605363fc7d0df8c7ce4ff0fb4ae6":"f736cb34fe25e701551bee6fd24c1cc7102a7daf9405cb15d97aafe16f757d03":"2faac08f851d35fea3604fcb4de82dc62c9b164a70974d0462e27f1ab278700f":"fe927ae271312e8bf0275b581c54eef020450dc4ecffaa05a1a35d27518e7803" +SSL TLS 1.3 Record Encryption, tls13.ulfheim.net Example #1 +# - Server App Key: 0b6d22c8ff68097ea871c672073773bf +# - Server App IV: 1b13dd9f8d8f17091d34b349 +# - Client App Key: 49134b95328f279f0183860589ac6707 +# - Client App IV: bc4dd5f7b98acff85466261d +# - App data payload: 70696e67 +# - Complete record: 1703030015c74061535eb12f5f25a781957874742ab7fb305dd5 +ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_CLIENT:0:"0b6d22c8ff68097ea871c672073773bf":"1b13dd9f8d8f17091d34b349":"49134b95328f279f0183860589ac6707":"bc4dd5f7b98acff85466261d":"70696e67":"c74061535eb12f5f25a781957874742ab7fb305dd5" + +SSL TLS 1.3 Record Encryption, tls13.ulfheim.net Example #2 +# - Server App Key: 0b6d22c8ff68097ea871c672073773bf +# - Server App IV: 1b13dd9f8d8f17091d34b349 +# - Client App Key: 49134b95328f279f0183860589ac6707 +# - Client App IV: bc4dd5f7b98acff85466261d +# - App data payload: 706f6e67 +# - Complete record: 1703030015370e5f168afa7fb16b663ecdfca3dbb81931a90ca7 +ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:"0b6d22c8ff68097ea871c672073773bf":"1b13dd9f8d8f17091d34b349":"49134b95328f279f0183860589ac6707":"bc4dd5f7b98acff85466261d":"706f6e67":"370e5f168afa7fb16b663ecdfca3dbb81931a90ca7" + +SSL TLS 1.3 Record Encryption RFC 8448 Example #1 +# Application Data record sent by Client in 1-RTT example of RFC 8448, Section 3 +# - Server App Key: 9f 02 28 3b 6c 9c 07 ef c2 6b b9 f2 ac 92 e3 56 +# - Server App IV: cf 78 2b 88 dd 83 54 9a ad f1 e9 84 +# - Client App Key: 17 42 2d da 59 6e d5 d9 ac d8 90 e3 c6 3f 50 51 +# - Client App IV: 5b 78 92 3d ee 08 57 90 33 e5 23 d9 +# - App data payload: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f +# 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f +# 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f +# 30 31 +# - Complete record: 17 03 03 00 43 a2 3f 70 54 b6 2c 94 d0 af fa fe +# 82 28 ba 55 cb ef ac ea 42 f9 14 aa 66 bc ab 3f +# 2b 98 19 a8 a5 b4 6b 39 5b d5 4a 9a 20 44 1e 2b +# 62 97 4e 1f 5a 62 92 a2 97 70 14 bd 1e 3d ea e6 +# 3a ee bb 21 69 49 15 e4 +ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_CLIENT:0:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"a23f7054b62c94d0affafe8228ba55cbefacea42f914aa66bcab3f2b9819a8a5b46b395bd54a9a20441e2b62974e1f5a6292a2977014bd1e3deae63aeebb21694915e4" + +SSL TLS 1.3 Record Encryption RFC 8448 Example #2 +# Application Data record sent by Server in 1-RTT example of RFC 8448, Section 3 +# - Server App Key: 9f 02 28 3b 6c 9c 07 ef c2 6b b9 f2 ac 92 e3 56 +# - Server App IV: cf 78 2b 88 dd 83 54 9a ad f1 e9 84 +# - Client App Key: 17 42 2d da 59 6e d5 d9 ac d8 90 e3 c6 3f 50 51 +# - Client App IV: 5b 78 92 3d ee 08 57 90 33 e5 23 d9 +# - App data payload: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f +# 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f +# 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f +# 30 31 +# - Complete record: 17 03 03 00 43 2e 93 7e 11 ef 4a c7 40 e5 38 ad +# 36 00 5f c4 a4 69 32 fc 32 25 d0 5f 82 aa 1b 36 +# e3 0e fa f9 7d 90 e6 df fc 60 2d cb 50 1a 59 a8 +# fc c4 9c 4b f2 e5 f0 a2 1c 00 47 c2 ab f3 32 54 +# 0d d0 32 e1 67 c2 95 5d +ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"2e937e11ef4ac740e538ad36005fc4a46932fc3225d05f82aa1b36e30efaf97d90e6dffc602dcb501a59a8fcc49c4bf2e5f0a21c0047c2abf332540dd032e167c2955d" + +SSL TLS_PRF MBEDTLS_SSL_TLS_PRF_NONE +ssl_tls_prf:MBEDTLS_SSL_TLS_PRF_NONE:"":"":"test tls_prf label":"":MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE + SSL TLS 1.3 Key schedule: Application secrets derivation helper # Vector from RFC 8448 ssl_tls1_3_derive_application_secrets:MBEDTLS_MD_SHA256:"e2d32d4ed66dd37897a0e80c84107503ce58bf8aad4cb55a5002d77ecb890ece":"b0aeffc46a2cfe33114e6fd7d51f9f04b1ca3c497dab08934a774a9d9ad7dbf3":"2abbf2b8e381d23dbebe1dd2a7d16a8bf484cb4950d23fb7fb7fa8547062d9a1":"cc21f1bf8feb7dd5fa505bd9c4b468a9984d554a993dc49e6d285598fb672691":"3fd93d4ffddc98e64b14dd107aedf8ee4add23f4510f58a4592d0b201bee56b4" diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 081e8a45a6..a83d6e2bef 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -3943,6 +3943,92 @@ void ssl_tls1_3_create_psk_binder( int hash_alg, } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ +void ssl_tls1_3_record_protection( int ciphersuite, + int endpoint, + int ctr, + data_t *server_write_key, + data_t *server_write_iv, + data_t *client_write_key, + data_t *client_write_iv, + data_t *plaintext, + data_t *ciphertext ) +{ + mbedtls_ssl_key_set keys; + mbedtls_ssl_transform transform_send; + mbedtls_ssl_transform transform_recv; + mbedtls_record rec; + unsigned char *buf = NULL; + int other_endpoint; + + TEST_ASSERT( endpoint == MBEDTLS_SSL_IS_CLIENT || + endpoint == MBEDTLS_SSL_IS_SERVER ); + + if( endpoint == MBEDTLS_SSL_IS_SERVER ) + other_endpoint = MBEDTLS_SSL_IS_CLIENT; + if( endpoint == MBEDTLS_SSL_IS_CLIENT ) + other_endpoint = MBEDTLS_SSL_IS_SERVER; + + TEST_ASSERT( server_write_key->len == client_write_key->len ); + TEST_ASSERT( server_write_iv->len == client_write_iv->len ); + + memcpy( keys.client_write_key, + client_write_key->x, client_write_key->len ); + memcpy( keys.client_write_iv, + client_write_iv->x, client_write_iv->len ); + memcpy( keys.server_write_key, + server_write_key->x, server_write_key->len ); + memcpy( keys.server_write_iv, + server_write_iv->x, server_write_iv->len ); + + keys.key_len = server_write_key->len; + keys.iv_len = server_write_iv->len; + + mbedtls_ssl_transform_init( &transform_recv ); + mbedtls_ssl_transform_init( &transform_send ); + + TEST_ASSERT( mbedtls_ssl_tls13_populate_transform( + &transform_send, endpoint, + ciphersuite, &keys, NULL ) == 0 ); + TEST_ASSERT( mbedtls_ssl_tls13_populate_transform( + &transform_recv, other_endpoint, + ciphersuite, &keys, NULL ) == 0 ); + + ASSERT_ALLOC( buf, ciphertext->len ); + rec.type = MBEDTLS_SSL_MSG_APPLICATION_DATA; + mbedtls_ssl_write_version( MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_TRANSPORT_STREAM, + rec.ver ); + + /* Copy plaintext into record structure */ + rec.buf = buf; + rec.buf_len = ciphertext->len; + rec.data_offset = 0; + TEST_ASSERT( plaintext->len <= ciphertext->len ); + memcpy( rec.buf + rec.data_offset, plaintext->x, plaintext->len ); + rec.data_len = plaintext->len; +#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) + rec.cid_len = 0; +#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ + + memset( &rec.ctr[0], 0, 8 ); + rec.ctr[7] = ctr; + + TEST_ASSERT( mbedtls_ssl_encrypt_buf( NULL, &transform_send, &rec, + NULL, NULL ) == 0 ); + ASSERT_COMPARE( rec.buf + rec.data_offset, rec.data_len, + ciphertext->x, ciphertext->len ); + + TEST_ASSERT( mbedtls_ssl_decrypt_buf( NULL, &transform_recv, &rec ) == 0 ); + ASSERT_COMPARE( rec.buf + rec.data_offset, rec.data_len, + plaintext->x, plaintext->len ); + + mbedtls_ssl_transform_free( &transform_send ); + mbedtls_ssl_transform_free( &transform_recv ); +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ void ssl_tls1_3_key_evolution( int hash_alg, data_t *secret, From 80e760e00642836a19e7c05efad3ac34a57230be Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 23 Mar 2021 06:00:21 +0000 Subject: [PATCH 137/966] Fix memory leak in TLS 1.3 record protection unit test Signed-off-by: Hanno Becker --- tests/suites/test_suite_ssl.function | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index a83d6e2bef..554e7b86e2 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -4024,6 +4024,7 @@ void ssl_tls1_3_record_protection( int ciphersuite, ASSERT_COMPARE( rec.buf + rec.data_offset, rec.data_len, plaintext->x, plaintext->len ); + mbedtls_free( buf ); mbedtls_ssl_transform_free( &transform_send ); mbedtls_ssl_transform_free( &transform_recv ); } From 7887a77c2507bfbddd2238a0a1a06f9b19d7f64e Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 20 Apr 2021 05:27:57 +0100 Subject: [PATCH 138/966] Match parameter check in TLS 1.3 populate transform to 1.2 version Signed-off-by: Hanno Becker --- library/ssl_tls13_keys.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 28313130f7..0977cabb34 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -719,12 +719,19 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, #endif ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuite ); + if( ciphersuite_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite info for %d not found", + ciphersuite ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } cipher_info = mbedtls_cipher_info_from_type( ciphersuite_info->cipher ); if( cipher_info == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "cipher info for %u not found", + ciphersuite_info->cipher ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ) } /* From edd5bf0a95d05d72c405be84011ea9638d2b966d Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 20 Apr 2021 05:32:16 +0100 Subject: [PATCH 139/966] Fix and document minimum length of record ciphertext in TLS 1.3 Signed-off-by: Hanno Becker --- library/ssl_tls13_keys.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 0977cabb34..8270009c76 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -808,9 +808,15 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, transform->ivlen = traffic_keys->iv_len; transform->maclen = 0; transform->fixed_ivlen = transform->ivlen; - transform->minlen = transform->taglen + 1; transform->minor_ver = MBEDTLS_SSL_MINOR_VERSION_4; + /* We add the true record content type (1 Byte) to the plaintext and + * then pad to the configured granularity. The mimimum length of the + * type-extended and padded plaintext is therefore the padding + * granularity. */ + transform->minlen = + transform->taglen + MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY; + return( 0 ); } From 41537452f495a7ee448a7bd4d0d5f566341263d6 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 20 Apr 2021 05:35:28 +0100 Subject: [PATCH 140/966] Add comment regarding the wire-version used in TLS 1.3 records Signed-off-by: Hanno Becker --- tests/suites/test_suite_ssl.function | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 554e7b86e2..2e09907228 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -3996,6 +3996,8 @@ void ssl_tls1_3_record_protection( int ciphersuite, ASSERT_ALLOC( buf, ciphertext->len ); rec.type = MBEDTLS_SSL_MSG_APPLICATION_DATA; + + /* TLS 1.3 uses the version identifier from TLS 1.2 on the wire. */ mbedtls_ssl_write_version( MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_TRANSPORT_STREAM, From f62a730e80ebdc976d32b1d0f52078273ee1fb7f Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Wed, 21 Apr 2021 05:21:28 +0100 Subject: [PATCH 141/966] Add missing semicolon in TLS 1.3 transform generation code Signed-off-by: Hanno Becker --- library/ssl_tls13_keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 8270009c76..91384f281f 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -731,7 +731,7 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, { MBEDTLS_SSL_DEBUG_MSG( 1, ( "cipher info for %u not found", ciphersuite_info->cipher ) ); - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); } /* From c0da10dc3a491a4aab41503c12921e11fe7b9fb7 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Wed, 21 Apr 2021 05:32:23 +0100 Subject: [PATCH 142/966] Remove TLS 1.3 specific code from TLS <= 1.2 transform generator Signed-off-by: Hanno Becker --- library/ssl_tls.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 33f4e601c3..88a3e745ef 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -714,6 +714,15 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, memcpy( transform->randbytes, randbytes, sizeof( transform->randbytes ) ); #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + if( minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) + { + /* At the moment, we keep TLS <= 1.2 and TLS 1.3 transform + * generation separate. This should never happen. */ + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* * Get various info structures */ @@ -806,19 +815,10 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, * sequence number). */ transform->ivlen = 12; -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - if( minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) - { + if( cipher_info->mode == MBEDTLS_MODE_CHACHAPOLY ) transform->fixed_ivlen = 12; - } else -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ - { - if( cipher_info->mode == MBEDTLS_MODE_CHACHAPOLY ) - transform->fixed_ivlen = 12; - else - transform->fixed_ivlen = 4; - } + transform->fixed_ivlen = 4; /* Minimum length of encrypted record */ explicit_ivlen = transform->ivlen - transform->fixed_ivlen; From dfba065d80adc007e81288e3655de82dfefb56d5 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sun, 1 Aug 2021 19:16:57 +0100 Subject: [PATCH 143/966] Adjust ssl_tls13_keys.c to consolidated CID/1.3 padding granularity Signed-off-by: Hanno Becker --- library/ssl_tls13_keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 91384f281f..902f99ea81 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -815,7 +815,7 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, * type-extended and padded plaintext is therefore the padding * granularity. */ transform->minlen = - transform->taglen + MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY; + transform->taglen + MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY; return( 0 ); } From 1f91878281cdb680c98f33a3312d1fce56f45eba Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sun, 1 Aug 2021 19:18:28 +0100 Subject: [PATCH 144/966] Specify padding granularity in TLS 1.3 record protection KATs Still check that encryption and decryption are inverse to each other if the granularity does not match the one used in the KAT. Signed-off-by: Hanno Becker --- tests/suites/test_suite_ssl.data | 12 ++++++++---- tests/suites/test_suite_ssl.function | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/suites/test_suite_ssl.data b/tests/suites/test_suite_ssl.data index efedd06154..04f6e1d344 100644 --- a/tests/suites/test_suite_ssl.data +++ b/tests/suites/test_suite_ssl.data @@ -6028,7 +6028,8 @@ SSL TLS 1.3 Record Encryption, tls13.ulfheim.net Example #1 # - Client App IV: bc4dd5f7b98acff85466261d # - App data payload: 70696e67 # - Complete record: 1703030015c74061535eb12f5f25a781957874742ab7fb305dd5 -ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_CLIENT:0:"0b6d22c8ff68097ea871c672073773bf":"1b13dd9f8d8f17091d34b349":"49134b95328f279f0183860589ac6707":"bc4dd5f7b98acff85466261d":"70696e67":"c74061535eb12f5f25a781957874742ab7fb305dd5" +# - Padding used: No (== granularity 1) +ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_CLIENT:0:1:"0b6d22c8ff68097ea871c672073773bf":"1b13dd9f8d8f17091d34b349":"49134b95328f279f0183860589ac6707":"bc4dd5f7b98acff85466261d":"70696e67":"c74061535eb12f5f25a781957874742ab7fb305dd5" SSL TLS 1.3 Record Encryption, tls13.ulfheim.net Example #2 # - Server App Key: 0b6d22c8ff68097ea871c672073773bf @@ -6037,7 +6038,8 @@ SSL TLS 1.3 Record Encryption, tls13.ulfheim.net Example #2 # - Client App IV: bc4dd5f7b98acff85466261d # - App data payload: 706f6e67 # - Complete record: 1703030015370e5f168afa7fb16b663ecdfca3dbb81931a90ca7 -ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:"0b6d22c8ff68097ea871c672073773bf":"1b13dd9f8d8f17091d34b349":"49134b95328f279f0183860589ac6707":"bc4dd5f7b98acff85466261d":"706f6e67":"370e5f168afa7fb16b663ecdfca3dbb81931a90ca7" +# - Padding used: No (== granularity 1) +ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:1:"0b6d22c8ff68097ea871c672073773bf":"1b13dd9f8d8f17091d34b349":"49134b95328f279f0183860589ac6707":"bc4dd5f7b98acff85466261d":"706f6e67":"370e5f168afa7fb16b663ecdfca3dbb81931a90ca7" SSL TLS 1.3 Record Encryption RFC 8448 Example #1 # Application Data record sent by Client in 1-RTT example of RFC 8448, Section 3 @@ -6054,7 +6056,8 @@ SSL TLS 1.3 Record Encryption RFC 8448 Example #1 # 2b 98 19 a8 a5 b4 6b 39 5b d5 4a 9a 20 44 1e 2b # 62 97 4e 1f 5a 62 92 a2 97 70 14 bd 1e 3d ea e6 # 3a ee bb 21 69 49 15 e4 -ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_CLIENT:0:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"a23f7054b62c94d0affafe8228ba55cbefacea42f914aa66bcab3f2b9819a8a5b46b395bd54a9a20441e2b62974e1f5a6292a2977014bd1e3deae63aeebb21694915e4" +# - Padding used: No (== granularity 1) +ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_CLIENT:0:1:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"a23f7054b62c94d0affafe8228ba55cbefacea42f914aa66bcab3f2b9819a8a5b46b395bd54a9a20441e2b62974e1f5a6292a2977014bd1e3deae63aeebb21694915e4" SSL TLS 1.3 Record Encryption RFC 8448 Example #2 # Application Data record sent by Server in 1-RTT example of RFC 8448, Section 3 @@ -6071,7 +6074,8 @@ SSL TLS 1.3 Record Encryption RFC 8448 Example #2 # e3 0e fa f9 7d 90 e6 df fc 60 2d cb 50 1a 59 a8 # fc c4 9c 4b f2 e5 f0 a2 1c 00 47 c2 ab f3 32 54 # 0d d0 32 e1 67 c2 95 5d -ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"2e937e11ef4ac740e538ad36005fc4a46932fc3225d05f82aa1b36e30efaf97d90e6dffc602dcb501a59a8fcc49c4bf2e5f0a21c0047c2abf332540dd032e167c2955d" +# - Padding used: No (== granularity 1) +ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:1:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"2e937e11ef4ac740e538ad36005fc4a46932fc3225d05f82aa1b36e30efaf97d90e6dffc602dcb501a59a8fcc49c4bf2e5f0a21c0047c2abf332540dd032e167c2955d" SSL TLS_PRF MBEDTLS_SSL_TLS_PRF_NONE ssl_tls_prf:MBEDTLS_SSL_TLS_PRF_NONE:"":"":"test tls_prf label":"":MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 2e09907228..6d8a9e8671 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -3947,6 +3947,7 @@ void ssl_tls1_3_create_psk_binder( int hash_alg, void ssl_tls1_3_record_protection( int ciphersuite, int endpoint, int ctr, + int padding_used, data_t *server_write_key, data_t *server_write_iv, data_t *client_write_key, @@ -3959,6 +3960,7 @@ void ssl_tls1_3_record_protection( int ciphersuite, mbedtls_ssl_transform transform_recv; mbedtls_record rec; unsigned char *buf = NULL; + size_t buf_len; int other_endpoint; TEST_ASSERT( endpoint == MBEDTLS_SSL_IS_CLIENT || @@ -3994,7 +3996,10 @@ void ssl_tls1_3_record_protection( int ciphersuite, &transform_recv, other_endpoint, ciphersuite, &keys, NULL ) == 0 ); - ASSERT_ALLOC( buf, ciphertext->len ); + /* Make sure we have enough space in the buffer even if + * we use more padding than the KAT. */ + buf_len = ciphertext->len + MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY; + ASSERT_ALLOC( buf, buf_len ); rec.type = MBEDTLS_SSL_MSG_APPLICATION_DATA; /* TLS 1.3 uses the version identifier from TLS 1.2 on the wire. */ @@ -4005,7 +4010,7 @@ void ssl_tls1_3_record_protection( int ciphersuite, /* Copy plaintext into record structure */ rec.buf = buf; - rec.buf_len = ciphertext->len; + rec.buf_len = buf_len; rec.data_offset = 0; TEST_ASSERT( plaintext->len <= ciphertext->len ); memcpy( rec.buf + rec.data_offset, plaintext->x, plaintext->len ); @@ -4019,8 +4024,12 @@ void ssl_tls1_3_record_protection( int ciphersuite, TEST_ASSERT( mbedtls_ssl_encrypt_buf( NULL, &transform_send, &rec, NULL, NULL ) == 0 ); - ASSERT_COMPARE( rec.buf + rec.data_offset, rec.data_len, - ciphertext->x, ciphertext->len ); + + if( padding_used == MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY ) + { + ASSERT_COMPARE( rec.buf + rec.data_offset, rec.data_len, + ciphertext->x, ciphertext->len ); + } TEST_ASSERT( mbedtls_ssl_decrypt_buf( NULL, &transform_recv, &rec ) == 0 ); ASSERT_COMPARE( rec.buf + rec.data_offset, rec.data_len, From 6c53ecc01db4212da1a8715afe1abc599a9c6f0d Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sun, 1 Aug 2021 19:20:10 +0100 Subject: [PATCH 145/966] all.sh: Run basic TLS 1.3 with and without record padding Signed-off-by: Hanno Becker --- tests/scripts/all.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f8e43c8714..5d2710cadc 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2437,11 +2437,22 @@ component_build_armcc () { } component_test_tls13_experimental () { - msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled" + msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, without padding" scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL + scripts/config.pl set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 1 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . make - msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled" + msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, without padding" + make test +} + +component_test_tls13_experimental_with_padding () { + msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with padding" + scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL + scripts/config.pl set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 16 + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make + msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with padding" make test } From d7e4b2ce4267c681a72e31faa2611b3250ee1541 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sun, 1 Aug 2021 20:13:06 +0100 Subject: [PATCH 146/966] Remove duplicated test from SSL test suite Signed-off-by: Hanno Becker --- tests/suites/test_suite_ssl.data | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/suites/test_suite_ssl.data b/tests/suites/test_suite_ssl.data index 04f6e1d344..25eefb3ab9 100644 --- a/tests/suites/test_suite_ssl.data +++ b/tests/suites/test_suite_ssl.data @@ -6077,9 +6077,6 @@ SSL TLS 1.3 Record Encryption RFC 8448 Example #2 # - Padding used: No (== granularity 1) ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:1:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"2e937e11ef4ac740e538ad36005fc4a46932fc3225d05f82aa1b36e30efaf97d90e6dffc602dcb501a59a8fcc49c4bf2e5f0a21c0047c2abf332540dd032e167c2955d" -SSL TLS_PRF MBEDTLS_SSL_TLS_PRF_NONE -ssl_tls_prf:MBEDTLS_SSL_TLS_PRF_NONE:"":"":"test tls_prf label":"":MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE - SSL TLS 1.3 Key schedule: Application secrets derivation helper # Vector from RFC 8448 ssl_tls1_3_derive_application_secrets:MBEDTLS_MD_SHA256:"e2d32d4ed66dd37897a0e80c84107503ce58bf8aad4cb55a5002d77ecb890ece":"b0aeffc46a2cfe33114e6fd7d51f9f04b1ca3c497dab08934a774a9d9ad7dbf3":"2abbf2b8e381d23dbebe1dd2a7d16a8bf484cb4950d23fb7fb7fa8547062d9a1":"cc21f1bf8feb7dd5fa505bd9c4b468a9984d554a993dc49e6d285598fb672691":"3fd93d4ffddc98e64b14dd107aedf8ee4add23f4510f58a4592d0b201bee56b4" From ec135544c81aa4c292f8b715244ac1b38682580b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 2 Aug 2021 23:14:03 +0200 Subject: [PATCH 147/966] Clarify some comments Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 7db9488eee..73630c122e 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2714,8 +2714,11 @@ pseudo_component_error_test () { echo "Expect three failing commands." fi error_test='this should not be used since the component runs in a subshell' + # Expected error: 'grep non_existent /dev/null -> 1' grep non_existent /dev/null + # Expected error: '! grep -q . tests/scripts/all.sh -> 1' not grep -q . "$0" + # Expected error: 'make unknown_target -> 2' make unknown_target false "this should not be executed" } @@ -2735,8 +2738,11 @@ run_component () { esac "${dd_cmd[@]}" - # Run the component in a subshell + # Run the component in a subshell, with error trapping and output + # redirection set up based on the relevant options. if [ $KEEP_GOING -eq 1 ]; then + # We want to keep running if the subshell fails, so 'set -e' must + # be off when the subshell runs. set +e fi ( From 88a7c2b32e6cf289d8287186a20370aead8e6eb1 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 2 Aug 2021 23:28:00 +0200 Subject: [PATCH 148/966] Improve --error-test reporting Count invocations from 1 to n instead of n to 1. Explain how changing the loop variable would cause an error if the function was not executed in a subshell. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 73630c122e..54b28b870f 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2709,11 +2709,13 @@ post_report () { # Function invoked by --error-test to test error reporting. pseudo_component_error_test () { - msg "Testing error reporting $error_test" + msg "Testing error reporting $error_test_i" if [ $KEEP_GOING -ne 0 ]; then echo "Expect three failing commands." fi - error_test='this should not be used since the component runs in a subshell' + # If the component doesn't run in a subshell, changing error_test_i to an + # invalid integer will cause an error in the loop that runs this function. + error_test_i=this_should_not_be_used_since_the_component_runs_in_a_subshell # Expected error: 'grep non_existent /dev/null -> 1' grep non_existent /dev/null # Expected error: '! grep -q . tests/scripts/all.sh -> 1' @@ -2796,10 +2798,10 @@ cleanup pre_generate_files # Run the requested tests. -while [ $error_test -gt 0 ]; do +for ((error_test_i=1; error_test_i <= error_test; error_test_i++)); do run_component pseudo_component_error_test - error_test=$((error_test - 1)) done +unset error_test_i for component in $RUN_COMPONENTS; do run_component "component_$component" done From c111e2429287ba5f20708a4853541fd3cb4f0ae1 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 2 Aug 2021 23:29:53 +0200 Subject: [PATCH 149/966] Improve the detection of keep-going commands Have simpler patterns related to 'test' (the central objective being to keep going if 'make test' or 'tests/...' fails, but not if 'make tests' fails). Add 'cd' as a can't-keep-going command. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 54b28b870f..6cdc922fe3 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -543,13 +543,19 @@ pre_setup_keep_going () { # Whether it makes sense to keep a component going after the specified # command fails (test command) or not (configure or build). # This doesn't have to be 100% accurate: all failures are recorded anyway. + # False positives result in running things that can't be expected to + # work. False negatives result in things not running after something else + # failed even though they might have given useful feedback. can_keep_going_after_failure () { case "$1" in "msg "*) false;; - *[!A-Za-z]"test"|*[!A-Za-z]"test"[!A-Za-z]*) true;; - "tests/"*) true;; - "grep "*|"! grep "*) true;; - "test "*|"[ "*) true;; + "cd "*) false;; + *make*[\ /]tests*) false;; # make tests, make CFLAGS=-I../tests, ... + *test*) true;; # make test, tests/stuff, env V=v tests/stuff, ... + *make*check*) true;; + "grep "*) true;; + "[ "*) true;; + "! "*) true;; *) false;; esac } From b0302c4c7bdc684c5307040e9e8d8c314e245c48 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 3 Aug 2021 09:39:42 +0100 Subject: [PATCH 150/966] Move messaging related session reset into separate helper function - Improves readability - Will be useful when we introduce MPS as an alternative msg layer. - Will be useful when we need to reset the messaging layer upon receipt of a HelloRetryRequest in TLS 1.3. Signed-off-by: Hanno Becker --- library/ssl_tls.c | 110 ++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index fe3b5e2e64..c43f92a376 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3231,9 +3231,9 @@ error: * If partial is non-zero, keep data in the input buffer and client ID. * (Use when a DTLS client reconnects from the same port.) */ -int mbedtls_ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) +static void ssl_session_reset_msg_layer( mbedtls_ssl_context *ssl, + int partial ) { - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH) size_t in_buf_len = ssl->in_buf_len; size_t out_buf_len = ssl->out_buf_len; @@ -3242,16 +3242,65 @@ int mbedtls_ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN; #endif -#if !defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) || \ - !defined(MBEDTLS_SSL_SRV_C) - ((void) partial); +#if !defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) || !defined(MBEDTLS_SSL_SRV_C) + partial = 0; #endif - ssl->state = MBEDTLS_SSL_HELLO_REQUEST; - /* Cancel any possibly running timer */ mbedtls_ssl_set_timer( ssl, 0 ); + mbedtls_ssl_reset_in_out_pointers( ssl ); + + /* Reset incoming message parsing */ + ssl->in_offt = NULL; + ssl->nb_zero = 0; + ssl->in_msgtype = 0; + ssl->in_msglen = 0; + ssl->in_hslen = 0; + ssl->keep_current_message = 0; + ssl->transform_in = NULL; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + ssl->next_record_offset = 0; + ssl->in_epoch = 0; +#endif + + /* Keep current datagram if partial == 1 */ + if( partial == 0 ) + { + ssl->in_left = 0; + memset( ssl->in_buf, 0, in_buf_len ); + } + + /* Reset outgoing message writing */ + ssl->out_msgtype = 0; + ssl->out_msglen = 0; + ssl->out_left = 0; + memset( ssl->out_buf, 0, out_buf_len ); + memset( ssl->cur_out_ctr, 0, sizeof( ssl->cur_out_ctr ) ); + ssl->transform_out = NULL; + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + mbedtls_ssl_dtls_replay_reset( ssl ); +#endif + + if( ssl->transform ) + { + mbedtls_ssl_transform_free( ssl->transform ); + mbedtls_free( ssl->transform ); + ssl->transform = NULL; + } +} + +int mbedtls_ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + ssl->state = MBEDTLS_SSL_HELLO_REQUEST; + + ssl_session_reset_msg_layer( ssl, partial ); + + /* Reset renegotiation state */ #if defined(MBEDTLS_SSL_RENEGOTIATION) ssl->renego_status = MBEDTLS_SSL_INITIAL_HANDSHAKE; ssl->renego_records_seen = 0; @@ -3262,53 +3311,8 @@ int mbedtls_ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) #endif ssl->secure_renegotiation = MBEDTLS_SSL_LEGACY_RENEGOTIATION; - ssl->in_offt = NULL; - mbedtls_ssl_reset_in_out_pointers( ssl ); - - ssl->in_msgtype = 0; - ssl->in_msglen = 0; -#if defined(MBEDTLS_SSL_PROTO_DTLS) - ssl->next_record_offset = 0; - ssl->in_epoch = 0; -#endif -#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) - mbedtls_ssl_dtls_replay_reset( ssl ); -#endif - - ssl->in_hslen = 0; - ssl->nb_zero = 0; - - ssl->keep_current_message = 0; - - ssl->out_msgtype = 0; - ssl->out_msglen = 0; - ssl->out_left = 0; - - memset( ssl->cur_out_ctr, 0, sizeof( ssl->cur_out_ctr ) ); - - ssl->transform_in = NULL; - ssl->transform_out = NULL; - - ssl->session_in = NULL; + ssl->session_in = NULL; ssl->session_out = NULL; - - memset( ssl->out_buf, 0, out_buf_len ); - -#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && defined(MBEDTLS_SSL_SRV_C) - if( partial == 0 ) -#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE && MBEDTLS_SSL_SRV_C */ - { - ssl->in_left = 0; - memset( ssl->in_buf, 0, in_buf_len ); - } - - if( ssl->transform ) - { - mbedtls_ssl_transform_free( ssl->transform ); - mbedtls_free( ssl->transform ); - ssl->transform = NULL; - } - if( ssl->session ) { mbedtls_ssl_session_free( ssl->session ); From 3a6c76937adce329cbc85fe5001cc7e533545b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 18 Aug 2020 10:28:51 +0200 Subject: [PATCH 151/966] Add arm-linux-gnueabi-gcc build to all.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently it can't be mandatory, since we can't install the required toolchain on Jenkins right away. Also, while at it, remove `SHELL='sh -x'` from the other arm5vte component; it was a leftover from debugging. Signed-off-by: Manuel Pégourié-Gonnard --- tests/scripts/all.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f8e43c8714..7570b1128f 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -161,6 +161,7 @@ pre_initialize_variables () { : ${ARMC5_BIN_DIR:=/usr/bin} : ${ARMC6_BIN_DIR:=/usr/bin} : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-} + : ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-} # if MAKEFLAGS is not set add the -j option to speed up invocations of make if [ -z "${MAKEFLAGS+set}" ]; then @@ -230,6 +231,9 @@ General options: --arm-none-eabi-gcc-prefix= Prefix for a cross-compiler for arm-none-eabi (default: "${ARM_NONE_EABI_GCC_PREFIX}") + --arm-linux-gnueabi-gcc-prefix= + Prefix for a cross-compiler for arm-linux-gnueabi + (default: "${ARM_LINUX_GNUEABI_GCC_PREFIX}") --armcc Run ARM Compiler builds (on by default). --except Exclude the COMPONENTs listed on the command line, instead of running only those. @@ -387,6 +391,7 @@ pre_parse_command_line () { case "$1" in --append-outcome) append_outcome=1;; --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";; + --arm-linux-gnueabi-gcc-prefix) shift; ARM_LINUX_GNUEABI_GCC_PREFIX="$1";; --armcc) no_armcc=;; --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; @@ -2369,14 +2374,29 @@ component_build_arm_none_eabi_gcc () { ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o } -component_build_arm_none_eabi_gcc_arm5vte () { - msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s +component_build_arm_linux_gnueabi_gcc_arm5vte () { + msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s scripts/config.py baremetal # Build for a target platform that's close to what Debian uses # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). # See https://github.com/ARMmbed/mbedtls/pull/2169 and comments. - # It would be better to build with arm-linux-gnueabi-gcc but - # we don't have that on our CI at this time. + # Build everything including programs, see for example + # https://github.com/ARMmbed/mbedtls/pull/3449#issuecomment-675313720 + make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' + + msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1" + ${ARM_LINUX_GNUEABI_GCC_PREFIX}size library/*.o +} +support_build_arm_linux_gnueabi_gcc_arm5vte () { + type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1 +} + +component_build_arm_none_eabi_gcc_arm5vte () { + msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s + scripts/config.py baremetal + # This is an imperfect substitute for + # component_build_arm_linux_gnueabi_gcc_arm5vte + # in case the gcc-arm-linux-gnueabihf toolchain is not available make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-std=c99 -Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1" From efd14bf9bd5bfa686d6f422a317f946ad472f5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 18 Aug 2020 10:31:36 +0200 Subject: [PATCH 152/966] Enable arm-linux-gnueabi-gcc build on Travis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 48faa4846c..8fa0b343e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ jobs: - graphviz - gcc-arm-none-eabi - libnewlib-arm-none-eabi + - gcc-arm-linux-gnueabi language: python # Needed to get pip for Python 3 python: 3.5 # version from Ubuntu 16.04 install: @@ -22,7 +23,7 @@ jobs: - tests/scripts/all.sh -k 'check_*' - tests/scripts/all.sh -k test_default_out_of_box - tests/scripts/all.sh -k test_ref_configs - - tests/scripts/all.sh -k build_arm_none_eabi_gcc_arm5vte build_arm_none_eabi_gcc_m0plus + - tests/scripts/all.sh -k build_arm_linux_gnueabi_gcc_arm5vte build_arm_none_eabi_gcc_m0plus - name: full configuration script: From ae505eeeed006c907bf05697eac8c7e8fd38aee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 6 Jul 2021 09:44:59 +0200 Subject: [PATCH 153/966] Fix missing dependency on Travis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was getting errors like: In file included from /usr/include/limits.h:25:0, from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/limits.h:168, from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/syslimits.h:7, from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/limits.h:34, from ../include/mbedtls/check_config.h:30, from ../include/mbedtls/build_info.h:81, from common.h:26, from asn1write.c:20: /usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory There are two packages to choose from: armhf or armel. Since the comment in all.sh says we're trying to be close to Debian's "armel" architecture, choose that, and fix a comment that was mentioning gnueabihf for no apparent reason. Signed-off-by: Manuel Pégourié-Gonnard --- .travis.yml | 1 + tests/scripts/all.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8fa0b343e4..39ae19c190 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ jobs: - gcc-arm-none-eabi - libnewlib-arm-none-eabi - gcc-arm-linux-gnueabi + - libc6-dev-armel-cross language: python # Needed to get pip for Python 3 python: 3.5 # version from Ubuntu 16.04 install: diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 7570b1128f..e103c9a3de 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2396,7 +2396,7 @@ component_build_arm_none_eabi_gcc_arm5vte () { scripts/config.py baremetal # This is an imperfect substitute for # component_build_arm_linux_gnueabi_gcc_arm5vte - # in case the gcc-arm-linux-gnueabihf toolchain is not available + # in case the gcc-arm-linux-gnueabi toolchain is not available make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-std=c99 -Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1" From 1d475b63981742afe9a90b2e70330111c8b65c3d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 3 Aug 2021 13:43:36 +0200 Subject: [PATCH 154/966] Disable wildcards when checking for unsupported components Otherwise $COMMAND_LINE_COMPONENTS would try to expand wildcard patterns based on files in the current directory. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 6cdc922fe3..4dfbaec668 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -444,7 +444,9 @@ pre_parse_command_line () { if [ $all_except -eq 0 ]; then unsupported=0 + set -f for component in $COMMAND_LINE_COMPONENTS; do + set +f case $component in *[*?\[]*) continue;; esac @@ -455,6 +457,7 @@ pre_parse_command_line () { unsupported=$((unsupported + 1));; esac done + set +f if [ $unsupported -ne 0 ]; then exit 2 fi From bf66e2cc8ffdd17c954d10fcc1431e41214aff7f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 3 Aug 2021 13:44:28 +0200 Subject: [PATCH 155/966] Documentation improvements Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 4dfbaec668..2dc13756a8 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -271,7 +271,9 @@ Tool path options: EOF } -# remove built files as well as the cmake cache/config +# Cleanup before/after running a component. +# Remove built files as well as the cmake cache/config. +# Does not remove generated source files. cleanup() { command make clean @@ -306,6 +308,8 @@ cleanup() done } +# Final cleanup when this script exits (except when exiting on a failure +# in non-keep-going mode). final_cleanup () { cleanup @@ -442,11 +446,14 @@ pre_parse_command_line () { COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" fi + # Error out if an explicitly requested component doesn't exist. if [ $all_except -eq 0 ]; then unsupported=0 set -f for component in $COMMAND_LINE_COMPONENTS; do set +f + # If the requested name includes a wildcard character, don't + # check it. Accept wildcard patterns that don't match anything. case $component in *[*?\[]*) continue;; esac From 3cbd69c4d42df872ba3bec1fe511a0183255da74 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 5 Aug 2021 15:10:27 +0200 Subject: [PATCH 156/966] Switch to 4-space indentation Signed-off-by: Gilles Peskine --- programs/test/generate_cpp_dummy_build.sh | 37 ++++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/programs/test/generate_cpp_dummy_build.sh b/programs/test/generate_cpp_dummy_build.sh index 41adf149eb..9e16348b52 100755 --- a/programs/test/generate_cpp_dummy_build.sh +++ b/programs/test/generate_cpp_dummy_build.sh @@ -21,7 +21,7 @@ set -e export LC_ALL=C print_cpp () { - cat <<'EOF' + cat <<'EOF' /* Automatically generated file. Do not edit. * * This program is a dummy C++ program to ensure Mbed TLS library header files @@ -47,19 +47,20 @@ print_cpp () { EOF - for header in include/mbedtls/*.h include/psa/*.h; do - case ${header#include/} in - mbedtls/mbedtls_config.h) :;; # not meant for direct inclusion - psa/crypto_config.h) :;; # not meant for direct inclusion - # Some of the psa/crypto_*.h headers are not meant to be included directly. - # They do have include guards that make them no-ops if psa/crypto.h - # has been included before. Since psa/crypto.h comes before psa/crypto_*.h - # in the wildcard enumeration, we don't need to skip those headers. - *) echo "#include \"${header#include/}\"";; - esac - done + for header in include/mbedtls/*.h include/psa/*.h; do + case ${header#include/} in + mbedtls/mbedtls_config.h) :;; # not meant for direct inclusion + psa/crypto_config.h) :;; # not meant for direct inclusion + # Some of the psa/crypto_*.h headers are not meant to be included + # directly. They do have include guards that make them no-ops if + # psa/crypto.h has been included before. Since psa/crypto.h comes + # before psa/crypto_*.h in the wildcard enumeration, we don't need + # to skip those headers. + *) echo "#include \"${header#include/}\"";; + esac + done - cat <<'EOF' + cat <<'EOF' int main() { @@ -72,14 +73,14 @@ EOF } if [ -d include/mbedtls ]; then - : + : elif [ -d ../include/mbedtls ]; then - cd .. + cd .. elif [ -d ../../include/mbedtls ]; then - cd ../.. + cd ../.. else - echo >&2 "This script must be run from an Mbed TLS source tree." - exit 3 + echo >&2 "This script must be run from an Mbed TLS source tree." + exit 3 fi print_cpp >"${1:-programs/test/cpp_dummy_build.cpp}" From 7530163f3b003e4851a48cb5661b1b1d4dbf6e6a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 5 Aug 2021 15:10:47 +0200 Subject: [PATCH 157/966] Make --quiet more effective when running make generated_files Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 2dc13756a8..7e8b2c3c20 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -752,7 +752,7 @@ pre_generate_files() { # file that might be around before generating fresh ones make neat if [ $QUIET -eq 1 ]; then - make -s generated_files + make generated_files >/dev/null else make generated_files fi From 86f6129067b7f2f6f6ff7aa1e1af69660e8f2d9a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 5 Aug 2021 15:11:33 +0200 Subject: [PATCH 158/966] Documentation improvement Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 7e8b2c3c20..6c322e29fc 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -242,7 +242,7 @@ General options: (default: "${ARM_NONE_EABI_GCC_PREFIX}") --armcc Run ARM Compiler builds (on by default). --error-test Error test mode: run a failing function in addition - to any specified component. + to any specified component. May be repeated. --except Exclude the COMPONENTs listed on the command line, instead of running only those. --no-append-outcome Write a new outcome file and analyze it (default). From 91e890e2fcefca43836dc174ad37906a6d6c996f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 5 Aug 2021 15:13:57 +0200 Subject: [PATCH 159/966] Add documentation Signed-off-by: Gilles Peskine --- programs/test/generate_cpp_dummy_build.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/programs/test/generate_cpp_dummy_build.sh b/programs/test/generate_cpp_dummy_build.sh index 9e16348b52..94e911515d 100755 --- a/programs/test/generate_cpp_dummy_build.sh +++ b/programs/test/generate_cpp_dummy_build.sh @@ -1,5 +1,18 @@ #!/bin/sh +DEFAULT_OUTPUT_FILE=programs/test/cpp_dummy_build.cpp + +if [ "$1" = "--help" ]; then + cat <"${1:-programs/test/cpp_dummy_build.cpp}" +print_cpp >"${1:-$DEFAULT_OUTPUT_FILE}" From 03af67891194788791572fe892eb5d49c0ab9202 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 6 Aug 2021 11:35:17 +0200 Subject: [PATCH 160/966] Documentation improvements Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 6c322e29fc..26a5b7e5de 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -203,6 +203,8 @@ pre_initialize_variables () { # Test whether the component $1 is included in the command line patterns. is_component_included() { + # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS + # only does word splitting. set -f for pattern in $COMMAND_LINE_COMPONENTS; do set +f @@ -449,6 +451,8 @@ pre_parse_command_line () { # Error out if an explicitly requested component doesn't exist. if [ $all_except -eq 0 ]; then unsupported=0 + # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS + # only does word splitting. set -f for component in $COMMAND_LINE_COMPONENTS; do set +f @@ -552,6 +556,9 @@ pre_setup_keep_going () { # Whether it makes sense to keep a component going after the specified # command fails (test command) or not (configure or build). + # This function normally receives the failing simple command + # ($BASH_COMMAND) as an argument, but if $report_failed_command is set, + # this is passed instead. # This doesn't have to be 100% accurate: all failures are recorded anyway. # False positives result in running things that can't be expected to # work. False negatives result in things not running after something else From 80ddb991c2eab48bf5ed1d91ac0cb4a05facd143 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 6 Aug 2021 11:51:59 +0200 Subject: [PATCH 161/966] Add --restore option to clean up but not necessarily run components Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 26a5b7e5de..f963e4bf03 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -243,6 +243,9 @@ General options: Prefix for a cross-compiler for arm-none-eabi (default: "${ARM_NONE_EABI_GCC_PREFIX}") --armcc Run ARM Compiler builds (on by default). + --restore First clean up the build tree, restoring backed up + files. Do not run any components unless they are + explicitly specified. --error-test Error test mode: run a failing function in addition to any specified component. May be repeated. --except Exclude the COMPONENTs listed on the command line, @@ -388,6 +391,7 @@ pre_parse_command_line () { COMMAND_LINE_COMPONENTS= all_except=0 error_test=0 + restore_first=0 no_armcc= # Note that legacy options are ignored instead of being omitted from this @@ -426,6 +430,7 @@ pre_parse_command_line () { --quiet|-q) QUIET=1;; --random-seed) unset SEED;; --release-test|-r) SEED=$RELEASE_SEED;; + --restore) restore_first=1;; --seed|-s) shift; SEED="$1";; -*) echo >&2 "Unknown option: $1" @@ -438,7 +443,7 @@ pre_parse_command_line () { done # With no list of components, run everything. - if [ -z "$COMMAND_LINE_COMPONENTS" ]; then + if [ -z "$COMMAND_LINE_COMPONENTS" ] && [ $restore_first -eq 0 ]; then all_except=1 fi From d5802926d983a09230cafa9b7b1f601c44a814af Mon Sep 17 00:00:00 2001 From: Darryl Green Date: Tue, 8 May 2018 15:30:59 +0100 Subject: [PATCH 162/966] Rewrite check-names.sh in python Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 276 +++++++++++++++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100755 tests/scripts/check-names.py diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py new file mode 100755 index 0000000000..6af6f8d545 --- /dev/null +++ b/tests/scripts/check-names.py @@ -0,0 +1,276 @@ +#!/usr/bin/env python3 +""" +This file is part of Mbed TLS (https://tls.mbed.org) + +Copyright (c) 2018, Arm Limited, All Rights Reserved + +Purpose + +This script confirms that the naming of all symbols and identifiers in mbed +TLS are consistent with the house style and are also self-consistent. +""" +import os +import sys +import traceback +import re +import shutil +import subprocess +import logging + + +class NameCheck(object): + def __init__(self): + self.log = None + self.setup_logger() + self.check_repo_path() + self.return_code = 0 + self.excluded_files = ["compat-1.3.h"] + self.header_files = self.get_files(os.path.join("include", "mbedtls")) + self.library_files = self.get_files("library") + self.macros = [] + self.MBED_names = [] + self.enum_consts = [] + self.identifiers = [] + self.actual_macros = [] + self.symbols = [] + self.macro_pattern = r"#define (?P\w+)" + self.MBED_pattern = r"\bMBED.+?_[A-Z0-9_]*" + self.symbol_pattern = r"^\S+( [0-9A-Fa-f]+)* . _*(?P\w+)" + self.identifier_check_pattern = r"^mbedtls_[0-9a-z_]*[0-9a-z]$" + self.decls_pattern = ( + r"^(extern \"C\"|(typedef )?(struct|enum)( {)?$|};?$|$)" + ) + self.macro_const_check_pattern = ( + r"^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$|^YOTTA_[0-9A-Z_]*[0-9A-Z]$" + ) + self.typo_check_pattern = r"XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$" + self.non_macros = ( + "asm", "inline", "EMIT", "_CRT_SECURE_NO_DEPRECATE", "MULADDC_" + ) + + def set_return_code(self, return_code): + if return_code > self.return_code: + self.return_code = return_code + + def setup_logger(self): + self.log = logging.getLogger() + self.log.setLevel(logging.INFO) + self.log.addHandler(logging.StreamHandler()) + + def check_repo_path(self): + current_dir = os.path.realpath('.') + root_dir = os.path.dirname(os.path.dirname( + os.path.dirname(os.path.realpath(__file__)))) + if current_dir != root_dir: + raise Exception("Must be run from Mbed TLS root") + + def get_files(self, directory): + filenames = [] + for root, dirs, files in sorted(os.walk(directory)): + for filename in sorted(files): + if (filename not in self.excluded_files and + filename.endswith((".c", ".h"))): + filenames.append(os.path.join(root, filename)) + return filenames + + def get_macros(self): + for header_file in self.header_files: + with open(header_file, "r") as header: + for line in iter(header.readline, ""): + macro = re.search(self.macro_pattern, line) + if (macro and not + macro.group("macro").startswith(self.non_macros)): + self.macros.append((macro.group("macro"), header_file)) + self.macros = list(set(self.macros)) + + def get_MBED_names(self): + for file_group in [self.header_files, self.library_files]: + for filename in file_group: + with open(filename, "r") as f: + for line in iter(f.readline, ""): + mbed_names = re.findall(self.MBED_pattern, line) + if mbed_names: + for name in mbed_names: + self.MBED_names.append((name, filename)) + self.MBED_names = list(set(self.MBED_names)) + + def get_enum_consts(self): + for header_file in self.header_files: + state = 0 + with open(header_file, "r") as header: + for line in iter(header.readline, ""): + if state is 0 and re.match(r"^(typedef )?enum {", line): + state = 1 + elif state is 0 and re.match(r"^(typedef )?enum", line): + state = 2 + elif state is 2 and re.match(r"^{", line): + state = 1 + elif state is 1 and re.match(r"^}", line): + state = 0 + elif state is 1: + enum_const = re.match(r"^\s*(?P\w+)", line) + if enum_const: + self.enum_consts.append( + (enum_const.group("enum_const"), header_file) + ) + + def line_contains_declaration(self, line): + return (re.match(r"^[^ /#{]", line) + and not re.match(self.decls_pattern, line)) + + def get_identifier_from_declaration(self, declaration): + identifier = re.search( + r"([a-zA-Z_][a-zA-Z0-9_]*)\(|" + r"\(\*(.+)\)\(|" + r"(\w+)\W*$", + declaration + ) + if identifier: + for group in identifier.groups(): + if group: + return group + self.log.error(declaration) + raise Exception("No identifier found") + + def get_identifiers(self): + for header_file in self.header_files: + with open(header_file, "r") as header: + for line in iter(header.readline, ""): + if self.line_contains_declaration(line): + self.identifiers.append( + (self.get_identifier_from_declaration(line), + header_file) + ) + + def get_symbols(self): + try: + shutil.copy("include/mbedtls/config.h", + "include/mbedtls/config.h.bak") + subprocess.run( + ["perl", "scripts/config.pl", "full"], + encoding=sys.stdout.encoding, + check=True + ) + my_environment = os.environ.copy() + my_environment["CFLAGS"] = "-fno-asynchronous-unwind-tables" + subprocess.run( + ["make", "clean", "lib"], + env=my_environment, + encoding=sys.stdout.encoding, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=True + ) + shutil.move("include/mbedtls/config.h.bak", + "include/mbedtls/config.h") + nm_output = "" + for lib in ["library/libmbedcrypto.a", + "library/libmbedtls.a", + "library/libmbedx509.a"]: + nm_output += subprocess.run( + ["nm", "-og", lib], + encoding=sys.stdout.encoding, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=True + ).stdout + for line in nm_output.splitlines(): + if not re.match(r"^\S+: +U |^$|^\S+:$", line): + symbol = re.match(self.symbol_pattern, line) + if symbol: + self.symbols.append(symbol.group('symbol')) + else: + self.log.error(line) + self.symbols.sort() + subprocess.run( + ["make", "clean"], + encoding=sys.stdout.encoding, + check=True + ) + except subprocess.CalledProcessError as error: + self.log.error(error) + self.set_return_code(2) + + def check_symbols_declared_in_header(self): + identifiers = [x[0] for x in self.identifiers] + bad_names = [] + for symbol in self.symbols: + if symbol not in identifiers: + bad_names.append(symbol) + if bad_names: + self.set_return_code(1) + self.log.info("Names of identifiers: FAIL") + for name in bad_names: + self.log.info(name) + else: + self.log.info("Names of identifiers: PASS") + + def check_group(self, group_to_check, check_pattern, name): + bad_names = [] + for item in group_to_check: + if not re.match(check_pattern, item[0]): + bad_names.append("{} - {}".format(item[0], item[1])) + if bad_names: + self.set_return_code(1) + self.log.info("Names of {}: FAIL".format(name)) + for name in bad_names: + self.log.info(name) + else: + self.log.info("Names of {}: PASS".format(name)) + + def check_for_typos(self): + bad_names = [] + all_caps_names = list(set( + [x[0] for x in self.actual_macros + self.enum_consts] + )) + for name in self.MBED_names: + if name[0] not in all_caps_names: + if not re.search(self.typo_check_pattern, name[0]): + bad_names.append("{} - {}".format(name[0], name[1])) + if bad_names: + self.set_return_code(1) + self.log.info("Likely typos: FAIL") + for name in bad_names: + self.log.info(name) + else: + self.log.info("Likely typos: PASS") + + def get_names_from_source_code(self): + self.log.info("Analysing source code...") + self.get_macros() + self.get_enum_consts() + self.get_identifiers() + self.get_symbols() + self.get_MBED_names() + self.actual_macros = list(set(self.macros) - set(self.identifiers)) + self.log.info("{} macros".format(len(self.macros))) + self.log.info("{} enum-consts".format(len(self.enum_consts))) + self.log.info("{} identifiers".format(len(self.identifiers))) + self.log.info("{} exported-symbols".format(len(self.symbols))) + + def check_names(self): + self.check_symbols_declared_in_header() + for group, check_pattern, name in [ + (self.actual_macros, self.macro_const_check_pattern, + "actual-macros"), + (self.enum_consts, self.macro_const_check_pattern, + "enum-consts"), + (self.identifiers, self.identifier_check_pattern, + "identifiers")]: + self.check_group(group, check_pattern, name) + self.check_for_typos() + + +def run_main(): + try: + name_check = NameCheck() + name_check.get_names_from_source_code() + name_check.check_names() + sys.exit(name_check.return_code) + except Exception: + traceback.print_exc() + sys.exit(2) + + +if __name__ == "__main__": + run_main() From 4e9b51bc1830dd898f86b2f3a7fbd2318e3ddc7e Mon Sep 17 00:00:00 2001 From: Darryl Green Date: Wed, 16 May 2018 22:32:41 +0100 Subject: [PATCH 163/966] Update scripts to use check-names.py Signed-off-by: Yuto Takano --- .travis.yml | 2 +- tests/git-scripts/pre-push.sh | 2 +- tests/scripts/all.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa01e5a24c..06495e4eb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ script: - tests/scripts/recursion.pl library/*.c - tests/scripts/check-generated-files.sh - tests/scripts/check-doxy-blocks.pl -- tests/scripts/check-names.sh +- tests/scripts/check-names.py - tests/scripts/doxygen.sh - cmake -D CMAKE_BUILD_TYPE:String="Check" . - make diff --git a/tests/git-scripts/pre-push.sh b/tests/git-scripts/pre-push.sh index ee54a6cffe..2058a57f91 100755 --- a/tests/git-scripts/pre-push.sh +++ b/tests/git-scripts/pre-push.sh @@ -43,5 +43,5 @@ run_test() } run_test ./tests/scripts/check-doxy-blocks.pl -run_test ./tests/scripts/check-names.sh +run_test ./tests/scripts/check-names.py run_test ./tests/scripts/check-generated-files.sh diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index e6c7549e6a..851287f104 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -415,7 +415,7 @@ tests/scripts/check-doxy-blocks.pl msg "test/build: declared and exported names" # < 3s cleanup -tests/scripts/check-names.sh +tests/scripts/check-names.py msg "test: doxygen warnings" # ~ 3s cleanup From a783d9c5ef2eb5c83a241c2d37f3423a1201529f Mon Sep 17 00:00:00 2001 From: Darryl Green Date: Thu, 17 May 2018 09:21:06 +0100 Subject: [PATCH 164/966] Remove check-names.sh and sub-scripts it used Signed-off-by: Yuto Takano --- tests/scripts/check-names.sh | 93 ------------------------------- tests/scripts/list-enum-consts.pl | 35 ------------ tests/scripts/list-identifiers.sh | 34 ----------- tests/scripts/list-macros.sh | 16 ------ tests/scripts/list-symbols.sh | 26 --------- 5 files changed, 204 deletions(-) delete mode 100755 tests/scripts/check-names.sh delete mode 100755 tests/scripts/list-enum-consts.pl delete mode 100755 tests/scripts/list-identifiers.sh delete mode 100755 tests/scripts/list-macros.sh delete mode 100755 tests/scripts/list-symbols.sh diff --git a/tests/scripts/check-names.sh b/tests/scripts/check-names.sh deleted file mode 100755 index 4c66440e25..0000000000 --- a/tests/scripts/check-names.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh -# -# This file is part of mbed TLS (https://tls.mbed.org) -# -# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved -# -# Purpose -# -# This script confirms that the naming of all symbols and identifiers in mbed -# TLS are consistent with the house style and are also self-consistent. -# -set -eu - -if grep --version|head -n1|grep GNU >/dev/null; then :; else - echo "This script requires GNU grep.">&2 - exit 1 -fi - -printf "Analysing source code...\n" - -tests/scripts/list-macros.sh -tests/scripts/list-enum-consts.pl -tests/scripts/list-identifiers.sh -tests/scripts/list-symbols.sh - -FAIL=0 - -printf "\nExported symbols declared in header: " -UNDECLARED=$( diff exported-symbols identifiers | sed -n -e 's/^< //p' ) -if [ "x$UNDECLARED" = "x" ]; then - echo "PASS" -else - echo "FAIL" - echo "$UNDECLARED" - FAIL=1 -fi - -diff macros identifiers | sed -n -e 's/< //p' > actual-macros - -for THING in actual-macros enum-consts; do - printf "Names of $THING: " - test -r $THING - BAD=$( grep -v '^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$\|^YOTTA_[0-9A-Z_]*[0-9A-Z]$' $THING || true ) - if [ "x$BAD" = "x" ]; then - echo "PASS" - else - echo "FAIL" - echo "$BAD" - FAIL=1 - fi -done - -for THING in identifiers; do - printf "Names of $THING: " - test -r $THING - BAD=$( grep -v '^mbedtls_[0-9a-z_]*[0-9a-z]$' $THING || true ) - if [ "x$BAD" = "x" ]; then - echo "PASS" - else - echo "FAIL" - echo "$BAD" - FAIL=1 - fi -done - -printf "Likely typos: " -sort -u actual-macros enum-consts > _caps -HEADERS=$( ls include/mbedtls/*.h | egrep -v 'compat-1\.3\.h' ) -NL=' -' -sed -n 's/MBED..._[A-Z0-9_]*/\'"$NL"'&\'"$NL"/gp \ - $HEADERS library/*.c \ - | grep MBEDTLS | sort -u > _MBEDTLS_XXX -TYPOS=$( diff _caps _MBEDTLS_XXX | sed -n 's/^> //p' \ - | egrep -v 'XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$' || true ) -rm _MBEDTLS_XXX _caps -if [ "x$TYPOS" = "x" ]; then - echo "PASS" -else - echo "FAIL" - echo "$TYPOS" - FAIL=1 -fi - -printf "\nOverall: " -if [ "$FAIL" -eq 0 ]; then - rm macros actual-macros enum-consts identifiers exported-symbols - echo "PASSED" - exit 0 -else - echo "FAILED" - exit 1 -fi diff --git a/tests/scripts/list-enum-consts.pl b/tests/scripts/list-enum-consts.pl deleted file mode 100755 index 633e3fdf9e..0000000000 --- a/tests/scripts/list-enum-consts.pl +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; - -use utf8; -use open qw(:std utf8); - --d 'include/mbedtls' or die "$0: must be run from root\n"; - -@ARGV = grep { ! /compat-1\.3\.h/ } ; - -my @consts; -my $state = 'out'; -while (<>) -{ - if( $state eq 'out' and /^(typedef )?enum \{/ ) { - $state = 'in'; - } elsif( $state eq 'out' and /^(typedef )?enum/ ) { - $state = 'start'; - } elsif( $state eq 'start' and /{/ ) { - $state = 'in'; - } elsif( $state eq 'in' and /}/ ) { - $state = 'out'; - } elsif( $state eq 'in' ) { - s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp; - push @consts, $_ if $_; - } -} - -open my $fh, '>', 'enum-consts' or die; -print $fh "$_\n" for sort @consts; -close $fh or die; - -printf "%8d enum-consts\n", scalar @consts; diff --git a/tests/scripts/list-identifiers.sh b/tests/scripts/list-identifiers.sh deleted file mode 100755 index 130d9d63f6..0000000000 --- a/tests/scripts/list-identifiers.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -set -eu - -if [ -d include/mbedtls ]; then :; else - echo "$0: must be run from root" >&2 - exit 1 -fi - -HEADERS=$( ls include/mbedtls/*.h | egrep -v 'compat-1\.3\.h|bn_mul' ) - -rm -f identifiers - -grep '^[^ /#{]' $HEADERS | \ - sed -e 's/^[^:]*://' | \ - egrep -v '^(extern "C"|(typedef )?(struct|enum)( {)?$|};?$)' \ - > _decls - -if true; then -sed -n -e 's/.* \**\([a-zA-Z_][a-zA-Z0-9_]*\)(.*/\1/p' \ - -e 's/.*(\*\(.*\))(.*/\1/p' _decls -grep -v '(' _decls | sed -e 's/\([a-zA-Z0-9_]*\)[;[].*/\1/' -e 's/.* \**//' -fi > _identifiers - -if [ $( wc -l < _identifiers ) -eq $( wc -l < _decls ) ]; then - rm _decls - egrep -v '^(u?int(16|32|64)_t)$' _identifiers | sort > identifiers - rm _identifiers -else - echo "$0: oops, lost some identifiers" 2>&1 - exit 1 -fi - -wc -l identifiers diff --git a/tests/scripts/list-macros.sh b/tests/scripts/list-macros.sh deleted file mode 100755 index 3c84adba63..0000000000 --- a/tests/scripts/list-macros.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -eu - -if [ -d include/mbedtls ]; then :; else - echo "$0: must be run from root" >&2 - exit 1 -fi - -HEADERS=$( ls include/mbedtls/*.h | egrep -v 'compat-1\.3\.h' ) - -sed -n -e 's/.*#define \([a-zA-Z0-9_]*\).*/\1/p' $HEADERS \ - | egrep -v '^(asm|inline|EMIT|_CRT_SECURE_NO_DEPRECATE)$|^MULADDC_' \ - | sort -u > macros - -wc -l macros diff --git a/tests/scripts/list-symbols.sh b/tests/scripts/list-symbols.sh deleted file mode 100755 index c258719429..0000000000 --- a/tests/scripts/list-symbols.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -set -eu - -if [ -d include/mbedtls ]; then :; else - echo "$0: must be run from root" >&2 - exit 1 -fi - -if grep -i cmake Makefile >/dev/null; then - echo "$0: not compatible with cmake" >&2 - exit 1 -fi - -cp include/mbedtls/config.h include/mbedtls/config.h.bak -scripts/config.pl full -CFLAGS=-fno-asynchronous-unwind-tables make clean lib >/dev/null 2>&1 -mv include/mbedtls/config.h.bak include/mbedtls/config.h -if uname | grep -F Darwin >/dev/null; then - nm -gUj library/libmbed*.a 2>/dev/null | sed -n -e 's/^_//p' -elif uname | grep -F Linux >/dev/null; then - nm -og library/libmbed*.a | grep -v '^[^ ]*: *U \|^$\|^[^ ]*:$' | sed 's/^[^ ]* . //' -fi | sort > exported-symbols -make clean - -wc -l exported-symbols From 6c79b5dce728e3754c6e6886a7c153705cfc6ce6 Mon Sep 17 00:00:00 2001 From: Darryl Green Date: Thu, 17 May 2018 14:14:50 +0100 Subject: [PATCH 165/966] Keep compatibility with python versions prior to 3.5 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 6af6f8d545..8a8e2dbbe6 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python2 """ This file is part of Mbed TLS (https://tls.mbed.org) @@ -146,20 +146,17 @@ class NameCheck(object): try: shutil.copy("include/mbedtls/config.h", "include/mbedtls/config.h.bak") - subprocess.run( + subprocess.check_output( ["perl", "scripts/config.pl", "full"], - encoding=sys.stdout.encoding, - check=True + universal_newlines=True, ) my_environment = os.environ.copy() my_environment["CFLAGS"] = "-fno-asynchronous-unwind-tables" - subprocess.run( + subprocess.check_output( ["make", "clean", "lib"], env=my_environment, - encoding=sys.stdout.encoding, - stdout=subprocess.PIPE, + universal_newlines=True, stderr=subprocess.STDOUT, - check=True ) shutil.move("include/mbedtls/config.h.bak", "include/mbedtls/config.h") @@ -167,13 +164,11 @@ class NameCheck(object): for lib in ["library/libmbedcrypto.a", "library/libmbedtls.a", "library/libmbedx509.a"]: - nm_output += subprocess.run( + nm_output += subprocess.check_output( ["nm", "-og", lib], - encoding=sys.stdout.encoding, - stdout=subprocess.PIPE, + universal_newlines=True, stderr=subprocess.STDOUT, - check=True - ).stdout + ) for line in nm_output.splitlines(): if not re.match(r"^\S+: +U |^$|^\S+:$", line): symbol = re.match(self.symbol_pattern, line) @@ -182,10 +177,9 @@ class NameCheck(object): else: self.log.error(line) self.symbols.sort() - subprocess.run( + subprocess.check_output( ["make", "clean"], - encoding=sys.stdout.encoding, - check=True + universal_newlines=True, ) except subprocess.CalledProcessError as error: self.log.error(error) From 3963967ebc4bf0b61b1d5fea26680cbc56fe29b1 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 19:47:48 +0100 Subject: [PATCH 166/966] Restructure check-names.py with more verbose error messages Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 596 +++++++++++++++++++++++++---------- 1 file changed, 429 insertions(+), 167 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 8a8e2dbbe6..431bcbb5c9 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -1,14 +1,27 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 +# +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """ -This file is part of Mbed TLS (https://tls.mbed.org) - -Copyright (c) 2018, Arm Limited, All Rights Reserved - -Purpose - -This script confirms that the naming of all symbols and identifiers in mbed -TLS are consistent with the house style and are also self-consistent. +This script confirms that the naming of all symbols and identifiers in Mbed TLS +are consistent with the house style and are also self-consistent. """ + +import argparse +import textwrap import os import sys import traceback @@ -17,47 +30,89 @@ import shutil import subprocess import logging +# Naming patterns to check against +MACRO_PATTERN = r"^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$|^YOTTA_[0-9A-Z_]*[0-9A-Z]$" +IDENTIFIER_PATTERN = r"^mbedtls_[0-9a-z_]*[0-9a-z]$" + +class Match(object): + def __init__(self, filename, line, pos, name): + self.filename = filename + self.line = line + self.pos = pos + self.name = name + + def __str__(self): + return self.name + +class Problem(object): + def __init__(self): + self.textwrapper = textwrap.TextWrapper() + self.textwrapper.initial_indent = " * " + self.textwrapper.subsequent_indent = " " + +class SymbolNotInHeader(Problem): + def __init__(self, symbol_name): + self.symbol_name = symbol_name + Problem.__init__(self) + + def __str__(self): + return self.textwrapper.fill( + "'{0}' was found as an available symbol in the output of nm, " + "however it was not declared in any header files." + .format(self.symbol_name)) + +class PatternMismatch(Problem): + def __init__(self, pattern, match): + self.pattern = pattern + self.match = match + Problem.__init__(self) + + def __str__(self): + return self.textwrapper.fill( + "{0}: '{1}' does not match the required pattern '{2}'." + .format(self.match.filename, self.match.name, self.pattern)) + +class Typo(Problem): + def __init__(self, match): + self.match = match + Problem.__init__(self) + + def __str__(self): + return self.textwrapper.fill( + "{0}: '{1}' looks like a typo. It was not found in any macros or " + "any enums. If this is not a typo, put //no-check-names after it." + .format(self.match.filename, self.match.name)) class NameCheck(object): def __init__(self): self.log = None - self.setup_logger() self.check_repo_path() self.return_code = 0 self.excluded_files = ["compat-1.3.h"] - self.header_files = self.get_files(os.path.join("include", "mbedtls")) - self.library_files = self.get_files("library") - self.macros = [] - self.MBED_names = [] - self.enum_consts = [] - self.identifiers = [] - self.actual_macros = [] - self.symbols = [] - self.macro_pattern = r"#define (?P\w+)" - self.MBED_pattern = r"\bMBED.+?_[A-Z0-9_]*" - self.symbol_pattern = r"^\S+( [0-9A-Fa-f]+)* . _*(?P\w+)" - self.identifier_check_pattern = r"^mbedtls_[0-9a-z_]*[0-9a-z]$" - self.decls_pattern = ( - r"^(extern \"C\"|(typedef )?(struct|enum)( {)?$|};?$|$)" - ) - self.macro_const_check_pattern = ( - r"^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$|^YOTTA_[0-9A-Z_]*[0-9A-Z]$" - ) self.typo_check_pattern = r"XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$" - self.non_macros = ( - "asm", "inline", "EMIT", "_CRT_SECURE_NO_DEPRECATE", "MULADDC_" - ) def set_return_code(self, return_code): if return_code > self.return_code: self.return_code = return_code - def setup_logger(self): + def setup_logger(self, verbose=False): + """ + Set up a logger and set the change the default logging level from + WARNING to INFO. Loggers are better than print statements since their + verbosity can be controlled. + """ self.log = logging.getLogger() - self.log.setLevel(logging.INFO) + if verbose: + self.log.setLevel(logging.DEBUG) + else: + self.log.setLevel(logging.INFO) self.log.addHandler(logging.StreamHandler()) def check_repo_path(self): + """ + Check that the current working directory is the project root, and throw + an exception if not. + """ current_dir = os.path.realpath('.') root_dir = os.path.dirname(os.path.dirname( os.path.dirname(os.path.realpath(__file__)))) @@ -73,32 +128,81 @@ class NameCheck(object): filenames.append(os.path.join(root, filename)) return filenames - def get_macros(self): - for header_file in self.header_files: + def parse_macros(self, header_files): + """ + Parse all macros defined by #define preprocessor directives. + + Args: + header_files: A list of filepaths to look through. + + Returns: + A list of Match objects for the macros. + """ + MACRO_REGEX = r"#define (?P\w+)" + NON_MACROS = ( + "asm", "inline", "EMIT", "_CRT_SECURE_NO_DEPRECATE", "MULADDC_" + ) + + macros = [] + + for header_file in header_files: with open(header_file, "r") as header: - for line in iter(header.readline, ""): - macro = re.search(self.macro_pattern, line) - if (macro and not - macro.group("macro").startswith(self.non_macros)): - self.macros.append((macro.group("macro"), header_file)) - self.macros = list(set(self.macros)) + for line in header: + macro = re.search(MACRO_REGEX, line) + if (macro and + not macro.group("macro").startswith(NON_MACROS)): + macros.append(Match( + header_file, + line, + (macro.start(), macro.end()), + macro.group("macro"))) - def get_MBED_names(self): - for file_group in [self.header_files, self.library_files]: - for filename in file_group: - with open(filename, "r") as f: - for line in iter(f.readline, ""): - mbed_names = re.findall(self.MBED_pattern, line) - if mbed_names: - for name in mbed_names: - self.MBED_names.append((name, filename)) - self.MBED_names = list(set(self.MBED_names)) + return macros - def get_enum_consts(self): - for header_file in self.header_files: + def parse_MBED_names(self, header_files, library_files): + """ + Parse all words in the file that begin with MBED. Includes macros. + + Args: + header_files: A list of filepaths to look through. + library_files: A list of filepaths to look through. + + Returns: + A list of Match objects for words beginning with MBED. + """ + MBED_names = [] + + for filename in header_files + library_files: + with open(filename, "r") as fp: + for line in fp: + for name in re.finditer(r"\bMBED.+?_[A-Z0-9_]*", line): + MBED_names.append(Match( + filename, + line, + (name.start(), name.end()), + name.group(0) + )) + + return MBED_names + + def parse_enum_consts(self, header_files): + """ + Parse all enum value constants that are declared. + + Args: + header_files: A list of filepaths to look through. + + Returns: + A list of (enum constants, containing filename). + """ + + enum_consts = [] + + for header_file in header_files: + # Emulate a finite state machine to parse enum declarations. state = 0 with open(header_file, "r") as header: - for line in iter(header.readline, ""): + for line in header: if state is 0 and re.match(r"^(typedef )?enum {", line): state = 1 elif state is 0 and re.match(r"^(typedef )?enum", line): @@ -110,156 +214,314 @@ class NameCheck(object): elif state is 1: enum_const = re.match(r"^\s*(?P\w+)", line) if enum_const: - self.enum_consts.append( - (enum_const.group("enum_const"), header_file) - ) + enum_consts.append(Match( + header_file, + line, + (enum_const.start(), enum_const.end()), + enum_const.group("enum_const"))) + + return enum_consts - def line_contains_declaration(self, line): - return (re.match(r"^[^ /#{]", line) - and not re.match(self.decls_pattern, line)) + def parse_identifiers(self, header_files): + """ + Parse all lines of a header where a function identifier is declared, + based on some huersitics. Assumes every line that is not a comment or a + preprocessor directive contains some identifier. - def get_identifier_from_declaration(self, declaration): - identifier = re.search( - r"([a-zA-Z_][a-zA-Z0-9_]*)\(|" - r"\(\*(.+)\)\(|" - r"(\w+)\W*$", - declaration + Args: + header_files: A list of filepaths to look through. + + Returns: + A list of (identifier, containing filename) + """ + EXCLUDED_DECLARATIONS = ( + r"^(extern \"C\"|(typedef )?(struct|enum)( {)?$|};?$|$)" ) - if identifier: - for group in identifier.groups(): - if group: - return group - self.log.error(declaration) - raise Exception("No identifier found") - def get_identifiers(self): - for header_file in self.header_files: + identifiers = [] + + for header_file in header_files: with open(header_file, "r") as header: - for line in iter(header.readline, ""): - if self.line_contains_declaration(line): - self.identifiers.append( - (self.get_identifier_from_declaration(line), - header_file) - ) + in_block_comment = False - def get_symbols(self): + for line in header: + # Skip parsing this line if it begins or ends a block + # comment, and set the state machine's state. + if re.search(r"/\*", line): + in_block_comment = True + continue + elif re.search(r"\*/", line) and in_block_comment: + in_block_comment = False + continue + + # Skip parsing this line if it's a line comment, or if it + # begins with a preprocessor directive + if in_block_comment or re.match(r"(//|#)", line): + continue + + if re.match(EXCLUDED_DECLARATIONS, line): + continue + + identifier = re.search( + # Matches: "mbedtls_aes_init(" + r"([a-zA-Z_][a-zA-Z0-9_]*)\(|" + # Matches: "(*f_rng)(" + r"\(\*(.+)\)\(|" + # TODO: unknown purpose + r"(\w+)\W*$", + line + ) + + if identifier: + for group in identifier.groups(): + if group: + identifiers.append(Match( + header_file, + line, + (identifier.start(), identifier.end()), + identifier.group(0))) + + return identifiers + + def parse_symbols(self): + """ + Compile the Mbed TLS libraries, and parse the TLS, Crypto, and x509 + object files using nm to retrieve the list of referenced symbols. + + Returns: + A list of unique symbols defined and used in the libraries. + """ + + symbols = [] + + # Back up the config and atomically compile with the full configratuion. + shutil.copy("include/mbedtls/mbedtls_config.h", + "include/mbedtls/mbedtls_config.h.bak") try: - shutil.copy("include/mbedtls/config.h", - "include/mbedtls/config.h.bak") - subprocess.check_output( + subprocess.run( ["perl", "scripts/config.pl", "full"], - universal_newlines=True, + encoding=sys.stdout.encoding, + check=True ) my_environment = os.environ.copy() my_environment["CFLAGS"] = "-fno-asynchronous-unwind-tables" - subprocess.check_output( + subprocess.run( ["make", "clean", "lib"], env=my_environment, - universal_newlines=True, + encoding=sys.stdout.encoding, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + check=True ) - shutil.move("include/mbedtls/config.h.bak", - "include/mbedtls/config.h") - nm_output = "" - for lib in ["library/libmbedcrypto.a", - "library/libmbedtls.a", - "library/libmbedx509.a"]: - nm_output += subprocess.check_output( - ["nm", "-og", lib], - universal_newlines=True, - stderr=subprocess.STDOUT, - ) - for line in nm_output.splitlines(): - if not re.match(r"^\S+: +U |^$|^\S+:$", line): - symbol = re.match(self.symbol_pattern, line) - if symbol: - self.symbols.append(symbol.group('symbol')) - else: - self.log.error(line) - self.symbols.sort() - subprocess.check_output( + + # Perform object file analysis using nm + symbols = self.parse_symbols_from_nm( + ["library/libmbedcrypto.a", + "library/libmbedtls.a", + "library/libmbedx509.a"]) + + symbols.sort() + + subprocess.run( ["make", "clean"], - universal_newlines=True, + encoding=sys.stdout.encoding, + check=True ) except subprocess.CalledProcessError as error: self.log.error(error) self.set_return_code(2) + finally: + shutil.move("include/mbedtls/mbedtls_config.h.bak", + "include/mbedtls/mbedtls_config.h") + + return symbols + + def parse_symbols_from_nm(self, object_files): + """ + Run nm to retrieve the list of referenced symbols in each object file. + Does not return the position data since it is of no use. + + Returns: + A list of unique symbols defined and used in any of the object files. + """ + UNDEFINED_SYMBOL = r"^\S+: +U |^$|^\S+:$" + VALID_SYMBOL = r"^\S+( [0-9A-Fa-f]+)* . _*(?P\w+)" + + symbols = [] + + nm_output = "" + for lib in object_files: + nm_output += subprocess.run( + ["nm", "-og", lib], + encoding=sys.stdout.encoding, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=True + ).stdout + for line in nm_output.splitlines(): + if not re.match(UNDEFINED_SYMBOL, line): + symbol = re.match(VALID_SYMBOL, line) + if symbol: + symbols.append(symbol.group('symbol')) + else: + self.log.error(line) + + return symbols + + def parse_names_in_source(self): + """ + Calls each parsing function to retrieve various elements of the code, + together with their source location. Puts the parsed values in the + internal variable self.parse_result. + """ + self.log.info("Parsing source code...") + + m_headers = self.get_files(os.path.join("include", "mbedtls")) + libraries = self.get_files("library") + + all_macros = self.parse_macros(m_headers) + enum_consts = self.parse_enum_consts(m_headers) + identifiers = self.parse_identifiers(m_headers) + symbols = self.parse_symbols() + mbed_names = self.parse_MBED_names(m_headers, libraries) + + # Remove identifier macros like mbedtls_printf or mbedtls_calloc + macros = list(set(all_macros) - set(identifiers)) + + self.log.info("Found:") + self.log.info(" {} Macros".format(len(all_macros))) + self.log.info(" {} Enum Constants".format(len(enum_consts))) + self.log.info(" {} Identifiers".format(len(identifiers))) + self.log.info(" {} Exported Symbols".format(len(symbols))) + self.log.info("Analysing...") + + self.parse_result = { + "macros": macros, + "enum_consts": enum_consts, + "identifiers": identifiers, + "symbols": symbols, + "mbed_names": mbed_names + } + + def perform_checks(self): + """ + Perform each check in order, output its PASS/FAIL status. Maintain an + overall test status, and output that at the end. + """ + problems = 0 + + problems += self.check_symbols_declared_in_header() + + pattern_checks = [ + ("macros", MACRO_PATTERN), + ("enum_consts", MACRO_PATTERN), + ("identifiers", IDENTIFIER_PATTERN)] + for group, check_pattern in pattern_checks: + problems += self.check_match_pattern(group, check_pattern) + + problems += self.check_for_typos() + + self.log.info("=============") + if problems > 0: + self.log.info("FAIL: {0} problem(s) to fix".format(str(problems))) + else: + self.log.info("PASS") def check_symbols_declared_in_header(self): - identifiers = [x[0] for x in self.identifiers] - bad_names = [] - for symbol in self.symbols: - if symbol not in identifiers: - bad_names.append(symbol) - if bad_names: - self.set_return_code(1) - self.log.info("Names of identifiers: FAIL") - for name in bad_names: - self.log.info(name) - else: - self.log.info("Names of identifiers: PASS") + """ + Perform a check that all detected symbols in the library object files + are properly declared in headers. + + Outputs to the logger the PASS/FAIL status, followed by the location of + problems. - def check_group(self, group_to_check, check_pattern, name): - bad_names = [] - for item in group_to_check: - if not re.match(check_pattern, item[0]): - bad_names.append("{} - {}".format(item[0], item[1])) - if bad_names: + Returns the number of problems that needs fixing. + """ + problems = [] + for symbol in self.parse_result["symbols"]: + found_symbol_declared = False + for identifier_match in self.parse_result["identifiers"]: + if symbol == identifier_match.name: + found_symbol_declared = True + break + + if not found_symbol_declared: + problems.append(SymbolNotInHeader(symbol)) + + if problems: self.set_return_code(1) - self.log.info("Names of {}: FAIL".format(name)) - for name in bad_names: - self.log.info(name) + self.log.info("All symbols in header: FAIL") + for problem in problems: + self.log.info(str(problem) + "\n") else: - self.log.info("Names of {}: PASS".format(name)) + self.log.info("All symbols in header: PASS") + + return len(problems) + + def check_match_pattern(self, group_to_check, check_pattern): + problems = [] + for item_match in self.parse_result[group_to_check]: + if not re.match(check_pattern, item_match.name): + problems.append(PatternMismatch(check_pattern, item_match)) + + if problems: + self.set_return_code(1) + self.log.info("Naming patterns of {}: FAIL".format(group_to_check)) + for problem in problems: + self.log.info(str(problem) + "\n") + else: + self.log.info("Naming patterns of {}: PASS".format(group_to_check)) + + return len(problems) def check_for_typos(self): - bad_names = [] - all_caps_names = list(set( - [x[0] for x in self.actual_macros + self.enum_consts] + problems = [] + all_caps_names = list(set([ + match.name for match + in self.parse_result["macros"] + self.parse_result["enum_consts"]] )) - for name in self.MBED_names: - if name[0] not in all_caps_names: - if not re.search(self.typo_check_pattern, name[0]): - bad_names.append("{} - {}".format(name[0], name[1])) - if bad_names: + + TYPO_EXCLUSION = r"XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$" + + for name_match in self.parse_result["mbed_names"]: + if name_match.name not in all_caps_names: + if not re.search(TYPO_EXCLUSION, name_match.name): + problems.append(Typo(name_match)) + + if problems: self.set_return_code(1) self.log.info("Likely typos: FAIL") - for name in bad_names: - self.log.info(name) + for problem in problems: + self.log.info(str(problem) + "\n") else: self.log.info("Likely typos: PASS") + + return len(problems) - def get_names_from_source_code(self): - self.log.info("Analysing source code...") - self.get_macros() - self.get_enum_consts() - self.get_identifiers() - self.get_symbols() - self.get_MBED_names() - self.actual_macros = list(set(self.macros) - set(self.identifiers)) - self.log.info("{} macros".format(len(self.macros))) - self.log.info("{} enum-consts".format(len(self.enum_consts))) - self.log.info("{} identifiers".format(len(self.identifiers))) - self.log.info("{} exported-symbols".format(len(self.symbols))) +def main(): + """ + Main function, parses command-line arguments. + """ - def check_names(self): - self.check_symbols_declared_in_header() - for group, check_pattern, name in [ - (self.actual_macros, self.macro_const_check_pattern, - "actual-macros"), - (self.enum_consts, self.macro_const_check_pattern, - "enum-consts"), - (self.identifiers, self.identifier_check_pattern, - "identifiers")]: - self.check_group(group, check_pattern, name) - self.check_for_typos() + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description=( + "This script confirms that the naming of all symbols and identifiers " + "in Mbed TLS are consistent with the house style and are also " + "self-consistent.\n\n" + "Expected to be run from the MbedTLS root directory.")) + parser.add_argument("-v", "--verbose", + action="store_true", + help="enable script debug outputs") + + args = parser.parse_args() -def run_main(): try: name_check = NameCheck() - name_check.get_names_from_source_code() - name_check.check_names() + name_check.setup_logger(verbose=args.verbose) + name_check.parse_names_in_source() + name_check.perform_checks() sys.exit(name_check.return_code) except Exception: traceback.print_exc() @@ -267,4 +529,4 @@ def run_main(): if __name__ == "__main__": - run_main() + main() From c1838937f1278bffa807313d46d43037cdad3899 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 19:52:09 +0100 Subject: [PATCH 167/966] Also check PSA: Python port of 2d9d6db60f5fd0a4993d90e47f39462647624ad6 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 431bcbb5c9..e14d140c47 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -32,7 +32,7 @@ import logging # Naming patterns to check against MACRO_PATTERN = r"^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$|^YOTTA_[0-9A-Z_]*[0-9A-Z]$" -IDENTIFIER_PATTERN = r"^mbedtls_[0-9a-z_]*[0-9a-z]$" +IDENTIFIER_PATTERN = r"^(mbedtls|psa)_[0-9a-z_]*[0-9a-z]$" class Match(object): def __init__(self, filename, line, pos, name): @@ -377,11 +377,12 @@ class NameCheck(object): self.log.info("Parsing source code...") m_headers = self.get_files(os.path.join("include", "mbedtls")) + p_headers = self.get_files(os.path.join("include", "psa")) libraries = self.get_files("library") - all_macros = self.parse_macros(m_headers) + all_macros = self.parse_macros(m_headers + ["configs/config-default.h"]) enum_consts = self.parse_enum_consts(m_headers) - identifiers = self.parse_identifiers(m_headers) + identifiers = self.parse_identifiers(m_headers + p_headers) symbols = self.parse_symbols() mbed_names = self.parse_MBED_names(m_headers, libraries) From ed91cf003a07dfaec7dcb66bd4e0eb412c848671 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 19:52:43 +0100 Subject: [PATCH 168/966] Remove Yotta: Python port of 3ad2efdc82a3d15f373b9d12e6764efec3577b55 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index e14d140c47..9467ec47ca 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -31,7 +31,7 @@ import subprocess import logging # Naming patterns to check against -MACRO_PATTERN = r"^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$|^YOTTA_[0-9A-Z_]*[0-9A-Z]$" +MACRO_PATTERN = r"^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$" IDENTIFIER_PATTERN = r"^(mbedtls|psa)_[0-9a-z_]*[0-9a-z]$" class Match(object): From bb7dca495fca9f2750529b40b99019417a49b849 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 19:57:58 +0100 Subject: [PATCH 169/966] Work with PSA constants: Python port of 03091d1114450dd19a10215094682f14761540d9 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 9467ec47ca..03b6a58030 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -31,7 +31,7 @@ import subprocess import logging # Naming patterns to check against -MACRO_PATTERN = r"^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$" +MACRO_PATTERN = r"^(MBEDTLS|PSA)_[0-9A-Z_]*[0-9A-Z]$" IDENTIFIER_PATTERN = r"^(mbedtls|psa)_[0-9a-z_]*[0-9a-z]$" class Match(object): @@ -159,20 +159,19 @@ class NameCheck(object): return macros - def parse_MBED_names(self, header_files, library_files): + def parse_MBED_names(self, files): """ Parse all words in the file that begin with MBED. Includes macros. Args: - header_files: A list of filepaths to look through. - library_files: A list of filepaths to look through. + files: A list of filepaths to look through. Returns: A list of Match objects for words beginning with MBED. """ MBED_names = [] - for filename in header_files + library_files: + for filename in files: with open(filename, "r") as fp: for line in fp: for name in re.finditer(r"\bMBED.+?_[A-Z0-9_]*", line): @@ -380,11 +379,12 @@ class NameCheck(object): p_headers = self.get_files(os.path.join("include", "psa")) libraries = self.get_files("library") - all_macros = self.parse_macros(m_headers + ["configs/config-default.h"]) + all_macros = self.parse_macros( + m_headers + p_headers) enum_consts = self.parse_enum_consts(m_headers) identifiers = self.parse_identifiers(m_headers + p_headers) symbols = self.parse_symbols() - mbed_names = self.parse_MBED_names(m_headers, libraries) + mbed_names = self.parse_MBED_names(m_headers + p_headers + libraries) # Remove identifier macros like mbedtls_printf or mbedtls_calloc macros = list(set(all_macros) - set(identifiers)) From fa950ae3448effe05031428423dbcca91d356758 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:03:44 +0100 Subject: [PATCH 170/966] Look in 3rdparty: Python port of 8a0f5bb3c11196a5bc0df6393a47e56c40adb7ac Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 03b6a58030..52854858d2 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -377,14 +377,19 @@ class NameCheck(object): m_headers = self.get_files(os.path.join("include", "mbedtls")) p_headers = self.get_files(os.path.join("include", "psa")) - libraries = self.get_files("library") + t_headers = ["3rdparty/everest/include/everest/everest.h", + "3rdparty/everest/include/everest/x25519.h"] + libraries = self.get_files("library") + [ + "3rdparty/everest/library/everest.c", + "3rdparty/everest/library/x25519.c"] all_macros = self.parse_macros( - m_headers + p_headers) - enum_consts = self.parse_enum_consts(m_headers) - identifiers = self.parse_identifiers(m_headers + p_headers) + m_headers + p_headers + t_headers) + enum_consts = self.parse_enum_consts(m_headers + t_headers) + identifiers = self.parse_identifiers(m_headers + p_headers + t_headers) symbols = self.parse_symbols() - mbed_names = self.parse_MBED_names(m_headers + p_headers + libraries) + mbed_names = self.parse_MBED_names( + m_headers + p_headers + t_headers + libraries) # Remove identifier macros like mbedtls_printf or mbedtls_calloc macros = list(set(all_macros) - set(identifiers)) From c763cc368fc27a3124a0af828153fd93bc5821a9 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:06:34 +0100 Subject: [PATCH 171/966] Check for double underscores: Python port of 712f7a804e391737b0e9d2593abe291f4ccb0303 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 52854858d2..35fda61149 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -469,6 +469,8 @@ class NameCheck(object): for item_match in self.parse_result[group_to_check]: if not re.match(check_pattern, item_match.name): problems.append(PatternMismatch(check_pattern, item_match)) + if re.match(r".*__.*", item_match.name): + problems.append(PatternMismatch("double underscore", item_match)) if problems: self.set_return_code(1) From 157444c24d84a0a7d05aeb926f1919b87c9ec342 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:10:45 +0100 Subject: [PATCH 172/966] Add library header files: Python port of 65a6fa3e2669cb02af5399d0f60b5bed3e62a9be Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 35fda61149..f494f7666c 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -119,12 +119,12 @@ class NameCheck(object): if current_dir != root_dir: raise Exception("Must be run from Mbed TLS root") - def get_files(self, directory): + def get_files(self, extension, directory): filenames = [] for root, dirs, files in sorted(os.walk(directory)): for filename in sorted(files): if (filename not in self.excluded_files and - filename.endswith((".c", ".h"))): + filename.endswith("." + extension)): filenames.append(os.path.join(root, filename)) return filenames @@ -375,21 +375,22 @@ class NameCheck(object): """ self.log.info("Parsing source code...") - m_headers = self.get_files(os.path.join("include", "mbedtls")) - p_headers = self.get_files(os.path.join("include", "psa")) + m_headers = self.get_files("h", os.path.join("include", "mbedtls")) + p_headers = self.get_files("h", os.path.join("include", "psa")) t_headers = ["3rdparty/everest/include/everest/everest.h", "3rdparty/everest/include/everest/x25519.h"] - libraries = self.get_files("library") + [ + l_headers = self.get_files("h", "library") + libraries = self.get_files("c", "library") + [ "3rdparty/everest/library/everest.c", "3rdparty/everest/library/x25519.c"] all_macros = self.parse_macros( - m_headers + p_headers + t_headers) + m_headers + p_headers + t_headers + l_headers) enum_consts = self.parse_enum_consts(m_headers + t_headers) identifiers = self.parse_identifiers(m_headers + p_headers + t_headers) symbols = self.parse_symbols() mbed_names = self.parse_MBED_names( - m_headers + p_headers + t_headers + libraries) + m_headers + p_headers + t_headers + l_headers + libraries) # Remove identifier macros like mbedtls_printf or mbedtls_calloc macros = list(set(all_macros) - set(identifiers)) From e503d61b998205caa04c2a6b1e1604f969e00254 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:14:05 +0100 Subject: [PATCH 173/966] Remove 1.3 to 2.0 helpers: Python port of 7d48b2821808e964ab594462e419fbed0e015729 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index f494f7666c..46cb00e224 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -88,8 +88,7 @@ class NameCheck(object): self.log = None self.check_repo_path() self.return_code = 0 - self.excluded_files = ["compat-1.3.h"] - self.typo_check_pattern = r"XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$" + self.excluded_files = ["bn_mul"] def set_return_code(self, return_code): if return_code > self.return_code: From c62b4084a2ae3977f21354da3b7d4dda781cc3bf Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:17:07 +0100 Subject: [PATCH 174/966] Per-line opt-out of typo check: Python port of b6837761815e1a8f6f475be4575824fc386a08dd Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 46cb00e224..f480a830e7 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -173,6 +173,10 @@ class NameCheck(object): for filename in files: with open(filename, "r") as fp: for line in fp: + # Ignore any names that are deliberately opted-out + if re.search(r"// *no-check-names", line): + continue + for name in re.finditer(r"\bMBED.+?_[A-Z0-9_]*", line): MBED_names.append(Match( filename, From 062289c6578c75f04744cd69d96a883d44ae55f4 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:19:57 +0100 Subject: [PATCH 175/966] Invoke config.py instead of pl: Python port of 5d46f6a89b25603f0a77466c618213200c328510 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index f480a830e7..2bb1b02010 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -301,7 +301,7 @@ class NameCheck(object): "include/mbedtls/mbedtls_config.h.bak") try: subprocess.run( - ["perl", "scripts/config.pl", "full"], + ["perl", "scripts/config.py", "full"], encoding=sys.stdout.encoding, check=True ) From e77f699ed554b010b80f5f2acf5994772e6f77be Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:22:59 +0100 Subject: [PATCH 176/966] Exclude FStar and Hacl: Python port of 9b33e7d7d7426e3d7f27cd7d206765ae33e3e61f Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 2bb1b02010..2d1eb83593 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -348,6 +348,7 @@ class NameCheck(object): """ UNDEFINED_SYMBOL = r"^\S+: +U |^$|^\S+:$" VALID_SYMBOL = r"^\S+( [0-9A-Fa-f]+)* . _*(?P\w+)" + EXCLUSIONS = ("FStar", "Hacl") symbols = [] @@ -363,8 +364,8 @@ class NameCheck(object): for line in nm_output.splitlines(): if not re.match(UNDEFINED_SYMBOL, line): symbol = re.match(VALID_SYMBOL, line) - if symbol: - symbols.append(symbol.group('symbol')) + if symbol and not symbol.group("symbol").startswith(EXCLUSIONS): + symbols.append(symbol.group("symbol")) else: self.log.error(line) From 56e3a5caa6c7d16ddca230b09cf8e13d97712b52 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:29:42 +0100 Subject: [PATCH 177/966] Add test driver symbols: Python port of 7f13fa2454282b21930045a3f4f9a2835d80425e Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 2d1eb83593..c3da69e448 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -383,13 +383,14 @@ class NameCheck(object): p_headers = self.get_files("h", os.path.join("include", "psa")) t_headers = ["3rdparty/everest/include/everest/everest.h", "3rdparty/everest/include/everest/x25519.h"] + d_headers = self.get_files("h", os.path.join("tests", "include", "test", "drivers")) l_headers = self.get_files("h", "library") libraries = self.get_files("c", "library") + [ "3rdparty/everest/library/everest.c", "3rdparty/everest/library/x25519.c"] all_macros = self.parse_macros( - m_headers + p_headers + t_headers + l_headers) + m_headers + p_headers + t_headers + l_headers + d_headers) enum_consts = self.parse_enum_consts(m_headers + t_headers) identifiers = self.parse_identifiers(m_headers + p_headers + t_headers) symbols = self.parse_symbols() From 17220988dcb2ca4d75bec0b8cb0963fba7366a44 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:30:18 +0100 Subject: [PATCH 178/966] Parse identifiers from library headers: Python port of d9eee3b417c2e8f63dd10d835ab9a9472242c2ed Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index c3da69e448..5b8159681c 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -392,7 +392,7 @@ class NameCheck(object): all_macros = self.parse_macros( m_headers + p_headers + t_headers + l_headers + d_headers) enum_consts = self.parse_enum_consts(m_headers + t_headers) - identifiers = self.parse_identifiers(m_headers + p_headers + t_headers) + identifiers = self.parse_identifiers(m_headers + p_headers + t_headers + l_headers) symbols = self.parse_symbols() mbed_names = self.parse_MBED_names( m_headers + p_headers + t_headers + l_headers + libraries) From 0fd48f793907f0b053334303074e42cdcc80eb5f Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:32:55 +0100 Subject: [PATCH 179/966] Python port of 7cc4c68eb63a24f9cbf814254cd537df819958e5 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 5b8159681c..96838f2f30 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -213,7 +213,7 @@ class NameCheck(object): state = 1 elif state is 1 and re.match(r"^}", line): state = 0 - elif state is 1: + elif state is 1 and not re.match(r"^#", line): enum_const = re.match(r"^\s*(?P\w+)", line) if enum_const: enum_consts.append(Match( From fe02684049e6036ffa1e3cd98570381a8710c0fc Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 20:34:24 +0100 Subject: [PATCH 180/966] Python port of f6643ccd90694ae99d05541990b78738a8444ab0 Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 96838f2f30..531ff3508f 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -391,7 +391,7 @@ class NameCheck(object): all_macros = self.parse_macros( m_headers + p_headers + t_headers + l_headers + d_headers) - enum_consts = self.parse_enum_consts(m_headers + t_headers) + enum_consts = self.parse_enum_consts(m_headers + l_headers + t_headers) identifiers = self.parse_identifiers(m_headers + p_headers + t_headers + l_headers) symbols = self.parse_symbols() mbed_names = self.parse_MBED_names( From 6f38ab3bcac69624ad78ab152d0fd0dbe52662fb Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 21:07:14 +0100 Subject: [PATCH 181/966] Fix legacy troublesome regex Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 531ff3508f..0d14429f23 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -237,7 +237,7 @@ class NameCheck(object): A list of (identifier, containing filename) """ EXCLUDED_DECLARATIONS = ( - r"^(extern \"C\"|(typedef )?(struct|enum)( {)?$|};?$|$)" + r"^(extern \"C\"|(typedef )?(struct|union|enum)( {)?$|};?$|$)" ) identifiers = [] @@ -258,19 +258,15 @@ class NameCheck(object): # Skip parsing this line if it's a line comment, or if it # begins with a preprocessor directive - if in_block_comment or re.match(r"(//|#)", line): + if in_block_comment or re.match(r"^(//|#)", line): continue if re.match(EXCLUDED_DECLARATIONS, line): continue - + identifier = re.search( # Matches: "mbedtls_aes_init(" - r"([a-zA-Z_][a-zA-Z0-9_]*)\(|" - # Matches: "(*f_rng)(" - r"\(\*(.+)\)\(|" - # TODO: unknown purpose - r"(\w+)\W*$", + r"([a-zA-Z_][a-zA-Z0-9_]*)\(", line ) @@ -281,7 +277,7 @@ class NameCheck(object): header_file, line, (identifier.start(), identifier.end()), - identifier.group(0))) + identifier.group(1))) return identifiers From 81528c058a9e23fe78cbebac903beb63f9eebc55 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 16:22:06 +0100 Subject: [PATCH 182/966] Add documentation, fix identifier parsing - Add documentation to all classes and functions that were not self-explanatory. - Fix the parsing of identifiers, so it now behaves identically to the original shell script. Detects the same amount of identifiers. - Fix macro parsing so MBEDTLS_PSA_ACCEL didn't error out - Reformat output to be comprehensible Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 467 +++++++++++++++++++++++------------ 1 file changed, 312 insertions(+), 155 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 0d14429f23..828702b172 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -17,7 +17,14 @@ """ This script confirms that the naming of all symbols and identifiers in Mbed TLS -are consistent with the house style and are also self-consistent. +are consistent with the house style and are also self-consistent. It performs +the following checks: + +- All exported and available symbols in the library object files, are explicitly + declared in the header files. +- All macros, constants, and identifiers (function names, struct names, etc) + follow the required pattern. +- Typo checking: All words that begin with MBED exist as macros or constants. """ import argparse @@ -30,27 +37,50 @@ import shutil import subprocess import logging -# Naming patterns to check against +# Naming patterns to check against. These are defined outside the NameCheck +# class for ease of modification. MACRO_PATTERN = r"^(MBEDTLS|PSA)_[0-9A-Z_]*[0-9A-Z]$" +CONSTANTS_PATTERN = MACRO_PATTERN IDENTIFIER_PATTERN = r"^(mbedtls|psa)_[0-9a-z_]*[0-9a-z]$" class Match(object): + """ + A class representing a match, together with its found position. + + Fields: + * filename: the file that the match was in. + * line: the full line containing the match. + * pos: a tuple of (start, end) positions on the line where the match is. + * name: the match itself. + """ def __init__(self, filename, line, pos, name): self.filename = filename self.line = line self.pos = pos self.name = name - - def __str__(self): - return self.name class Problem(object): + """ + A parent class representing a form of static analysis error. + + Fields: + * textwrapper: a TextWrapper instance to format problems nicely. + """ def __init__(self): self.textwrapper = textwrap.TextWrapper() - self.textwrapper.initial_indent = " * " - self.textwrapper.subsequent_indent = " " + self.textwrapper.width = 80 + self.textwrapper.initial_indent = " * " + self.textwrapper.subsequent_indent = " " class SymbolNotInHeader(Problem): + """ + A problem that occurs when an exported/available symbol in the object file + is not explicitly declared in header files. Created with + NameCheck.check_symbols_declared_in_header() + + Fields: + * symbol_name: the name of the symbol. + """ def __init__(self, symbol_name): self.symbol_name = symbol_name Problem.__init__(self) @@ -62,21 +92,36 @@ class SymbolNotInHeader(Problem): .format(self.symbol_name)) class PatternMismatch(Problem): + """ + A problem that occurs when something doesn't match the expected pattern. + Created with NameCheck.check_match_pattern() + + Fields: + * pattern: the expected regex pattern + * match: the Match object in question + """ def __init__(self, pattern, match): self.pattern = pattern self.match = match Problem.__init__(self) - + def __str__(self): return self.textwrapper.fill( "{0}: '{1}' does not match the required pattern '{2}'." .format(self.match.filename, self.match.name, self.pattern)) class Typo(Problem): + """ + A problem that occurs when a word using MBED doesn't appear to be defined as + constants nor enum values. Created with NameCheck.check_for_typos() + + Fields: + * match: the Match object of the MBED name in question. + """ def __init__(self, match): self.match = match Problem.__init__(self) - + def __str__(self): return self.textwrapper.fill( "{0}: '{1}' looks like a typo. It was not found in any macros or " @@ -84,11 +129,15 @@ class Typo(Problem): .format(self.match.filename, self.match.name)) class NameCheck(object): + """ + Representation of the core name checking operation performed by this script. + Shares a common logger, common excluded filenames, and a shared return_code. + """ def __init__(self): self.log = None self.check_repo_path() self.return_code = 0 - self.excluded_files = ["bn_mul"] + self.excluded_files = ["bn_mul", "compat-2.x.h"] def set_return_code(self, return_code): if return_code > self.return_code: @@ -97,7 +146,7 @@ class NameCheck(object): def setup_logger(self, verbose=False): """ Set up a logger and set the change the default logging level from - WARNING to INFO. Loggers are better than print statements since their + WARNING to INFO. Loggers are better than print statements since their verbosity can be controlled. """ self.log = logging.getLogger() @@ -119,6 +168,16 @@ class NameCheck(object): raise Exception("Must be run from Mbed TLS root") def get_files(self, extension, directory): + """ + Get all files that end with .extension in the specified directory + recursively. + + Args: + * extension: the file extension to search for, without the dot + * directory: the directory to recursively search for + + Returns a List of relative filepaths. + """ filenames = [] for root, dirs, files in sorted(os.walk(directory)): for filename in sorted(files): @@ -127,15 +186,65 @@ class NameCheck(object): filenames.append(os.path.join(root, filename)) return filenames + def parse_names_in_source(self): + """ + Calls each parsing function to retrieve various elements of the code, + together with their source location. Puts the parsed values in the + internal variable self.parse_result. + """ + self.log.info("Parsing source code...") + + m_headers = self.get_files("h", os.path.join("include", "mbedtls")) + p_headers = self.get_files("h", os.path.join("include", "psa")) + t_headers = ["3rdparty/everest/include/everest/everest.h", + "3rdparty/everest/include/everest/x25519.h"] + d_headers = self.get_files("h", os.path.join("tests", "include", "test", "drivers")) + l_headers = self.get_files("h", "library") + libraries = self.get_files("c", "library") + [ + "3rdparty/everest/library/everest.c", + "3rdparty/everest/library/x25519.c"] + + all_macros = self.parse_macros( + m_headers + p_headers + t_headers + l_headers + d_headers) + enum_consts = self.parse_enum_consts( + m_headers + l_headers + t_headers) + identifiers = self.parse_identifiers( + m_headers + p_headers + t_headers + l_headers) + mbed_names = self.parse_MBED_names( + m_headers + p_headers + t_headers + l_headers + libraries) + symbols = self.parse_symbols() + + # Remove identifier macros like mbedtls_printf or mbedtls_calloc + identifiers_justname = [x.name for x in identifiers] + actual_macros = [] + for macro in all_macros: + if macro.name not in identifiers_justname: + actual_macros.append(macro) + + self.log.debug("Found:") + self.log.debug(" {} Macros".format(len(all_macros))) + self.log.debug(" {} Non-identifier Macros".format(len(actual_macros))) + self.log.debug(" {} Enum Constants".format(len(enum_consts))) + self.log.debug(" {} Identifiers".format(len(identifiers))) + self.log.debug(" {} Exported Symbols".format(len(symbols))) + self.log.info("Analysing...") + + self.parse_result = { + "macros": actual_macros, + "enum_consts": enum_consts, + "identifiers": identifiers, + "symbols": symbols, + "mbed_names": mbed_names + } + def parse_macros(self, header_files): """ Parse all macros defined by #define preprocessor directives. Args: - header_files: A list of filepaths to look through. - - Returns: - A list of Match objects for the macros. + * header_files: A List of filepaths to look through. + + Returns a List of Match objects for the found macros. """ MACRO_REGEX = r"#define (?P\w+)" NON_MACROS = ( @@ -147,36 +256,36 @@ class NameCheck(object): for header_file in header_files: with open(header_file, "r") as header: for line in header: - macro = re.search(MACRO_REGEX, line) - if (macro and - not macro.group("macro").startswith(NON_MACROS)): - macros.append(Match( - header_file, - line, - (macro.start(), macro.end()), - macro.group("macro"))) + for macro in re.finditer(MACRO_REGEX, line): + if not macro.group("macro").startswith(NON_MACROS): + macros.append(Match( + header_file, + line, + (macro.start(), macro.end()), + macro.group("macro"))) return macros def parse_MBED_names(self, files): """ Parse all words in the file that begin with MBED. Includes macros. + There have been typos of TLS, hence the broader check than MBEDTLS. Args: - files: A list of filepaths to look through. - - Returns: - A list of Match objects for words beginning with MBED. + * files: a List of filepaths to look through. + + Returns a List of Match objects for words beginning with MBED. """ MBED_names = [] - + for filename in files: with open(filename, "r") as fp: for line in fp: - # Ignore any names that are deliberately opted-out - if re.search(r"// *no-check-names", line): + # Ignore any names that are deliberately opted-out or in + # legacy error directives + if re.search(r"// *no-check-names|#error", line): continue - + for name in re.finditer(r"\bMBED.+?_[A-Z0-9_]*", line): MBED_names.append(Match( filename, @@ -192,16 +301,18 @@ class NameCheck(object): Parse all enum value constants that are declared. Args: - header_files: A list of filepaths to look through. + * header_files: A List of filepaths to look through. - Returns: - A list of (enum constants, containing filename). + Returns a List of Match objects for the findings. """ enum_consts = [] for header_file in header_files: # Emulate a finite state machine to parse enum declarations. + # 0 = not in enum + # 1 = inside enum + # 2 = almost inside enum state = 0 with open(header_file, "r") as header: for line in header: @@ -221,23 +332,28 @@ class NameCheck(object): line, (enum_const.start(), enum_const.end()), enum_const.group("enum_const"))) - + return enum_consts def parse_identifiers(self, header_files): """ Parse all lines of a header where a function identifier is declared, - based on some huersitics. Assumes every line that is not a comment or a - preprocessor directive contains some identifier. + based on some huersitics. Highly dependent on formatting style. Args: - header_files: A list of filepaths to look through. - - Returns: - A list of (identifier, containing filename) + * header_files: A List of filepaths to look through. + + Returns a List of Match objects with identifiers. """ - EXCLUDED_DECLARATIONS = ( - r"^(extern \"C\"|(typedef )?(struct|union|enum)( {)?$|};?$|$)" + EXCLUDED_LINES = ( + r"^(" + r"extern \"C\"|" + r"(typedef )?(struct|union|enum)( {)?$|" + r"};?$|" + r"$|" + r"//|" + r"#" + r")" ) identifiers = [] @@ -245,39 +361,69 @@ class NameCheck(object): for header_file in header_files: with open(header_file, "r") as header: in_block_comment = False + previous_line = None for line in header: - # Skip parsing this line if it begins or ends a block - # comment, and set the state machine's state. + # Skip parsing this line if a block comment ends on it, + # but don't skip if it has just started -- there is a chance + # it ends on the same line. if re.search(r"/\*", line): - in_block_comment = True - continue - elif re.search(r"\*/", line) and in_block_comment: - in_block_comment = False - continue - - # Skip parsing this line if it's a line comment, or if it - # begins with a preprocessor directive - if in_block_comment or re.match(r"^(//|#)", line): + in_block_comment = not in_block_comment + if re.search(r"\*/", line): + in_block_comment = not in_block_comment continue - if re.match(EXCLUDED_DECLARATIONS, line): + if in_block_comment: + previous_line = None + continue + + if re.match(EXCLUDED_LINES, line): + previous_line = None + continue + + # Match "^something something$", with optional inline/static + # This *might* be a function with its argument brackets on + # the next line, or a struct declaration, so keep note of it + if re.match( + r"(inline |static |typedef )*\w+ \w+$", + line): + previous_line = line + continue + + # If previous line seemed to start an unfinished declaration + # (as above), and this line begins with a bracket, concat + # them and treat them as one line. + if previous_line and re.match(" *[\({]", line): + line = previous_line.strip() + line.strip() + previous_line = None + + # Skip parsing if line has a space in front = hueristic to + # skip function argument lines (highly subject to formatting + # changes) + if line[0] == " ": continue identifier = re.search( - # Matches: "mbedtls_aes_init(" - r"([a-zA-Z_][a-zA-Z0-9_]*)\(", + # Match something( + r".* \**(\w+)\(|" + # Match (*something)( + r".*\( *\* *(\w+) *\) *\(|" + # Match names of named data structures + r"(?:typedef +)?(?:struct|union|enum) +(\w+)(?: *{)?$|" + # Match names of typedef instances, after closing bracket + r"}? *(\w+)[;[].*", line ) if identifier: + # Find the group that matched, and append it for group in identifier.groups(): if group: identifiers.append(Match( header_file, line, (identifier.start(), identifier.end()), - identifier.group(1))) + group)) return identifiers @@ -285,19 +431,23 @@ class NameCheck(object): """ Compile the Mbed TLS libraries, and parse the TLS, Crypto, and x509 object files using nm to retrieve the list of referenced symbols. - - Returns: - A list of unique symbols defined and used in the libraries. - """ + Exceptions thrown here are rethrown because they would be critical + errors that void several tests, and thus needs to halt the program. This + is explicitly done for clarity. + Returns a List of unique symbols defined and used in the libraries. + """ + self.log.info("Compiling...") symbols = [] # Back up the config and atomically compile with the full configratuion. shutil.copy("include/mbedtls/mbedtls_config.h", - "include/mbedtls/mbedtls_config.h.bak") + "include/mbedtls/mbedtls_config.h.bak") try: + # Use check=True in all subprocess calls so that failures are raised + # as exceptions and logged. subprocess.run( - ["perl", "scripts/config.py", "full"], + ["python3", "scripts/config.py", "full"], encoding=sys.stdout.encoding, check=True ) @@ -326,8 +476,8 @@ class NameCheck(object): check=True ) except subprocess.CalledProcessError as error: - self.log.error(error) self.set_return_code(2) + raise error finally: shutil.move("include/mbedtls/mbedtls_config.h.bak", "include/mbedtls/mbedtls_config.h") @@ -339,8 +489,11 @@ class NameCheck(object): Run nm to retrieve the list of referenced symbols in each object file. Does not return the position data since it is of no use. - Returns: - A list of unique symbols defined and used in any of the object files. + Args: + * object_files: a List of compiled object files to search through. + + Returns a List of unique symbols defined and used in any of the object + files. """ UNDEFINED_SYMBOL = r"^\S+: +U |^$|^\S+:$" VALID_SYMBOL = r"^\S+( [0-9A-Fa-f]+)* . _*(?P\w+)" @@ -348,6 +501,7 @@ class NameCheck(object): symbols = [] + # Gather all outputs of nm nm_output = "" for lib in object_files: nm_output += subprocess.run( @@ -357,6 +511,7 @@ class NameCheck(object): stderr=subprocess.STDOUT, check=True ).stdout + for line in nm_output.splitlines(): if not re.match(UNDEFINED_SYMBOL, line): symbol = re.match(VALID_SYMBOL, line) @@ -364,86 +519,49 @@ class NameCheck(object): symbols.append(symbol.group("symbol")) else: self.log.error(line) - + return symbols - def parse_names_in_source(self): - """ - Calls each parsing function to retrieve various elements of the code, - together with their source location. Puts the parsed values in the - internal variable self.parse_result. - """ - self.log.info("Parsing source code...") - - m_headers = self.get_files("h", os.path.join("include", "mbedtls")) - p_headers = self.get_files("h", os.path.join("include", "psa")) - t_headers = ["3rdparty/everest/include/everest/everest.h", - "3rdparty/everest/include/everest/x25519.h"] - d_headers = self.get_files("h", os.path.join("tests", "include", "test", "drivers")) - l_headers = self.get_files("h", "library") - libraries = self.get_files("c", "library") + [ - "3rdparty/everest/library/everest.c", - "3rdparty/everest/library/x25519.c"] - - all_macros = self.parse_macros( - m_headers + p_headers + t_headers + l_headers + d_headers) - enum_consts = self.parse_enum_consts(m_headers + l_headers + t_headers) - identifiers = self.parse_identifiers(m_headers + p_headers + t_headers + l_headers) - symbols = self.parse_symbols() - mbed_names = self.parse_MBED_names( - m_headers + p_headers + t_headers + l_headers + libraries) - - # Remove identifier macros like mbedtls_printf or mbedtls_calloc - macros = list(set(all_macros) - set(identifiers)) - - self.log.info("Found:") - self.log.info(" {} Macros".format(len(all_macros))) - self.log.info(" {} Enum Constants".format(len(enum_consts))) - self.log.info(" {} Identifiers".format(len(identifiers))) - self.log.info(" {} Exported Symbols".format(len(symbols))) - self.log.info("Analysing...") - - self.parse_result = { - "macros": macros, - "enum_consts": enum_consts, - "identifiers": identifiers, - "symbols": symbols, - "mbed_names": mbed_names - } - - def perform_checks(self): + def perform_checks(self, show_problems: True): """ Perform each check in order, output its PASS/FAIL status. Maintain an overall test status, and output that at the end. + + Args: + * show_problems: whether to show the problematic examples. """ + self.log.info("=============") problems = 0 - problems += self.check_symbols_declared_in_header() + problems += self.check_symbols_declared_in_header(show_problems) pattern_checks = [ ("macros", MACRO_PATTERN), - ("enum_consts", MACRO_PATTERN), + ("enum_consts", CONSTANTS_PATTERN), ("identifiers", IDENTIFIER_PATTERN)] for group, check_pattern in pattern_checks: - problems += self.check_match_pattern(group, check_pattern) + problems += self.check_match_pattern( + show_problems, group, check_pattern) - problems += self.check_for_typos() + problems += self.check_for_typos(show_problems) self.log.info("=============") if problems > 0: self.log.info("FAIL: {0} problem(s) to fix".format(str(problems))) + if not show_problems: + self.log.info("Remove --quiet to show the problems.") else: self.log.info("PASS") - def check_symbols_declared_in_header(self): + def check_symbols_declared_in_header(self, show_problems): """ Perform a check that all detected symbols in the library object files are properly declared in headers. - - Outputs to the logger the PASS/FAIL status, followed by the location of - problems. - Returns the number of problems that needs fixing. + Args: + * show_problems: whether to show the problematic examples. + + Returns the number of problems that need fixing. """ problems = [] for symbol in self.parse_result["symbols"]: @@ -452,39 +570,48 @@ class NameCheck(object): if symbol == identifier_match.name: found_symbol_declared = True break - + if not found_symbol_declared: problems.append(SymbolNotInHeader(symbol)) - if problems: - self.set_return_code(1) - self.log.info("All symbols in header: FAIL") - for problem in problems: - self.log.info(str(problem) + "\n") - else: - self.log.info("All symbols in header: PASS") - + self.output_check_result("All symbols in header", problems, show_problems) return len(problems) - def check_match_pattern(self, group_to_check, check_pattern): + + def check_match_pattern(self, show_problems, group_to_check, check_pattern): + """ + Perform a check that all items of a group conform to a regex pattern. + + Args: + * show_problems: whether to show the problematic examples. + * group_to_check: string key to index into self.parse_result. + * check_pattern: the regex to check against. + + Returns the number of problems that need fixing. + """ problems = [] for item_match in self.parse_result[group_to_check]: if not re.match(check_pattern, item_match.name): problems.append(PatternMismatch(check_pattern, item_match)) if re.match(r".*__.*", item_match.name): problems.append(PatternMismatch("double underscore", item_match)) - - if problems: - self.set_return_code(1) - self.log.info("Naming patterns of {}: FAIL".format(group_to_check)) - for problem in problems: - self.log.info(str(problem) + "\n") - else: - self.log.info("Naming patterns of {}: PASS".format(group_to_check)) - + + self.output_check_result( + "Naming patterns of {}".format(group_to_check), + problems, + show_problems) return len(problems) - def check_for_typos(self): + def check_for_typos(self, show_problems): + """ + Perform a check that all words in the soure code beginning with MBED are + either defined as macros, or as enum constants. + + Args: + * show_problems: whether to show the problematic examples. + + Returns the number of problems that need fixing. + """ problems = [] all_caps_names = list(set([ match.name for match @@ -494,23 +621,45 @@ class NameCheck(object): TYPO_EXCLUSION = r"XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$" for name_match in self.parse_result["mbed_names"]: - if name_match.name not in all_caps_names: - if not re.search(TYPO_EXCLUSION, name_match.name): + found = name_match.name in all_caps_names + + # Since MBEDTLS_PSA_ACCEL_XXX defines are defined by the + # PSA driver, they will not exist as macros. However, they + # should still be checked for typos using the equivalent + # BUILTINs that exist. + if "MBEDTLS_PSA_ACCEL_" in name_match.name: + found = name_match.name.replace( + "MBEDTLS_PSA_ACCEL_", + "MBEDTLS_PSA_BUILTIN_") in all_caps_names + + if not found and not re.search(TYPO_EXCLUSION, name_match.name): problems.append(Typo(name_match)) + self.output_check_result("Likely typos", problems, show_problems) + return len(problems) + + def output_check_result(self, name, problems, show_problems): + """ + Write out the PASS/FAIL status of a performed check depending on whether + there were problems. + + Args: + * show_problems: whether to show the problematic examples. + """ if problems: self.set_return_code(1) - self.log.info("Likely typos: FAIL") - for problem in problems: - self.log.info(str(problem) + "\n") + self.log.info("{}: FAIL".format(name)) + if show_problems: + self.log.info("") + for problem in problems: + self.log.warn(str(problem) + "\n") else: - self.log.info("Likely typos: PASS") - - return len(problems) + self.log.info("{}: PASS".format(name)) def main(): """ - Main function, parses command-line arguments. + Perform argument parsing, and create an instance of NameCheck to begin the + core operation. """ parser = argparse.ArgumentParser( @@ -523,20 +672,28 @@ def main(): parser.add_argument("-v", "--verbose", action="store_true", - help="enable script debug outputs") - + help="show parse results") + + parser.add_argument("-q", "--quiet", + action="store_true", + help="hide unnecessary text and problematic examples") + args = parser.parse_args() try: name_check = NameCheck() name_check.setup_logger(verbose=args.verbose) name_check.parse_names_in_source() - name_check.perform_checks() + name_check.perform_checks(show_problems=not args.quiet) + sys.exit(name_check.return_code) + except subprocess.CalledProcessError as error: + traceback.print_exc() + print("!! Compilation faced a critical error, " + "check-names can't continue further.") sys.exit(name_check.return_code) except Exception: traceback.print_exc() sys.exit(2) - if __name__ == "__main__": main() From 201f9e85cad648db01895af6e79084a064bdab8a Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 16:36:54 +0100 Subject: [PATCH 183/966] Make use of -v to log some debug information Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 828702b172..e3863cfc8d 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -141,6 +141,7 @@ class NameCheck(object): def set_return_code(self, return_code): if return_code > self.return_code: + self.log.debug("Setting new return code to {}".format(return_code)) self.return_code = return_code def setup_logger(self, verbose=False): @@ -252,7 +253,7 @@ class NameCheck(object): ) macros = [] - + self.log.debug("Looking for macros in {} files".format(len(header_files))) for header_file in header_files: with open(header_file, "r") as header: for line in header: @@ -277,7 +278,7 @@ class NameCheck(object): Returns a List of Match objects for words beginning with MBED. """ MBED_names = [] - + self.log.debug("Looking for MBED names in {} files".format(len(files))) for filename in files: with open(filename, "r") as fp: for line in fp: @@ -307,7 +308,7 @@ class NameCheck(object): """ enum_consts = [] - + self.log.debug("Looking for enum consts in {} files".format(len(header_files))) for header_file in header_files: # Emulate a finite state machine to parse enum declarations. # 0 = not in enum @@ -357,7 +358,7 @@ class NameCheck(object): ) identifiers = [] - + self.log.debug("Looking for identifiers in {} files".format(len(header_files))) for header_file in header_files: with open(header_file, "r") as header: in_block_comment = False @@ -593,6 +594,7 @@ class NameCheck(object): for item_match in self.parse_result[group_to_check]: if not re.match(check_pattern, item_match.name): problems.append(PatternMismatch(check_pattern, item_match)) + # Double underscore is a reserved identifier, never to be used if re.match(r".*__.*", item_match.name): problems.append(PatternMismatch("double underscore", item_match)) @@ -633,7 +635,7 @@ class NameCheck(object): "MBEDTLS_PSA_BUILTIN_") in all_caps_names if not found and not re.search(TYPO_EXCLUSION, name_match.name): - problems.append(Typo(name_match)) + problems.append(Typo(name_match)) self.output_check_result("Likely typos", problems, show_problems) return len(problems) From 5939a2a4de08e4c1be482532d329411af823294e Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 16:40:30 +0100 Subject: [PATCH 184/966] Check environment by verifying other dirs' existence Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index e3863cfc8d..b9e028bdd3 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -162,11 +162,10 @@ class NameCheck(object): Check that the current working directory is the project root, and throw an exception if not. """ - current_dir = os.path.realpath('.') - root_dir = os.path.dirname(os.path.dirname( - os.path.dirname(os.path.realpath(__file__)))) - if current_dir != root_dir: - raise Exception("Must be run from Mbed TLS root") + if (not os.path.isdir("include") or + not os.path.isdir("tests") or + not os.path.isdir("library")): + raise Exception("This script must be run from Mbed TLS root") def get_files(self, extension, directory): """ From d24e037dd1742af979d046cff4be0ea583f3791c Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 16:42:33 +0100 Subject: [PATCH 185/966] Warn user if files are excluded from search Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index b9e028bdd3..406810b8c4 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -193,6 +193,10 @@ class NameCheck(object): internal variable self.parse_result. """ self.log.info("Parsing source code...") + self.log.debug( + "The following files are excluded from the search: {}" + .format(str(self.excluded_files)) + ) m_headers = self.get_files("h", os.path.join("include", "mbedtls")) p_headers = self.get_files("h", os.path.join("include", "psa")) From 5c1acf2735c103c70251df2d389a152138ae0e8f Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 16:44:08 +0100 Subject: [PATCH 186/966] Match macros with spaces between # and define Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 406810b8c4..7286cb751e 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -250,7 +250,7 @@ class NameCheck(object): Returns a List of Match objects for the found macros. """ - MACRO_REGEX = r"#define (?P\w+)" + MACRO_REGEX = r"# *define +(?P\w+)" NON_MACROS = ( "asm", "inline", "EMIT", "_CRT_SECURE_NO_DEPRECATE", "MULADDC_" ) From 13ecd996fc87e9da03fd0b4013e00f2be8e00394 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 16:56:52 +0100 Subject: [PATCH 187/966] Improve regex to adapt to flexible spaces Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 7286cb751e..100001beeb 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -320,16 +320,19 @@ class NameCheck(object): state = 0 with open(header_file, "r") as header: for line in header: - if state is 0 and re.match(r"^(typedef )?enum {", line): + # Match typedefs and brackets only when they are at the + # beginning of the line -- if they are indented, they might + # be sub-structures within structs, etc. + if state is 0 and re.match(r"^(typedef +)?enum +{", line): state = 1 - elif state is 0 and re.match(r"^(typedef )?enum", line): + elif state is 0 and re.match(r"^(typedef +)?enum", line): state = 2 elif state is 2 and re.match(r"^{", line): state = 1 elif state is 1 and re.match(r"^}", line): state = 0 - elif state is 1 and not re.match(r"^#", line): - enum_const = re.match(r"^\s*(?P\w+)", line) + elif state is 1 and not re.match(r" *#", line): + enum_const = re.match(r" *(?P\w+)", line) if enum_const: enum_consts.append(Match( header_file, @@ -351,9 +354,9 @@ class NameCheck(object): """ EXCLUDED_LINES = ( r"^(" - r"extern \"C\"|" - r"(typedef )?(struct|union|enum)( {)?$|" - r"};?$|" + r"extern +\"C\"|" + r"(typedef +)?(struct|union|enum)( *{)?$|" + r"} *;?$|" r"$|" r"//|" r"#" @@ -389,7 +392,7 @@ class NameCheck(object): # This *might* be a function with its argument brackets on # the next line, or a struct declaration, so keep note of it if re.match( - r"(inline |static |typedef )*\w+ \w+$", + r"(inline +|static +|typedef +)*\w+ +\w+$", line): previous_line = line continue @@ -408,7 +411,7 @@ class NameCheck(object): continue identifier = re.search( - # Match something( + # Match " something(" or " *something(". function calls. r".* \**(\w+)\(|" # Match (*something)( r".*\( *\* *(\w+) *\) *\(|" From 159255ab7bacc519b4364b8ff9f23ed0d9e88744 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 17:00:28 +0100 Subject: [PATCH 188/966] Document dependency on nm Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 100001beeb..659eda9039 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -17,11 +17,13 @@ """ This script confirms that the naming of all symbols and identifiers in Mbed TLS -are consistent with the house style and are also self-consistent. It performs -the following checks: +are consistent with the house style and are also self-consistent. It only runs +on Linux and macOS since it depends on nm. + +The script performs the following checks: - All exported and available symbols in the library object files, are explicitly - declared in the header files. + declared in the header files. This uses the nm command. - All macros, constants, and identifiers (function names, struct names, etc) follow the required pattern. - Typo checking: All words that begin with MBED exist as macros or constants. From a4e751257a27af4fd8277d37c4c85e852b3429c0 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 17:23:28 +0100 Subject: [PATCH 189/966] Output line number, line, and position of error Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 43 ++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 659eda9039..5213bf4da3 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -52,15 +52,23 @@ class Match(object): Fields: * filename: the file that the match was in. * line: the full line containing the match. + * line_no: the line number of the file. * pos: a tuple of (start, end) positions on the line where the match is. * name: the match itself. """ - def __init__(self, filename, line, pos, name): + def __init__(self, filename, line, line_no, pos, name): self.filename = filename self.line = line + self.line_no = line_no self.pos = pos self.name = name + def __str__(self): + return ( + " |\n" + + " | {}".format(self.line) + + " | " + self.pos[0] * " " + (self.pos[1] - self.pos[0]) * "^" + ) class Problem(object): """ A parent class representing a form of static analysis error. @@ -71,7 +79,7 @@ class Problem(object): def __init__(self): self.textwrapper = textwrap.TextWrapper() self.textwrapper.width = 80 - self.textwrapper.initial_indent = " * " + self.textwrapper.initial_indent = " > " self.textwrapper.subsequent_indent = " " class SymbolNotInHeader(Problem): @@ -109,8 +117,12 @@ class PatternMismatch(Problem): def __str__(self): return self.textwrapper.fill( - "{0}: '{1}' does not match the required pattern '{2}'." - .format(self.match.filename, self.match.name, self.pattern)) + "{0}:{1}: '{2}' does not match the required pattern '{3}'." + .format( + self.match.filename, + self.match.line_no, + self.match.name, + self.pattern)) + "\n" + str(self.match) class Typo(Problem): """ @@ -125,10 +137,15 @@ class Typo(Problem): Problem.__init__(self) def __str__(self): + match_len = self.match.pos[1] - self.match.pos[0] return self.textwrapper.fill( - "{0}: '{1}' looks like a typo. It was not found in any macros or " - "any enums. If this is not a typo, put //no-check-names after it." - .format(self.match.filename, self.match.name)) + "{0}:{1}: '{2}' looks like a typo. It was not found in any " + "macros or any enums. If this is not a typo, put " + "//no-check-names after it." + .format( + self.match.filename, + self.match.line_no, + self.match.name)) + "\n" + str(self.match) class NameCheck(object): """ @@ -261,12 +278,15 @@ class NameCheck(object): self.log.debug("Looking for macros in {} files".format(len(header_files))) for header_file in header_files: with open(header_file, "r") as header: + line_no = 0 for line in header: + line_no += 1 for macro in re.finditer(MACRO_REGEX, line): if not macro.group("macro").startswith(NON_MACROS): macros.append(Match( header_file, line, + line_no, (macro.start(), macro.end()), macro.group("macro"))) @@ -286,7 +306,9 @@ class NameCheck(object): self.log.debug("Looking for MBED names in {} files".format(len(files))) for filename in files: with open(filename, "r") as fp: + line_no = 0 for line in fp: + line_no += 1 # Ignore any names that are deliberately opted-out or in # legacy error directives if re.search(r"// *no-check-names|#error", line): @@ -296,6 +318,7 @@ class NameCheck(object): MBED_names.append(Match( filename, line, + line_no, (name.start(), name.end()), name.group(0) )) @@ -321,7 +344,9 @@ class NameCheck(object): # 2 = almost inside enum state = 0 with open(header_file, "r") as header: + line_no = 0 for line in header: + line_no += 1 # Match typedefs and brackets only when they are at the # beginning of the line -- if they are indented, they might # be sub-structures within structs, etc. @@ -339,6 +364,7 @@ class NameCheck(object): enum_consts.append(Match( header_file, line, + line_no, (enum_const.start(), enum_const.end()), enum_const.group("enum_const"))) @@ -369,10 +395,12 @@ class NameCheck(object): self.log.debug("Looking for identifiers in {} files".format(len(header_files))) for header_file in header_files: with open(header_file, "r") as header: + line_no = 0 in_block_comment = False previous_line = None for line in header: + line_no += 1 # Skip parsing this line if a block comment ends on it, # but don't skip if it has just started -- there is a chance # it ends on the same line. @@ -431,6 +459,7 @@ class NameCheck(object): identifiers.append(Match( header_file, line, + line_no, (identifier.start(), identifier.end()), group)) From 8f457cf2227151c7b1239167d586226e396fe337 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 17:54:58 +0100 Subject: [PATCH 190/966] Use enumerate() to get line numbers Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 5213bf4da3..07e29458cb 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -278,9 +278,7 @@ class NameCheck(object): self.log.debug("Looking for macros in {} files".format(len(header_files))) for header_file in header_files: with open(header_file, "r") as header: - line_no = 0 - for line in header: - line_no += 1 + for line_no, line in enumerate(header): for macro in re.finditer(MACRO_REGEX, line): if not macro.group("macro").startswith(NON_MACROS): macros.append(Match( @@ -306,9 +304,7 @@ class NameCheck(object): self.log.debug("Looking for MBED names in {} files".format(len(files))) for filename in files: with open(filename, "r") as fp: - line_no = 0 - for line in fp: - line_no += 1 + for line_no, line in enumerate(fp): # Ignore any names that are deliberately opted-out or in # legacy error directives if re.search(r"// *no-check-names|#error", line): @@ -344,9 +340,7 @@ class NameCheck(object): # 2 = almost inside enum state = 0 with open(header_file, "r") as header: - line_no = 0 - for line in header: - line_no += 1 + for line_no, line in enumerate(header): # Match typedefs and brackets only when they are at the # beginning of the line -- if they are indented, they might # be sub-structures within structs, etc. @@ -395,12 +389,10 @@ class NameCheck(object): self.log.debug("Looking for identifiers in {} files".format(len(header_files))) for header_file in header_files: with open(header_file, "r") as header: - line_no = 0 in_block_comment = False previous_line = None - for line in header: - line_no += 1 + for line_no, line in enumerate(header): # Skip parsing this line if a block comment ends on it, # but don't skip if it has just started -- there is a chance # it ends on the same line. From cfc9e4a275072d9e2e7dabc9a09bbdd005e1cdfa Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 20:02:32 +0100 Subject: [PATCH 191/966] Change identifier regex to better support multiline declarations Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 07e29458cb..8ee50702fb 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -410,20 +410,21 @@ class NameCheck(object): previous_line = None continue - # Match "^something something$", with optional inline/static - # This *might* be a function with its argument brackets on - # the next line, or a struct declaration, so keep note of it - if re.match( - r"(inline +|static +|typedef +)*\w+ +\w+$", - line): - previous_line = line + # If the line contains only space-separated alphanumeric + # characters (or underscore, asterisk, or, open bracket), + # and nothing else, high chance it's a declaration that + # continues on the next line + if re.match(r"^([\w\*\(]+\s+)+$", line): + if previous_line: + previous_line += " " + line + else: + previous_line = line continue # If previous line seemed to start an unfinished declaration - # (as above), and this line begins with a bracket, concat - # them and treat them as one line. - if previous_line and re.match(" *[\({]", line): - line = previous_line.strip() + line.strip() + # (as above), concat and treat them as one. + if previous_line: + line = previous_line.strip() + " " + line.strip() previous_line = None # Skip parsing if line has a space in front = hueristic to @@ -433,9 +434,15 @@ class NameCheck(object): continue identifier = re.search( - # Match " something(" or " *something(". function calls. - r".* \**(\w+)\(|" - # Match (*something)( + # Match " something(a" or " *something(a". Functions. + # Assumptions: + # - function definition from return type to one of its + # arguments is all on one line (enforced by the above + # previous_line concat) + # - function definition line only contains alphanumeric, + # asterisk, underscore, and open bracket + r".* \**(\w+) *\( *\w|" + # Match "(*something)(". Flexible with spaces. r".*\( *\* *(\w+) *\) *\(|" # Match names of named data structures r"(?:typedef +)?(?:struct|union|enum) +(\w+)(?: *{)?$|" From 25eeb7b935418fdbd4c6b63cd724e9eaff468703 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 21:27:59 +0100 Subject: [PATCH 192/966] Output subprocess stdout if it errored Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 8ee50702fb..3310ae2a03 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -513,6 +513,7 @@ class NameCheck(object): check=True ) except subprocess.CalledProcessError as error: + self.log.debug(error.output) self.set_return_code(2) raise error finally: From 9e0e0e9980788278eb8d41bfccf16a69bf21a252 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 22:01:37 +0100 Subject: [PATCH 193/966] Fix Pylint-detected function argument syntax error Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 3310ae2a03..349e66bdff 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -560,7 +560,7 @@ class NameCheck(object): return symbols - def perform_checks(self, show_problems: True): + def perform_checks(self, show_problems=True): """ Perform each check in order, output its PASS/FAIL status. Maintain an overall test status, and output that at the end. From d93fa37aa67bb6dfa153292eb7ce47e178ebb0d6 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 23:05:55 +0100 Subject: [PATCH 194/966] Address all pylint issues to follow style Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 234 +++++++++++++++++------------------ 1 file changed, 113 insertions(+), 121 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 349e66bdff..7863569909 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -45,21 +45,20 @@ MACRO_PATTERN = r"^(MBEDTLS|PSA)_[0-9A-Z_]*[0-9A-Z]$" CONSTANTS_PATTERN = MACRO_PATTERN IDENTIFIER_PATTERN = r"^(mbedtls|psa)_[0-9a-z_]*[0-9a-z]$" -class Match(object): +class Match(): # pylint: disable=too-few-public-methods """ A class representing a match, together with its found position. Fields: * filename: the file that the match was in. * line: the full line containing the match. - * line_no: the line number of the file. - * pos: a tuple of (start, end) positions on the line where the match is. + * pos: a tuple of (line_no, start, end) positions on the file line where the + match is. * name: the match itself. """ - def __init__(self, filename, line, line_no, pos, name): + def __init__(self, filename, line, pos, name): self.filename = filename self.line = line - self.line_no = line_no self.pos = pos self.name = name @@ -67,9 +66,10 @@ class Match(object): return ( " |\n" + " | {}".format(self.line) + - " | " + self.pos[0] * " " + (self.pos[1] - self.pos[0]) * "^" + " | " + self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^" ) -class Problem(object): + +class Problem(): # pylint: disable=too-few-public-methods """ A parent class representing a form of static analysis error. @@ -82,7 +82,7 @@ class Problem(object): self.textwrapper.initial_indent = " > " self.textwrapper.subsequent_indent = " " -class SymbolNotInHeader(Problem): +class SymbolNotInHeader(Problem): # pylint: disable=too-few-public-methods """ A problem that occurs when an exported/available symbol in the object file is not explicitly declared in header files. Created with @@ -101,7 +101,7 @@ class SymbolNotInHeader(Problem): "however it was not declared in any header files." .format(self.symbol_name)) -class PatternMismatch(Problem): +class PatternMismatch(Problem): # pylint: disable=too-few-public-methods """ A problem that occurs when something doesn't match the expected pattern. Created with NameCheck.check_match_pattern() @@ -120,11 +120,11 @@ class PatternMismatch(Problem): "{0}:{1}: '{2}' does not match the required pattern '{3}'." .format( self.match.filename, - self.match.line_no, + self.match.pos[0], self.match.name, self.pattern)) + "\n" + str(self.match) -class Typo(Problem): +class Typo(Problem): # pylint: disable=too-few-public-methods """ A problem that occurs when a word using MBED doesn't appear to be defined as constants nor enum values. Created with NameCheck.check_for_typos() @@ -137,26 +137,25 @@ class Typo(Problem): Problem.__init__(self) def __str__(self): - match_len = self.match.pos[1] - self.match.pos[0] return self.textwrapper.fill( "{0}:{1}: '{2}' looks like a typo. It was not found in any " "macros or any enums. If this is not a typo, put " "//no-check-names after it." .format( self.match.filename, - self.match.line_no, + self.match.pos[0], self.match.name)) + "\n" + str(self.match) -class NameCheck(object): +class NameCheck(): """ Representation of the core name checking operation performed by this script. Shares a common logger, common excluded filenames, and a shared return_code. """ def __init__(self): self.log = None - self.check_repo_path() self.return_code = 0 self.excluded_files = ["bn_mul", "compat-2.x.h"] + self.parse_result = {} def set_return_code(self, return_code): if return_code > self.return_code: @@ -176,16 +175,6 @@ class NameCheck(object): self.log.setLevel(logging.INFO) self.log.addHandler(logging.StreamHandler()) - def check_repo_path(self): - """ - Check that the current working directory is the project root, and throw - an exception if not. - """ - if (not os.path.isdir("include") or - not os.path.isdir("tests") or - not os.path.isdir("library")): - raise Exception("This script must be run from Mbed TLS root") - def get_files(self, extension, directory): """ Get all files that end with .extension in the specified directory @@ -198,7 +187,7 @@ class NameCheck(object): Returns a List of relative filepaths. """ filenames = [] - for root, dirs, files in sorted(os.walk(directory)): + for root, _, files in sorted(os.walk(directory)): for filename in sorted(files): if (filename not in self.excluded_files and filename.endswith("." + extension)): @@ -233,7 +222,7 @@ class NameCheck(object): m_headers + l_headers + t_headers) identifiers = self.parse_identifiers( m_headers + p_headers + t_headers + l_headers) - mbed_names = self.parse_MBED_names( + mbed_words = self.parse_mbed_words( m_headers + p_headers + t_headers + l_headers + libraries) symbols = self.parse_symbols() @@ -257,7 +246,7 @@ class NameCheck(object): "enum_consts": enum_consts, "identifiers": identifiers, "symbols": symbols, - "mbed_names": mbed_names + "mbed_words": mbed_words } def parse_macros(self, header_files): @@ -269,28 +258,29 @@ class NameCheck(object): Returns a List of Match objects for the found macros. """ - MACRO_REGEX = r"# *define +(?P\w+)" - NON_MACROS = ( + macro_regex = re.compile(r"# *define +(?P\w+)") + exclusions = ( "asm", "inline", "EMIT", "_CRT_SECURE_NO_DEPRECATE", "MULADDC_" ) - macros = [] self.log.debug("Looking for macros in {} files".format(len(header_files))) + + macros = [] + for header_file in header_files: with open(header_file, "r") as header: for line_no, line in enumerate(header): - for macro in re.finditer(MACRO_REGEX, line): - if not macro.group("macro").startswith(NON_MACROS): + for macro in macro_regex.finditer(line): + if not macro.group("macro").startswith(exclusions): macros.append(Match( header_file, line, - line_no, - (macro.start(), macro.end()), + (line_no, macro.start(), macro.end()), macro.group("macro"))) return macros - def parse_MBED_names(self, files): + def parse_mbed_words(self, files): """ Parse all words in the file that begin with MBED. Includes macros. There have been typos of TLS, hence the broader check than MBEDTLS. @@ -300,26 +290,28 @@ class NameCheck(object): Returns a List of Match objects for words beginning with MBED. """ - MBED_names = [] + mbed_regex = re.compile(r"\bMBED.+?_[A-Z0-9_]*") + exclusions = re.compile(r"// *no-check-names|#error") + self.log.debug("Looking for MBED names in {} files".format(len(files))) + + mbed_words = [] + for filename in files: with open(filename, "r") as fp: for line_no, line in enumerate(fp): - # Ignore any names that are deliberately opted-out or in - # legacy error directives - if re.search(r"// *no-check-names|#error", line): + if exclusions.search(line): continue - for name in re.finditer(r"\bMBED.+?_[A-Z0-9_]*", line): - MBED_names.append(Match( + for name in mbed_regex.finditer(line): + mbed_words.append(Match( filename, line, - line_no, - (name.start(), name.end()), + (line_no, name.start(), name.end()), name.group(0) )) - return MBED_names + return mbed_words def parse_enum_consts(self, header_files): """ @@ -330,9 +322,10 @@ class NameCheck(object): Returns a List of Match objects for the findings. """ + self.log.debug("Looking for enum consts in {} files".format(len(header_files))) enum_consts = [] - self.log.debug("Looking for enum consts in {} files".format(len(header_files))) + for header_file in header_files: # Emulate a finite state machine to parse enum declarations. # 0 = not in enum @@ -344,22 +337,21 @@ class NameCheck(object): # Match typedefs and brackets only when they are at the # beginning of the line -- if they are indented, they might # be sub-structures within structs, etc. - if state is 0 and re.match(r"^(typedef +)?enum +{", line): + if state == 0 and re.match(r"^(typedef +)?enum +{", line): state = 1 - elif state is 0 and re.match(r"^(typedef +)?enum", line): + elif state == 0 and re.match(r"^(typedef +)?enum", line): state = 2 - elif state is 2 and re.match(r"^{", line): + elif state == 2 and re.match(r"^{", line): state = 1 - elif state is 1 and re.match(r"^}", line): + elif state == 1 and re.match(r"^}", line): state = 0 - elif state is 1 and not re.match(r" *#", line): + elif state == 1 and not re.match(r" *#", line): enum_const = re.match(r" *(?P\w+)", line) if enum_const: enum_consts.append(Match( header_file, line, - line_no, - (enum_const.start(), enum_const.end()), + (line_no, enum_const.start(), enum_const.end()), enum_const.group("enum_const"))) return enum_consts @@ -374,23 +366,37 @@ class NameCheck(object): Returns a List of Match objects with identifiers. """ - EXCLUDED_LINES = ( - r"^(" - r"extern +\"C\"|" - r"(typedef +)?(struct|union|enum)( *{)?$|" - r"} *;?$|" - r"$|" - r"//|" - r"#" - r")" - ) + identifier_regex = re.compile( + # Match " something(a" or " *something(a". Functions. + # Assumptions: + # - function definition from return type to one of its arguments is + # all on one line (enforced by the previous_line concat below) + # - function definition line only contains alphanumeric, asterisk, + # underscore, and open bracket + r".* \**(\w+) *\( *\w|" + # Match "(*something)(". Flexible with spaces. + r".*\( *\* *(\w+) *\) *\(|" + # Match names of named data structures. + r"(?:typedef +)?(?:struct|union|enum) +(\w+)(?: *{)?$|" + # Match names of typedef instances, after closing bracket. + r"}? *(\w+)[;[].*") + exclusion_lines = re.compile(r"^(" + r"extern +\"C\"|" + r"(typedef +)?(struct|union|enum)( *{)?$|" + r"} *;?$|" + r"$|" + r"//|" + r"#" + r")") + + self.log.debug("Looking for identifiers in {} files".format(len(header_files))) identifiers = [] - self.log.debug("Looking for identifiers in {} files".format(len(header_files))) + for header_file in header_files: with open(header_file, "r") as header: in_block_comment = False - previous_line = None + previous_line = "" for line_no, line in enumerate(header): # Skip parsing this line if a block comment ends on it, @@ -403,11 +409,11 @@ class NameCheck(object): continue if in_block_comment: - previous_line = None + previous_line = "" continue - if re.match(EXCLUDED_LINES, line): - previous_line = None + if exclusion_lines.match(line): + previous_line = "" continue # If the line contains only space-separated alphanumeric @@ -415,17 +421,14 @@ class NameCheck(object): # and nothing else, high chance it's a declaration that # continues on the next line if re.match(r"^([\w\*\(]+\s+)+$", line): - if previous_line: - previous_line += " " + line - else: - previous_line = line + previous_line += line continue # If previous line seemed to start an unfinished declaration # (as above), concat and treat them as one. if previous_line: line = previous_line.strip() + " " + line.strip() - previous_line = None + previous_line = "" # Skip parsing if line has a space in front = hueristic to # skip function argument lines (highly subject to formatting @@ -433,23 +436,7 @@ class NameCheck(object): if line[0] == " ": continue - identifier = re.search( - # Match " something(a" or " *something(a". Functions. - # Assumptions: - # - function definition from return type to one of its - # arguments is all on one line (enforced by the above - # previous_line concat) - # - function definition line only contains alphanumeric, - # asterisk, underscore, and open bracket - r".* \**(\w+) *\( *\w|" - # Match "(*something)(". Flexible with spaces. - r".*\( *\* *(\w+) *\) *\(|" - # Match names of named data structures - r"(?:typedef +)?(?:struct|union|enum) +(\w+)(?: *{)?$|" - # Match names of typedef instances, after closing bracket - r"}? *(\w+)[;[].*", - line - ) + identifier = identifier_regex.search(line) if identifier: # Find the group that matched, and append it @@ -458,8 +445,7 @@ class NameCheck(object): identifiers.append(Match( header_file, line, - line_no, - (identifier.start(), identifier.end()), + (line_no, identifier.start(), identifier.end()), group)) return identifiers @@ -502,10 +488,8 @@ class NameCheck(object): # Perform object file analysis using nm symbols = self.parse_symbols_from_nm( ["library/libmbedcrypto.a", - "library/libmbedtls.a", - "library/libmbedx509.a"]) - - symbols.sort() + "library/libmbedtls.a", + "library/libmbedx509.a"]) subprocess.run( ["make", "clean"], @@ -533,9 +517,9 @@ class NameCheck(object): Returns a List of unique symbols defined and used in any of the object files. """ - UNDEFINED_SYMBOL = r"^\S+: +U |^$|^\S+:$" - VALID_SYMBOL = r"^\S+( [0-9A-Fa-f]+)* . _*(?P\w+)" - EXCLUSIONS = ("FStar", "Hacl") + nm_undefined_regex = re.compile(r"^\S+: +U |^$|^\S+:$") + nm_valid_regex = re.compile(r"^\S+( [0-9A-Fa-f]+)* . _*(?P\w+)") + nm_exclusions = ("FStar", "Hacl") symbols = [] @@ -551,9 +535,10 @@ class NameCheck(object): ).stdout for line in nm_output.splitlines(): - if not re.match(UNDEFINED_SYMBOL, line): - symbol = re.match(VALID_SYMBOL, line) - if symbol and not symbol.group("symbol").startswith(EXCLUSIONS): + if not nm_undefined_regex.match(line): + symbol = nm_valid_regex.match(line) + if (symbol and not symbol.group("symbol").startswith( + nm_exclusions)): symbols.append(symbol.group("symbol")) else: self.log.error(line) @@ -573,10 +558,9 @@ class NameCheck(object): problems += self.check_symbols_declared_in_header(show_problems) - pattern_checks = [ - ("macros", MACRO_PATTERN), - ("enum_consts", CONSTANTS_PATTERN), - ("identifiers", IDENTIFIER_PATTERN)] + pattern_checks = [("macros", MACRO_PATTERN), + ("enum_consts", CONSTANTS_PATTERN), + ("identifiers", IDENTIFIER_PATTERN)] for group, check_pattern in pattern_checks: problems += self.check_match_pattern( show_problems, group, check_pattern) @@ -602,6 +586,7 @@ class NameCheck(object): Returns the number of problems that need fixing. """ problems = [] + for symbol in self.parse_result["symbols"]: found_symbol_declared = False for identifier_match in self.parse_result["identifiers"]: @@ -628,6 +613,7 @@ class NameCheck(object): Returns the number of problems that need fixing. """ problems = [] + for item_match in self.parse_result[group_to_check]: if not re.match(check_pattern, item_match.name): problems.append(PatternMismatch(check_pattern, item_match)) @@ -652,14 +638,15 @@ class NameCheck(object): Returns the number of problems that need fixing. """ problems = [] - all_caps_names = list(set([ - match.name for match - in self.parse_result["macros"] + self.parse_result["enum_consts"]] - )) - TYPO_EXCLUSION = r"XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$" + # Set comprehension, equivalent to a list comprehension inside set() + all_caps_names = { + match.name + for match + in self.parse_result["macros"] + self.parse_result["enum_consts"]} + typo_exclusion = re.compile(r"XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$") - for name_match in self.parse_result["mbed_names"]: + for name_match in self.parse_result["mbed_words"]: found = name_match.name in all_caps_names # Since MBEDTLS_PSA_ACCEL_XXX defines are defined by the @@ -671,7 +658,7 @@ class NameCheck(object): "MBEDTLS_PSA_ACCEL_", "MBEDTLS_PSA_BUILTIN_") in all_caps_names - if not found and not re.search(TYPO_EXCLUSION, name_match.name): + if not found and not typo_exclusion.search(name_match.name): problems.append(Typo(name_match)) self.output_check_result("Likely typos", problems, show_problems) @@ -691,16 +678,25 @@ class NameCheck(object): if show_problems: self.log.info("") for problem in problems: - self.log.warn(str(problem) + "\n") + self.log.warning("{}\n".format(str(problem))) else: self.log.info("{}: PASS".format(name)) +def check_repo_path(): + """ + Check that the current working directory is the project root, and throw + an exception if not. + """ + if (not os.path.isdir("include") or + not os.path.isdir("tests") or + not os.path.isdir("library")): + raise Exception("This script must be run from Mbed TLS root") + def main(): """ Perform argument parsing, and create an instance of NameCheck to begin the core operation. """ - parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description=( @@ -720,17 +716,13 @@ def main(): args = parser.parse_args() try: + check_repo_path() name_check = NameCheck() name_check.setup_logger(verbose=args.verbose) name_check.parse_names_in_source() name_check.perform_checks(show_problems=not args.quiet) sys.exit(name_check.return_code) - except subprocess.CalledProcessError as error: - traceback.print_exc() - print("!! Compilation faced a critical error, " - "check-names can't continue further.") - sys.exit(name_check.return_code) - except Exception: + except Exception: # pylint: disable=broad-except traceback.print_exc() sys.exit(2) From bcc3d99cc10561fd40f8c1eba585a9cf4f8bd123 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 23:14:58 +0100 Subject: [PATCH 195/966] Fix compatibiliy with Python 3.5 on the CI Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 7863569909..b1835c6801 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -471,7 +471,7 @@ class NameCheck(): # as exceptions and logged. subprocess.run( ["python3", "scripts/config.py", "full"], - encoding=sys.stdout.encoding, + universal_newlines=True, check=True ) my_environment = os.environ.copy() @@ -479,7 +479,7 @@ class NameCheck(): subprocess.run( ["make", "clean", "lib"], env=my_environment, - encoding=sys.stdout.encoding, + universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True @@ -493,7 +493,7 @@ class NameCheck(): subprocess.run( ["make", "clean"], - encoding=sys.stdout.encoding, + universal_newlines=True, check=True ) except subprocess.CalledProcessError as error: @@ -528,7 +528,7 @@ class NameCheck(): for lib in object_files: nm_output += subprocess.run( ["nm", "-og", lib], - encoding=sys.stdout.encoding, + universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True From 381fda8550212a6250a7dbb6b1a56300674cd9e6 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Fri, 6 Aug 2021 23:37:20 +0100 Subject: [PATCH 196/966] Print line number next to problem in check-names Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index b1835c6801..5878bfa498 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -63,10 +63,15 @@ class Match(): # pylint: disable=too-few-public-methods self.name = name def __str__(self): + ln_str = str(self.pos[0]) + gutter_len = max(4, len(ln_str)) + gutter = (gutter_len - len(ln_str)) * " " + ln_str + underline = self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^" + return ( - " |\n" + - " | {}".format(self.line) + - " | " + self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^" + " {0} |\n".format(gutter_len * " ") + + " {0} | {1}".format(gutter, self.line) + + " {0} | {1}".format(gutter_len * " ", underline) ) class Problem(): # pylint: disable=too-few-public-methods From a083d15eddbe0c55b91ce5289dd672b6490452e0 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Sat, 7 Aug 2021 00:25:59 +0100 Subject: [PATCH 197/966] Specify file open encoding as utf-8 in check-names Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 5878bfa498..f47d7e6c52 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -273,7 +273,7 @@ class NameCheck(): macros = [] for header_file in header_files: - with open(header_file, "r") as header: + with open(header_file, "r", encoding="utf-8") as header: for line_no, line in enumerate(header): for macro in macro_regex.finditer(line): if not macro.group("macro").startswith(exclusions): @@ -303,7 +303,7 @@ class NameCheck(): mbed_words = [] for filename in files: - with open(filename, "r") as fp: + with open(filename, "r", encoding="utf-8") as fp: for line_no, line in enumerate(fp): if exclusions.search(line): continue @@ -337,7 +337,7 @@ class NameCheck(): # 1 = inside enum # 2 = almost inside enum state = 0 - with open(header_file, "r") as header: + with open(header_file, "r", encoding="utf-8") as header: for line_no, line in enumerate(header): # Match typedefs and brackets only when they are at the # beginning of the line -- if they are indented, they might @@ -399,7 +399,7 @@ class NameCheck(): identifiers = [] for header_file in header_files: - with open(header_file, "r") as header: + with open(header_file, "r", encoding="utf-8") as header: in_block_comment = False previous_line = "" From 12a7ecda5afa649d43a388dd280c116f5505d071 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Sat, 7 Aug 2021 00:40:29 +0100 Subject: [PATCH 198/966] Fix further pylint issues picked up by Travis CI Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index f47d7e6c52..81fd5ffb84 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -386,13 +386,13 @@ class NameCheck(): # Match names of typedef instances, after closing bracket. r"}? *(\w+)[;[].*") exclusion_lines = re.compile(r"^(" - r"extern +\"C\"|" - r"(typedef +)?(struct|union|enum)( *{)?$|" - r"} *;?$|" - r"$|" - r"//|" - r"#" - r")") + r"extern +\"C\"|" + r"(typedef +)?(struct|union|enum)( *{)?$|" + r"} *;?$|" + r"$|" + r"//|" + r"#" + r")") self.log.debug("Looking for identifiers in {} files".format(len(header_files))) @@ -524,7 +524,7 @@ class NameCheck(): """ nm_undefined_regex = re.compile(r"^\S+: +U |^$|^\S+:$") nm_valid_regex = re.compile(r"^\S+( [0-9A-Fa-f]+)* . _*(?P\w+)") - nm_exclusions = ("FStar", "Hacl") + exclusions = ("FStar", "Hacl") symbols = [] @@ -542,8 +542,7 @@ class NameCheck(): for line in nm_output.splitlines(): if not nm_undefined_regex.match(line): symbol = nm_valid_regex.match(line) - if (symbol and not symbol.group("symbol").startswith( - nm_exclusions)): + if (symbol and not symbol.group("symbol").startswith(exclusions)): symbols.append(symbol.group("symbol")) else: self.log.error(line) From b47b504418e146dc0fae6be266bbdfd71a2d9827 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Sat, 7 Aug 2021 00:42:54 +0100 Subject: [PATCH 199/966] Improve comments in parse_mbed_words() Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 81fd5ffb84..228ab4c646 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -287,14 +287,15 @@ class NameCheck(): def parse_mbed_words(self, files): """ - Parse all words in the file that begin with MBED. Includes macros. - There have been typos of TLS, hence the broader check than MBEDTLS. + Parse all words in the file that begin with MBED, in and out of macros, + comments, anything. Args: * files: a List of filepaths to look through. Returns a List of Match objects for words beginning with MBED. """ + # Typos of TLS are common, hence the broader check below than MBEDTLS. mbed_regex = re.compile(r"\bMBED.+?_[A-Z0-9_]*") exclusions = re.compile(r"// *no-check-names|#error") From 55614b51f11d992266e552be9b0b41185d777a10 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Sat, 7 Aug 2021 01:00:18 +0100 Subject: [PATCH 200/966] Use --quiet to hide explanations and show only minimal necessary info Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 88 +++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 228ab4c646..509b4353af 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -71,7 +71,7 @@ class Match(): # pylint: disable=too-few-public-methods return ( " {0} |\n".format(gutter_len * " ") + " {0} | {1}".format(gutter, self.line) + - " {0} | {1}".format(gutter_len * " ", underline) + " {0} | {1}\n".format(gutter_len * " ", underline) ) class Problem(): # pylint: disable=too-few-public-methods @@ -96,11 +96,15 @@ class SymbolNotInHeader(Problem): # pylint: disable=too-few-public-methods Fields: * symbol_name: the name of the symbol. """ - def __init__(self, symbol_name): + def __init__(self, symbol_name, quiet=False): self.symbol_name = symbol_name + self.quiet = quiet Problem.__init__(self) def __str__(self): + if self.quiet: + return "{0}".format(self.symbol_name) + return self.textwrapper.fill( "'{0}' was found as an available symbol in the output of nm, " "however it was not declared in any header files." @@ -115,12 +119,20 @@ class PatternMismatch(Problem): # pylint: disable=too-few-public-methods * pattern: the expected regex pattern * match: the Match object in question """ - def __init__(self, pattern, match): + def __init__(self, pattern, match, quiet=False): self.pattern = pattern self.match = match + self.quiet = quiet Problem.__init__(self) def __str__(self): + if self.quiet: + return ("{0}:{1}:{3}" + .format( + self.match.filename, + self.match.pos[0], + self.match.name)) + return self.textwrapper.fill( "{0}:{1}: '{2}' does not match the required pattern '{3}'." .format( @@ -137,11 +149,19 @@ class Typo(Problem): # pylint: disable=too-few-public-methods Fields: * match: the Match object of the MBED name in question. """ - def __init__(self, match): + def __init__(self, match, quiet=False): self.match = match + self.quiet = quiet Problem.__init__(self) def __str__(self): + if self.quiet: + return ("{0}:{1}:{2}" + .format( + self.match.filename, + self.match.pos[0], + self.match.name)) + return self.textwrapper.fill( "{0}:{1}: '{2}' looks like a typo. It was not found in any " "macros or any enums. If this is not a typo, put " @@ -550,43 +570,42 @@ class NameCheck(): return symbols - def perform_checks(self, show_problems=True): + def perform_checks(self, quiet=False): """ Perform each check in order, output its PASS/FAIL status. Maintain an overall test status, and output that at the end. Args: - * show_problems: whether to show the problematic examples. + * quiet: whether to hide detailed problem explanation. """ self.log.info("=============") problems = 0 - problems += self.check_symbols_declared_in_header(show_problems) + problems += self.check_symbols_declared_in_header(quiet) pattern_checks = [("macros", MACRO_PATTERN), ("enum_consts", CONSTANTS_PATTERN), ("identifiers", IDENTIFIER_PATTERN)] for group, check_pattern in pattern_checks: - problems += self.check_match_pattern( - show_problems, group, check_pattern) + problems += self.check_match_pattern(quiet, group, check_pattern) - problems += self.check_for_typos(show_problems) + problems += self.check_for_typos(quiet) self.log.info("=============") if problems > 0: self.log.info("FAIL: {0} problem(s) to fix".format(str(problems))) - if not show_problems: - self.log.info("Remove --quiet to show the problems.") + if quiet: + self.log.info("Remove --quiet to see explanations.") else: self.log.info("PASS") - def check_symbols_declared_in_header(self, show_problems): + def check_symbols_declared_in_header(self, quiet): """ Perform a check that all detected symbols in the library object files are properly declared in headers. Args: - * show_problems: whether to show the problematic examples. + * quiet: whether to hide detailed problem explanation. Returns the number of problems that need fixing. """ @@ -600,18 +619,18 @@ class NameCheck(): break if not found_symbol_declared: - problems.append(SymbolNotInHeader(symbol)) + problems.append(SymbolNotInHeader(symbol, quiet=quiet)) - self.output_check_result("All symbols in header", problems, show_problems) + self.output_check_result("All symbols in header", problems) return len(problems) - def check_match_pattern(self, show_problems, group_to_check, check_pattern): + def check_match_pattern(self, quiet, group_to_check, check_pattern): """ Perform a check that all items of a group conform to a regex pattern. Args: - * show_problems: whether to show the problematic examples. + * quiet: whether to hide detailed problem explanation. * group_to_check: string key to index into self.parse_result. * check_pattern: the regex to check against. @@ -624,21 +643,23 @@ class NameCheck(): problems.append(PatternMismatch(check_pattern, item_match)) # Double underscore is a reserved identifier, never to be used if re.match(r".*__.*", item_match.name): - problems.append(PatternMismatch("double underscore", item_match)) + problems.append(PatternMismatch( + "double underscore", + item_match, + quiet=quiet)) self.output_check_result( "Naming patterns of {}".format(group_to_check), - problems, - show_problems) + problems) return len(problems) - def check_for_typos(self, show_problems): + def check_for_typos(self, quiet): """ Perform a check that all words in the soure code beginning with MBED are either defined as macros, or as enum constants. Args: - * show_problems: whether to show the problematic examples. + * quiet: whether to hide detailed problem explanation. Returns the number of problems that need fixing. """ @@ -664,26 +685,21 @@ class NameCheck(): "MBEDTLS_PSA_BUILTIN_") in all_caps_names if not found and not typo_exclusion.search(name_match.name): - problems.append(Typo(name_match)) + problems.append(Typo(name_match, quiet=quiet)) - self.output_check_result("Likely typos", problems, show_problems) + self.output_check_result("Likely typos", problems) return len(problems) - def output_check_result(self, name, problems, show_problems): + def output_check_result(self, name, problems): """ Write out the PASS/FAIL status of a performed check depending on whether there were problems. - - Args: - * show_problems: whether to show the problematic examples. """ if problems: self.set_return_code(1) - self.log.info("{}: FAIL".format(name)) - if show_problems: - self.log.info("") - for problem in problems: - self.log.warning("{}\n".format(str(problem))) + self.log.info("{}: FAIL\n".format(name)) + for problem in problems: + self.log.warning(str(problem)) else: self.log.info("{}: PASS".format(name)) @@ -716,7 +732,7 @@ def main(): parser.add_argument("-q", "--quiet", action="store_true", - help="hide unnecessary text and problematic examples") + help="hide unnecessary text, explanations, and highlighs") args = parser.parse_args() @@ -725,7 +741,7 @@ def main(): name_check = NameCheck() name_check.setup_logger(verbose=args.verbose) name_check.parse_names_in_source() - name_check.perform_checks(show_problems=not args.quiet) + name_check.perform_checks(quiet=args.quiet) sys.exit(name_check.return_code) except Exception: # pylint: disable=broad-except traceback.print_exc() From f3cce8b0e1bb5df423e4c4bf46ac1cd5d5387300 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 7 Aug 2021 14:29:49 +0100 Subject: [PATCH 201/966] Add handshake message writing variant that doesn't update checksum The helper `mbedtls_ssl_write_handshake_msg` writes a handshake message and updates the handshake transcript. With TLS 1.3, we need finer control over the checksum: updating at message granularity is not sufficient. To allow for manual maintenance of the checksum in those cases, refine `mbedtls_ssl_write_handshake_msg()` into `mbedtls_ssl_write_handshake_msg_ext()` which takes a parameter determining whether the checksum should be updated. Signed-off-by: Hanno Becker --- library/ssl_misc.h | 8 +++++++- library/ssl_msg.c | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index cc19f4723b..e4966f0198 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -971,7 +971,13 @@ int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl, unsigned update_hs_digest ); int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ); -int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_write_handshake_msg_ext( mbedtls_ssl_context *ssl, + int update_checksum ); +static inline int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_write_handshake_msg_ext( ssl, 1 /* update checksum */ ) ); +} + int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 76cc2b17d4..fe26eaaf29 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2360,7 +2360,8 @@ void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl ) * (including handshake headers but excluding record headers) * - ssl->out_msg: the record contents (handshake headers + content) */ -int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_write_handshake_msg_ext( mbedtls_ssl_context *ssl, + int update_checksum ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const size_t hs_len = ssl->out_msglen - 4; @@ -2469,7 +2470,7 @@ int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_SSL_PROTO_DTLS */ /* Update running hashes of handshake messages seen */ - if( hs_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) + if( hs_type != MBEDTLS_SSL_HS_HELLO_REQUEST && update_checksum != 0 ) ssl->handshake->update_checksum( ssl, ssl->out_msg, ssl->out_msglen ); } From fc54dfb0d662301de595fc5e8a9c83a8d766bd35 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Sat, 7 Aug 2021 17:18:28 +0100 Subject: [PATCH 202/966] Move check_repo_path into NameCheck as staticmethod Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 509b4353af..b8a12885f1 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -27,6 +27,9 @@ The script performs the following checks: - All macros, constants, and identifiers (function names, struct names, etc) follow the required pattern. - Typo checking: All words that begin with MBED exist as macros or constants. + +Returns 0 on success, 1 on test failure, and 2 if there is a script error or a +subprocess error. Must be run from Mbed TLS root. """ import argparse @@ -178,6 +181,7 @@ class NameCheck(): """ def __init__(self): self.log = None + self.check_repo_path() self.return_code = 0 self.excluded_files = ["bn_mul", "compat-2.x.h"] self.parse_result = {} @@ -187,6 +191,15 @@ class NameCheck(): self.log.debug("Setting new return code to {}".format(return_code)) self.return_code = return_code + @staticmethod + def check_repo_path(): + """ + Check that the current working directory is the project root, and throw + an exception if not. + """ + if not all(os.path.isdir(d) for d in ["include", "library", "tests"]): + raise Exception("This script must be run from Mbed TLS root") + def setup_logger(self, verbose=False): """ Set up a logger and set the change the default logging level from @@ -596,6 +609,8 @@ class NameCheck(): self.log.info("FAIL: {0} problem(s) to fix".format(str(problems))) if quiet: self.log.info("Remove --quiet to see explanations.") + else: + self.log.info("Use --quiet for minimal output.") else: self.log.info("PASS") @@ -703,16 +718,6 @@ class NameCheck(): else: self.log.info("{}: PASS".format(name)) -def check_repo_path(): - """ - Check that the current working directory is the project root, and throw - an exception if not. - """ - if (not os.path.isdir("include") or - not os.path.isdir("tests") or - not os.path.isdir("library")): - raise Exception("This script must be run from Mbed TLS root") - def main(): """ Perform argument parsing, and create an instance of NameCheck to begin the @@ -737,7 +742,6 @@ def main(): args = parser.parse_args() try: - check_repo_path() name_check = NameCheck() name_check.setup_logger(verbose=args.verbose) name_check.parse_names_in_source() From 6fececf192e653a37fe100ae931fcad874c0ee7b Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Sat, 7 Aug 2021 17:28:23 +0100 Subject: [PATCH 203/966] Comment why is used Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index b8a12885f1..5fe85b7bd6 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -540,6 +540,8 @@ class NameCheck(): self.set_return_code(2) raise error finally: + # Put back the original config regardless of there being errors. + # Works also for keyboard interrupts. shutil.move("include/mbedtls/mbedtls_config.h.bak", "include/mbedtls/mbedtls_config.h") From 41934dd20a71fc474f0bd4f6cb754b09b48bd52f Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 7 Aug 2021 19:13:43 +0100 Subject: [PATCH 204/966] Share preparatory code between client and server handshake steps Signed-off-by: Hanno Becker --- library/ssl_cli.c | 15 --------------- library/ssl_srv.c | 15 --------------- library/ssl_tls.c | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index e0a1c24ec1..59c5460429 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -4210,23 +4210,8 @@ int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ) { int ret = 0; - if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); - if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) - return( ret ); - -#if defined(MBEDTLS_SSL_PROTO_DTLS) - if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && - ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) - { - if( ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) - return( ret ); - } -#endif /* MBEDTLS_SSL_PROTO_DTLS */ - /* Change state now, so that it is right in mbedtls_ssl_read_record(), used * by DTLS for dropping out-of-sequence ChangeCipherSpec records */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) diff --git a/library/ssl_srv.c b/library/ssl_srv.c index d82ec0471f..3d6739342d 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -4258,23 +4258,8 @@ int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ) { int ret = 0; - if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "server state: %d", ssl->state ) ); - if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) - return( ret ); - -#if defined(MBEDTLS_SSL_PROTO_DTLS) - if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && - ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) - { - if( ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) - return( ret ); - } -#endif /* MBEDTLS_SSL_PROTO_DTLS */ - switch( ssl->state ) { case MBEDTLS_SSL_HELLO_REQUEST: diff --git a/library/ssl_tls.c b/library/ssl_tls.c index bb5ddc470e..bf87fe56dc 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5076,12 +5076,40 @@ int mbedtls_ssl_session_load( mbedtls_ssl_session *session, /* * Perform a single step of the SSL handshake */ +static int ssl_prepare_handshake_step( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + return( ret ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) + { + if( ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) + return( ret ); + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + return( ret ); +} + int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) { - int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - if( ssl == NULL || ssl->conf == NULL ) + if( ssl == NULL || + ssl->conf == NULL || + ssl->handshake == NULL || + ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) + { return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + ret = ssl_prepare_handshake_step( ssl ); + if( ret != 0 ) + return( ret ); #if defined(MBEDTLS_SSL_CLI_C) if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) From 51efcb143da3e25a9bcda904c3830c69b5a69c51 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 11:54:12 +0100 Subject: [PATCH 205/966] Rename check-names.py to check_names.py This is necessary to import check_names from other scripts, which will inevitably happen in the next few commits to implement the equivalent of `list-identifiers.sh --internal`. Signed-off-by: Yuto Takano --- tests/scripts/all.sh | 2 +- tests/scripts/{check-names.py => check_names.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/scripts/{check-names.py => check_names.py} (100%) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index efcb5543e1..cbb337ffac 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -733,7 +733,7 @@ component_check_changelog () { component_check_names () { msg "Check: declared and exported names (builds the library)" # < 3s - record_status tests/scripts/check-names.py -v + record_status tests/scripts/check_names.py -v } component_check_test_cases () { diff --git a/tests/scripts/check-names.py b/tests/scripts/check_names.py similarity index 100% rename from tests/scripts/check-names.py rename to tests/scripts/check_names.py From 977e07f5c8248cc27c36035685ba82faee0ac01a Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 11:56:15 +0100 Subject: [PATCH 206/966] Use glob in get_files(), call setup_logger on init glob is more flexible and simplifies the function arguments drastically. It is also much more intuitive to extend in the future when the filepaths need to be extended or changed. setup_logger had to be called as the first thing after instantiation, so this commit simplify makes it automatic. Several clarification comments are added too. Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 66 +++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 5fe85b7bd6..c129def4ed 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -33,6 +33,7 @@ subprocess error. Must be run from Mbed TLS root. """ import argparse +import glob import textwrap import os import sys @@ -177,13 +178,19 @@ class Typo(Problem): # pylint: disable=too-few-public-methods class NameCheck(): """ Representation of the core name checking operation performed by this script. - Shares a common logger, common excluded filenames, and a shared return_code. + Shares a common logger, and a shared return code. """ - def __init__(self): + def __init__(self, verbose=False): self.log = None self.check_repo_path() self.return_code = 0 + + self.setup_logger(verbose) + + # Globally excluded filenames self.excluded_files = ["bn_mul", "compat-2.x.h"] + + # Will contain the parse result after a comprehensive parse self.parse_result = {} def set_return_code(self, return_code): @@ -213,30 +220,30 @@ class NameCheck(): self.log.setLevel(logging.INFO) self.log.addHandler(logging.StreamHandler()) - def get_files(self, extension, directory): + def get_files(self, wildcard): """ - Get all files that end with .extension in the specified directory - recursively. + Get all files that match a UNIX-style wildcard recursively. While the + script is designed only for use on UNIX/macOS (due to nm), this function + would work fine on Windows even with forward slashes in the wildcard. Args: - * extension: the file extension to search for, without the dot - * directory: the directory to recursively search for + * wildcard: shell-style wildcards to match filepaths against. Returns a List of relative filepaths. """ - filenames = [] - for root, _, files in sorted(os.walk(directory)): - for filename in sorted(files): - if (filename not in self.excluded_files and - filename.endswith("." + extension)): - filenames.append(os.path.join(root, filename)) - return filenames + accumulator = [] + + for filepath in glob.iglob(wildcard, recursive=True): + if os.path.basename(filepath) not in self.excluded_files: + accumulator.append(filepath) + return accumulator def parse_names_in_source(self): """ - Calls each parsing function to retrieve various elements of the code, - together with their source location. Puts the parsed values in the - internal variable self.parse_result. + Comprehensive function to call each parsing function and retrieve + various elements of the code, together with their source location. + Puts the parsed values in the internal variable self.parse_result, so + they can be used from perform_checks(). """ self.log.info("Parsing source code...") self.log.debug( @@ -244,13 +251,13 @@ class NameCheck(): .format(str(self.excluded_files)) ) - m_headers = self.get_files("h", os.path.join("include", "mbedtls")) - p_headers = self.get_files("h", os.path.join("include", "psa")) + m_headers = self.get_files("include/mbedtls/*.h") + p_headers = self.get_files("include/psa/*.h") t_headers = ["3rdparty/everest/include/everest/everest.h", "3rdparty/everest/include/everest/x25519.h"] - d_headers = self.get_files("h", os.path.join("tests", "include", "test", "drivers")) - l_headers = self.get_files("h", "library") - libraries = self.get_files("c", "library") + [ + d_headers = self.get_files("tests/include/test/drivers/*.h") + l_headers = self.get_files("library/*.h") + libraries = self.get_files("library/*.c") + [ "3rdparty/everest/library/everest.c", "3rdparty/everest/library/x25519.c"] @@ -589,6 +596,7 @@ class NameCheck(): """ Perform each check in order, output its PASS/FAIL status. Maintain an overall test status, and output that at the end. + Assumes parse_names_in_source() was called before this. Args: * quiet: whether to hide detailed problem explanation. @@ -620,6 +628,7 @@ class NameCheck(): """ Perform a check that all detected symbols in the library object files are properly declared in headers. + Assumes parse_names_in_source() was called before this. Args: * quiet: whether to hide detailed problem explanation. @@ -645,6 +654,7 @@ class NameCheck(): def check_match_pattern(self, quiet, group_to_check, check_pattern): """ Perform a check that all items of a group conform to a regex pattern. + Assumes parse_names_in_source() was called before this. Args: * quiet: whether to hide detailed problem explanation. @@ -674,6 +684,7 @@ class NameCheck(): """ Perform a check that all words in the soure code beginning with MBED are either defined as macros, or as enum constants. + Assumes parse_names_in_source() was called before this. Args: * quiet: whether to hide detailed problem explanation. @@ -725,7 +736,7 @@ def main(): Perform argument parsing, and create an instance of NameCheck to begin the core operation. """ - parser = argparse.ArgumentParser( + argparser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description=( "This script confirms that the naming of all symbols and identifiers " @@ -733,19 +744,18 @@ def main(): "self-consistent.\n\n" "Expected to be run from the MbedTLS root directory.")) - parser.add_argument("-v", "--verbose", + argparser.add_argument("-v", "--verbose", action="store_true", help="show parse results") - parser.add_argument("-q", "--quiet", + argparser.add_argument("-q", "--quiet", action="store_true", help="hide unnecessary text, explanations, and highlighs") - args = parser.parse_args() + args = argparser.parse_args() try: - name_check = NameCheck() - name_check.setup_logger(verbose=args.verbose) + name_check = NameCheck(verbose=args.verbose) name_check.parse_names_in_source() name_check.perform_checks(quiet=args.quiet) sys.exit(name_check.return_code) From 68d241211b4e18334f0e959204888a07c790cade Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 12:10:31 +0100 Subject: [PATCH 207/966] Create list_internal_identifiers.py This is the equivalent of `list-identifiers.sh --internal`, which is useful for generating an exclusion file for ABI/API checking. Signed-off-by: Yuto Takano --- tests/scripts/list_internal_identifiers.py | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 tests/scripts/list_internal_identifiers.py diff --git a/tests/scripts/list_internal_identifiers.py b/tests/scripts/list_internal_identifiers.py new file mode 100755 index 0000000000..d58cb3f051 --- /dev/null +++ b/tests/scripts/list_internal_identifiers.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +This script generates a file called _identifiers that contains all Mbed TLS +identifiers found on internal headers. This is the equivalent of what was +previously `list-identifiers.sh --internal`, and is useful for generating an +exclusion file list for ABI/API checking, since we do not promise compatibility +for them. + +It uses the NameCeck class from check_names.py to perform the parsing. + +Returns 0 on success, 1 if there is a script error. +Must be run from Mbed TLS root. +""" + +import argparse +import traceback +import sys +from check_names import NameCheck + +def main(): + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description=( + "This script writes a list of parsed identifiers in internal " + "headers to \"_identifiers\". This is useful for generating a list " + "of names to exclude from ABI checking. ")) + + parser.parse_args() + + try: + name_check = NameCheck() + internal_headers = ( + name_check.get_files("include/mbedtls/*_internal.h") + + name_check.get_files("library/*.h") + ) + + result = name_check.parse_identifiers(internal_headers) + + identifiers = ["{}\n".format(match.name) for match in result] + with open("_identifiers", "w", encoding="utf-8") as f: + f.writelines(identifiers) + + except Exception: # pylint: disable=broad-except + traceback.print_exc() + sys.exit(1) + +if __name__ == "__main__": + main() From d70d446d6925f24872c751038431db66df47b47b Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 12:45:51 +0100 Subject: [PATCH 208/966] Improve code style consistency in check_names.py Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 236 ++++++++++++++++++++--------------- 1 file changed, 133 insertions(+), 103 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index c129def4ed..32eac3c749 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -81,11 +81,9 @@ class Match(): # pylint: disable=too-few-public-methods class Problem(): # pylint: disable=too-few-public-methods """ A parent class representing a form of static analysis error. - - Fields: - * textwrapper: a TextWrapper instance to format problems nicely. """ def __init__(self): + self.quiet = False self.textwrapper = textwrap.TextWrapper() self.textwrapper.width = 80 self.textwrapper.initial_indent = " > " @@ -100,9 +98,8 @@ class SymbolNotInHeader(Problem): # pylint: disable=too-few-public-methods Fields: * symbol_name: the name of the symbol. """ - def __init__(self, symbol_name, quiet=False): + def __init__(self, symbol_name): self.symbol_name = symbol_name - self.quiet = quiet Problem.__init__(self) def __str__(self): @@ -123,19 +120,17 @@ class PatternMismatch(Problem): # pylint: disable=too-few-public-methods * pattern: the expected regex pattern * match: the Match object in question """ - def __init__(self, pattern, match, quiet=False): + def __init__(self, pattern, match): self.pattern = pattern self.match = match - self.quiet = quiet Problem.__init__(self) def __str__(self): if self.quiet: - return ("{0}:{1}:{3}" - .format( - self.match.filename, - self.match.pos[0], - self.match.name)) + return ( + "{0}:{1}:{3}" + .format(self.match.filename, self.match.pos[0], self.match.name) + ) return self.textwrapper.fill( "{0}:{1}: '{2}' does not match the required pattern '{3}'." @@ -143,7 +138,9 @@ class PatternMismatch(Problem): # pylint: disable=too-few-public-methods self.match.filename, self.match.pos[0], self.match.name, - self.pattern)) + "\n" + str(self.match) + self.pattern + ) + ) + "\n" + str(self.match) class Typo(Problem): # pylint: disable=too-few-public-methods """ @@ -153,27 +150,23 @@ class Typo(Problem): # pylint: disable=too-few-public-methods Fields: * match: the Match object of the MBED name in question. """ - def __init__(self, match, quiet=False): + def __init__(self, match): self.match = match - self.quiet = quiet Problem.__init__(self) def __str__(self): if self.quiet: - return ("{0}:{1}:{2}" - .format( - self.match.filename, - self.match.pos[0], - self.match.name)) + return ( + "{0}:{1}:{2}" + .format(self.match.filename, self.match.pos[0], self.match.name) + ) return self.textwrapper.fill( "{0}:{1}: '{2}' looks like a typo. It was not found in any " "macros or any enums. If this is not a typo, put " "//no-check-names after it." - .format( - self.match.filename, - self.match.pos[0], - self.match.name)) + "\n" + str(self.match) + .format(self.match.filename, self.match.pos[0], self.match.name) + ) + "\n" + str(self.match) class NameCheck(): """ @@ -184,7 +177,6 @@ class NameCheck(): self.log = None self.check_repo_path() self.return_code = 0 - self.setup_logger(verbose) # Globally excluded filenames @@ -193,11 +185,6 @@ class NameCheck(): # Will contain the parse result after a comprehensive parse self.parse_result = {} - def set_return_code(self, return_code): - if return_code > self.return_code: - self.log.debug("Setting new return code to {}".format(return_code)) - self.return_code = return_code - @staticmethod def check_repo_path(): """ @@ -207,6 +194,11 @@ class NameCheck(): if not all(os.path.isdir(d) for d in ["include", "library", "tests"]): raise Exception("This script must be run from Mbed TLS root") + def set_return_code(self, return_code): + if return_code > self.return_code: + self.log.debug("Setting new return code to {}".format(return_code)) + self.return_code = return_code + def setup_logger(self, verbose=False): """ Set up a logger and set the change the default logging level from @@ -247,28 +239,35 @@ class NameCheck(): """ self.log.info("Parsing source code...") self.log.debug( - "The following files are excluded from the search: {}" + "The following filenames are excluded from the search: {}" .format(str(self.excluded_files)) ) m_headers = self.get_files("include/mbedtls/*.h") p_headers = self.get_files("include/psa/*.h") - t_headers = ["3rdparty/everest/include/everest/everest.h", - "3rdparty/everest/include/everest/x25519.h"] + t_headers = [ + "3rdparty/everest/include/everest/everest.h", + "3rdparty/everest/include/everest/x25519.h" + ] d_headers = self.get_files("tests/include/test/drivers/*.h") l_headers = self.get_files("library/*.h") libraries = self.get_files("library/*.c") + [ "3rdparty/everest/library/everest.c", - "3rdparty/everest/library/x25519.c"] + "3rdparty/everest/library/x25519.c" + ] all_macros = self.parse_macros( - m_headers + p_headers + t_headers + l_headers + d_headers) + m_headers + p_headers + t_headers + l_headers + d_headers + ) enum_consts = self.parse_enum_consts( - m_headers + l_headers + t_headers) + m_headers + l_headers + t_headers + ) identifiers = self.parse_identifiers( - m_headers + p_headers + t_headers + l_headers) + m_headers + p_headers + t_headers + l_headers + ) mbed_words = self.parse_mbed_words( - m_headers + p_headers + t_headers + l_headers + libraries) + m_headers + p_headers + t_headers + l_headers + libraries + ) symbols = self.parse_symbols() # Remove identifier macros like mbedtls_printf or mbedtls_calloc @@ -279,7 +278,7 @@ class NameCheck(): actual_macros.append(macro) self.log.debug("Found:") - self.log.debug(" {} Macros".format(len(all_macros))) + self.log.debug(" {} Total Macros".format(len(all_macros))) self.log.debug(" {} Non-identifier Macros".format(len(actual_macros))) self.log.debug(" {} Enum Constants".format(len(enum_consts))) self.log.debug(" {} Identifiers".format(len(identifiers))) @@ -294,12 +293,12 @@ class NameCheck(): "mbed_words": mbed_words } - def parse_macros(self, header_files): + def parse_macros(self, files): """ Parse all macros defined by #define preprocessor directives. Args: - * header_files: A List of filepaths to look through. + * files: A List of filepaths to look through. Returns a List of Match objects for the found macros. """ @@ -308,20 +307,22 @@ class NameCheck(): "asm", "inline", "EMIT", "_CRT_SECURE_NO_DEPRECATE", "MULADDC_" ) - self.log.debug("Looking for macros in {} files".format(len(header_files))) + self.log.debug("Looking for macros in {} files".format(len(files))) macros = [] - for header_file in header_files: + for header_file in files: with open(header_file, "r", encoding="utf-8") as header: for line_no, line in enumerate(header): for macro in macro_regex.finditer(line): - if not macro.group("macro").startswith(exclusions): - macros.append(Match( - header_file, - line, - (line_no, macro.start(), macro.end()), - macro.group("macro"))) + if macro.group("macro").startswith(exclusions): + continue + + macros.append(Match( + header_file, + line, + (line_no, macro.start(), macro.end()), + macro.group("macro"))) return macros @@ -359,20 +360,23 @@ class NameCheck(): return mbed_words - def parse_enum_consts(self, header_files): + def parse_enum_consts(self, files): """ Parse all enum value constants that are declared. Args: - * header_files: A List of filepaths to look through. + * files: A List of filepaths to look through. Returns a List of Match objects for the findings. """ - self.log.debug("Looking for enum consts in {} files".format(len(header_files))) + self.log.debug( + "Looking for enum consts in {} files" + .format(len(files)) + ) enum_consts = [] - for header_file in header_files: + for header_file in files: # Emulate a finite state machine to parse enum declarations. # 0 = not in enum # 1 = inside enum @@ -393,22 +397,26 @@ class NameCheck(): state = 0 elif state == 1 and not re.match(r" *#", line): enum_const = re.match(r" *(?P\w+)", line) - if enum_const: - enum_consts.append(Match( - header_file, - line, - (line_no, enum_const.start(), enum_const.end()), - enum_const.group("enum_const"))) + if not enum_const: + continue + + enum_consts.append(Match( + header_file, + line, + (line_no, enum_const.start(), enum_const.end()), + enum_const.group("enum_const"))) return enum_consts - def parse_identifiers(self, header_files): + def parse_identifiers(self, files): """ Parse all lines of a header where a function identifier is declared, based on some huersitics. Highly dependent on formatting style. + Note: .match() checks at the beginning of the string (implicit ^), while + .search() checks throughout. Args: - * header_files: A List of filepaths to look through. + * files: A List of filepaths to look through. Returns a List of Match objects with identifiers. """ @@ -425,23 +433,31 @@ class NameCheck(): # Match names of named data structures. r"(?:typedef +)?(?:struct|union|enum) +(\w+)(?: *{)?$|" # Match names of typedef instances, after closing bracket. - r"}? *(\w+)[;[].*") - exclusion_lines = re.compile(r"^(" - r"extern +\"C\"|" - r"(typedef +)?(struct|union|enum)( *{)?$|" - r"} *;?$|" - r"$|" - r"//|" - r"#" - r")") + r"}? *(\w+)[;[].*" + ) + exclusion_lines = re.compile( + r"^(" + r"extern +\"C\"|" + r"(typedef +)?(struct|union|enum)( *{)?$|" + r"} *;?$|" + r"$|" + r"//|" + r"#" + r")" + ) - self.log.debug("Looking for identifiers in {} files".format(len(header_files))) + self.log.debug( + "Looking for identifiers in {} files" + .format(len(files)) + ) identifiers = [] - for header_file in header_files: + for header_file in files: with open(header_file, "r", encoding="utf-8") as header: in_block_comment = False + # The previous line varibale is used for concatenating lines + # when identifiers are formatted and spread across multiple. previous_line = "" for line_no, line in enumerate(header): @@ -484,15 +500,19 @@ class NameCheck(): identifier = identifier_regex.search(line) - if identifier: - # Find the group that matched, and append it - for group in identifier.groups(): - if group: - identifiers.append(Match( - header_file, - line, - (line_no, identifier.start(), identifier.end()), - group)) + if not identifier: + continue + + # Find the group that matched, and append it + for group in identifier.groups(): + if not group: + continue + + identifiers.append(Match( + header_file, + line, + (line_no, identifier.start(), identifier.end()), + group)) return identifiers @@ -510,8 +530,10 @@ class NameCheck(): symbols = [] # Back up the config and atomically compile with the full configratuion. - shutil.copy("include/mbedtls/mbedtls_config.h", - "include/mbedtls/mbedtls_config.h.bak") + shutil.copy( + "include/mbedtls/mbedtls_config.h", + "include/mbedtls/mbedtls_config.h.bak" + ) try: # Use check=True in all subprocess calls so that failures are raised # as exceptions and logged. @@ -532,10 +554,11 @@ class NameCheck(): ) # Perform object file analysis using nm - symbols = self.parse_symbols_from_nm( - ["library/libmbedcrypto.a", - "library/libmbedtls.a", - "library/libmbedx509.a"]) + symbols = self.parse_symbols_from_nm([ + "library/libmbedcrypto.a", + "library/libmbedtls.a", + "library/libmbedx509.a" + ]) subprocess.run( ["make", "clean"], @@ -549,8 +572,10 @@ class NameCheck(): finally: # Put back the original config regardless of there being errors. # Works also for keyboard interrupts. - shutil.move("include/mbedtls/mbedtls_config.h.bak", - "include/mbedtls/mbedtls_config.h") + shutil.move( + "include/mbedtls/mbedtls_config.h.bak", + "include/mbedtls/mbedtls_config.h" + ) return symbols @@ -606,9 +631,11 @@ class NameCheck(): problems += self.check_symbols_declared_in_header(quiet) - pattern_checks = [("macros", MACRO_PATTERN), - ("enum_consts", CONSTANTS_PATTERN), - ("identifiers", IDENTIFIER_PATTERN)] + pattern_checks = [ + ("macros", MACRO_PATTERN), + ("enum_consts", CONSTANTS_PATTERN), + ("identifiers", IDENTIFIER_PATTERN) + ] for group, check_pattern in pattern_checks: problems += self.check_match_pattern(quiet, group, check_pattern) @@ -645,12 +672,11 @@ class NameCheck(): break if not found_symbol_declared: - problems.append(SymbolNotInHeader(symbol, quiet=quiet)) + problems.append(SymbolNotInHeader(symbol)) - self.output_check_result("All symbols in header", problems) + self.output_check_result(quiet, "All symbols in header", problems) return len(problems) - def check_match_pattern(self, quiet, group_to_check, check_pattern): """ Perform a check that all items of a group conform to a regex pattern. @@ -670,12 +696,10 @@ class NameCheck(): problems.append(PatternMismatch(check_pattern, item_match)) # Double underscore is a reserved identifier, never to be used if re.match(r".*__.*", item_match.name): - problems.append(PatternMismatch( - "double underscore", - item_match, - quiet=quiet)) + problems.append(PatternMismatch("double underscore", item_match)) self.output_check_result( + quiet, "Naming patterns of {}".format(group_to_check), problems) return len(problems) @@ -693,7 +717,7 @@ class NameCheck(): """ problems = [] - # Set comprehension, equivalent to a list comprehension inside set() + # Set comprehension, equivalent to a list comprehension wrapped by set() all_caps_names = { match.name for match @@ -713,20 +737,26 @@ class NameCheck(): "MBEDTLS_PSA_BUILTIN_") in all_caps_names if not found and not typo_exclusion.search(name_match.name): - problems.append(Typo(name_match, quiet=quiet)) + problems.append(Typo(name_match)) - self.output_check_result("Likely typos", problems) + self.output_check_result(quiet, "Likely typos", problems) return len(problems) - def output_check_result(self, name, problems): + def output_check_result(self, quiet, name, problems): """ Write out the PASS/FAIL status of a performed check depending on whether there were problems. + + Args: + * quiet: whether to hide detailed problem explanation. + * name: the name of the test + * problems: a List of encountered Problems """ if problems: self.set_return_code(1) self.log.info("{}: FAIL\n".format(name)) for problem in problems: + problem.quiet = quiet self.log.warning(str(problem)) else: self.log.info("{}: PASS".format(name)) From f005c3369ac17be7860e4256ff2d497354d12338 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 13:56:36 +0100 Subject: [PATCH 209/966] Change variable name argparser to parser Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 32eac3c749..ce03b8a661 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -766,23 +766,26 @@ def main(): Perform argument parsing, and create an instance of NameCheck to begin the core operation. """ - argparser = argparse.ArgumentParser( + parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description=( "This script confirms that the naming of all symbols and identifiers " "in Mbed TLS are consistent with the house style and are also " "self-consistent.\n\n" - "Expected to be run from the MbedTLS root directory.")) + "Expected to be run from the MbedTLS root directory.") + ) + parser.add_argument( + "-v", "--verbose", + action="store_true", + help="show parse results" + ) + parser.add_argument( + "-q", "--quiet", + action="store_true", + help="hide unnecessary text, explanations, and highlighs" + ) - argparser.add_argument("-v", "--verbose", - action="store_true", - help="show parse results") - - argparser.add_argument("-q", "--quiet", - action="store_true", - help="hide unnecessary text, explanations, and highlighs") - - args = argparser.parse_args() + args = parser.parse_args() try: name_check = NameCheck(verbose=args.verbose) From 8e9a219310b498465cbf172e239e81317850118f Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 14:48:53 +0100 Subject: [PATCH 210/966] Improve ease of specifying which files to look in (check_names) - Instead of os.path.join, use glob patterns (supports Windows too) - Instead of creating the lists beforehand (which adds messiness), pass glob expessions to functions and let them memoise it. - Add support for excluding based on glob patterns, which isn't used now but could come in handy. Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 140 ++++++++++++--------- tests/scripts/list_internal_identifiers.py | 10 +- 2 files changed, 84 insertions(+), 66 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index ce03b8a661..37a8be325d 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -179,8 +179,11 @@ class NameCheck(): self.return_code = 0 self.setup_logger(verbose) + # Memo for storing "glob expression": set(filepaths) + self.files = {} + # Globally excluded filenames - self.excluded_files = ["bn_mul", "compat-2.x.h"] + self.excluded_files = ["**/bn_mul", "**/compat-2.x.h"] # Will contain the parse result after a comprehensive parse self.parse_result = {} @@ -212,23 +215,46 @@ class NameCheck(): self.log.setLevel(logging.INFO) self.log.addHandler(logging.StreamHandler()) - def get_files(self, wildcard): + def get_files(self, include_wildcards, exclude_wildcards): """ - Get all files that match a UNIX-style wildcard recursively. While the - script is designed only for use on UNIX/macOS (due to nm), this function - would work fine on Windows even with forward slashes in the wildcard. + Get all files that match any of the UNIX-style wildcards. While the + check_names script is designed only for use on UNIX/macOS (due to nm), + this function alone would work fine on Windows even with forward slashes + in the wildcard. Args: - * wildcard: shell-style wildcards to match filepaths against. + * include_wildcards: a List of shell-style wildcards to match filepaths. + * exclude_wildacrds: a List of shell-style wildcards to exclude. Returns a List of relative filepaths. """ - accumulator = [] + accumulator = set() - for filepath in glob.iglob(wildcard, recursive=True): - if os.path.basename(filepath) not in self.excluded_files: - accumulator.append(filepath) - return accumulator + # exclude_wildcards may be None. Also, consider the global exclusions. + exclude_wildcards = (exclude_wildcards or []) + self.excluded_files + + # Perform set union on the glob results. Memoise individual sets. + for include_wildcard in include_wildcards: + if include_wildcard not in self.files: + self.files[include_wildcard] = set(glob.glob( + include_wildcard, + recursive=True + )) + + accumulator = accumulator.union(self.files[include_wildcard]) + + # Perform set difference to exclude. Also use the same memo since their + # behaviour is pretty much identical and it can benefit from the cache. + for exclude_wildcard in exclude_wildcards: + if exclude_wildcard not in self.files: + self.files[exclude_wildcard] = set(glob.glob( + exclude_wildcard, + recursive=True + )) + + accumulator = accumulator.difference(self.files[exclude_wildcard]) + + return list(accumulator) def parse_names_in_source(self): """ @@ -243,31 +269,37 @@ class NameCheck(): .format(str(self.excluded_files)) ) - m_headers = self.get_files("include/mbedtls/*.h") - p_headers = self.get_files("include/psa/*.h") - t_headers = [ + all_macros = self.parse_macros([ + "include/mbedtls/*.h", + "include/psa/*.h", + "library/*.h", + "tests/include/test/drivers/*.h", "3rdparty/everest/include/everest/everest.h", "3rdparty/everest/include/everest/x25519.h" - ] - d_headers = self.get_files("tests/include/test/drivers/*.h") - l_headers = self.get_files("library/*.h") - libraries = self.get_files("library/*.c") + [ + ]) + enum_consts = self.parse_enum_consts([ + "include/mbedtls/*.h", + "library/*.h", + "3rdparty/everest/include/everest/everest.h", + "3rdparty/everest/include/everest/x25519.h" + ]) + identifiers = self.parse_identifiers([ + "include/mbedtls/*.h", + "include/psa/*.h", + "library/*.h", + "3rdparty/everest/include/everest/everest.h", + "3rdparty/everest/include/everest/x25519.h" + ]) + mbed_words = self.parse_mbed_words([ + "include/mbedtls/*.h", + "include/psa/*.h", + "library/*.h", + "3rdparty/everest/include/everest/everest.h", + "3rdparty/everest/include/everest/x25519.h", + "library/*.c", "3rdparty/everest/library/everest.c", "3rdparty/everest/library/x25519.c" - ] - - all_macros = self.parse_macros( - m_headers + p_headers + t_headers + l_headers + d_headers - ) - enum_consts = self.parse_enum_consts( - m_headers + l_headers + t_headers - ) - identifiers = self.parse_identifiers( - m_headers + p_headers + t_headers + l_headers - ) - mbed_words = self.parse_mbed_words( - m_headers + p_headers + t_headers + l_headers + libraries - ) + ]) symbols = self.parse_symbols() # Remove identifier macros like mbedtls_printf or mbedtls_calloc @@ -284,7 +316,6 @@ class NameCheck(): self.log.debug(" {} Identifiers".format(len(identifiers))) self.log.debug(" {} Exported Symbols".format(len(symbols))) self.log.info("Analysing...") - self.parse_result = { "macros": actual_macros, "enum_consts": enum_consts, @@ -293,12 +324,13 @@ class NameCheck(): "mbed_words": mbed_words } - def parse_macros(self, files): + def parse_macros(self, include, exclude=None): """ Parse all macros defined by #define preprocessor directives. Args: - * files: A List of filepaths to look through. + * include: A List of glob expressions to look for files through. + * exclude: A List of glob expressions for excluding files. Returns a List of Match objects for the found macros. """ @@ -307,11 +339,9 @@ class NameCheck(): "asm", "inline", "EMIT", "_CRT_SECURE_NO_DEPRECATE", "MULADDC_" ) - self.log.debug("Looking for macros in {} files".format(len(files))) - macros = [] - for header_file in files: + for header_file in self.get_files(include, exclude): with open(header_file, "r", encoding="utf-8") as header: for line_no, line in enumerate(header): for macro in macro_regex.finditer(line): @@ -326,13 +356,14 @@ class NameCheck(): return macros - def parse_mbed_words(self, files): + def parse_mbed_words(self, include, exclude=None): """ Parse all words in the file that begin with MBED, in and out of macros, comments, anything. Args: - * files: a List of filepaths to look through. + * include: A List of glob expressions to look for files through. + * exclude: A List of glob expressions for excluding files. Returns a List of Match objects for words beginning with MBED. """ @@ -340,11 +371,9 @@ class NameCheck(): mbed_regex = re.compile(r"\bMBED.+?_[A-Z0-9_]*") exclusions = re.compile(r"// *no-check-names|#error") - self.log.debug("Looking for MBED names in {} files".format(len(files))) - mbed_words = [] - for filename in files: + for filename in self.get_files(include, exclude): with open(filename, "r", encoding="utf-8") as fp: for line_no, line in enumerate(fp): if exclusions.search(line): @@ -360,23 +389,19 @@ class NameCheck(): return mbed_words - def parse_enum_consts(self, files): + def parse_enum_consts(self, include, exclude=None): """ Parse all enum value constants that are declared. Args: - * files: A List of filepaths to look through. + * include: A List of glob expressions to look for files through. + * exclude: A List of glob expressions for excluding files. Returns a List of Match objects for the findings. """ - self.log.debug( - "Looking for enum consts in {} files" - .format(len(files)) - ) - enum_consts = [] - for header_file in files: + for header_file in self.get_files(include, exclude): # Emulate a finite state machine to parse enum declarations. # 0 = not in enum # 1 = inside enum @@ -408,7 +433,7 @@ class NameCheck(): return enum_consts - def parse_identifiers(self, files): + def parse_identifiers(self, include, exclude=None): """ Parse all lines of a header where a function identifier is declared, based on some huersitics. Highly dependent on formatting style. @@ -416,7 +441,8 @@ class NameCheck(): .search() checks throughout. Args: - * files: A List of filepaths to look through. + * include: A List of glob expressions to look for files through. + * exclude: A List of glob expressions for excluding files. Returns a List of Match objects with identifiers. """ @@ -445,15 +471,9 @@ class NameCheck(): r"#" r")" ) - - self.log.debug( - "Looking for identifiers in {} files" - .format(len(files)) - ) - identifiers = [] - for header_file in files: + for header_file in self.get_files(include, exclude): with open(header_file, "r", encoding="utf-8") as header: in_block_comment = False # The previous line varibale is used for concatenating lines diff --git a/tests/scripts/list_internal_identifiers.py b/tests/scripts/list_internal_identifiers.py index d58cb3f051..75b1646aa1 100755 --- a/tests/scripts/list_internal_identifiers.py +++ b/tests/scripts/list_internal_identifiers.py @@ -45,12 +45,10 @@ def main(): try: name_check = NameCheck() - internal_headers = ( - name_check.get_files("include/mbedtls/*_internal.h") + - name_check.get_files("library/*.h") - ) - - result = name_check.parse_identifiers(internal_headers) + result = name_check.parse_identifiers([ + "include/mbedtls/*_internal.h", + "library/*.h" + ]) identifiers = ["{}\n".format(match.name) for match in result] with open("_identifiers", "w", encoding="utf-8") as f: From 50953433a440dc0c2d377d0bc0289716a92d2edd Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 14:54:36 +0100 Subject: [PATCH 211/966] Bring back logging of number of files Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 37a8be325d..9a7f3918e6 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -265,7 +265,7 @@ class NameCheck(): """ self.log.info("Parsing source code...") self.log.debug( - "The following filenames are excluded from the search: {}" + "The following files are excluded from the search: {}" .format(str(self.excluded_files)) ) @@ -339,9 +339,11 @@ class NameCheck(): "asm", "inline", "EMIT", "_CRT_SECURE_NO_DEPRECATE", "MULADDC_" ) - macros = [] + files = self.get_files(include, exclude) + self.log.debug("Looking for macros in {} files".format(len(files))) - for header_file in self.get_files(include, exclude): + macros = [] + for header_file in files: with open(header_file, "r", encoding="utf-8") as header: for line_no, line in enumerate(header): for macro in macro_regex.finditer(line): @@ -371,9 +373,11 @@ class NameCheck(): mbed_regex = re.compile(r"\bMBED.+?_[A-Z0-9_]*") exclusions = re.compile(r"// *no-check-names|#error") - mbed_words = [] + files = self.get_files(include, exclude) + self.log.debug("Looking for MBED words in {} files".format(len(files))) - for filename in self.get_files(include, exclude): + mbed_words = [] + for filename in files: with open(filename, "r", encoding="utf-8") as fp: for line_no, line in enumerate(fp): if exclusions.search(line): @@ -399,9 +403,11 @@ class NameCheck(): Returns a List of Match objects for the findings. """ - enum_consts = [] + files = self.get_files(include, exclude) + self.log.debug("Looking for enum consts in {} files".format(len(files))) - for header_file in self.get_files(include, exclude): + enum_consts = [] + for header_file in files: # Emulate a finite state machine to parse enum declarations. # 0 = not in enum # 1 = inside enum @@ -471,9 +477,12 @@ class NameCheck(): r"#" r")" ) - identifiers = [] - for header_file in self.get_files(include, exclude): + files = self.get_files(include, exclude) + self.log.debug("Looking for identifiers in {} files".format(len(files))) + + identifiers = [] + for header_file in files: with open(header_file, "r", encoding="utf-8") as header: in_block_comment = False # The previous line varibale is used for concatenating lines From 55c6c87d951823b31e353a6bad5d7cc2e7957557 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 15:35:19 +0100 Subject: [PATCH 212/966] Separate code parsing and name checking in two classes Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 191 +++++++++++---------- tests/scripts/list_internal_identifiers.py | 5 +- 2 files changed, 99 insertions(+), 97 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 9a7f3918e6..957701433a 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -20,16 +20,26 @@ This script confirms that the naming of all symbols and identifiers in Mbed TLS are consistent with the house style and are also self-consistent. It only runs on Linux and macOS since it depends on nm. -The script performs the following checks: +It contains two major Python classes, CodeParser and NameChecker. They both have +a comprehensive "run-all" function (comprehensive_parse() and perform_checks()) +but the individual functions can also be used for specific needs. + +CodeParser makes heavy use of regular expressions to parse the code, and is +dependent on the current code formatting. Many Python C parser libraries require +preprocessed C code, which means no macro parsing. Compiler tools are also not +very helpful when we want the exact location in the original source (which +becomes impossible when e.g. comments are stripped). + +NameChecker performs the following checks: - All exported and available symbols in the library object files, are explicitly declared in the header files. This uses the nm command. - All macros, constants, and identifiers (function names, struct names, etc) - follow the required pattern. + follow the required regex pattern. - Typo checking: All words that begin with MBED exist as macros or constants. -Returns 0 on success, 1 on test failure, and 2 if there is a script error or a -subprocess error. Must be run from Mbed TLS root. +The script returns 0 on success, 1 on test failure, and 2 if there is a script +error error. Must be run from Mbed TLS root. """ import argparse @@ -168,16 +178,15 @@ class Typo(Problem): # pylint: disable=too-few-public-methods .format(self.match.filename, self.match.pos[0], self.match.name) ) + "\n" + str(self.match) -class NameCheck(): +class CodeParser(): """ - Representation of the core name checking operation performed by this script. - Shares a common logger, and a shared return code. + Class for retrieving files and parsing the code. This can be used + independently of the checks that NameChecker performs, for example for + list_internal_identifiers.py. """ - def __init__(self, verbose=False): - self.log = None + def __init__(self, log): + self.log = log self.check_repo_path() - self.return_code = 0 - self.setup_logger(verbose) # Memo for storing "glob expression": set(filepaths) self.files = {} @@ -185,9 +194,6 @@ class NameCheck(): # Globally excluded filenames self.excluded_files = ["**/bn_mul", "**/compat-2.x.h"] - # Will contain the parse result after a comprehensive parse - self.parse_result = {} - @staticmethod def check_repo_path(): """ @@ -197,71 +203,12 @@ class NameCheck(): if not all(os.path.isdir(d) for d in ["include", "library", "tests"]): raise Exception("This script must be run from Mbed TLS root") - def set_return_code(self, return_code): - if return_code > self.return_code: - self.log.debug("Setting new return code to {}".format(return_code)) - self.return_code = return_code - - def setup_logger(self, verbose=False): + def comprehensive_parse(self): """ - Set up a logger and set the change the default logging level from - WARNING to INFO. Loggers are better than print statements since their - verbosity can be controlled. - """ - self.log = logging.getLogger() - if verbose: - self.log.setLevel(logging.DEBUG) - else: - self.log.setLevel(logging.INFO) - self.log.addHandler(logging.StreamHandler()) + Comprehensive ("default") function to call each parsing function and + retrieve various elements of the code, together with the source location. - def get_files(self, include_wildcards, exclude_wildcards): - """ - Get all files that match any of the UNIX-style wildcards. While the - check_names script is designed only for use on UNIX/macOS (due to nm), - this function alone would work fine on Windows even with forward slashes - in the wildcard. - - Args: - * include_wildcards: a List of shell-style wildcards to match filepaths. - * exclude_wildacrds: a List of shell-style wildcards to exclude. - - Returns a List of relative filepaths. - """ - accumulator = set() - - # exclude_wildcards may be None. Also, consider the global exclusions. - exclude_wildcards = (exclude_wildcards or []) + self.excluded_files - - # Perform set union on the glob results. Memoise individual sets. - for include_wildcard in include_wildcards: - if include_wildcard not in self.files: - self.files[include_wildcard] = set(glob.glob( - include_wildcard, - recursive=True - )) - - accumulator = accumulator.union(self.files[include_wildcard]) - - # Perform set difference to exclude. Also use the same memo since their - # behaviour is pretty much identical and it can benefit from the cache. - for exclude_wildcard in exclude_wildcards: - if exclude_wildcard not in self.files: - self.files[exclude_wildcard] = set(glob.glob( - exclude_wildcard, - recursive=True - )) - - accumulator = accumulator.difference(self.files[exclude_wildcard]) - - return list(accumulator) - - def parse_names_in_source(self): - """ - Comprehensive function to call each parsing function and retrieve - various elements of the code, together with their source location. - Puts the parsed values in the internal variable self.parse_result, so - they can be used from perform_checks(). + Returns a dict of parsed item key to the corresponding List of Matches. """ self.log.info("Parsing source code...") self.log.debug( @@ -315,8 +262,7 @@ class NameCheck(): self.log.debug(" {} Enum Constants".format(len(enum_consts))) self.log.debug(" {} Identifiers".format(len(identifiers))) self.log.debug(" {} Exported Symbols".format(len(symbols))) - self.log.info("Analysing...") - self.parse_result = { + return { "macros": actual_macros, "enum_consts": enum_consts, "identifiers": identifiers, @@ -324,6 +270,47 @@ class NameCheck(): "mbed_words": mbed_words } + def get_files(self, include_wildcards, exclude_wildcards): + """ + Get all files that match any of the UNIX-style wildcards. While the + check_names script is designed only for use on UNIX/macOS (due to nm), + this function alone would work fine on Windows even with forward slashes + in the wildcard. + + Args: + * include_wildcards: a List of shell-style wildcards to match filepaths. + * exclude_wildcards: a List of shell-style wildcards to exclude. + + Returns a List of relative filepaths. + """ + accumulator = set() + + # exclude_wildcards may be None. Also, consider the global exclusions. + exclude_wildcards = (exclude_wildcards or []) + self.excluded_files + + # Perform set union on the glob results. Memoise individual sets. + for include_wildcard in include_wildcards: + if include_wildcard not in self.files: + self.files[include_wildcard] = set(glob.glob( + include_wildcard, + recursive=True + )) + + accumulator = accumulator.union(self.files[include_wildcard]) + + # Perform set difference to exclude. Also use the same memo since their + # behaviour is pretty much identical and it can benefit from the cache. + for exclude_wildcard in exclude_wildcards: + if exclude_wildcard not in self.files: + self.files[exclude_wildcard] = set(glob.glob( + exclude_wildcard, + recursive=True + )) + + accumulator = accumulator.difference(self.files[exclude_wildcard]) + + return list(accumulator) + def parse_macros(self, include, exclude=None): """ Parse all macros defined by #define preprocessor directives. @@ -456,11 +443,11 @@ class NameCheck(): # Match " something(a" or " *something(a". Functions. # Assumptions: # - function definition from return type to one of its arguments is - # all on one line (enforced by the previous_line concat below) + # all on one line # - function definition line only contains alphanumeric, asterisk, # underscore, and open bracket r".* \**(\w+) *\( *\w|" - # Match "(*something)(". Flexible with spaces. + # Match "(*something)(". r".*\( *\* *(\w+) *\) *\(|" # Match names of named data structures. r"(?:typedef +)?(?:struct|union|enum) +(\w+)(?: *{)?$|" @@ -485,7 +472,7 @@ class NameCheck(): for header_file in files: with open(header_file, "r", encoding="utf-8") as header: in_block_comment = False - # The previous line varibale is used for concatenating lines + # The previous line variable is used for concatenating lines # when identifiers are formatted and spread across multiple. previous_line = "" @@ -596,7 +583,6 @@ class NameCheck(): ) except subprocess.CalledProcessError as error: self.log.debug(error.output) - self.set_return_code(2) raise error finally: # Put back the original config regardless of there being errors. @@ -614,7 +600,7 @@ class NameCheck(): Does not return the position data since it is of no use. Args: - * object_files: a List of compiled object files to search through. + * object_files: a List of compiled object filepaths to search through. Returns a List of unique symbols defined and used in any of the object files. @@ -646,18 +632,24 @@ class NameCheck(): return symbols +class NameChecker(): + """ + Representation of the core name checking operation performed by this script. + """ + def __init__(self, parse_result, log): + self.parse_result = parse_result + self.log = log + def perform_checks(self, quiet=False): """ - Perform each check in order, output its PASS/FAIL status. Maintain an - overall test status, and output that at the end. - Assumes parse_names_in_source() was called before this. + A comprehensive checker that performs each check in order, and outputs + a final verdict. Args: * quiet: whether to hide detailed problem explanation. """ self.log.info("=============") problems = 0 - problems += self.check_symbols_declared_in_header(quiet) pattern_checks = [ @@ -677,8 +669,10 @@ class NameCheck(): self.log.info("Remove --quiet to see explanations.") else: self.log.info("Use --quiet for minimal output.") + return 1 else: self.log.info("PASS") + return 0 def check_symbols_declared_in_header(self, quiet): """ @@ -782,7 +776,6 @@ class NameCheck(): * problems: a List of encountered Problems """ if problems: - self.set_return_code(1) self.log.info("{}: FAIL\n".format(name)) for problem in problems: problem.quiet = quiet @@ -792,8 +785,8 @@ class NameCheck(): def main(): """ - Perform argument parsing, and create an instance of NameCheck to begin the - core operation. + Perform argument parsing, and create an instance of CodeParser and + NameChecker to begin the core operation. """ parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, @@ -816,14 +809,22 @@ def main(): args = parser.parse_args() + # Configure the global logger, which is then passed to the classes below + log = logging.getLogger() + log.setLevel(logging.DEBUG if args.verbose else logging.INFO) + log.addHandler(logging.StreamHandler()) + try: - name_check = NameCheck(verbose=args.verbose) - name_check.parse_names_in_source() - name_check.perform_checks(quiet=args.quiet) - sys.exit(name_check.return_code) + code_parser = CodeParser(log) + parse_result = code_parser.comprehensive_parse() except Exception: # pylint: disable=broad-except traceback.print_exc() sys.exit(2) + name_checker = NameChecker(parse_result, log) + return_code = name_checker.perform_checks(quiet=args.quiet) + + sys.exit(return_code) + if __name__ == "__main__": main() diff --git a/tests/scripts/list_internal_identifiers.py b/tests/scripts/list_internal_identifiers.py index 75b1646aa1..64a4c3531b 100755 --- a/tests/scripts/list_internal_identifiers.py +++ b/tests/scripts/list_internal_identifiers.py @@ -29,9 +29,10 @@ Must be run from Mbed TLS root. """ import argparse +import logging import traceback import sys -from check_names import NameCheck +from check_names import CodeParser def main(): parser = argparse.ArgumentParser( @@ -44,7 +45,7 @@ def main(): parser.parse_args() try: - name_check = NameCheck() + name_check = CodeParser(logging.getLogger()) result = name_check.parse_identifiers([ "include/mbedtls/*_internal.h", "library/*.h" From 7bfac1d7fe9bc5c13a55e87a2352ea44b88cba84 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 9 Aug 2021 15:49:25 +0100 Subject: [PATCH 213/966] Fix incorrect reference to NameCheck in script docstring Signed-off-by: Yuto Takano --- tests/scripts/list_internal_identifiers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/scripts/list_internal_identifiers.py b/tests/scripts/list_internal_identifiers.py index 64a4c3531b..822486ae42 100755 --- a/tests/scripts/list_internal_identifiers.py +++ b/tests/scripts/list_internal_identifiers.py @@ -22,9 +22,9 @@ previously `list-identifiers.sh --internal`, and is useful for generating an exclusion file list for ABI/API checking, since we do not promise compatibility for them. -It uses the NameCeck class from check_names.py to perform the parsing. +It uses the CodeParser class from check_names.py to perform the parsing. -Returns 0 on success, 1 if there is a script error. +The script returns 0 on success, 1 if there is a script error. Must be run from Mbed TLS root. """ @@ -40,7 +40,7 @@ def main(): description=( "This script writes a list of parsed identifiers in internal " "headers to \"_identifiers\". This is useful for generating a list " - "of names to exclude from ABI checking. ")) + "of names to exclude from API/ABI compatibility checking. ")) parser.parse_args() From b6bbbb174da33a860b5556e989e334f8d7eee7b3 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Aug 2021 09:00:14 +0100 Subject: [PATCH 214/966] Fix typo in documentation of ssl->transform_out Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 221cee3379..639e3d962a 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1329,7 +1329,7 @@ struct mbedtls_ssl_context * Record layer transformations */ mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_in); /*!< current transform params (in) */ - mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_out); /*!< current transform params (in) */ + mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_out); /*!< current transform params (out) */ mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform); /*!< negotiated transform params */ mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_negotiate); /*!< transform params in negotiation */ From 0e719ff34144a71d60e1c4e14d63565cb15673bf Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Aug 2021 09:24:08 +0100 Subject: [PATCH 215/966] Improve the documentation of legacy msg layer transforms Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 639e3d962a..dc4782e65b 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1328,10 +1328,18 @@ struct mbedtls_ssl_context /* * Record layer transformations */ - mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_in); /*!< current transform params (in) */ - mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_out); /*!< current transform params (out) */ - mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform); /*!< negotiated transform params */ - mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_negotiate); /*!< transform params in negotiation */ + mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_in); /*!< current transform params (in) + * This is always a reference, + * never an owning pointer. */ + mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_out); /*!< current transform params (out) + * This is always a reference, + * never an owning pointer. */ + mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform); /*!< negotiated transform params + * This pointer owns the transform + * it references. */ + mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_negotiate); /*!< transform params in negotiation + * This pointer owns the transform + * it references. */ /* * Timers From 3aa186f9462f6afd2943980863f37d8a608dbaa5 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Aug 2021 09:24:19 +0100 Subject: [PATCH 216/966] Add transforms to be used for TLS 1.3 Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 6 ++++++ library/ssl_misc.h | 7 +++++++ library/ssl_tls.c | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index dc4782e65b..34353daffb 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1341,6 +1341,12 @@ struct mbedtls_ssl_context * This pointer owns the transform * it references. */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + /* The application data transform in TLS 1.3. + * This pointer owns the transform it references. */ + mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_application); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* * Timers */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index cc19f4723b..174bad88b5 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -562,6 +562,13 @@ struct mbedtls_ssl_handshake_params uint16_t mtu; /*!< Handshake mtu, used to fragment outgoing messages */ #endif /* MBEDTLS_SSL_PROTO_DTLS */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + /* TLS 1.3 transforms for 0-RTT and encrypted handshake messages. + * Those pointers own the transforms they reference. */ + mbedtls_ssl_transform *transform_handshake; + mbedtls_ssl_transform *transform_earlydata; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* * Checksum contexts */ diff --git a/library/ssl_tls.c b/library/ssl_tls.c index bb5ddc470e..8316d252b7 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5393,6 +5393,13 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ) handle_buffer_resizing( ssl, 1, mbedtls_ssl_get_input_buflen( ssl ), mbedtls_ssl_get_output_buflen( ssl ) ); #endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + mbedtls_free( handshake->transform_earlydata ); + mbedtls_free( handshake->transform_handshake ); + handshake->transform_earlydata = NULL; + handshake->transform_handshake = NULL; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ } void mbedtls_ssl_session_free( mbedtls_ssl_session *session ) @@ -6091,6 +6098,11 @@ void mbedtls_ssl_free( mbedtls_ssl_context *ssl ) mbedtls_free( ssl->session_negotiate ); } +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + mbedtls_ssl_transform_free( ssl->transform_application ); + mbedtls_free( ssl->transform_application ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + if( ssl->session ) { mbedtls_ssl_session_free( ssl->session ); From 7828ca2ea435464a5bbd2cc6f948684ced2d82c5 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 10 Aug 2021 11:26:15 +0100 Subject: [PATCH 217/966] Fix typos pointed out by check_names Signed-off-by: Yuto Takano --- include/mbedtls/config_psa.h | 2 +- include/mbedtls/mbedtls_config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/config_psa.h b/include/mbedtls/config_psa.h index 9080cd19bc..3b01b78d29 100644 --- a/include/mbedtls/config_psa.h +++ b/include/mbedtls/config_psa.h @@ -586,7 +586,7 @@ extern "C" { #define MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN 1 #define PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1 #define PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW 1 -#endif /* MBEDTLSS_PKCS1_V15 */ +#endif /* MBEDTLS_PKCS1_V15 */ #if defined(MBEDTLS_PKCS1_V21) #define MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP 1 #define PSA_WANT_ALG_RSA_OAEP 1 diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index a60db7e930..ecf10bbf52 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -3179,7 +3179,7 @@ * Maximum number of heap-allocated bytes for the purpose of * DTLS handshake message reassembly and future message buffering. * - * This should be at least 9/8 * MBEDTLSSL_IN_CONTENT_LEN + * This should be at least 9/8 * MBEDTLS_SSL_IN_CONTENT_LEN * to account for a reassembled handshake message of maximum size, * together with its reassembly bitmap. * From 206b022ad0e192ce759d7ca3ebf596294ccba4b5 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 10 Aug 2021 11:30:43 +0100 Subject: [PATCH 218/966] Fix off-by-one error in string formatting in Python Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 957701433a..591389b960 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -138,7 +138,7 @@ class PatternMismatch(Problem): # pylint: disable=too-few-public-methods def __str__(self): if self.quiet: return ( - "{0}:{1}:{3}" + "{0}:{1}:{2}" .format(self.match.filename, self.match.pos[0], self.match.name) ) From 89d469cdb4c576ceb74008ede2345879245d0f4a Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 22 Jun 2021 16:24:28 +0200 Subject: [PATCH 219/966] Move working variables to ccm context structure Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 10 +++++ library/ccm.c | 98 +++++++++++++++++++++---------------------- 2 files changed, 58 insertions(+), 50 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index b3adecc4fb..2b9909e1a6 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -77,6 +77,16 @@ extern "C" { typedef struct mbedtls_ccm_context { mbedtls_cipher_context_t MBEDTLS_PRIVATE(cipher_ctx); /*!< The cipher context used. */ + unsigned char MBEDTLS_PRIVATE(b)[16]; /*!< The B working buffer */ + unsigned char MBEDTLS_PRIVATE(y)[16]; /*!< The Y working buffer */ + unsigned char MBEDTLS_PRIVATE(ctr)[16]; /*!< The counter buffer */ + unsigned char MBEDTLS_PRIVATE(q); /*!< The Q working value */ + size_t MBEDTLS_PRIVATE(plaintext_len); /*!< The counter buffer */ + int MBEDTLS_PRIVATE(mode); /*!< The operation to perform: + #MBEDTLS_CCM_ENCRYPT or + #MBEDTLS_CCM_DECRYPT or + #MBEDTLS_CCM_STAR_ENCRYPT or + #MBEDTLS_CCM_STAR_DECRYPT. */ } mbedtls_ccm_context; diff --git a/library/ccm.c b/library/ccm.c index 424ee77b69..686eda5437 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -117,11 +117,11 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) * Update the CBC-MAC state in y using a block in b * (Always using b as the source helps the compiler optimise a bit better.) */ -#define UPDATE_CBC_MAC \ - for( i = 0; i < 16; i++ ) \ - y[i] ^= b[i]; \ - \ - if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, y, 16, y, &olen ) ) != 0 ) \ +#define UPDATE_CBC_MAC \ + for( i = 0; i < 16; i++ ) \ + ctx->y[i] ^= ctx->b[i]; \ + \ + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) \ return( ret ); /* @@ -130,16 +130,16 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) * This avoids allocating one more 16 bytes buffer while allowing src == dst. */ #define CTR_CRYPT( dst, src, len ) \ - do \ - { \ - if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctr, \ - 16, b, &olen ) ) != 0 ) \ - { \ - return( ret ); \ - } \ - \ - for( i = 0; i < (len); i++ ) \ - (dst)[i] = (src)[i] ^ b[i]; \ + do \ + { \ + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->ctr, \ + 16, ctx->b, &olen ) ) != 0 ) \ + { \ + return( ret ); \ + } \ + \ + for( i = 0; i < (len); i++ ) \ + (dst)[i] = (src)[i] ^ ctx->b[i]; \ } while( 0 ) /* @@ -153,14 +153,12 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; - unsigned char q; size_t len_left, olen; - unsigned char b[16]; - unsigned char y[16]; - unsigned char ctr[16]; const unsigned char *src; unsigned char *dst; + ctx->mode = mode; + /* * Check length requirements: SP800-38C A.1 * Additional requirement: a < 2^16 - 2^8 to simplify the code. @@ -178,7 +176,7 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, if( add_len >= 0xFF00 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); - q = 16 - 1 - (unsigned char) iv_len; + ctx->q = 16 - 1 - (unsigned char) iv_len; /* * First block B_0: @@ -192,22 +190,22 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, * 5 .. 3 (t - 2) / 2 * 2 .. 0 q - 1 */ - b[0] = 0; - b[0] |= ( add_len > 0 ) << 6; - b[0] |= ( ( tag_len - 2 ) / 2 ) << 3; - b[0] |= q - 1; + ctx->b[0] = 0; + ctx->b[0] |= ( add_len > 0 ) << 6; + ctx->b[0] |= ( ( tag_len - 2 ) / 2 ) << 3; + ctx->b[0] |= ctx->q - 1; - memcpy( b + 1, iv, iv_len ); + memcpy( ctx->b + 1, iv, iv_len ); - for( i = 0, len_left = length; i < q; i++, len_left >>= 8 ) - b[15-i] = (unsigned char)( len_left & 0xFF ); + for( i = 0, len_left = length; i < ctx->q; i++, len_left >>= 8 ) + ctx->b[15-i] = (unsigned char)( len_left & 0xFF ); if( len_left > 0 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); /* Start CBC-MAC with first block */ - memset( y, 0, 16 ); + memset( ctx->y, 0, 16 ); UPDATE_CBC_MAC; /* @@ -220,12 +218,12 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, len_left = add_len; src = add; - memset( b, 0, 16 ); - b[0] = (unsigned char)( ( add_len >> 8 ) & 0xFF ); - b[1] = (unsigned char)( ( add_len ) & 0xFF ); + memset( ctx->b, 0, 16 ); + ctx->b[0] = (unsigned char)( ( add_len >> 8 ) & 0xFF ); + ctx->b[1] = (unsigned char)( ( add_len ) & 0xFF ); use_len = len_left < 16 - 2 ? len_left : 16 - 2; - memcpy( b + 2, src, use_len ); + memcpy( ctx->b + 2, src, use_len ); len_left -= use_len; src += use_len; @@ -235,8 +233,8 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, { use_len = len_left > 16 ? 16 : len_left; - memset( b, 0, 16 ); - memcpy( b, src, use_len ); + memset( ctx->b, 0, 16 ); + memcpy( ctx->b, src, use_len ); UPDATE_CBC_MAC; len_left -= use_len; @@ -254,10 +252,10 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, * 7 .. 3 0 * 2 .. 0 q - 1 */ - ctr[0] = q - 1; - memcpy( ctr + 1, iv, iv_len ); - memset( ctr + 1 + iv_len, 0, q ); - ctr[15] = 1; + ctx->ctr[0] = ctx->q - 1; + memcpy( ctx->ctr + 1, iv, iv_len ); + memset( ctx->ctr + 1 + iv_len, 0, ctx->q ); + ctx->ctr[15] = 1; /* * Authenticate and {en,de}crypt the message. @@ -273,19 +271,19 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, { size_t use_len = len_left > 16 ? 16 : len_left; - if( mode == CCM_ENCRYPT ) + if( ctx->mode == CCM_ENCRYPT ) { - memset( b, 0, 16 ); - memcpy( b, src, use_len ); + memset( ctx->b, 0, 16 ); + memcpy( ctx->b, src, use_len ); UPDATE_CBC_MAC; } CTR_CRYPT( dst, src, use_len ); - if( mode == CCM_DECRYPT ) + if( ctx->mode == CCM_DECRYPT ) { - memset( b, 0, 16 ); - memcpy( b, dst, use_len ); + memset( ctx->b, 0, 16 ); + memcpy( ctx->b, dst, use_len ); UPDATE_CBC_MAC; } @@ -297,19 +295,19 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, * Increment counter. * No need to check for overflow thanks to the length check above. */ - for( i = 0; i < q; i++ ) - if( ++ctr[15-i] != 0 ) + for( i = 0; i < ctx->q; i++ ) + if( ++(ctx->ctr)[15-i] != 0 ) break; } /* * Authentication: reset counter and crypt/mask internal tag */ - for( i = 0; i < q; i++ ) - ctr[15-i] = 0; + for( i = 0; i < ctx->q; i++ ) + ctx->ctr[15-i] = 0; - CTR_CRYPT( y, y, 16 ); - memcpy( tag, y, tag_len ); + CTR_CRYPT( ctx->y, ctx->y, 16 ); + memcpy( tag, ctx->y, tag_len ); return( 0 ); } From 793692cbcb296042cc1d5a35b39536e8dc59cdbf Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 22 Jun 2021 20:34:20 +0200 Subject: [PATCH 220/966] Split ccm_auth function. Move logic to ccm_starts, ccm_set_lengths, ccm_update_ad, ccm_update and ccm_finish Use separate variable to track context state. Encode first block only if both mbedtls_ccm_starts() and mbedtls_ccm_set_lengths() were called. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 3 + library/ccm.c | 225 ++++++++++++++++++++++++++++++++---------- 2 files changed, 178 insertions(+), 50 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index 2b9909e1a6..f9f8000fba 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -87,6 +87,9 @@ typedef struct mbedtls_ccm_context #MBEDTLS_CCM_DECRYPT or #MBEDTLS_CCM_STAR_ENCRYPT or #MBEDTLS_CCM_STAR_DECRYPT. */ + int MBEDTLS_PRIVATE(state); /*!< Working value holding context's + state. Used for chunked data + input */ } mbedtls_ccm_context; diff --git a/library/ccm.c b/library/ccm.c index 686eda5437..a2ca98600c 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -142,22 +142,105 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) (dst)[i] = (src)[i] ^ ctx->b[i]; \ } while( 0 ) -/* - * Authenticated encryption or decryption - */ -static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, - const unsigned char *iv, size_t iv_len, - const unsigned char *add, size_t add_len, - const unsigned char *input, unsigned char *output, - unsigned char *tag, size_t tag_len ) +#define CCM_STATE__CLEAR 0 +#define CCM_STATE__STARTED 0x0001 +#define CCM_STATE__LENGHTS_SET 0x0002 + +static void mbedtls_ccm_clear_state(mbedtls_ccm_context *ctx) { + ctx->state = CCM_STATE__CLEAR; + memset( ctx->b, 0, 16); + memset( ctx->y, 0, 16); + memset( ctx->ctr, 0, 16); +} + +static int mbedtls_ccm_calculate_first_block(mbedtls_ccm_context *ctx) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; size_t len_left, olen; - const unsigned char *src; - unsigned char *dst; + + /* length calulcation can be done only after both + * mbedtls_ccm_starts() and mbedtls_ccm_set_lengths() have been executed + */ + if( !(ctx->state & CCM_STATE__STARTED) || !(ctx->state & CCM_STATE__LENGHTS_SET) ) + return 0; + + /* + * First block B_0: + * 0 .. 0 flags - set by: mbedtls_ccm_starts() and mbedtls_ccm_set_lenghts() + * 1 .. iv_len nonce (aka iv) - set by: mbedtls_ccm_starts() + * iv_len+1 .. 15 length - set by: mbedtls_ccm_calculate_first_block() + */ + for( i = 0, len_left = ctx->plaintext_len; i < ctx->q; i++, len_left >>= 8 ) + ctx->b[15-i] = (unsigned char)( len_left & 0xFF ); + + if( len_left > 0 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + /* Start CBC-MAC with first block*/ + UPDATE_CBC_MAC; + + return (0); +} + +int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, + int mode, + const unsigned char *iv, + size_t iv_len ) +{ + int ret; + + /* Also implies q is within bounds */ + if( iv_len < 7 || iv_len > 13 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); ctx->mode = mode; + ctx->q = 16 - 1 - (unsigned char) iv_len; + + /* + * Prepare counter block for encryption: + * 0 .. 0 flags + * 1 .. iv_len nonce (aka iv) + * iv_len+1 .. 15 counter (initially 1) + * + * With flags as (bits): + * 7 .. 3 0 + * 2 .. 0 q - 1 + */ + memset( ctx->ctr, 0, 16); + ctx->ctr[0] = ctx->q - 1; + memcpy( ctx->ctr + 1, iv, iv_len ); + memset( ctx->ctr + 1 + iv_len, 0, ctx->q ); + ctx->ctr[15] = 1; + + /* + * First block B_0: + * 0 .. 0 flags - set by: mbedtls_ccm_starts() and mbedtls_ccm_set_lenghts() + * 1 .. iv_len nonce (aka iv) - set by: mbedtls_ccm_starts() + * iv_len+1 .. 15 length - set by: mbedtls_ccm_calculate_first_block() + * + * With flags as (bits): + * 7 0 + * 6 add present? - set by: mbedtls_ccm_set_lengths() + * 5 .. 3 (t - 2) / 2 - set by: mbedtls_ccm_set_lengths() + * 2 .. 0 q - 1 - set by: mbedtls_ccm_starts() + */ + ctx->b[0] |= ctx->q - 1; + + memcpy( ctx->b + 1, iv, iv_len ); + + ctx->state |= CCM_STATE__STARTED; + ret = mbedtls_ccm_calculate_first_block(ctx); + + return ret; +} + +int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, + size_t total_ad_len, + size_t plaintext_len, + size_t tag_len ) +{ + int ret; /* * Check length requirements: SP800-38C A.1 @@ -169,44 +252,40 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, if( tag_len == 2 || tag_len > 16 || tag_len % 2 != 0 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); - /* Also implies q is within bounds */ - if( iv_len < 7 || iv_len > 13 ) + if( total_ad_len >= 0xFF00 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); - if( add_len >= 0xFF00 ) - return( MBEDTLS_ERR_CCM_BAD_INPUT ); - - ctx->q = 16 - 1 - (unsigned char) iv_len; - /* * First block B_0: - * 0 .. 0 flags - * 1 .. iv_len nonce (aka iv) - * iv_len+1 .. 15 length + * 0 .. 0 flags - set by: mbedtls_ccm_starts() and mbedtls_ccm_set_lenghts() + * 1 .. iv_len nonce (aka iv) - set by: mbedtls_ccm_starts() + * iv_len+1 .. 15 length - set by: mbedtls_ccm_calculate_first_block() * * With flags as (bits): * 7 0 - * 6 add present? - * 5 .. 3 (t - 2) / 2 - * 2 .. 0 q - 1 + * 6 add present? - set by: mbedtls_ccm_set_lengths() + * 5 .. 3 (t - 2) / 2 - set by: mbedtls_ccm_set_lengths() + * 2 .. 0 q - 1 - set by: mbedtls_ccm_starts() */ - ctx->b[0] = 0; - ctx->b[0] |= ( add_len > 0 ) << 6; + ctx->b[0] |= ( total_ad_len > 0 ) << 6; ctx->b[0] |= ( ( tag_len - 2 ) / 2 ) << 3; - ctx->b[0] |= ctx->q - 1; - memcpy( ctx->b + 1, iv, iv_len ); + ctx->plaintext_len = plaintext_len; - for( i = 0, len_left = length; i < ctx->q; i++, len_left >>= 8 ) - ctx->b[15-i] = (unsigned char)( len_left & 0xFF ); + ctx->state |= CCM_STATE__LENGHTS_SET; + ret = mbedtls_ccm_calculate_first_block(ctx); - if( len_left > 0 ) - return( MBEDTLS_ERR_CCM_BAD_INPUT ); + return ret; +} - - /* Start CBC-MAC with first block */ - memset( ctx->y, 0, 16 ); - UPDATE_CBC_MAC; +int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, + const unsigned char *add, + size_t add_len ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + unsigned char i; + size_t len_left, olen; + const unsigned char *src; /* * If there is additional data, update CBC-MAC with @@ -242,20 +321,24 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, } } - /* - * Prepare counter block for encryption: - * 0 .. 0 flags - * 1 .. iv_len nonce (aka iv) - * iv_len+1 .. 15 counter (initially 1) - * - * With flags as (bits): - * 7 .. 3 0 - * 2 .. 0 q - 1 - */ - ctx->ctr[0] = ctx->q - 1; - memcpy( ctx->ctr + 1, iv, iv_len ); - memset( ctx->ctr + 1 + iv_len, 0, ctx->q ); - ctx->ctr[15] = 1; + return (0); +} + +int mbedtls_ccm_update( mbedtls_ccm_context *ctx, + const unsigned char *input, size_t input_len, + unsigned char *output, size_t output_size, + size_t *output_len ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + unsigned char i; + size_t len_left, olen; + const unsigned char *src; + unsigned char *dst; + + if( output_size < input_len ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + CCM_VALIDATE_RET( output_length != NULL ); + *output_len = input_len; /* * Authenticate and {en,de}crypt the message. @@ -263,7 +346,7 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, * The only difference between encryption and decryption is * the respective order of authentication and {en,de}cryption. */ - len_left = length; + len_left = input_len; src = input; dst = output; @@ -300,6 +383,16 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, break; } + return (0); +} + +int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, + unsigned char *tag, size_t tag_len ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + unsigned char i; + size_t olen; + /* * Authentication: reset counter and crypt/mask internal tag */ @@ -308,6 +401,38 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, CTR_CRYPT( ctx->y, ctx->y, 16 ); memcpy( tag, ctx->y, tag_len ); + mbedtls_ccm_clear_state(ctx); + + return( 0 ); +} + +/* + * Authenticated encryption or decryption + */ +static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + unsigned char *tag, size_t tag_len ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + size_t olen; + + if( ( ret = mbedtls_ccm_starts( ctx, mode, iv, iv_len ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_ccm_set_lengths( ctx, add_len, length, tag_len ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_ccm_update_ad( ctx, add, add_len ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_ccm_update( ctx, input, length, + output, length, &olen ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_ccm_finish( ctx, tag, tag_len ) ) != 0 ) + return( ret ); return( 0 ); } From 88c4d624f80582d7b242912ce65c37cc8382f39c Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 5 Jul 2021 17:09:16 +0200 Subject: [PATCH 221/966] Clear context state if previous operation failed. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index a2ca98600c..34531a4162 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -122,7 +122,10 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) ctx->y[i] ^= ctx->b[i]; \ \ if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) \ - return( ret ); + { \ + ctx->state |= CCM_STATE__ERROR; \ + return( ret ); \ + } \ /* * Encrypt or decrypt a partial block with CTR @@ -135,6 +138,7 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->ctr, \ 16, ctx->b, &olen ) ) != 0 ) \ { \ + ctx->state |= CCM_STATE__ERROR; \ return( ret ); \ } \ \ @@ -145,6 +149,7 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) #define CCM_STATE__CLEAR 0 #define CCM_STATE__STARTED 0x0001 #define CCM_STATE__LENGHTS_SET 0x0002 +#define CCM_STATE__ERROR 0x0004 static void mbedtls_ccm_clear_state(mbedtls_ccm_context *ctx) { ctx->state = CCM_STATE__CLEAR; @@ -175,7 +180,10 @@ static int mbedtls_ccm_calculate_first_block(mbedtls_ccm_context *ctx) ctx->b[15-i] = (unsigned char)( len_left & 0xFF ); if( len_left > 0 ) + { + ctx->state |= CCM_STATE__ERROR; return( MBEDTLS_ERR_CCM_BAD_INPUT ); + } /* Start CBC-MAC with first block*/ UPDATE_CBC_MAC; @@ -188,12 +196,15 @@ int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, const unsigned char *iv, size_t iv_len ) { - int ret; - /* Also implies q is within bounds */ if( iv_len < 7 || iv_len > 13 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); + if( ctx->state & CCM_STATE__ERROR ) + { + mbedtls_ccm_clear_state(ctx); + } + ctx->mode = mode; ctx->q = 16 - 1 - (unsigned char) iv_len; @@ -230,9 +241,7 @@ int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, memcpy( ctx->b + 1, iv, iv_len ); ctx->state |= CCM_STATE__STARTED; - ret = mbedtls_ccm_calculate_first_block(ctx); - - return ret; + return mbedtls_ccm_calculate_first_block(ctx); } int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, @@ -240,8 +249,6 @@ int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, size_t plaintext_len, size_t tag_len ) { - int ret; - /* * Check length requirements: SP800-38C A.1 * Additional requirement: a < 2^16 - 2^8 to simplify the code. @@ -255,6 +262,11 @@ int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, if( total_ad_len >= 0xFF00 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); + if( ctx->state & CCM_STATE__ERROR ) + { + mbedtls_ccm_clear_state(ctx); + } + /* * First block B_0: * 0 .. 0 flags - set by: mbedtls_ccm_starts() and mbedtls_ccm_set_lenghts() @@ -273,9 +285,7 @@ int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, ctx->plaintext_len = plaintext_len; ctx->state |= CCM_STATE__LENGHTS_SET; - ret = mbedtls_ccm_calculate_first_block(ctx); - - return ret; + return mbedtls_ccm_calculate_first_block(ctx); } int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, From eb2ca96d69e564385f4830e0fb32bc2714375544 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 6 Jul 2021 12:45:11 +0200 Subject: [PATCH 222/966] Store set lenghts in ccm context. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 5 ++++- library/ccm.c | 45 +++++++++++++++---------------------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index f9f8000fba..813959be0b 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -81,7 +81,10 @@ typedef struct mbedtls_ccm_context unsigned char MBEDTLS_PRIVATE(y)[16]; /*!< The Y working buffer */ unsigned char MBEDTLS_PRIVATE(ctr)[16]; /*!< The counter buffer */ unsigned char MBEDTLS_PRIVATE(q); /*!< The Q working value */ - size_t MBEDTLS_PRIVATE(plaintext_len); /*!< The counter buffer */ + size_t MBEDTLS_PRIVATE(plaintext_len); /*!< Total plaintext length */ + size_t MBEDTLS_PRIVATE(add_len); /*!< Total authentication data length */ + size_t MBEDTLS_PRIVATE(tag_len); /*!< Total tag length */ + size_t MBEDTLS_PRIVATE(processed); /*!< How many bytes of input data were processed (chunked input) */ int MBEDTLS_PRIVATE(mode); /*!< The operation to perform: #MBEDTLS_CCM_ENCRYPT or #MBEDTLS_CCM_DECRYPT or diff --git a/library/ccm.c b/library/ccm.c index 34531a4162..36b1e91583 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -172,10 +172,20 @@ static int mbedtls_ccm_calculate_first_block(mbedtls_ccm_context *ctx) /* * First block B_0: - * 0 .. 0 flags - set by: mbedtls_ccm_starts() and mbedtls_ccm_set_lenghts() + * 0 .. 0 flags * 1 .. iv_len nonce (aka iv) - set by: mbedtls_ccm_starts() - * iv_len+1 .. 15 length - set by: mbedtls_ccm_calculate_first_block() + * iv_len+1 .. 15 length + * + * With flags as (bits): + * 7 0 + * 6 add present? + * 5 .. 3 (t - 2) / 2 + * 2 .. 0 q - 1 */ + ctx->b[0] |= ( ctx->add_len > 0 ) << 6; + ctx->b[0] |= ( ( ctx->tag_len - 2 ) / 2 ) << 3; + ctx->b[0] |= ctx->q - 1; + for( i = 0, len_left = ctx->plaintext_len; i < ctx->q; i++, len_left >>= 8 ) ctx->b[15-i] = (unsigned char)( len_left & 0xFF ); @@ -225,19 +235,8 @@ int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, ctx->ctr[15] = 1; /* - * First block B_0: - * 0 .. 0 flags - set by: mbedtls_ccm_starts() and mbedtls_ccm_set_lenghts() - * 1 .. iv_len nonce (aka iv) - set by: mbedtls_ccm_starts() - * iv_len+1 .. 15 length - set by: mbedtls_ccm_calculate_first_block() - * - * With flags as (bits): - * 7 0 - * 6 add present? - set by: mbedtls_ccm_set_lengths() - * 5 .. 3 (t - 2) / 2 - set by: mbedtls_ccm_set_lengths() - * 2 .. 0 q - 1 - set by: mbedtls_ccm_starts() + * See mbedtls_ccm_calculate_first_block() for B block layout description */ - ctx->b[0] |= ctx->q - 1; - memcpy( ctx->b + 1, iv, iv_len ); ctx->state |= CCM_STATE__STARTED; @@ -267,22 +266,10 @@ int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, mbedtls_ccm_clear_state(ctx); } - /* - * First block B_0: - * 0 .. 0 flags - set by: mbedtls_ccm_starts() and mbedtls_ccm_set_lenghts() - * 1 .. iv_len nonce (aka iv) - set by: mbedtls_ccm_starts() - * iv_len+1 .. 15 length - set by: mbedtls_ccm_calculate_first_block() - * - * With flags as (bits): - * 7 0 - * 6 add present? - set by: mbedtls_ccm_set_lengths() - * 5 .. 3 (t - 2) / 2 - set by: mbedtls_ccm_set_lengths() - * 2 .. 0 q - 1 - set by: mbedtls_ccm_starts() - */ - ctx->b[0] |= ( total_ad_len > 0 ) << 6; - ctx->b[0] |= ( ( tag_len - 2 ) / 2 ) << 3; - ctx->plaintext_len = plaintext_len; + ctx->add_len = total_ad_len; + ctx->tag_len = tag_len; + ctx->processed = 0; ctx->state |= CCM_STATE__LENGHTS_SET; return mbedtls_ccm_calculate_first_block(ctx); From 33392450b75dac7a45c523f67b1ea6b7bcd43e4c Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 6 Jul 2021 15:38:35 +0200 Subject: [PATCH 223/966] Add chunked auth data support Signed-off-by: Mateusz Starzyk --- library/ccm.c | 59 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 36b1e91583..0a886a0e10 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -281,43 +281,44 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; - size_t len_left, olen; - const unsigned char *src; + size_t olen, use_len, offset; - /* - * If there is additional data, update CBC-MAC with - * add_len, add, 0 (padding to a block boundary) - */ - if( add_len > 0 ) + if( ctx->add_len > 0 && add_len > 0) { - size_t use_len; - len_left = add_len; - src = add; - - memset( ctx->b, 0, 16 ); - ctx->b[0] = (unsigned char)( ( add_len >> 8 ) & 0xFF ); - ctx->b[1] = (unsigned char)( ( add_len ) & 0xFF ); - - use_len = len_left < 16 - 2 ? len_left : 16 - 2; - memcpy( ctx->b + 2, src, use_len ); - len_left -= use_len; - src += use_len; - - UPDATE_CBC_MAC; - - while( len_left > 0 ) + if( ctx->processed == 0 ) { - use_len = len_left > 16 ? 16 : len_left; - memset( ctx->b, 0, 16 ); - memcpy( ctx->b, src, use_len ); - UPDATE_CBC_MAC; + ctx->b[0] = (unsigned char)( ( ctx->add_len >> 8 ) & 0xFF ); + ctx->b[1] = (unsigned char)( ( ctx->add_len ) & 0xFF ); - len_left -= use_len; - src += use_len; + ctx->processed += 2; + } + + while( add_len > 0 ) + { + offset = ctx->processed % 16; + + use_len = 16 - offset; + + if( use_len > add_len ) + use_len = add_len; + + memcpy( ctx->b + offset, add, use_len ); + ctx->processed += use_len; + add_len -= use_len; + add += use_len; + + if( use_len + offset == 16 || ctx->processed - 2 == ctx->add_len ) + { + UPDATE_CBC_MAC; + memset( ctx->b, 0, 16 ); + } } } + if( ctx->processed - 2 == ctx->add_len ) + ctx->processed = 0; // prepare for mbedtls_ccm_update() + return (0); } From 2ad7d8e1ffcaa1b431db6e994206798987ea779e Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 7 Jul 2021 11:05:45 +0200 Subject: [PATCH 224/966] Replace CCM_CRYPT macro with a more versatile static function. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 59 ++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 0a886a0e10..ae5fa34252 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -108,14 +108,11 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) mbedtls_platform_zeroize( ctx, sizeof( mbedtls_ccm_context ) ); } -/* - * Macros for common operations. - * Results in smaller compiled code than static inline functions. - */ - /* * Update the CBC-MAC state in y using a block in b * (Always using b as the source helps the compiler optimise a bit better.) + * + * Macro results in smaller compiled code than static inline functions. */ #define UPDATE_CBC_MAC \ for( i = 0; i < 16; i++ ) \ @@ -127,30 +124,37 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) return( ret ); \ } \ -/* - * Encrypt or decrypt a partial block with CTR - * Warning: using b for temporary storage! src and dst must not be b! - * This avoids allocating one more 16 bytes buffer while allowing src == dst. - */ -#define CTR_CRYPT( dst, src, len ) \ - do \ - { \ - if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->ctr, \ - 16, ctx->b, &olen ) ) != 0 ) \ - { \ - ctx->state |= CCM_STATE__ERROR; \ - return( ret ); \ - } \ - \ - for( i = 0; i < (len); i++ ) \ - (dst)[i] = (src)[i] ^ ctx->b[i]; \ - } while( 0 ) - #define CCM_STATE__CLEAR 0 #define CCM_STATE__STARTED 0x0001 #define CCM_STATE__LENGHTS_SET 0x0002 #define CCM_STATE__ERROR 0x0004 +/* + * Encrypt or decrypt a partial block with CTR + */ +static int mbedtls_ccm_crypt( mbedtls_ccm_context *ctx, + size_t offset, size_t use_len, + const unsigned char *input, + unsigned char *output ) +{ + size_t i; + size_t olen = 0; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + unsigned char tmp_buf[16] = {0}; + + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->ctr, 16, tmp_buf, + &olen ) ) != 0 ) + { + ctx->state |= CCM_STATE__ERROR; \ + return ret; + } + + for( i = 0; i < use_len; i++ ) + output[i] = input[i] ^ tmp_buf[offset + i]; + + return ret; +} + static void mbedtls_ccm_clear_state(mbedtls_ccm_context *ctx) { ctx->state = CCM_STATE__CLEAR; memset( ctx->b, 0, 16); @@ -359,7 +363,7 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, UPDATE_CBC_MAC; } - CTR_CRYPT( dst, src, use_len ); + mbedtls_ccm_crypt( ctx, 0, use_len, src, dst ); if( ctx->mode == CCM_DECRYPT ) { @@ -389,7 +393,6 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; - size_t olen; /* * Authentication: reset counter and crypt/mask internal tag @@ -397,7 +400,9 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, for( i = 0; i < ctx->q; i++ ) ctx->ctr[15-i] = 0; - CTR_CRYPT( ctx->y, ctx->y, 16 ); + ret = mbedtls_ccm_crypt( ctx, 0, 16, ctx->y, ctx->y ); + if( ret != 0 ) + return ret; memcpy( tag, ctx->y, tag_len ); mbedtls_ccm_clear_state(ctx); From 6a15bcf61be1e6691c9209a0ecc4a32f63e248ae Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 7 Jul 2021 13:41:30 +0200 Subject: [PATCH 225/966] Add support for chunked plaintext/cyphertext input. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 96 ++++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index ae5fa34252..4b1b499ad1 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -333,59 +333,67 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; - size_t len_left, olen; - const unsigned char *src; - unsigned char *dst; + size_t use_len, offset, olen; if( output_size < input_len ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); CCM_VALIDATE_RET( output_length != NULL ); *output_len = input_len; - /* - * Authenticate and {en,de}crypt the message. - * - * The only difference between encryption and decryption is - * the respective order of authentication and {en,de}cryption. - */ - len_left = input_len; - src = input; - dst = output; - - while( len_left > 0 ) + if( ctx->processed == 0 ) { - size_t use_len = len_left > 16 ? 16 : len_left; - - if( ctx->mode == CCM_ENCRYPT ) - { - memset( ctx->b, 0, 16 ); - memcpy( ctx->b, src, use_len ); - UPDATE_CBC_MAC; - } - - mbedtls_ccm_crypt( ctx, 0, use_len, src, dst ); - - if( ctx->mode == CCM_DECRYPT ) - { - memset( ctx->b, 0, 16 ); - memcpy( ctx->b, dst, use_len ); - UPDATE_CBC_MAC; - } - - dst += use_len; - src += use_len; - len_left -= use_len; - - /* - * Increment counter. - * No need to check for overflow thanks to the length check above. - */ - for( i = 0; i < ctx->q; i++ ) - if( ++(ctx->ctr)[15-i] != 0 ) - break; + memset( ctx->b, 0, 16 ); } - return (0); + while ( input_len > 0 ) + { + offset = ctx->processed % 16; + + use_len = 16 - offset; + + if( use_len > input_len ) + use_len = input_len; + + ctx->processed += use_len; + memcpy( ctx->b + offset, input, use_len ); + + if( use_len + offset == 16 || ctx->processed == ctx->plaintext_len ) + { + if( ctx->mode == CCM_ENCRYPT ) + { + UPDATE_CBC_MAC; + ret = mbedtls_ccm_crypt( ctx, 0, use_len, ctx->b, output ); + if( ret != 0 ) + return ret; + memset( ctx->b, 0, 16 ); + } + + if( ctx->mode == CCM_DECRYPT ) + { + ret = mbedtls_ccm_crypt( ctx, 0, use_len, ctx->b, output ); + if( ret != 0 ) + return ret; + memset( ctx->b, 0, 16 ); + memcpy( ctx->b, output, use_len ); + UPDATE_CBC_MAC; + memset( ctx->b, 0, 16 ); + } + + input_len -= use_len; + input += use_len; + output += use_len; + + /* + * Increment counter. + * No need to check for overflow thanks to the length check above. + */ + for( i = 0; i < ctx->q; i++ ) + if( ++(ctx->ctr)[15-i] != 0 ) + break; + } + } + + return 0; } int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, From 05e92d67bbe15f30c9ad74c123362e1701125dad Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Fri, 9 Jul 2021 12:44:07 +0200 Subject: [PATCH 226/966] Fix crypt mode configuration. Validate parameters in chunked input functions. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 107 ++++++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 47 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 4b1b499ad1..4f7ebfa827 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -52,8 +52,6 @@ #define CCM_VALIDATE( cond ) \ MBEDTLS_INTERNAL_VALIDATE( cond ) -#define CCM_ENCRYPT 0 -#define CCM_DECRYPT 1 /* * Initialize context @@ -174,6 +172,10 @@ static int mbedtls_ccm_calculate_first_block(mbedtls_ccm_context *ctx) if( !(ctx->state & CCM_STATE__STARTED) || !(ctx->state & CCM_STATE__LENGHTS_SET) ) return 0; + if( ctx->tag_len == 0 && \ + ( ctx->mode == MBEDTLS_CCM_ENCRYPT || ctx->mode == MBEDTLS_CCM_DECRYPT ) ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + /* * First block B_0: * 0 .. 0 flags @@ -210,6 +212,13 @@ int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, const unsigned char *iv, size_t iv_len ) { + CCM_VALIDATE_RET( ctx != NULL ); + CCM_VALIDATE_RET( iv != NULL ); + CCM_VALIDATE_RET( mode == MBEDTLS_CCM_DECRYPT || \ + mode == MBEDTLS_CCM_STAR_DECRYPT || \ + mode == MBEDTLS_CCM_ENCRYPT || \ + mode == MBEDTLS_CCM_STAR_ENCRYPT ); + /* Also implies q is within bounds */ if( iv_len < 7 || iv_len > 13 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); @@ -252,6 +261,8 @@ int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, size_t plaintext_len, size_t tag_len ) { + CCM_VALIDATE_RET( ctx != NULL ); + /* * Check length requirements: SP800-38C A.1 * Additional requirement: a < 2^16 - 2^8 to simplify the code. @@ -283,6 +294,8 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, const unsigned char *add, size_t add_len ) { + CCM_VALIDATE_RET( ctx->add_len == 0 || add != NULL ); + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; size_t olen, use_len, offset; @@ -331,6 +344,9 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, unsigned char *output, size_t output_size, size_t *output_len ) { + CCM_VALIDATE_RET( ctx->plaintext_len == 0 || input != NULL ); + CCM_VALIDATE_RET( ctx->plaintext_len == 0 || output != NULL ); + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; size_t use_len, offset, olen; @@ -359,7 +375,8 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, if( use_len + offset == 16 || ctx->processed == ctx->plaintext_len ) { - if( ctx->mode == CCM_ENCRYPT ) + if( ctx->mode == MBEDTLS_CCM_ENCRYPT || \ + ctx->mode == MBEDTLS_CCM_STAR_ENCRYPT ) { UPDATE_CBC_MAC; ret = mbedtls_ccm_crypt( ctx, 0, use_len, ctx->b, output ); @@ -368,7 +385,8 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, memset( ctx->b, 0, 16 ); } - if( ctx->mode == CCM_DECRYPT ) + if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ + ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) { ret = mbedtls_ccm_crypt( ctx, 0, use_len, ctx->b, output ); if( ret != 0 ) @@ -402,6 +420,7 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; + CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); /* * Authentication: reset counter and crypt/mask internal tag */ @@ -457,13 +476,7 @@ int mbedtls_ccm_star_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len ) { - CCM_VALIDATE_RET( ctx != NULL ); - CCM_VALIDATE_RET( iv != NULL ); - CCM_VALIDATE_RET( add_len == 0 || add != NULL ); - CCM_VALIDATE_RET( length == 0 || input != NULL ); - CCM_VALIDATE_RET( length == 0 || output != NULL ); - CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); - return( ccm_auth_crypt( ctx, CCM_ENCRYPT, length, iv, iv_len, + return( ccm_auth_crypt( ctx, MBEDTLS_CCM_STAR_ENCRYPT, length, iv, iv_len, add, add_len, input, output, tag, tag_len ) ); } @@ -473,17 +486,25 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len ) { - CCM_VALIDATE_RET( ctx != NULL ); - CCM_VALIDATE_RET( iv != NULL ); - CCM_VALIDATE_RET( add_len == 0 || add != NULL ); - CCM_VALIDATE_RET( length == 0 || input != NULL ); - CCM_VALIDATE_RET( length == 0 || output != NULL ); - CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); - if( tag_len == 0 ) - return( MBEDTLS_ERR_CCM_BAD_INPUT ); + return( ccm_auth_crypt( ctx, MBEDTLS_CCM_ENCRYPT, length, iv, iv_len, + add, add_len, input, output, tag, tag_len ) ); +} - return( mbedtls_ccm_star_encrypt_and_tag( ctx, length, iv, iv_len, add, - add_len, input, output, tag, tag_len ) ); +static int mbedtls_ccm_compare_tags(const unsigned char *tag1, const unsigned char *tag2, size_t tag_len) +{ + unsigned char i; + int diff; + + /* Check tag in "constant-time" */ + for( diff = 0, i = 0; i < tag_len; i++ ) + diff |= tag1[i] ^ tag2[i]; + + if( diff != 0 ) + { + return( MBEDTLS_ERR_CCM_AUTH_FAILED ); + } + + return( 0 ); } /* @@ -497,31 +518,18 @@ int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char check_tag[16]; - unsigned char i; - int diff; - CCM_VALIDATE_RET( ctx != NULL ); - CCM_VALIDATE_RET( iv != NULL ); - CCM_VALIDATE_RET( add_len == 0 || add != NULL ); - CCM_VALIDATE_RET( length == 0 || input != NULL ); - CCM_VALIDATE_RET( length == 0 || output != NULL ); - CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); - - if( ( ret = ccm_auth_crypt( ctx, CCM_DECRYPT, length, + if( ( ret = ccm_auth_crypt( ctx, MBEDTLS_CCM_STAR_DECRYPT, length, iv, iv_len, add, add_len, input, output, check_tag, tag_len ) ) != 0 ) { return( ret ); } - /* Check tag in "constant-time" */ - for( diff = 0, i = 0; i < tag_len; i++ ) - diff |= tag[i] ^ check_tag[i]; - - if( diff != 0 ) + if( ( ret = mbedtls_ccm_compare_tags( tag, check_tag, tag_len ) ) != 0 ) { mbedtls_platform_zeroize( output, length ); - return( MBEDTLS_ERR_CCM_AUTH_FAILED ); + return( ret ); } return( 0 ); @@ -533,18 +541,23 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len ) { - CCM_VALIDATE_RET( ctx != NULL ); - CCM_VALIDATE_RET( iv != NULL ); - CCM_VALIDATE_RET( add_len == 0 || add != NULL ); - CCM_VALIDATE_RET( length == 0 || input != NULL ); - CCM_VALIDATE_RET( length == 0 || output != NULL ); - CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + unsigned char check_tag[16]; - if( tag_len == 0 ) - return( MBEDTLS_ERR_CCM_BAD_INPUT ); + if( ( ret = ccm_auth_crypt( ctx, MBEDTLS_CCM_DECRYPT, length, + iv, iv_len, add, add_len, + input, output, check_tag, tag_len ) ) != 0 ) + { + return( ret ); + } - return( mbedtls_ccm_star_auth_decrypt( ctx, length, iv, iv_len, add, - add_len, input, output, tag, tag_len ) ); + if( ( ret = mbedtls_ccm_compare_tags( tag, check_tag, tag_len ) ) != 0 ) + { + mbedtls_platform_zeroize( output, length ); + return( ret ); + } + + return( 0 ); } #endif /* !MBEDTLS_CCM_ALT */ From 20bac2fbe4ac0e002f4e622634cd858925c258c7 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 12 Jul 2021 14:52:44 +0200 Subject: [PATCH 227/966] Fix chunked ccm update. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 71 ++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 4f7ebfa827..5450e408c1 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -373,42 +373,49 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, ctx->processed += use_len; memcpy( ctx->b + offset, input, use_len ); + if( ctx->mode == MBEDTLS_CCM_ENCRYPT || \ + ctx->mode == MBEDTLS_CCM_STAR_ENCRYPT ) + { + if( use_len + offset == 16 || ctx->processed == ctx->plaintext_len ) + { + UPDATE_CBC_MAC; + } + ret = mbedtls_ccm_crypt( ctx, offset, use_len, ctx->b + offset, output ); + if( ret != 0 ) + return ret; + } + + if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ + ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) + { + ret = mbedtls_ccm_crypt( ctx, offset, use_len, ctx->b + offset, output ); + if( ret != 0 ) + return ret; + + for( i = 0; i < use_len; i++ ) + ctx->y[i + offset] ^= output[i]; + + if( use_len + offset == 16 || ctx->processed == ctx->plaintext_len ) + { + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) + { + ctx->state |= CCM_STATE__ERROR; + return( ret ); + } + } + } + if( use_len + offset == 16 || ctx->processed == ctx->plaintext_len ) { - if( ctx->mode == MBEDTLS_CCM_ENCRYPT || \ - ctx->mode == MBEDTLS_CCM_STAR_ENCRYPT ) - { - UPDATE_CBC_MAC; - ret = mbedtls_ccm_crypt( ctx, 0, use_len, ctx->b, output ); - if( ret != 0 ) - return ret; - memset( ctx->b, 0, 16 ); - } - - if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ - ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) - { - ret = mbedtls_ccm_crypt( ctx, 0, use_len, ctx->b, output ); - if( ret != 0 ) - return ret; - memset( ctx->b, 0, 16 ); - memcpy( ctx->b, output, use_len ); - UPDATE_CBC_MAC; - memset( ctx->b, 0, 16 ); - } - - input_len -= use_len; - input += use_len; - output += use_len; - - /* - * Increment counter. - * No need to check for overflow thanks to the length check above. - */ for( i = 0; i < ctx->q; i++ ) - if( ++(ctx->ctr)[15-i] != 0 ) - break; + if( ++(ctx->ctr)[15-i] != 0 ) + break; + memset( ctx->b, 0, 16 ); } + + input_len -= use_len; + input += use_len; + output += use_len; } return 0; From 25a3dfe7dd3ba598b79e70d1d407081810dec8a1 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 12 Jul 2021 14:53:45 +0200 Subject: [PATCH 228/966] Add multipart tests for ccm suite. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.function | 114 +++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 6 deletions(-) diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 840583c5ca..77ecf689b5 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -1,5 +1,64 @@ /* BEGIN_HEADER */ #include "mbedtls/ccm.h" + +/* Use the multipart interface to process the encrypted data in two parts + * and check that the output matches the expected output. + * The context must have been set up with the key. */ +static int check_multipart( mbedtls_ccm_context *ctx, + int mode, + const data_t *iv, + const data_t *add, + const data_t *input, + const data_t *expected_output, + const data_t *tag, + size_t n1, + size_t n1_add) +{ + int ok = 0; + uint8_t *output = NULL; + size_t n2 = input->len - n1; + size_t n2_add = add->len - n1_add; + size_t olen; + + /* Sanity checks on the test data */ + TEST_ASSERT( n1 <= input->len ); + TEST_ASSERT( n1_add <= add->len ); + TEST_EQUAL( input->len, expected_output->len ); + TEST_EQUAL( 0, mbedtls_ccm_starts( ctx, mode, iv->x, iv->len ) ); + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( ctx, add->len, input->len, tag->len ) ); + TEST_EQUAL( 0, mbedtls_ccm_update_ad( ctx, add->x, n1_add) ); + TEST_EQUAL( 0, mbedtls_ccm_update_ad( ctx, add->x + n1_add, n2_add ) ); + + /* Allocate a tight buffer for each update call. This way, if the function + * tries to write beyond the advertised required buffer size, this will + * count as an overflow for memory sanitizers and static checkers. */ + ASSERT_ALLOC( output, n1 ); + olen = 0xdeadbeef; + TEST_EQUAL( 0, mbedtls_ccm_update( ctx, input->x, n1, output, n1, &olen ) ); + TEST_EQUAL( n1, olen ); + ASSERT_COMPARE( output, olen, expected_output->x, n1 ); + mbedtls_free( output ); + output = NULL; + + ASSERT_ALLOC( output, n2 ); + olen = 0xdeadbeef; + TEST_EQUAL( 0, mbedtls_ccm_update( ctx, input->x + n1, n2, output, n2, &olen ) ); + TEST_EQUAL( n2, olen ); + ASSERT_COMPARE( output, olen, expected_output->x + n1, n2 ); + mbedtls_free( output ); + output = NULL; + + ASSERT_ALLOC( output, tag->len ); + TEST_EQUAL( 0, mbedtls_ccm_finish( ctx, output, tag->len ) ); + ASSERT_COMPARE( output, tag->len, tag->x, tag->len ); + mbedtls_free( output ); + output = NULL; + + ok = 1; +exit: + mbedtls_free( output ); + return( ok ); +} /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -123,6 +182,7 @@ void mbedtls_ccm_encrypt_and_tag( int cipher_id, data_t * key, { mbedtls_ccm_context ctx; size_t tag_len; + size_t n1, n1_add; uint8_t * msg_n_tag = (uint8_t *)malloc( result->len + 2 ); mbedtls_ccm_init( &ctx ); @@ -143,6 +203,25 @@ void mbedtls_ccm_encrypt_and_tag( int cipher_id, data_t * key, /* Check we didn't write past the end */ TEST_ASSERT( msg_n_tag[result->len] == 0 && msg_n_tag[result->len + 1] == 0 ); + const data_t encrypted_expected = { .x = result->x, + .len = msg->len }; + const data_t tag_expected = { .x = result->x + msg->len, + .len = tag_len }; + + for( n1 = 0; n1 <= msg->len; n1 += 1 ) + { + for( n1_add = 0; n1_add <= add->len; n1_add += 1 ) + { + mbedtls_test_set_step( n1 * 10000 + n1_add ); + if( !check_multipart( &ctx, MBEDTLS_CCM_ENCRYPT, + iv, add, msg, + &encrypted_expected, + &tag_expected, + n1, n1_add ) ) + goto exit; + } + } + exit: mbedtls_ccm_free( &ctx ); free( msg_n_tag ); @@ -157,6 +236,7 @@ void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, { unsigned char tag[16]; mbedtls_ccm_context ctx; + size_t n1, n1_add; mbedtls_ccm_init( &ctx ); @@ -165,28 +245,50 @@ void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, msg->len -= tag_len; memcpy( tag, msg->x + msg->len, tag_len ); + uint8_t * io_msg = (uint8_t *)malloc( msg->len + 2 ); + memset( io_msg, 0, msg->len + 2 ); + memcpy( io_msg, msg->x, msg->len ); + TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ) == 0 ); /* Test with input == output */ TEST_ASSERT( mbedtls_ccm_auth_decrypt( &ctx, msg->len, iv->x, iv->len, add->x, add->len, - msg->x, msg->x, msg->x + msg->len, tag_len ) == result ); + io_msg, io_msg, tag, tag_len ) == result ); + + /* Check we didn't write past the end */ + TEST_ASSERT( io_msg[msg->len] == 0 && io_msg[msg->len + 1] == 0 ); if( result == 0 ) { - TEST_ASSERT( memcmp( msg->x, expected_msg->x, expected_msg->len ) == 0 ); + TEST_ASSERT( memcmp( io_msg, expected_msg->x, expected_msg->len ) == 0 ); + + const data_t tag_expected = { .x = tag, + .len = tag_len }; + + for( n1 = 0; n1 <= msg->len; n1 += 1 ) + { + for( n1_add = 0; n1_add <= add->len; n1_add += 1 ) + { + mbedtls_test_set_step( n1 * 10000 + n1_add ); + if( !check_multipart( &ctx, MBEDTLS_CCM_DECRYPT, + iv, add, msg, + expected_msg, + &tag_expected, + n1, n1_add ) ) + goto exit; + } + } } else { size_t i; for( i = 0; i < msg->len; i++ ) - TEST_ASSERT( msg->x[i] == 0 ); + TEST_ASSERT( io_msg[i] == 0 ); } - /* Check we didn't write past the end (where the original tag is) */ - TEST_ASSERT( memcmp( msg->x + msg->len, tag, tag_len ) == 0 ); - exit: + free(io_msg); mbedtls_ccm_free( &ctx ); } /* END_CASE */ From 663055f78464a27f9470ed04142eb975554cf4ec Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 12 Jul 2021 19:13:52 +0200 Subject: [PATCH 229/966] Remove UPDATE_CBC macro and working b buffer. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 1 - library/ccm.c | 74 +++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index 813959be0b..72dfd3d6c4 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -77,7 +77,6 @@ extern "C" { typedef struct mbedtls_ccm_context { mbedtls_cipher_context_t MBEDTLS_PRIVATE(cipher_ctx); /*!< The cipher context used. */ - unsigned char MBEDTLS_PRIVATE(b)[16]; /*!< The B working buffer */ unsigned char MBEDTLS_PRIVATE(y)[16]; /*!< The Y working buffer */ unsigned char MBEDTLS_PRIVATE(ctr)[16]; /*!< The counter buffer */ unsigned char MBEDTLS_PRIVATE(q); /*!< The Q working value */ diff --git a/library/ccm.c b/library/ccm.c index 5450e408c1..399a936e93 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -106,22 +106,6 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) mbedtls_platform_zeroize( ctx, sizeof( mbedtls_ccm_context ) ); } -/* - * Update the CBC-MAC state in y using a block in b - * (Always using b as the source helps the compiler optimise a bit better.) - * - * Macro results in smaller compiled code than static inline functions. - */ -#define UPDATE_CBC_MAC \ - for( i = 0; i < 16; i++ ) \ - ctx->y[i] ^= ctx->b[i]; \ - \ - if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) \ - { \ - ctx->state |= CCM_STATE__ERROR; \ - return( ret ); \ - } \ - #define CCM_STATE__CLEAR 0 #define CCM_STATE__STARTED 0x0001 #define CCM_STATE__LENGHTS_SET 0x0002 @@ -155,7 +139,6 @@ static int mbedtls_ccm_crypt( mbedtls_ccm_context *ctx, static void mbedtls_ccm_clear_state(mbedtls_ccm_context *ctx) { ctx->state = CCM_STATE__CLEAR; - memset( ctx->b, 0, 16); memset( ctx->y, 0, 16); memset( ctx->ctr, 0, 16); } @@ -177,7 +160,7 @@ static int mbedtls_ccm_calculate_first_block(mbedtls_ccm_context *ctx) return( MBEDTLS_ERR_CCM_BAD_INPUT ); /* - * First block B_0: + * First block: * 0 .. 0 flags * 1 .. iv_len nonce (aka iv) - set by: mbedtls_ccm_starts() * iv_len+1 .. 15 length @@ -188,12 +171,12 @@ static int mbedtls_ccm_calculate_first_block(mbedtls_ccm_context *ctx) * 5 .. 3 (t - 2) / 2 * 2 .. 0 q - 1 */ - ctx->b[0] |= ( ctx->add_len > 0 ) << 6; - ctx->b[0] |= ( ( ctx->tag_len - 2 ) / 2 ) << 3; - ctx->b[0] |= ctx->q - 1; + ctx->y[0] |= ( ctx->add_len > 0 ) << 6; + ctx->y[0] |= ( ( ctx->tag_len - 2 ) / 2 ) << 3; + ctx->y[0] |= ctx->q - 1; for( i = 0, len_left = ctx->plaintext_len; i < ctx->q; i++, len_left >>= 8 ) - ctx->b[15-i] = (unsigned char)( len_left & 0xFF ); + ctx->y[15-i] = (unsigned char)( len_left & 0xFF ); if( len_left > 0 ) { @@ -202,7 +185,11 @@ static int mbedtls_ccm_calculate_first_block(mbedtls_ccm_context *ctx) } /* Start CBC-MAC with first block*/ - UPDATE_CBC_MAC; + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) + { + ctx->state |= CCM_STATE__ERROR; + return( ret ); + } return (0); } @@ -248,9 +235,9 @@ int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, ctx->ctr[15] = 1; /* - * See mbedtls_ccm_calculate_first_block() for B block layout description + * See mbedtls_ccm_calculate_first_block() for block layout description */ - memcpy( ctx->b + 1, iv, iv_len ); + memcpy( ctx->y + 1, iv, iv_len ); ctx->state |= CCM_STATE__STARTED; return mbedtls_ccm_calculate_first_block(ctx); @@ -304,9 +291,8 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, { if( ctx->processed == 0 ) { - memset( ctx->b, 0, 16 ); - ctx->b[0] = (unsigned char)( ( ctx->add_len >> 8 ) & 0xFF ); - ctx->b[1] = (unsigned char)( ( ctx->add_len ) & 0xFF ); + ctx->y[0] ^= (unsigned char)( ( ctx->add_len >> 8 ) & 0xFF ); + ctx->y[1] ^= (unsigned char)( ( ctx->add_len ) & 0xFF ); ctx->processed += 2; } @@ -320,15 +306,20 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, if( use_len > add_len ) use_len = add_len; - memcpy( ctx->b + offset, add, use_len ); + for( i = 0; i < use_len; i++ ) + ctx->y[i + offset] ^= add[i]; + ctx->processed += use_len; add_len -= use_len; add += use_len; if( use_len + offset == 16 || ctx->processed - 2 == ctx->add_len ) { - UPDATE_CBC_MAC; - memset( ctx->b, 0, 16 ); + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) + { + ctx->state |= CCM_STATE__ERROR; + return( ret ); + } } } } @@ -356,11 +347,6 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, CCM_VALIDATE_RET( output_length != NULL ); *output_len = input_len; - if( ctx->processed == 0 ) - { - memset( ctx->b, 0, 16 ); - } - while ( input_len > 0 ) { offset = ctx->processed % 16; @@ -371,16 +357,23 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, use_len = input_len; ctx->processed += use_len; - memcpy( ctx->b + offset, input, use_len ); if( ctx->mode == MBEDTLS_CCM_ENCRYPT || \ ctx->mode == MBEDTLS_CCM_STAR_ENCRYPT ) { + for( i = 0; i < use_len; i++ ) + ctx->y[i + offset] ^= input[i]; + if( use_len + offset == 16 || ctx->processed == ctx->plaintext_len ) { - UPDATE_CBC_MAC; + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) + { + ctx->state |= CCM_STATE__ERROR; + return( ret ); + } } - ret = mbedtls_ccm_crypt( ctx, offset, use_len, ctx->b + offset, output ); + + ret = mbedtls_ccm_crypt( ctx, offset, use_len, input, output ); if( ret != 0 ) return ret; } @@ -388,7 +381,7 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) { - ret = mbedtls_ccm_crypt( ctx, offset, use_len, ctx->b + offset, output ); + ret = mbedtls_ccm_crypt( ctx, offset, use_len, input, output ); if( ret != 0 ) return ret; @@ -410,7 +403,6 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, for( i = 0; i < ctx->q; i++ ) if( ++(ctx->ctr)[15-i] != 0 ) break; - memset( ctx->b, 0, 16 ); } input_len -= use_len; From 29ec75b34e9f34aac91524308966b0631f9c05b5 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 13 Jul 2021 12:26:17 +0200 Subject: [PATCH 230/966] Add multipart testing to CCM* tests. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.function | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 77ecf689b5..72c707ea0d 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -304,6 +304,7 @@ void mbedtls_ccm_star_encrypt_and_tag( int cipher_id, unsigned char result[50]; mbedtls_ccm_context ctx; size_t iv_len, tag_len; + size_t n1, n1_add; int ret; mbedtls_ccm_init( &ctx ); @@ -338,6 +339,31 @@ void mbedtls_ccm_star_encrypt_and_tag( int cipher_id, TEST_ASSERT( result[expected_result->len] == 0 && result[expected_result->len + 1] == 0 ); + if( ret == 0 ) + { + const data_t iv_data = { .x = iv, + .len = iv_len }; + + const data_t encrypted_expected = { .x = expected_result->x, + .len = msg->len }; + const data_t tag_expected = { .x = expected_result->x + msg->len, + .len = tag_len }; + + for( n1 = 0; n1 <= msg->len; n1 += 1 ) + { + for( n1_add = 0; n1_add <= add->len; n1_add += 1 ) + { + mbedtls_test_set_step( n1 * 10000 + n1_add ); + if( !check_multipart( &ctx, MBEDTLS_CCM_STAR_ENCRYPT, + &iv_data, add, msg, + &encrypted_expected, + &tag_expected, + n1, n1_add ) ) + goto exit; + } + } + } + exit: mbedtls_ccm_free( &ctx ); } @@ -354,6 +380,7 @@ void mbedtls_ccm_star_auth_decrypt( int cipher_id, unsigned char result[50]; mbedtls_ccm_context ctx; size_t iv_len, tag_len; + size_t n1, n1_add; int ret; mbedtls_ccm_init( &ctx ); @@ -389,6 +416,31 @@ void mbedtls_ccm_star_auth_decrypt( int cipher_id, TEST_EQUAL( result[msg->len], '+' ); TEST_EQUAL( result[msg->len + 1], '+' ); + if( ret == 0 ) + { + msg->len -= tag_len; + + const data_t iv_data = { .x = iv, + .len = iv_len }; + + const data_t tag_expected = { .x = msg->x + msg->len, + .len = tag_len }; + + for( n1 = 0; n1 <= msg->len; n1 += 1 ) + { + for( n1_add = 0; n1_add <= add->len; n1_add += 1 ) + { + mbedtls_test_set_step( n1 * 10000 + n1_add ); + if( !check_multipart( &ctx, MBEDTLS_CCM_STAR_DECRYPT, + &iv_data, add, msg, + expected_result, + &tag_expected, + n1, n1_add ) ) + goto exit; + } + } + } + exit: mbedtls_ccm_free( &ctx ); } From 27a1bef89d6b238473751f48a66335a7d2850aad Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 13 Jul 2021 15:33:19 +0200 Subject: [PATCH 231/966] Tidy up test functions. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.function | 216 ++++++++++++++------------- 1 file changed, 114 insertions(+), 102 deletions(-) diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 72c707ea0d..25cc49b8d2 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -48,7 +48,10 @@ static int check_multipart( mbedtls_ccm_context *ctx, mbedtls_free( output ); output = NULL; - ASSERT_ALLOC( output, tag->len ); + if( tag->len == 0 ) + ASSERT_ALLOC( output, 16 ); + else + ASSERT_ALLOC( output, tag->len ); TEST_EQUAL( 0, mbedtls_ccm_finish( ctx, output, tag->len ) ); ASSERT_COMPARE( output, tag->len, tag->x, tag->len ); mbedtls_free( output ); @@ -181,32 +184,34 @@ void mbedtls_ccm_encrypt_and_tag( int cipher_id, data_t * key, data_t * add, data_t * result ) { mbedtls_ccm_context ctx; - size_t tag_len; size_t n1, n1_add; - uint8_t * msg_n_tag = (uint8_t *)malloc( result->len + 2 ); + uint8_t* io_msg_buf = NULL; + uint8_t* tag_buf = NULL; + const size_t expected_tag_len = result->len - msg->len; + const uint8_t* expected_tag = result->x + msg->len; + + /* Prepare input/output message buffer */ + ASSERT_ALLOC( io_msg_buf, msg->len ); + if( msg->len != 0 ) + memcpy( io_msg_buf, msg->x, msg->len ); + + /* Prepare tag buffer */ + ASSERT_ALLOC( tag_buf, expected_tag_len ); mbedtls_ccm_init( &ctx ); - - memset( msg_n_tag, 0, result->len + 2 ); - memcpy( msg_n_tag, msg->x, msg->len ); - - tag_len = result->len - msg->len; - - TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ) == 0 ); - + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); /* Test with input == output */ - TEST_ASSERT( mbedtls_ccm_encrypt_and_tag( &ctx, msg->len, iv->x, iv->len, add->x, add->len, - msg_n_tag, msg_n_tag, msg_n_tag + msg->len, tag_len ) == 0 ); + TEST_EQUAL( mbedtls_ccm_encrypt_and_tag( &ctx, msg->len, iv->x, iv->len, add->x, add->len, + io_msg_buf, io_msg_buf, tag_buf, expected_tag_len ), 0); - TEST_ASSERT( memcmp( msg_n_tag, result->x, result->len ) == 0 ); - - /* Check we didn't write past the end */ - TEST_ASSERT( msg_n_tag[result->len] == 0 && msg_n_tag[result->len + 1] == 0 ); + ASSERT_COMPARE( io_msg_buf, msg->len, result->x, msg->len ); + ASSERT_COMPARE( tag_buf, expected_tag_len, expected_tag, expected_tag_len ); + /* Prepare data_t structers for multipart testing */ const data_t encrypted_expected = { .x = result->x, .len = msg->len }; - const data_t tag_expected = { .x = result->x + msg->len, - .len = tag_len }; + const data_t tag_expected = { .x = (uint8_t*) expected_tag, /* cast to conform with data_t x type */ + .len = expected_tag_len }; for( n1 = 0; n1 <= msg->len; n1 += 1 ) { @@ -224,54 +229,53 @@ void mbedtls_ccm_encrypt_and_tag( int cipher_id, data_t * key, exit: mbedtls_ccm_free( &ctx ); - free( msg_n_tag ); + mbedtls_free( io_msg_buf ); + mbedtls_free( tag_buf ); } /* END_CASE */ /* BEGIN_CASE */ void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, data_t * msg, data_t * iv, - data_t * add, int tag_len, int result, + data_t * add, int expected_tag_len, int result, data_t * expected_msg ) { - unsigned char tag[16]; mbedtls_ccm_context ctx; size_t n1, n1_add; + const size_t expected_msg_len = msg->len - expected_tag_len; + const uint8_t* expected_tag = msg->x + expected_msg_len; + + /* Prepare input/output message buffer */ + uint8_t* io_msg_buf = NULL; + ASSERT_ALLOC( io_msg_buf, expected_msg_len ); + if( expected_msg_len ) + memcpy( io_msg_buf, msg->x, expected_msg_len ); + mbedtls_ccm_init( &ctx ); - - memset( tag, 0x00, sizeof( tag ) ); - - msg->len -= tag_len; - memcpy( tag, msg->x + msg->len, tag_len ); - - uint8_t * io_msg = (uint8_t *)malloc( msg->len + 2 ); - memset( io_msg, 0, msg->len + 2 ); - memcpy( io_msg, msg->x, msg->len ); - - TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ) == 0 ); - + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); /* Test with input == output */ - TEST_ASSERT( mbedtls_ccm_auth_decrypt( &ctx, msg->len, iv->x, iv->len, add->x, add->len, - io_msg, io_msg, tag, tag_len ) == result ); - - /* Check we didn't write past the end */ - TEST_ASSERT( io_msg[msg->len] == 0 && io_msg[msg->len + 1] == 0 ); + TEST_EQUAL( mbedtls_ccm_auth_decrypt( &ctx, expected_msg_len, iv->x, iv->len, add->x, add->len, + io_msg_buf, io_msg_buf, expected_tag, expected_tag_len ), result ); if( result == 0 ) { - TEST_ASSERT( memcmp( io_msg, expected_msg->x, expected_msg->len ) == 0 ); + ASSERT_COMPARE( io_msg_buf, expected_msg_len, expected_msg->x, expected_msg_len ); - const data_t tag_expected = { .x = tag, - .len = tag_len }; + /* Prepare data_t structers for multipart testing */ + const data_t encrypted = { .x = msg->x, + .len = expected_msg_len }; - for( n1 = 0; n1 <= msg->len; n1 += 1 ) + const data_t tag_expected = { .x = (uint8_t*) expected_tag, + .len = expected_tag_len }; + + for( n1 = 0; n1 <= expected_msg_len; n1 += 1 ) { for( n1_add = 0; n1_add <= add->len; n1_add += 1 ) { mbedtls_test_set_step( n1 * 10000 + n1_add ); if( !check_multipart( &ctx, MBEDTLS_CCM_DECRYPT, - iv, add, msg, + iv, add, &encrypted, expected_msg, &tag_expected, n1, n1_add ) ) @@ -283,12 +287,12 @@ void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, { size_t i; - for( i = 0; i < msg->len; i++ ) - TEST_ASSERT( io_msg[i] == 0 ); + for( i = 0; i < expected_msg_len; i++ ) + TEST_EQUAL( io_msg_buf[i], 0 ); } exit: - free(io_msg); + mbedtls_free(io_msg_buf); mbedtls_ccm_free( &ctx ); } /* END_CASE */ @@ -301,21 +305,32 @@ void mbedtls_ccm_star_encrypt_and_tag( int cipher_id, data_t *expected_result, int output_ret ) { unsigned char iv[13]; - unsigned char result[50]; mbedtls_ccm_context ctx; - size_t iv_len, tag_len; + size_t iv_len, expected_tag_len; size_t n1, n1_add; - int ret; + uint8_t* io_msg_buf = NULL; + uint8_t* tag_buf = NULL; - mbedtls_ccm_init( &ctx ); - - memset( result, 0x00, sizeof( result ) ); + const uint8_t* expected_tag = expected_result->x + msg->len; + /* Calculate tag length */ if( sec_level % 4 == 0) - tag_len = 0; + expected_tag_len = 0; else - tag_len = 1 << ( sec_level % 4 + 1); + expected_tag_len = 1 << ( sec_level % 4 + 1); + /* Prepare input/output message buffer */ + ASSERT_ALLOC( io_msg_buf, msg->len ); + if( msg->len ) + memcpy( io_msg_buf, msg->x, msg->len ); + + /* Prepare tag buffer */ + if( expected_tag_len == 0 ) + ASSERT_ALLOC( tag_buf, 16 ); + else + ASSERT_ALLOC( tag_buf, expected_tag_len ); + + /* Calculate iv */ TEST_ASSERT( source_address->len == 8 ); TEST_ASSERT( frame_counter->len == 4 ); memcpy( iv, source_address->x, source_address->len ); @@ -323,31 +338,26 @@ void mbedtls_ccm_star_encrypt_and_tag( int cipher_id, iv[source_address->len + frame_counter->len] = sec_level; iv_len = sizeof( iv ); - TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, - key->x, key->len * 8 ) == 0 ); + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, + key->x, key->len * 8 ), 0 ); + /* Test with input == output */ + TEST_EQUAL( mbedtls_ccm_star_encrypt_and_tag( &ctx, msg->len, iv, iv_len, + add->x, add->len, io_msg_buf, + io_msg_buf, tag_buf, expected_tag_len), output_ret ); - ret = mbedtls_ccm_star_encrypt_and_tag( &ctx, msg->len, iv, iv_len, - add->x, add->len, msg->x, - result, result + msg->len, tag_len ); + ASSERT_COMPARE( io_msg_buf, msg->len, expected_result->x, msg->len ); + ASSERT_COMPARE( tag_buf, expected_tag_len, expected_tag, expected_tag_len ); - TEST_ASSERT( ret == output_ret ); - - TEST_ASSERT( memcmp( result, - expected_result->x, expected_result->len ) == 0 ); - - /* Check we didn't write past the end */ - TEST_ASSERT( result[expected_result->len] == 0 && - result[expected_result->len + 1] == 0 ); - - if( ret == 0 ) + if( output_ret == 0 ) { const data_t iv_data = { .x = iv, .len = iv_len }; const data_t encrypted_expected = { .x = expected_result->x, .len = msg->len }; - const data_t tag_expected = { .x = expected_result->x + msg->len, - .len = tag_len }; + const data_t tag_expected = { .x = (uint8_t*)expected_tag, + .len = expected_tag_len }; for( n1 = 0; n1 <= msg->len; n1 += 1 ) { @@ -366,6 +376,8 @@ void mbedtls_ccm_star_encrypt_and_tag( int cipher_id, exit: mbedtls_ccm_free( &ctx ); + mbedtls_free( io_msg_buf ); + mbedtls_free( tag_buf ); } /* END_CASE */ @@ -377,22 +389,27 @@ void mbedtls_ccm_star_auth_decrypt( int cipher_id, data_t *expected_result, int output_ret ) { unsigned char iv[13]; - unsigned char result[50]; mbedtls_ccm_context ctx; - size_t iv_len, tag_len; + size_t iv_len, expected_tag_len; size_t n1, n1_add; - int ret; - - mbedtls_ccm_init( &ctx ); - - memset( iv, 0x00, sizeof( iv ) ); - memset( result, '+', sizeof( result ) ); + /* Calculate tag length */ if( sec_level % 4 == 0) - tag_len = 0; + expected_tag_len = 0; else - tag_len = 1 << ( sec_level % 4 + 1); + expected_tag_len = 1 << ( sec_level % 4 + 1); + const size_t expected_msg_len = msg->len - expected_tag_len; + const uint8_t* expected_tag = msg->x + expected_msg_len; + + /* Prepare input/output message buffer */ + uint8_t* io_msg_buf = NULL; + ASSERT_ALLOC( io_msg_buf, expected_msg_len ); + if( expected_msg_len ) + memcpy( io_msg_buf, msg->x, expected_msg_len ); + + /* Calculate iv */ + memset( iv, 0x00, sizeof( iv ) ); TEST_ASSERT( source_address->len == 8 ); TEST_ASSERT( frame_counter->len == 4 ); memcpy( iv, source_address->x, source_address->len ); @@ -400,39 +417,33 @@ void mbedtls_ccm_star_auth_decrypt( int cipher_id, iv[source_address->len + frame_counter->len] = sec_level; iv_len = sizeof( iv ); + mbedtls_ccm_init( &ctx ); TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ) == 0 ); + /* Test with input == output */ + TEST_EQUAL( mbedtls_ccm_star_auth_decrypt( &ctx, expected_msg_len, iv, iv_len, + add->x, add->len, io_msg_buf, io_msg_buf, + expected_tag, expected_tag_len ), output_ret ); - ret = mbedtls_ccm_star_auth_decrypt( &ctx, msg->len - tag_len, iv, iv_len, - add->x, add->len, msg->x, result, - msg->x + msg->len - tag_len, tag_len ); + ASSERT_COMPARE( io_msg_buf, expected_msg_len, expected_result->x, expected_msg_len ); - TEST_ASSERT( ret == output_ret ); - - TEST_ASSERT( memcmp( result, expected_result->x, - expected_result->len ) == 0 ); - - /* Check we didn't write past the end (where the original tag is) */ - TEST_ASSERT( ( msg->len + 2 ) <= sizeof( result ) ); - TEST_EQUAL( result[msg->len], '+' ); - TEST_EQUAL( result[msg->len + 1], '+' ); - - if( ret == 0 ) + if( output_ret == 0 ) { - msg->len -= tag_len; - const data_t iv_data = { .x = iv, .len = iv_len }; - const data_t tag_expected = { .x = msg->x + msg->len, - .len = tag_len }; + const data_t encrypted = { .x = msg->x, + .len = expected_msg_len} ; - for( n1 = 0; n1 <= msg->len; n1 += 1 ) + const data_t tag_expected = { .x = (uint8_t*) expected_tag, + .len = expected_tag_len }; + + for( n1 = 0; n1 <= expected_msg_len; n1 += 1 ) { for( n1_add = 0; n1_add <= add->len; n1_add += 1 ) { mbedtls_test_set_step( n1 * 10000 + n1_add ); if( !check_multipart( &ctx, MBEDTLS_CCM_STAR_DECRYPT, - &iv_data, add, msg, + &iv_data, add, &encrypted, expected_result, &tag_expected, n1, n1_add ) ) @@ -443,5 +454,6 @@ void mbedtls_ccm_star_auth_decrypt( int cipher_id, exit: mbedtls_ccm_free( &ctx ); + mbedtls_free( io_msg_buf ); } /* END_CASE */ From de7a83da0d571e97364dbf9fd3571d1fd316a2a0 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 14 Jul 2021 12:39:14 +0200 Subject: [PATCH 232/966] Add changelog for chunked CCM implementation. Signed-off-by: Mateusz Starzyk --- ChangeLog.d/chunked_ccm.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 ChangeLog.d/chunked_ccm.txt diff --git a/ChangeLog.d/chunked_ccm.txt b/ChangeLog.d/chunked_ccm.txt new file mode 100644 index 0000000000..4e3065f906 --- /dev/null +++ b/ChangeLog.d/chunked_ccm.txt @@ -0,0 +1,8 @@ +Changes + * Implement multi-part CCM API. + The multi-part functions: mbedtls_ccm_starts(), mbedtls_ccm_set_lengths(), + mbedtls_ccm_update_ad(), mbedtls_ccm_update(), mbedtls_ccm_finish() + were introduced in mbedTLS 3.0 release, however their implementation was + postponed util now. + Implemented functions support chunked data input for both CCM and CCM* + algorithms. From 4df9ac4882b467c2bd06eec87c144cf024c0f0af Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 27 Jul 2021 13:47:23 +0200 Subject: [PATCH 233/966] Reorganize ccm context structure. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index 72dfd3d6c4..c903e68fd3 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -76,19 +76,19 @@ extern "C" { */ typedef struct mbedtls_ccm_context { - mbedtls_cipher_context_t MBEDTLS_PRIVATE(cipher_ctx); /*!< The cipher context used. */ unsigned char MBEDTLS_PRIVATE(y)[16]; /*!< The Y working buffer */ unsigned char MBEDTLS_PRIVATE(ctr)[16]; /*!< The counter buffer */ - unsigned char MBEDTLS_PRIVATE(q); /*!< The Q working value */ + mbedtls_cipher_context_t MBEDTLS_PRIVATE(cipher_ctx); /*!< The cipher context used. */ size_t MBEDTLS_PRIVATE(plaintext_len); /*!< Total plaintext length */ size_t MBEDTLS_PRIVATE(add_len); /*!< Total authentication data length */ size_t MBEDTLS_PRIVATE(tag_len); /*!< Total tag length */ size_t MBEDTLS_PRIVATE(processed); /*!< How many bytes of input data were processed (chunked input) */ - int MBEDTLS_PRIVATE(mode); /*!< The operation to perform: - #MBEDTLS_CCM_ENCRYPT or - #MBEDTLS_CCM_DECRYPT or - #MBEDTLS_CCM_STAR_ENCRYPT or - #MBEDTLS_CCM_STAR_DECRYPT. */ + unsigned char MBEDTLS_PRIVATE(q); /*!< The Q working value */ + unsigned char MBEDTLS_PRIVATE(mode); /*!< The operation to perform: + #MBEDTLS_CCM_ENCRYPT or + #MBEDTLS_CCM_DECRYPT or + #MBEDTLS_CCM_STAR_ENCRYPT or + #MBEDTLS_CCM_STAR_DECRYPT. */ int MBEDTLS_PRIVATE(state); /*!< Working value holding context's state. Used for chunked data input */ From a9cbdfbb349a3bed44ad7241472e938e944278f5 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 27 Jul 2021 13:49:54 +0200 Subject: [PATCH 234/966] Replace ccm status flags with bitshifts. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 399a936e93..be1671c04c 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -107,9 +107,9 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) } #define CCM_STATE__CLEAR 0 -#define CCM_STATE__STARTED 0x0001 -#define CCM_STATE__LENGHTS_SET 0x0002 -#define CCM_STATE__ERROR 0x0004 +#define CCM_STATE__STARTED (1 << 0) +#define CCM_STATE__LENGHTS_SET (1 << 1) +#define CCM_STATE__ERROR (1 << 2) /* * Encrypt or decrypt a partial block with CTR From c52220d775aba3a30a1a64035aacb448cb6e58d3 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 27 Jul 2021 13:54:55 +0200 Subject: [PATCH 235/966] Clear temporary buffer after block crypt operation. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/ccm.c b/library/ccm.c index be1671c04c..425872dc32 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -127,13 +127,15 @@ static int mbedtls_ccm_crypt( mbedtls_ccm_context *ctx, if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->ctr, 16, tmp_buf, &olen ) ) != 0 ) { - ctx->state |= CCM_STATE__ERROR; \ + ctx->state |= CCM_STATE__ERROR; + mbedtls_platform_zeroize(tmp_buf, sizeof(tmp_buf)); return ret; } for( i = 0; i < use_len; i++ ) output[i] = input[i] ^ tmp_buf[offset + i]; + mbedtls_platform_zeroize(tmp_buf, sizeof(tmp_buf)); return ret; } From ca9dc8d1d742b5e5f193c5b8f70709fe3c043ee4 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 27 Jul 2021 14:03:53 +0200 Subject: [PATCH 236/966] Rename ccm_calculate_first_block function. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 425872dc32..d8c65b552e 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -145,7 +145,7 @@ static void mbedtls_ccm_clear_state(mbedtls_ccm_context *ctx) { memset( ctx->ctr, 0, 16); } -static int mbedtls_ccm_calculate_first_block(mbedtls_ccm_context *ctx) +static int ccm_calculate_first_block_if_ready(mbedtls_ccm_context *ctx) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; @@ -237,12 +237,12 @@ int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, ctx->ctr[15] = 1; /* - * See mbedtls_ccm_calculate_first_block() for block layout description + * See ccm_calculate_first_block_if_ready() for block layout description */ memcpy( ctx->y + 1, iv, iv_len ); ctx->state |= CCM_STATE__STARTED; - return mbedtls_ccm_calculate_first_block(ctx); + return ccm_calculate_first_block_if_ready(ctx); } int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, @@ -276,7 +276,7 @@ int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, ctx->processed = 0; ctx->state |= CCM_STATE__LENGHTS_SET; - return mbedtls_ccm_calculate_first_block(ctx); + return ccm_calculate_first_block_if_ready(ctx); } int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, From 5d97601e81af90dc92bc9577d2515f7849a25837 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 27 Jul 2021 14:12:30 +0200 Subject: [PATCH 237/966] Remove ccm input validation. VALIDATE and VALIDATE_RET macros are obsolete. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index d8c65b552e..80a795fc1d 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -47,18 +47,12 @@ #if !defined(MBEDTLS_CCM_ALT) -#define CCM_VALIDATE_RET( cond ) \ - MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_CCM_BAD_INPUT ) -#define CCM_VALIDATE( cond ) \ - MBEDTLS_INTERNAL_VALIDATE( cond ) - /* * Initialize context */ void mbedtls_ccm_init( mbedtls_ccm_context *ctx ) { - CCM_VALIDATE( ctx != NULL ); memset( ctx, 0, sizeof( mbedtls_ccm_context ) ); } @@ -70,9 +64,6 @@ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const mbedtls_cipher_info_t *cipher_info; - CCM_VALIDATE_RET( ctx != NULL ); - CCM_VALIDATE_RET( key != NULL ); - cipher_info = mbedtls_cipher_info_from_values( cipher, keybits, MBEDTLS_MODE_ECB ); if( cipher_info == NULL ) @@ -201,13 +192,6 @@ int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, const unsigned char *iv, size_t iv_len ) { - CCM_VALIDATE_RET( ctx != NULL ); - CCM_VALIDATE_RET( iv != NULL ); - CCM_VALIDATE_RET( mode == MBEDTLS_CCM_DECRYPT || \ - mode == MBEDTLS_CCM_STAR_DECRYPT || \ - mode == MBEDTLS_CCM_ENCRYPT || \ - mode == MBEDTLS_CCM_STAR_ENCRYPT ); - /* Also implies q is within bounds */ if( iv_len < 7 || iv_len > 13 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); @@ -250,8 +234,6 @@ int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, size_t plaintext_len, size_t tag_len ) { - CCM_VALIDATE_RET( ctx != NULL ); - /* * Check length requirements: SP800-38C A.1 * Additional requirement: a < 2^16 - 2^8 to simplify the code. @@ -283,8 +265,6 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, const unsigned char *add, size_t add_len ) { - CCM_VALIDATE_RET( ctx->add_len == 0 || add != NULL ); - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; size_t olen, use_len, offset; @@ -337,16 +317,12 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, unsigned char *output, size_t output_size, size_t *output_len ) { - CCM_VALIDATE_RET( ctx->plaintext_len == 0 || input != NULL ); - CCM_VALIDATE_RET( ctx->plaintext_len == 0 || output != NULL ); - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; size_t use_len, offset, olen; if( output_size < input_len ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); - CCM_VALIDATE_RET( output_length != NULL ); *output_len = input_len; while ( input_len > 0 ) @@ -421,7 +397,6 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; - CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); /* * Authentication: reset counter and crypt/mask internal tag */ From 2d5652aceed0a4d3a15d949baae6cbc939ce4d75 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 27 Jul 2021 16:07:54 +0200 Subject: [PATCH 238/966] Move ccm error state handling. Remove error clearing from ccm_starts() and ccm_set_lengths(). Add error check in ccm_update_ad(), ccm_update() and ccm_finish(). Signed-off-by: Mateusz Starzyk --- library/ccm.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 80a795fc1d..1247f8d377 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -118,7 +118,7 @@ static int mbedtls_ccm_crypt( mbedtls_ccm_context *ctx, if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->ctr, 16, tmp_buf, &olen ) ) != 0 ) { - ctx->state |= CCM_STATE__ERROR; + ctx->state |= CCM_STATE__ERROR; mbedtls_platform_zeroize(tmp_buf, sizeof(tmp_buf)); return ret; } @@ -196,11 +196,6 @@ int mbedtls_ccm_starts( mbedtls_ccm_context *ctx, if( iv_len < 7 || iv_len > 13 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); - if( ctx->state & CCM_STATE__ERROR ) - { - mbedtls_ccm_clear_state(ctx); - } - ctx->mode = mode; ctx->q = 16 - 1 - (unsigned char) iv_len; @@ -247,11 +242,6 @@ int mbedtls_ccm_set_lengths( mbedtls_ccm_context *ctx, if( total_ad_len >= 0xFF00 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); - if( ctx->state & CCM_STATE__ERROR ) - { - mbedtls_ccm_clear_state(ctx); - } - ctx->plaintext_len = plaintext_len; ctx->add_len = total_ad_len; ctx->tag_len = tag_len; @@ -269,6 +259,11 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, unsigned char i; size_t olen, use_len, offset; + if( ctx->state & CCM_STATE__ERROR ) + { + return ret; + } + if( ctx->add_len > 0 && add_len > 0) { if( ctx->processed == 0 ) @@ -321,6 +316,11 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, unsigned char i; size_t use_len, offset, olen; + if( ctx->state & CCM_STATE__ERROR ) + { + return ret; + } + if( output_size < input_len ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); *output_len = input_len; @@ -397,6 +397,11 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; + if( ctx->state & CCM_STATE__ERROR ) + { + return ret; + } + /* * Authentication: reset counter and crypt/mask internal tag */ From 36d3b89c84a46726eba6040b945724ec78bfffee Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 28 Jul 2021 14:14:58 +0200 Subject: [PATCH 239/966] Verify input data lengths. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 1247f8d377..a6ba77435c 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -100,7 +100,8 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) #define CCM_STATE__CLEAR 0 #define CCM_STATE__STARTED (1 << 0) #define CCM_STATE__LENGHTS_SET (1 << 1) -#define CCM_STATE__ERROR (1 << 2) +#define CCM_STATE__AUTH_DATA_FINISHED (1 << 2) +#define CCM_STATE__ERROR (1 << 4) /* * Encrypt or decrypt a partial block with CTR @@ -264,15 +265,29 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, return ret; } - if( ctx->add_len > 0 && add_len > 0) + if( ctx->add_len > 0 && add_len > 0 ) { + if( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) + { + return ret; + } + if( ctx->processed == 0 ) { + if ( add_len > ctx->add_len ) + { + return MBEDTLS_ERR_CCM_BAD_INPUT; + } + ctx->y[0] ^= (unsigned char)( ( ctx->add_len >> 8 ) & 0xFF ); ctx->y[1] ^= (unsigned char)( ( ctx->add_len ) & 0xFF ); ctx->processed += 2; } + else if ( ctx->processed - 2 + add_len > ctx->add_len ) + { + return MBEDTLS_ERR_CCM_BAD_INPUT; + } while( add_len > 0 ) { @@ -299,10 +314,13 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, } } } - } - if( ctx->processed - 2 == ctx->add_len ) - ctx->processed = 0; // prepare for mbedtls_ccm_update() + if( ctx->processed - 2 == ctx->add_len ) + { + ctx->state |= CCM_STATE__AUTH_DATA_FINISHED; + ctx->processed = 0; // prepare for mbedtls_ccm_update() + } + } return (0); } @@ -321,6 +339,11 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, return ret; } + if( ctx->processed + input_len > ctx->plaintext_len ) + { + return MBEDTLS_ERR_CCM_BAD_INPUT; + } + if( output_size < input_len ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); *output_len = input_len; @@ -402,6 +425,16 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, return ret; } + if( ctx->add_len > 0 && !( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) ) + { + return ret; + } + + if( ctx->plaintext_len > 0 && ctx->processed != ctx->plaintext_len ) + { + return ret; + } + /* * Authentication: reset counter and crypt/mask internal tag */ From 22f7a35ca4de9bca49aa2e994eaa87460b3abe77 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 28 Jul 2021 15:08:47 +0200 Subject: [PATCH 240/966] Do not use output buffer for internal XOR during decryption. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 2 ++ library/ccm.c | 56 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index c903e68fd3..06aa6a8884 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -61,6 +61,8 @@ #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /** Authenticated decryption failed. */ #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F +/** Memory allocation failed */ +#define MBEDTLS_ERR_CCM_ALLOC_FAILED -0x0011 #ifdef __cplusplus extern "C" { diff --git a/library/ccm.c b/library/ccm.c index a6ba77435c..3663a769da 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -36,14 +36,17 @@ #include -#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) #if defined(MBEDTLS_PLATFORM_C) #include "mbedtls/platform.h" #else +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) #include #define mbedtls_printf printf -#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif /* MBEDTLS_PLATFORM_C */ #if !defined(MBEDTLS_CCM_ALT) @@ -330,13 +333,16 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, unsigned char *output, size_t output_size, size_t *output_len ) { - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + int ret; unsigned char i; size_t use_len, offset, olen; + const size_t local_output_len = input_len; + unsigned char* local_output = NULL; + if( ctx->state & CCM_STATE__ERROR ) { - return ret; + return MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; } if( ctx->processed + input_len > ctx->plaintext_len ) @@ -344,10 +350,24 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, return MBEDTLS_ERR_CCM_BAD_INPUT; } + /* Local output is used for decryption only. */ + if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ + ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) + { + local_output = mbedtls_calloc( local_output_len, sizeof( *local_output) ); + if( local_output == NULL ) + { + ctx->state |= CCM_STATE__ERROR; + return MBEDTLS_ERR_CCM_ALLOC_FAILED; + } + } + if( output_size < input_len ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); *output_len = input_len; + ret = 0; + while ( input_len > 0 ) { offset = ctx->processed % 16; @@ -370,31 +390,37 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) { ctx->state |= CCM_STATE__ERROR; - return( ret ); + goto exit; } } ret = mbedtls_ccm_crypt( ctx, offset, use_len, input, output ); if( ret != 0 ) - return ret; + goto exit; } if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) { - ret = mbedtls_ccm_crypt( ctx, offset, use_len, input, output ); + /* Write decrypted data to local_output to avoid using output variable as + * input in the XOR operation for Y. + */ + ret = mbedtls_ccm_crypt( ctx, offset, use_len, input, local_output ); if( ret != 0 ) - return ret; + goto exit; for( i = 0; i < use_len; i++ ) - ctx->y[i + offset] ^= output[i]; + ctx->y[i + offset] ^= local_output[i]; + + memcpy( output, local_output, use_len ); + mbedtls_platform_zeroize( local_output, local_output_len ); if( use_len + offset == 16 || ctx->processed == ctx->plaintext_len ) { if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) { ctx->state |= CCM_STATE__ERROR; - return( ret ); + goto exit; } } } @@ -411,7 +437,15 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, output += use_len; } - return 0; +exit: + if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ + ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) + { + mbedtls_platform_zeroize( local_output, local_output_len ); + mbedtls_free( local_output ); + } + + return ret; } int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, From eb395c00c9253aa6552128d0da1e05002df30aa1 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 28 Jul 2021 15:10:54 +0200 Subject: [PATCH 241/966] Move 'Authenticated decryption' comment. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 3663a769da..51cee939f3 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -538,6 +538,9 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, add, add_len, input, output, tag, tag_len ) ); } +/* + * Authenticated decryption + */ static int mbedtls_ccm_compare_tags(const unsigned char *tag1, const unsigned char *tag2, size_t tag_len) { unsigned char i; @@ -555,9 +558,6 @@ static int mbedtls_ccm_compare_tags(const unsigned char *tag1, const unsigned ch return( 0 ); } -/* - * Authenticated decryption - */ int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, From 1bda9451ef395c35b99255625fc647287e4ecc8e Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 28 Jul 2021 15:21:46 +0200 Subject: [PATCH 242/966] Factor out common code from ccm decrypt functions. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 51cee939f3..a14e025ded 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -558,16 +558,16 @@ static int mbedtls_ccm_compare_tags(const unsigned char *tag1, const unsigned ch return( 0 ); } -int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, - const unsigned char *iv, size_t iv_len, - const unsigned char *add, size_t add_len, - const unsigned char *input, unsigned char *output, - const unsigned char *tag, size_t tag_len ) +static int ccm_auth_decrypt( mbedtls_ccm_context *ctx, int mode, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + const unsigned char *tag, size_t tag_len ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char check_tag[16]; - if( ( ret = ccm_auth_crypt( ctx, MBEDTLS_CCM_STAR_DECRYPT, length, + if( ( ret = ccm_auth_crypt( ctx, mode, length, iv, iv_len, add, add_len, input, output, check_tag, tag_len ) ) != 0 ) { @@ -583,29 +583,26 @@ int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, return( 0 ); } +int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + const unsigned char *tag, size_t tag_len ) +{ + return ccm_auth_decrypt( ctx, MBEDTLS_CCM_STAR_DECRYPT, length, + iv, iv_len, add, add_len, + input, output, tag, tag_len ); +} + int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len ) { - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - unsigned char check_tag[16]; - - if( ( ret = ccm_auth_crypt( ctx, MBEDTLS_CCM_DECRYPT, length, - iv, iv_len, add, add_len, - input, output, check_tag, tag_len ) ) != 0 ) - { - return( ret ); - } - - if( ( ret = mbedtls_ccm_compare_tags( tag, check_tag, tag_len ) ) != 0 ) - { - mbedtls_platform_zeroize( output, length ); - return( ret ); - } - - return( 0 ); + return ccm_auth_decrypt( ctx, MBEDTLS_CCM_DECRYPT, length, + iv, iv_len, add, add_len, + input, output, tag, tag_len ); } #endif /* !MBEDTLS_CCM_ALT */ From c8bdf36a728989cab1b81f0dbcd856f75ea4fdda Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 28 Jul 2021 15:39:51 +0200 Subject: [PATCH 243/966] Validate tag pointer in ccm function. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 3 ++- tests/suites/test_suite_ccm.function | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index a14e025ded..af26de8d4f 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -478,7 +478,8 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, ret = mbedtls_ccm_crypt( ctx, 0, 16, ctx->y, ctx->y ); if( ret != 0 ) return ret; - memcpy( tag, ctx->y, tag_len ); + if( tag != NULL ) + memcpy( tag, ctx->y, tag_len ); mbedtls_ccm_clear_state(ctx); return( 0 ); diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 25cc49b8d2..21f0699b4a 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -48,10 +48,7 @@ static int check_multipart( mbedtls_ccm_context *ctx, mbedtls_free( output ); output = NULL; - if( tag->len == 0 ) - ASSERT_ALLOC( output, 16 ); - else - ASSERT_ALLOC( output, tag->len ); + ASSERT_ALLOC( output, tag->len ); TEST_EQUAL( 0, mbedtls_ccm_finish( ctx, output, tag->len ) ); ASSERT_COMPARE( output, tag->len, tag->x, tag->len ); mbedtls_free( output ); From 87889069477435c8f5cfd2a13db6f62df08cf233 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 29 Jul 2021 14:08:18 +0200 Subject: [PATCH 244/966] Add CCM test for edge cases. Cover: - not calling auth data update - not calling cipher text update - exceeding configured auth data length - exceeding configured cipher text length Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 64 +++++++++++++++ tests/suites/test_suite_ccm.function | 111 +++++++++++++++++++++++++++ 2 files changed, 175 insertions(+) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index a14d4be252..382d2180f2 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -1517,3 +1517,67 @@ mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_CAMELLIA:"D75C2778078CA93D971F96FD CCM-Camellia encrypt and tag RFC 5528 #24 depends_on:MBEDTLS_CAMELLIA_C mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_CAMELLIA:"D75C2778078CA93D971F96FDE720F4CD":"9DC9EDAE2FF5DF8636E8C6DE0EED55F7867E33337D":"003B8FD8D3A937B160B6A31C1C":"A4D499F78419728C19178B0C":"4B198156393B0F7796086AAFB454F8C3F034CCA966945F1FCEA7E11BEE6A2F" + +CCM encrypt, skip auth NIST VADT AES-128 (P=24, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d24a3d3dde8c84830280cb87abad0bb3":"7c86135ed9c2a515aaae0e9a208133897269220f30870006":"f1100035bb24a8d26004e0e24b":"1faeb0ee2ca2cd52f0aa3966578344f24e69b742c4ab37ab":"1123301219c70599b7c373ad4b3ad67b" + +CCM* encrypt, skip auth NIST VADT AES-128 (P=24, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d24a3d3dde8c84830280cb87abad0bb3":"7c86135ed9c2a515aaae0e9a208133897269220f30870006":"f1100035bb24a8d26004e0e24b":"1faeb0ee2ca2cd52f0aa3966578344f24e69b742c4ab37ab":"1123301219c70599b7c373ad4b3ad67b" + +CCM decrypt, skip auth NIST DVPT AES-192 (P=24, N=7, A=0, T=4) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22":"ddc93a54" + +CCM* decrypt, skip auth NIST DVPT AES-192 (P=24, N=7, A=0, T=4) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22":"ddc93a54" + +CCM encrypt, skip cipher NIST VPT AES-128 #1 (P=0, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"2ebf60f0969013a54a3dedb19d20f6c8":"1de8c5e21f9db33123ff870add":"e1de6c6119d7db471136285d10b47a450221b16978569190ef6a22b055295603":"0ead29ef205fbb86d11abe5ed704b880" + +CCM* encrypt, skip cipher NIST VPT AES-128 #1 (P=0, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"2ebf60f0969013a54a3dedb19d20f6c8":"1de8c5e21f9db33123ff870add":"e1de6c6119d7db471136285d10b47a450221b16978569190ef6a22b055295603":"0ead29ef205fbb86d11abe5ed704b880" + +CCM decrypt, skip cipher NIST DVPT AES-256 #23 (P=0, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"867b0d87cf6e0f718200a97b4f6d5ad5" + +CCM* decrypt, skip cipher NIST DVPT AES-256 #23 (P=0, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"867b0d87cf6e0f718200a97b4f6d5ad5" + +CCM encrypt, overflow auth NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_overflow_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM encrypt, overflow cipher NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_overflow_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM decrypt, overflow auth NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_overflow_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM decrypt, overflow cipher NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_overflow_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* encrypt, overflow auth NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_overflow_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* encrypt, overflow cipher NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_overflow_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* decrypt, overflow auth NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_overflow_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* decrypt, overflow cipher NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_overflow_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 21f0699b4a..347f189777 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -454,3 +454,114 @@ exit: mbedtls_free( io_msg_buf ); } /* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ccm_skip_auth( int cipher_id, int mode, + data_t * key, data_t * msg, data_t * iv, + data_t * result, data_t * tag ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + size_t olen; + + /* Sanity checks on the test data */ + TEST_EQUAL( msg->len, result->len ); + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, 0, msg->len, tag->len ) ); + + ASSERT_ALLOC( output, result->len ); + olen = 0xdeadbeef; + TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg->x, msg->len, output, result->len, &olen ) ); + TEST_EQUAL( result->len, olen ); + ASSERT_COMPARE( output, olen, result->x, result->len ); + mbedtls_free( output ); + output = NULL; + + ASSERT_ALLOC( output, tag->len ); + TEST_EQUAL( 0, mbedtls_ccm_finish( &ctx, output, tag->len ) ); + ASSERT_COMPARE( output, tag->len, tag->x, tag->len ); + mbedtls_free( output ); + output = NULL; + +exit: + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ccm_skip_cipher( int cipher_id, int mode, + data_t * key, data_t * iv, data_t* add, + data_t * tag ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, 0, tag->len ) ); + + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); + + ASSERT_ALLOC( output, tag->len ); + TEST_EQUAL( 0, mbedtls_ccm_finish( &ctx, output, tag->len ) ); + ASSERT_COMPARE( output, tag->len, tag->x, tag->len ); + mbedtls_free( output ); + output = NULL; + +exit: + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ccm_overflow_auth( int cipher_id, int mode, + data_t * key, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded values for msg length and tag length. They are not a part of this test + // set half of auth data length to provoke an overflow + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len / 2, 16, 16 ) ); + + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); +exit: + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ccm_overflow_cipher( int cipher_id, int mode, + data_t * key, data_t * msg, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + size_t olen; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded value for tag length. It is a not a part of this test + // set half of msg length to provoke an overflow + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, msg->len / 2, 16 ) ); + + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); + + ASSERT_ALLOC( output, msg->len ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, \ + mbedtls_ccm_update( &ctx, msg->x, msg->len, output, msg->len, &olen ) ); +exit: + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ From ceb5bc6150877c658f3572cb74448b8a343229b4 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Fri, 30 Jul 2021 14:36:22 +0200 Subject: [PATCH 245/966] Fix typos. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.function | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 347f189777..39e0b0b532 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -204,7 +204,7 @@ void mbedtls_ccm_encrypt_and_tag( int cipher_id, data_t * key, ASSERT_COMPARE( io_msg_buf, msg->len, result->x, msg->len ); ASSERT_COMPARE( tag_buf, expected_tag_len, expected_tag, expected_tag_len ); - /* Prepare data_t structers for multipart testing */ + /* Prepare data_t structures for multipart testing */ const data_t encrypted_expected = { .x = result->x, .len = msg->len }; const data_t tag_expected = { .x = (uint8_t*) expected_tag, /* cast to conform with data_t x type */ @@ -259,7 +259,7 @@ void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, { ASSERT_COMPARE( io_msg_buf, expected_msg_len, expected_msg->x, expected_msg_len ); - /* Prepare data_t structers for multipart testing */ + /* Prepare data_t structures for multipart testing */ const data_t encrypted = { .x = msg->x, .len = expected_msg_len }; From c562788068ed9186807aa2c857954f925dd9644d Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 2 Aug 2021 11:49:58 +0200 Subject: [PATCH 246/966] Fix local buffer allocation conditions. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index af26de8d4f..20e9414acc 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -351,8 +351,9 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, } /* Local output is used for decryption only. */ - if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ - ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) + if( local_output_len > 0 && \ + ( ctx->mode == MBEDTLS_CCM_DECRYPT || \ + ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) ) { local_output = mbedtls_calloc( local_output_len, sizeof( *local_output) ); if( local_output == NULL ) From f337850738ca8d77dd0d31514fdb451381f6bd38 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 9 Aug 2021 11:32:11 +0200 Subject: [PATCH 247/966] Use const size buffer for local output in CCM decryption. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 2 -- library/ccm.c | 28 +++------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index 06aa6a8884..c903e68fd3 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -61,8 +61,6 @@ #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /** Authenticated decryption failed. */ #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F -/** Memory allocation failed */ -#define MBEDTLS_ERR_CCM_ALLOC_FAILED -0x0011 #ifdef __cplusplus extern "C" { diff --git a/library/ccm.c b/library/ccm.c index 20e9414acc..13582d2a0e 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -43,9 +43,6 @@ #include #define mbedtls_printf printf #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ -#include -#define mbedtls_calloc calloc -#define mbedtls_free free #endif /* MBEDTLS_PLATFORM_C */ #if !defined(MBEDTLS_CCM_ALT) @@ -337,8 +334,7 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, unsigned char i; size_t use_len, offset, olen; - const size_t local_output_len = input_len; - unsigned char* local_output = NULL; + unsigned char local_output[16]; if( ctx->state & CCM_STATE__ERROR ) { @@ -350,19 +346,6 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, return MBEDTLS_ERR_CCM_BAD_INPUT; } - /* Local output is used for decryption only. */ - if( local_output_len > 0 && \ - ( ctx->mode == MBEDTLS_CCM_DECRYPT || \ - ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) ) - { - local_output = mbedtls_calloc( local_output_len, sizeof( *local_output) ); - if( local_output == NULL ) - { - ctx->state |= CCM_STATE__ERROR; - return MBEDTLS_ERR_CCM_ALLOC_FAILED; - } - } - if( output_size < input_len ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); *output_len = input_len; @@ -414,7 +397,7 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, ctx->y[i + offset] ^= local_output[i]; memcpy( output, local_output, use_len ); - mbedtls_platform_zeroize( local_output, local_output_len ); + mbedtls_platform_zeroize( local_output, 16 ); if( use_len + offset == 16 || ctx->processed == ctx->plaintext_len ) { @@ -439,12 +422,7 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, } exit: - if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ - ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) - { - mbedtls_platform_zeroize( local_output, local_output_len ); - mbedtls_free( local_output ); - } + mbedtls_platform_zeroize( local_output, 16 ); return ret; } From 4f2dd8aada0f75717db1ff9c0139de71f93a0321 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 9 Aug 2021 15:37:47 +0200 Subject: [PATCH 248/966] Fix errors returned by CCM functions. Add new error code for calling functions in wrong order. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 2 ++ library/ccm.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index c903e68fd3..d478414395 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -61,6 +61,8 @@ #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /** Authenticated decryption failed. */ #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F +/** CCM functions called in the wrong sequence. */ +#define MBEDTLS_ERR_CCM_BAD_SEQUENCE -0x0011 #ifdef __cplusplus extern "C" { diff --git a/library/ccm.c b/library/ccm.c index 13582d2a0e..33c631a87a 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -269,7 +269,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, { if( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) { - return ret; + return MBEDTLS_ERR_CCM_BAD_SEQUENCE; } if( ctx->processed == 0 ) @@ -430,22 +430,22 @@ exit: int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, unsigned char *tag, size_t tag_len ) { - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + int ret; unsigned char i; if( ctx->state & CCM_STATE__ERROR ) { - return ret; + return MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; } if( ctx->add_len > 0 && !( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) ) { - return ret; + return MBEDTLS_ERR_CCM_BAD_SEQUENCE; } if( ctx->plaintext_len > 0 && ctx->processed != ctx->plaintext_len ) { - return ret; + return MBEDTLS_ERR_CCM_BAD_SEQUENCE; } /* From 62d22f9782dd68876353feb23889210ebb9a7efc Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 9 Aug 2021 15:53:41 +0200 Subject: [PATCH 249/966] Use additional state in CCM to track auth data input. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 33c631a87a..7574bdcf62 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -100,7 +100,8 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) #define CCM_STATE__CLEAR 0 #define CCM_STATE__STARTED (1 << 0) #define CCM_STATE__LENGHTS_SET (1 << 1) -#define CCM_STATE__AUTH_DATA_FINISHED (1 << 2) +#define CCM_STATE__AUTH_DATA_STARTED (1 << 2) +#define CCM_STATE__AUTH_DATA_FINISHED (1 << 3) #define CCM_STATE__ERROR (1 << 4) /* @@ -272,7 +273,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, return MBEDTLS_ERR_CCM_BAD_SEQUENCE; } - if( ctx->processed == 0 ) + if( !(ctx->state & CCM_STATE__AUTH_DATA_STARTED) ) { if ( add_len > ctx->add_len ) { @@ -282,17 +283,17 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, ctx->y[0] ^= (unsigned char)( ( ctx->add_len >> 8 ) & 0xFF ); ctx->y[1] ^= (unsigned char)( ( ctx->add_len ) & 0xFF ); - ctx->processed += 2; + ctx->state |= CCM_STATE__AUTH_DATA_STARTED; } - else if ( ctx->processed - 2 + add_len > ctx->add_len ) + else if ( ctx->processed + add_len > ctx->add_len ) { return MBEDTLS_ERR_CCM_BAD_INPUT; } while( add_len > 0 ) { - offset = ctx->processed % 16; - + offset = (ctx->processed + 2) % 16; /* account for y[0] and y[1] + * holding total auth data length */ use_len = 16 - offset; if( use_len > add_len ) @@ -305,7 +306,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, add_len -= use_len; add += use_len; - if( use_len + offset == 16 || ctx->processed - 2 == ctx->add_len ) + if( use_len + offset == 16 || ctx->processed == ctx->add_len ) { if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctx->y, 16, ctx->y, &olen ) ) != 0 ) { @@ -315,7 +316,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, } } - if( ctx->processed - 2 == ctx->add_len ) + if( ctx->processed == ctx->add_len ) { ctx->state |= CCM_STATE__AUTH_DATA_FINISHED; ctx->processed = 0; // prepare for mbedtls_ccm_update() From b73c3ec1bc5f8e885421af5352a6f57455900137 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 9 Aug 2021 15:55:38 +0200 Subject: [PATCH 250/966] Restore MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED as default ret. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 7574bdcf62..b7c8f6d4d9 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -331,7 +331,7 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, unsigned char *output, size_t output_size, size_t *output_len ) { - int ret; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; size_t use_len, offset, olen; @@ -431,7 +431,7 @@ exit: int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, unsigned char *tag, size_t tag_len ) { - int ret; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char i; if( ctx->state & CCM_STATE__ERROR ) From a42f9537b53411effa79b0b14591f131ee2a2ebc Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 9 Aug 2021 16:00:24 +0200 Subject: [PATCH 251/966] Improve documentation for CCM's `processed` variable. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index d478414395..8aacfce55e 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -84,7 +84,12 @@ typedef struct mbedtls_ccm_context size_t MBEDTLS_PRIVATE(plaintext_len); /*!< Total plaintext length */ size_t MBEDTLS_PRIVATE(add_len); /*!< Total authentication data length */ size_t MBEDTLS_PRIVATE(tag_len); /*!< Total tag length */ - size_t MBEDTLS_PRIVATE(processed); /*!< How many bytes of input data were processed (chunked input) */ + size_t MBEDTLS_PRIVATE(processed); /*!< Track how many bytes of input data + were processed (chunked input). + Used indepenedantly for both auth data + and plaintext/ciphertext. + This variable is set to zero after + auth data input is finished. */ unsigned char MBEDTLS_PRIVATE(q); /*!< The Q working value */ unsigned char MBEDTLS_PRIVATE(mode); /*!< The operation to perform: #MBEDTLS_CCM_ENCRYPT or From 2f1754916c7a478f44aa430d086412925fd6b35e Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 9 Aug 2021 16:05:14 +0200 Subject: [PATCH 252/966] Improve comment on local_output. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/ccm.c b/library/ccm.c index b7c8f6d4d9..1e88f90679 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -387,7 +387,10 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) { - /* Write decrypted data to local_output to avoid using output variable as + /* Since output may be in shared memory, we cannot be sure that + * it will contain what we wrote to it. Therefore, we should avoid using + * it as input to any operations. + * Write decrypted data to local_output to avoid using output variable as * input in the XOR operation for Y. */ ret = mbedtls_ccm_crypt( ctx, offset, use_len, input, local_output ); From bccbf88bc3843f36a851ab6c7a02cd5c46129456 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 9 Aug 2021 16:12:46 +0200 Subject: [PATCH 253/966] Rename CCM test functions. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 64 ++++++++++++++-------------- tests/suites/test_suite_ccm.function | 8 ++-- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index 382d2180f2..ff92e5fd78 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -1518,66 +1518,66 @@ CCM-Camellia encrypt and tag RFC 5528 #24 depends_on:MBEDTLS_CAMELLIA_C mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_CAMELLIA:"D75C2778078CA93D971F96FDE720F4CD":"9DC9EDAE2FF5DF8636E8C6DE0EED55F7867E33337D":"003B8FD8D3A937B160B6A31C1C":"A4D499F78419728C19178B0C":"4B198156393B0F7796086AAFB454F8C3F034CCA966945F1FCEA7E11BEE6A2F" -CCM encrypt, skip auth NIST VADT AES-128 (P=24, N=13, A=0, T=16) +CCM encrypt, skip ad NIST VADT AES-128 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_skip_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d24a3d3dde8c84830280cb87abad0bb3":"7c86135ed9c2a515aaae0e9a208133897269220f30870006":"f1100035bb24a8d26004e0e24b":"1faeb0ee2ca2cd52f0aa3966578344f24e69b742c4ab37ab":"1123301219c70599b7c373ad4b3ad67b" +mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d24a3d3dde8c84830280cb87abad0bb3":"7c86135ed9c2a515aaae0e9a208133897269220f30870006":"f1100035bb24a8d26004e0e24b":"1faeb0ee2ca2cd52f0aa3966578344f24e69b742c4ab37ab":"1123301219c70599b7c373ad4b3ad67b" -CCM* encrypt, skip auth NIST VADT AES-128 (P=24, N=13, A=0, T=16) +CCM* encrypt, skip ad NIST VADT AES-128 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_skip_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d24a3d3dde8c84830280cb87abad0bb3":"7c86135ed9c2a515aaae0e9a208133897269220f30870006":"f1100035bb24a8d26004e0e24b":"1faeb0ee2ca2cd52f0aa3966578344f24e69b742c4ab37ab":"1123301219c70599b7c373ad4b3ad67b" +mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d24a3d3dde8c84830280cb87abad0bb3":"7c86135ed9c2a515aaae0e9a208133897269220f30870006":"f1100035bb24a8d26004e0e24b":"1faeb0ee2ca2cd52f0aa3966578344f24e69b742c4ab37ab":"1123301219c70599b7c373ad4b3ad67b" -CCM decrypt, skip auth NIST DVPT AES-192 (P=24, N=7, A=0, T=4) +CCM decrypt, skip ad NIST DVPT AES-192 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_skip_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22":"ddc93a54" +mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22":"ddc93a54" -CCM* decrypt, skip auth NIST DVPT AES-192 (P=24, N=7, A=0, T=4) +CCM* decrypt, skip ad NIST DVPT AES-192 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_skip_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22":"ddc93a54" +mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22":"ddc93a54" -CCM encrypt, skip cipher NIST VPT AES-128 #1 (P=0, N=13, A=32, T=16) +CCM encrypt, skip update NIST VPT AES-128 #1 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_skip_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"2ebf60f0969013a54a3dedb19d20f6c8":"1de8c5e21f9db33123ff870add":"e1de6c6119d7db471136285d10b47a450221b16978569190ef6a22b055295603":"0ead29ef205fbb86d11abe5ed704b880" +mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"2ebf60f0969013a54a3dedb19d20f6c8":"1de8c5e21f9db33123ff870add":"e1de6c6119d7db471136285d10b47a450221b16978569190ef6a22b055295603":"0ead29ef205fbb86d11abe5ed704b880" -CCM* encrypt, skip cipher NIST VPT AES-128 #1 (P=0, N=13, A=32, T=16) +CCM* encrypt, skip update NIST VPT AES-128 #1 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_skip_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"2ebf60f0969013a54a3dedb19d20f6c8":"1de8c5e21f9db33123ff870add":"e1de6c6119d7db471136285d10b47a450221b16978569190ef6a22b055295603":"0ead29ef205fbb86d11abe5ed704b880" +mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"2ebf60f0969013a54a3dedb19d20f6c8":"1de8c5e21f9db33123ff870add":"e1de6c6119d7db471136285d10b47a450221b16978569190ef6a22b055295603":"0ead29ef205fbb86d11abe5ed704b880" -CCM decrypt, skip cipher NIST DVPT AES-256 #23 (P=0, N=13, A=32, T=16) +CCM decrypt, skip update NIST DVPT AES-256 #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_skip_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"867b0d87cf6e0f718200a97b4f6d5ad5" +mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"867b0d87cf6e0f718200a97b4f6d5ad5" -CCM* decrypt, skip cipher NIST DVPT AES-256 #23 (P=0, N=13, A=32, T=16) +CCM* decrypt, skip update NIST DVPT AES-256 #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_skip_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"867b0d87cf6e0f718200a97b4f6d5ad5" +mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"867b0d87cf6e0f718200a97b4f6d5ad5" -CCM encrypt, overflow auth NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM encrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" -CCM encrypt, overflow cipher NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM encrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" -CCM decrypt, overflow auth NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM decrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" -CCM decrypt, overflow cipher NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM decrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" -CCM* encrypt, overflow auth NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* encrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" -CCM* encrypt, overflow cipher NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* encrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" -CCM* decrypt, overflow auth NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* decrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_auth:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" -CCM* decrypt, overflow cipher NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* decrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_cipher:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 39e0b0b532..028ab896e7 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -456,7 +456,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ccm_skip_auth( int cipher_id, int mode, +void mbedtls_ccm_skip_ad( int cipher_id, int mode, data_t * key, data_t * msg, data_t * iv, data_t * result, data_t * tag ) { @@ -493,7 +493,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ccm_skip_cipher( int cipher_id, int mode, +void mbedtls_ccm_skip_update( int cipher_id, int mode, data_t * key, data_t * iv, data_t* add, data_t * tag ) { @@ -520,7 +520,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ccm_overflow_auth( int cipher_id, int mode, +void mbedtls_ccm_overflow_ad( int cipher_id, int mode, data_t * key, data_t * iv, data_t * add ) { @@ -540,7 +540,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ccm_overflow_cipher( int cipher_id, int mode, +void mbedtls_ccm_overflow_update( int cipher_id, int mode, data_t * key, data_t * msg, data_t * iv, data_t * add ) { From f442de69ebb3aa5db2d642382a0b7b9604937ef3 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 10 Aug 2021 13:36:43 +0200 Subject: [PATCH 254/966] Add tests for CCM corner cases. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 64 ++++++++++++++++ tests/suites/test_suite_ccm.function | 108 +++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index ff92e5fd78..5d23e6a74c 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -1554,30 +1554,94 @@ CCM encrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +CCM encrypt, incomplete ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM encrypt, full ad and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + CCM encrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +CCM encrypt, incomplete update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM encrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + CCM decrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +CCM decrypt, incomplete ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM decrypt, full ad and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + CCM decrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +CCM decrypt, incomplete update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM decrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + CCM* encrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +CCM* encrypt, incomplete ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* encrypt, full ad and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + CCM* encrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +CCM* encrypt, incomplete update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* encrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + CCM* decrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +CCM* decrypt, incomplete ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* decrypt, full ad and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + CCM* decrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* decrypt, incomplete update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM* decrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 028ab896e7..74893bb294 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -539,6 +539,53 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void mbedtls_ccm_incomplete_ad( int cipher_id, int mode, + data_t * key, data_t * iv, data_t* add ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded values for msg length and tag length. They are not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, 0, 16 ) ); + + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len/2) ); + + ASSERT_ALLOC( output, 16 ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + +exit: + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + + +/* BEGIN_CASE */ +void mbedtls_ccm_full_ad_and_overflow( int cipher_id, int mode, + data_t * key, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded values for msg length and tag length. They are not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, 16, 16 ) ); + + // pass full auth data + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); + // pass 1 extra byte + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_update_ad( &ctx, add->x, 1) ); +exit: + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + /* BEGIN_CASE */ void mbedtls_ccm_overflow_update( int cipher_id, int mode, data_t * key, data_t * msg, data_t * iv, @@ -565,3 +612,64 @@ exit: mbedtls_ccm_free( &ctx ); } /* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ccm_incomplete_update( int cipher_id, int mode, + data_t * key, data_t * msg, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + size_t olen; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded value for tag length. It is not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, msg->len, 16 ) ); + + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); + + ASSERT_ALLOC( output, msg->len ); + olen = 0xdeadbeef; + TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg->x, msg->len/2, output, msg->len, &olen ) ); + mbedtls_free( output ); + output = NULL; + + ASSERT_ALLOC( output, 16 ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + +exit: + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ccm_full_update_and_overflow( int cipher_id, int mode, + data_t * key, data_t * msg, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + size_t olen; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded value for tag length. It is a not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, msg->len, 16 ) ); + + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); + + ASSERT_ALLOC( output, msg->len ); + // pass full text + TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg->x, msg->len, output, msg->len, &olen ) ); + // pass 1 extra byte + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, \ + mbedtls_ccm_update( &ctx, msg->x, 1, output, 1, &olen ) ); +exit: + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ From 8fb1754e1ab4408fad3496abe52fdc61fb0d0e81 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 10 Aug 2021 13:45:19 +0200 Subject: [PATCH 255/966] Add short description for CCM test functions. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.function | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 74893bb294..d9c397c68e 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -455,6 +455,7 @@ exit: } /* END_CASE */ +/* Skip auth data, provide full text */ /* BEGIN_CASE */ void mbedtls_ccm_skip_ad( int cipher_id, int mode, data_t * key, data_t * msg, data_t * iv, @@ -492,6 +493,7 @@ exit: } /* END_CASE */ +/* Provide auth data, skip full text */ /* BEGIN_CASE */ void mbedtls_ccm_skip_update( int cipher_id, int mode, data_t * key, data_t * iv, data_t* add, @@ -519,6 +521,7 @@ exit: } /* END_CASE */ +/* Provide too much auth data */ /* BEGIN_CASE */ void mbedtls_ccm_overflow_ad( int cipher_id, int mode, data_t * key, data_t * iv, @@ -539,6 +542,7 @@ exit: } /* END_CASE */ +/* Provide incomplete auth data and finish */ /* BEGIN_CASE */ void mbedtls_ccm_incomplete_ad( int cipher_id, int mode, data_t * key, data_t * iv, data_t* add ) @@ -563,7 +567,8 @@ exit: } /* END_CASE */ - +/* Provide complete auth data on first update_ad. + * Provide unexpected auth data on second update_ad */ /* BEGIN_CASE */ void mbedtls_ccm_full_ad_and_overflow( int cipher_id, int mode, data_t * key, data_t * iv, @@ -586,6 +591,7 @@ exit: } /* END_CASE */ +/* Provide too much plaintext/ciphertext */ /* BEGIN_CASE */ void mbedtls_ccm_overflow_update( int cipher_id, int mode, data_t * key, data_t * msg, data_t * iv, @@ -613,6 +619,7 @@ exit: } /* END_CASE */ +/* Provide incomplete plaintext/ciphertext and finish */ /* BEGIN_CASE */ void mbedtls_ccm_incomplete_update( int cipher_id, int mode, data_t * key, data_t * msg, data_t * iv, @@ -645,6 +652,8 @@ exit: } /* END_CASE */ +/* Provide full plaintext/ciphertext of first update + * Provide unexpected plaintext/ciphertext on second update */ /* BEGIN_CASE */ void mbedtls_ccm_full_update_and_overflow( int cipher_id, int mode, data_t * key, data_t * msg, data_t * iv, From 551265f8798eb843ee61063b34d42add44dd9bb7 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Aug 2021 13:03:48 +0100 Subject: [PATCH 256/966] Add TLS 1.3 IANA signature-algorithm values Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 221cee3379..3090f9313c 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -337,6 +337,41 @@ #define MBEDTLS_SSL_SIG_RSA 1 #define MBEDTLS_SSL_SIG_ECDSA 3 +/* + * TLS 1.3 signature algorithms + * RFC 8446, Section 4.2.2 + */ + +/* RSASSA-PKCS1-v1_5 algorithms */ +#define MBEDTLS_TLS13_SIG_RSA_PKCS1_SHA256 0x0401 +#define MBEDTLS_TLS13_SIG_RSA_PKCS1_SHA384 0x0501 +#define MBEDTLS_TLS13_SIG_RSA_PKCS1_SHA512 0x0601 + +/* ECDSA algorithms */ +#define MBEDTLS_TLS13_SIG_ECDSA_SECP256R1_SHA256 0x0403 +#define MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384 0x0503 +#define MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512 0x0603 + +/* RSASSA-PSS algorithms with public key OID rsaEncryption */ +#define MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256 0x0804 +#define MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA384 0x0805 +#define MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA512 0x0806 + +/* EdDSA algorithms */ +#define MBEDTLS_TLS13_SIG_ED25519 0x0807 +#define MBEDTLS_TLS13_SIG_ED448 0x0808 + +/* RSASSA-PSS algorithms with public key OID RSASSA-PSS */ +#define MBEDTLS_TLS13_SIG_RSA_PSS_PSS_SHA256 0x0809 +#define MBEDTLS_TLS13_SIG_RSA_PSS_PSS_SHA384 0x080A +#define MBEDTLS_TLS13_SIG_RSA_PSS_PSS_SHA512 0x080B + +/* LEGACY ALGORITHMS */ +#define MBEDTLS_TLS13_SIG_RSA_PKCS1_SHA1 0x0201 +#define MBEDTLS_TLS13_SIG_ECDSA_SHA1 0x0203 + +#define MBEDTLS_TLS13_SIG_NONE 0x0 + /* * Client Certificate Types * RFC 5246 section 7.4.4 plus RFC 4492 section 5.5 From e0f5227550f7798aeff2ce2933d184aaa10fad89 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 10 Aug 2021 13:55:47 +0200 Subject: [PATCH 257/966] Add CCM test for calling finish without any input. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 12 ++++++++++++ tests/suites/test_suite_ccm.function | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index 5d23e6a74c..91aa98bd43 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -1645,3 +1645,15 @@ mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5 CCM* decrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" + +CCM encrypt, instant finish NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a" + +CCM decrypt, instant finish NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a" + +CCM* encrypt, instant finish NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a" + +CCM* decrypt, instant finish NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a" diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index d9c397c68e..48c4fe919d 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -682,3 +682,27 @@ exit: mbedtls_ccm_free( &ctx ); } /* END_CASE */ + +/* Finish without passing any auth data or plaintext/ciphertext input */ +/* BEGIN_CASE */ +void mbedtls_ccm_instant_finish( int cipher_id, int mode, + data_t * key, data_t * iv ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded values for add length, msg length and tag length. + // They are not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, 16, 16, 16 ) ); + + ASSERT_ALLOC( output, 16 ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + +exit: + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ From 1cd6e0021f14d9f1b5015c8851781a0e07ffabec Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Aug 2021 13:27:10 +0100 Subject: [PATCH 258/966] Add experimental API for configuration of TLS 1.3 sig algs Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 17 +++++++++++++++++ library/ssl_tls.c | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 3090f9313c..c62f730b3e 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1182,6 +1182,10 @@ struct mbedtls_ssl_config #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) const int *MBEDTLS_PRIVATE(sig_hashes); /*!< allowed signature hashes */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + const uint16_t* MBEDTLS_PRIVATE(tls13_sig_algs); /*!< allowed signature algorithms in TLS 1.3 */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif #if defined(MBEDTLS_ECP_C) @@ -3026,6 +3030,19 @@ void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf, */ void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, const int *hashes ); + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +/** + * \brief Configure allowed signature algorithms for use in TLS 1.3 + * + * \param conf The SSL configuration to use. + * \param sig_algs A 0-terminated list of IANA values for TLS 1.3 signature algorithms, + * with the most preferred algorithm listed first. Supported values + * are available as \c MBEDTLS_TLS13_SIG_XXX. + */ +void mbedtls_ssl_conf_sig_algs( mbedtls_ssl_config *conf, + const uint16_t* sig_algs ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #if defined(MBEDTLS_X509_CRT_PARSE_C) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 923c671a7b..e2fb9b66fb 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3933,6 +3933,22 @@ void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, { conf->sig_hashes = hashes; } + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +/** + * \brief Configure allowed signature algorithms for use in TLS 1.3 + * + * \param conf The SSL configuration to use. + * \param sig_algs A 0-terminated list of IANA values for TLS 1.3 signature algorithms, + * with the most preferred algorithm listed first. Supported values + * are available as \c MBEDTLS_TLS13_SIG_XXX. + */ +void mbedtls_ssl_conf_sig_algs( mbedtls_ssl_config *conf, + const uint16_t* sig_algs ) +{ + conf->tls13_sig_algs = sig_algs; +} +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #if defined(MBEDTLS_ECP_C) From 11ceadd382b1edb83031b4fcb10af3fcd11997fd Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Aug 2021 13:36:41 +0100 Subject: [PATCH 259/966] Add cmdline param for TLS 1.3 sig alg config to ssl_{client,server}2 Signed-off-by: Hanno Becker --- programs/ssl/ssl_client2.c | 90 ++++++++++++++++++++++++++++++++++++-- programs/ssl/ssl_server2.c | 89 ++++++++++++++++++++++++++++++++++++- 2 files changed, 174 insertions(+), 5 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 86c314c35d..17b1ccf939 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -88,6 +88,7 @@ int main( void ) #define DFL_TICKETS MBEDTLS_SSL_SESSION_TICKETS_ENABLED #define DFL_ALPN_STRING NULL #define DFL_CURVES NULL +#define DFL_SIG_ALGS NULL #define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM #define DFL_HS_TO_MIN 0 #define DFL_HS_TO_MAX 0 @@ -269,6 +270,15 @@ int main( void ) #define USAGE_CURVES "" #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && \ + defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) +#define USAGE_SIG_ALGS \ + " sig_algs=a,b,c,d default: \"default\" (library default)\n" \ + " example: \"ecdsa_secp256r1_sha256,ecdsa_secp384r1_sha384\"\n" +#else +#define USAGE_SIG_ALGS "" +#endif + #if defined(MBEDTLS_SSL_PROTO_DTLS) #define USAGE_DTLS \ " dtls=%%d default: 0 (TLS)\n" \ @@ -393,6 +403,7 @@ int main( void ) USAGE_ETM \ USAGE_REPRODUCIBLE \ USAGE_CURVES \ + USAGE_SIG_ALGS \ USAGE_DHMLEN \ "\n" @@ -417,9 +428,9 @@ int main( void ) USAGE_SERIALIZATION \ " acceptable ciphersuite names:\n" -#define ALPN_LIST_SIZE 10 -#define CURVE_LIST_SIZE 20 - +#define ALPN_LIST_SIZE 10 +#define CURVE_LIST_SIZE 20 +#define SIG_ALG_LIST_SIZE 5 /* * global options @@ -472,6 +483,7 @@ struct options int reconnect_hard; /* unexpectedly reconnect from the same port */ int tickets; /* enable / disable session tickets */ const char *curves; /* list of supported elliptic curves */ + const char *sig_algs; /* supported TLS 1.3 signature algorithms */ const char *alpn_string; /* ALPN supported protocols */ int transport; /* TLS or DTLS? */ uint32_t hs_to_min; /* Initial value of DTLS handshake timer */ @@ -631,6 +643,12 @@ int main( int argc, char *argv[] ) mbedtls_net_context server_fd; io_ctx_t io_ctx; +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && \ + defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + uint16_t sig_alg_list[SIG_ALG_LIST_SIZE]; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && + MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + unsigned char buf[MAX_REQUEST_SIZE + 1]; #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) @@ -833,6 +851,7 @@ int main( int argc, char *argv[] ) opt.tickets = DFL_TICKETS; opt.alpn_string = DFL_ALPN_STRING; opt.curves = DFL_CURVES; + opt.sig_algs = DFL_SIG_ALGS; opt.transport = DFL_TRANSPORT; opt.hs_to_min = DFL_HS_TO_MIN; opt.hs_to_max = DFL_HS_TO_MAX; @@ -1063,6 +1082,12 @@ int main( int argc, char *argv[] ) } else if( strcmp( p, "curves" ) == 0 ) opt.curves = q; +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && \ + defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + else if( strcmp( p, "sig_algs" ) == 0 ) + opt.sig_algs = q; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && + MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ else if( strcmp( p, "etm" ) == 0 ) { switch( atoi( q ) ) @@ -1450,6 +1475,60 @@ int main( int argc, char *argv[] ) } #endif /* MBEDTLS_ECP_C */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && \ + defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + if( opt.sig_algs != NULL ) + { + p = (char *) opt.sig_algs; + i = 0; + + /* Leave room for a final NULL in signature algorithm list */ + while( i < SIG_ALG_LIST_SIZE - 1 && *p != '\0' ) + { + q = p; + + /* Terminate the current string */ + while( *p != ',' && *p != '\0' ) + p++; + if( *p == ',' ) + *p++ = '\0'; + + if( strcmp( q, "ecdsa_secp256r1_sha256" ) == 0 ) + { + sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP256R1_SHA256; + } + else if( strcmp( q, "ecdsa_secp384r1_sha384" ) == 0 ) + { + sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384; + } + else if( strcmp( q, "ecdsa_secp521r1_sha512" ) == 0 ) + { + sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512; + } + else + { + mbedtls_printf( "unknown signature algorithm %s\n", q ); + mbedtls_printf( "supported signature algorithms: " ); + mbedtls_printf( "ecdsa_secp256r1_sha256 " ); + mbedtls_printf( "ecdsa_secp384r1_sha384 " ); + mbedtls_printf( "ecdsa_secp521r1_sha512 " ); + mbedtls_printf( "\n" ); + goto exit; + } + } + + if( i == ( SIG_ALG_LIST_SIZE - 1 ) && *p != '\0' ) + { + mbedtls_printf( "signature algorithm list too long, maximum %d", + SIG_ALG_LIST_SIZE - 1 ); + goto exit; + } + + sig_alg_list[i] = MBEDTLS_TLS13_SIG_NONE; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && + MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + #if defined(MBEDTLS_SSL_ALPN) if( opt.alpn_string != NULL ) { @@ -1785,6 +1864,11 @@ int main( int argc, char *argv[] ) } #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + if( opt.sig_algs != NULL ) + mbedtls_ssl_conf_sig_algs( &conf, sig_alg_list ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) #if defined(MBEDTLS_USE_PSA_CRYPTO) if( opt.psk_opaque != 0 ) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 83bd617c68..c7110e850e 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -119,6 +119,7 @@ int main( void ) #define DFL_SNI NULL #define DFL_ALPN_STRING NULL #define DFL_CURVES NULL +#define DFL_SIG_ALGS NULL #define DFL_DHM_FILE NULL #define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM #define DFL_COOKIES 1 @@ -418,6 +419,15 @@ int main( void ) #define USAGE_CURVES "" #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && \ + defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) +#define USAGE_SIG_ALGS \ + " sig_algs=a,b,c,d default: \"default\" (library default)\n" \ + " example: \"ecdsa_secp256r1_sha256,ecdsa_secp384r1_sha384\"\n" +#else +#define USAGE_SIG_ALGS "" +#endif + #if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) #define USAGE_SERIALIZATION \ " serialize=%%d default: 0 (do not serialize/deserialize)\n" \ @@ -484,6 +494,7 @@ int main( void ) USAGE_EMS \ USAGE_ETM \ USAGE_CURVES \ + USAGE_SIG_ALGS \ "\n" #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) @@ -509,8 +520,9 @@ int main( void ) USAGE_SERIALIZATION \ " acceptable ciphersuite names:\n" -#define ALPN_LIST_SIZE 10 -#define CURVE_LIST_SIZE 20 +#define ALPN_LIST_SIZE 10 +#define CURVE_LIST_SIZE 20 +#define SIG_ALG_LIST_SIZE 5 #define PUT_UINT64_BE(out_be,in_le,i) \ { \ @@ -583,6 +595,7 @@ struct options int cache_timeout; /* expiration delay of session cache entries */ char *sni; /* string describing sni information */ const char *curves; /* list of supported elliptic curves */ + const char *sig_algs; /* supported TLS 1.3 signature algorithms */ const char *alpn_string; /* ALPN supported protocols */ const char *dhm_file; /* the file with the DH parameters */ int extended_ms; /* allow negotiation of extended MS? */ @@ -1326,6 +1339,12 @@ int main( int argc, char *argv[] ) size_t context_buf_len = 0; #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && \ + defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + uint16_t sig_alg_list[SIG_ALG_LIST_SIZE]; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && + MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + int i; char *p, *q; const int *list; @@ -1498,6 +1517,7 @@ int main( int argc, char *argv[] ) opt.sni = DFL_SNI; opt.alpn_string = DFL_ALPN_STRING; opt.curves = DFL_CURVES; + opt.sig_algs = DFL_SIG_ALGS; opt.dhm_file = DFL_DHM_FILE; opt.transport = DFL_TRANSPORT; opt.cookies = DFL_COOKIES; @@ -1665,6 +1685,12 @@ int main( int argc, char *argv[] ) } else if( strcmp( p, "curves" ) == 0 ) opt.curves = q; +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && \ + defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + else if( strcmp( p, "sig_algs" ) == 0 ) + opt.sig_algs = q; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && && \ + MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ else if( strcmp( p, "renegotiation" ) == 0 ) { opt.renegotiation = (atoi( q )) ? @@ -2172,6 +2198,60 @@ int main( int argc, char *argv[] ) } #endif /* MBEDTLS_ECP_C */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && \ + defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + if( opt.sig_algs != NULL ) + { + p = (char *) opt.sig_algs; + i = 0; + + /* Leave room for a final NULL in signature algorithm list */ + while( i < SIG_ALG_LIST_SIZE - 1 && *p != '\0' ) + { + q = p; + + /* Terminate the current string */ + while( *p != ',' && *p != '\0' ) + p++; + if( *p == ',' ) + *p++ = '\0'; + + if( strcmp( q, "ecdsa_secp256r1_sha256" ) == 0 ) + { + sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP256R1_SHA256; + } + else if( strcmp( q, "ecdsa_secp384r1_sha384" ) == 0 ) + { + sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384; + } + else if( strcmp( q, "ecdsa_secp521r1_sha512" ) == 0 ) + { + sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512; + } + else + { + mbedtls_printf( "unknown signature algorithm %s\n", q ); + mbedtls_printf( "supported signature algorithms: " ); + mbedtls_printf( "ecdsa_secp256r1_sha256 " ); + mbedtls_printf( "ecdsa_secp384r1_sha384 " ); + mbedtls_printf( "ecdsa_secp521r1_sha512 " ); + mbedtls_printf( "\n" ); + goto exit; + } + } + + if( i == ( SIG_ALG_LIST_SIZE - 1 ) && *p != '\0' ) + { + mbedtls_printf( "signature algorithm list too long, maximum %d", + SIG_ALG_LIST_SIZE - 1 ); + goto exit; + } + + sig_alg_list[i] = MBEDTLS_TLS13_SIG_NONE; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && + MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + #if defined(MBEDTLS_SSL_ALPN) if( opt.alpn_string != NULL ) { @@ -2750,6 +2830,11 @@ int main( int argc, char *argv[] ) } #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + if( opt.sig_algs != NULL ) + mbedtls_ssl_conf_sig_algs( &conf, sig_alg_list ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) if( strlen( opt.psk ) != 0 && strlen( opt.psk_identity ) != 0 ) From 9c6aa7bb9a37ad694de9493941b422f8d4e85887 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Aug 2021 13:50:43 +0100 Subject: [PATCH 260/966] Add default values for TLS 1.3 SigAlg configuration Signed-off-by: Hanno Becker --- library/ssl_tls.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index e2fb9b66fb..4843e423dd 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6277,6 +6277,41 @@ static int ssl_preset_suiteb_hashes[] = { MBEDTLS_MD_SHA384, MBEDTLS_MD_NONE }; + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +static uint16_t ssl_preset_default_sig_algs[] = { + /* ECDSA algorithms */ +#if defined(MBEDTLS_ECDSA_C) +#if defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + MBEDTLS_TLS13_SIG_ECDSA_SECP256R1_SHA256, +#endif /* MBEDTLS_SHA256_C && MBEDTLS_ECP_DP_SECP256R1_ENABLED */ +#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384, +#endif /* MBEDTLS_SHA512_C && MBEDTLS_ECP_DP_SECP384R1_ENABLED */ +#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) + MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512, +#endif /* MBEDTLS_SHA512_C && MBEDTLS_ECP_DP_SECP521R1_ENABLED */ +#endif /* MBEDTLS_ECDSA_C */ + /* RSA algorithms */ +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256, +#endif + MBEDTLS_TLS13_SIG_NONE +}; + +static uint16_t ssl_preset_suiteb_sig_algs[] = { + /* ECDSA algorithms */ +#if defined(MBEDTLS_ECDSA_C) +#if defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + MBEDTLS_TLS13_SIG_ECDSA_SECP256R1_SHA256, +#endif /* MBEDTLS_SHA256_C && MBEDTLS_ECP_DP_SECP256R1_ENABLED */ +#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384, +#endif /* MBEDTLS_SHA512_C && MBEDTLS_ECP_DP_SECP384R1_ENABLED */ +#endif /* MBEDTLS_ECDSA_C */ + MBEDTLS_TLS13_SIG_NONE +}; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif #if defined(MBEDTLS_ECP_C) @@ -6391,6 +6426,9 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) conf->sig_hashes = ssl_preset_suiteb_hashes; +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + conf->tls13_sig_algs = ssl_preset_suiteb_sig_algs; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif #if defined(MBEDTLS_ECP_C) @@ -6427,6 +6465,10 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, conf->sig_hashes = ssl_preset_default_hashes; #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + conf->tls13_sig_algs = ssl_preset_default_sig_algs; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_ECP_C) conf->curve_list = ssl_preset_default_curves; #endif From ac72fac465b720c55b472e38cfa7664890bfbc32 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 10 Aug 2021 15:09:16 +0100 Subject: [PATCH 261/966] Put back list-identifiers.sh as a thin wrapper around the python script Signed-off-by: Yuto Takano --- tests/scripts/list-identifiers.sh | 66 ++++++++++++++++++++++ tests/scripts/list_internal_identifiers.py | 7 ++- 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100755 tests/scripts/list-identifiers.sh diff --git a/tests/scripts/list-identifiers.sh b/tests/scripts/list-identifiers.sh new file mode 100755 index 0000000000..49ecc93ef7 --- /dev/null +++ b/tests/scripts/list-identifiers.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# Create a file named identifiers containing identifiers from internal header +# files, based on the --internal flag. +# Outputs the line count of the file to stdout. +# A very thin wrapper around list_internal_identifiers.py for backwards +# compatibility. +# Must be run from Mbed TLS root. +# +# Usage: list-identifiers.sh [ -i | --internal ] +# +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +if [ -d include/mbedtls ]; then :; else + echo "$0: Must be run from Mbed TLS root" >&2 + exit 1 +fi + +INTERNAL="" + +until [ -z "${1-}" ] +do + case "$1" in + -i|--internal) + INTERNAL="1" + ;; + *) + # print error + echo "Unknown argument: '$1'" + exit 1 + ;; + esac + shift +done + +if [ $INTERNAL ] +then + tests/scripts/list_internal_identifiers.py + wc -l identifiers +else + cat < Date: Tue, 10 Aug 2021 15:45:28 +0100 Subject: [PATCH 262/966] Add newline at end of list-identifiers.sh Signed-off-by: Yuto Takano --- tests/scripts/list-identifiers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/list-identifiers.sh b/tests/scripts/list-identifiers.sh index 49ecc93ef7..781c609fc1 100755 --- a/tests/scripts/list-identifiers.sh +++ b/tests/scripts/list-identifiers.sh @@ -63,4 +63,4 @@ is a thin wrapper around list_internal_identifiers.py. check-names.sh, which used to depend on this script, has been replaced with check_names.py and is now self-complete. EOF -fi \ No newline at end of file +fi From deb68ce2d1935024d24cf85e1ef78528143b917f Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Aug 2021 16:04:05 +0100 Subject: [PATCH 263/966] Fix guard around TLS 1.3 SigAlg configuration Signed-off-by: Hanno Becker --- library/ssl_tls.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 4843e423dd..07d468ca72 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6463,11 +6463,10 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) conf->sig_hashes = ssl_preset_default_hashes; -#endif - #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) conf->tls13_sig_algs = ssl_preset_default_sig_algs; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #if defined(MBEDTLS_ECP_C) conf->curve_list = ssl_preset_default_curves; From 0402979ed39530a894812d9b9361de943bd8530f Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 10 Aug 2021 16:45:37 +0800 Subject: [PATCH 264/966] Add openssl/gnutls tls1.3 feature tests. Add functions and test cases to make sure tls1.3 is available in openssl/gnutls Change-Id: I797d15117a8de96614f392e6bb2ed16b6d71ba69 Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 01265ae9b3..9ee6b761db 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -77,6 +77,14 @@ else O_LEGACY_CLI=false fi +if [ -n "${OPENSSL_NEXT:-}" ]; then + O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key" + O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client" +else + O_NEXT_SRV=false + O_NEXT_CLI=false +fi + if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" else @@ -346,6 +354,57 @@ requires_openssl_legacy() { fi } +requires_openssl_next() { + if [ -z "${OPENSSL_NEXT_AVAILABLE:-}" ]; then + if which "${OPENSSL_NEXT:-}" >/dev/null 2>&1; then + OPENSSL_NEXT_AVAILABLE="YES" + else + OPENSSL_NEXT_AVAILABLE="NO" + fi + fi + if [ "$OPENSSL_NEXT_AVAILABLE" = "NO" ]; then + SKIP_NEXT="YES" + fi +} + +# skip next test if tls1_3 is not available +requires_openssl_tls1_3() { + requires_openssl_next + if [ "$OPENSSL_NEXT_AVAILABLE" = "NO" ]; then + OPENSSL_TLS1_3_AVAILABLE="NO" + fi + if [ -z "${OPENSSL_TLS1_3_AVAILABLE:-}" ]; then + if $OPENSSL_NEXT s_client -help 2>&1 | grep tls1_3 >/dev/null + then + OPENSSL_TLS1_3_AVAILABLE="YES" + else + OPENSSL_TLS1_3_AVAILABLE="NO" + fi + fi + if [ "$OPENSSL_TLS1_3_AVAILABLE" = "NO" ]; then + SKIP_NEXT="YES" + fi +} + +# skip next test if tls1_3 is not available +requires_gnutls_tls1_3() { + requires_gnutls_next + if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then + GNUTLS_TLS1_3_AVAILABLE="NO" + fi + if [ -z "${GNUTLS_TLS1_3_AVAILABLE:-}" ]; then + if $GNUTLS_NEXT_CLI -l 2>&1 | grep VERS-TLS1.3 >/dev/null + then + GNUTLS_TLS1_3_AVAILABLE="YES" + else + GNUTLS_TLS1_3_AVAILABLE="NO" + fi + fi + if [ "$GNUTLS_TLS1_3_AVAILABLE" = "NO" ]; then + SKIP_NEXT="YES" + fi +} + # skip next test if IPv6 isn't available on this host requires_ipv6() { if [ -z "${HAS_IPV6:-}" ]; then @@ -8487,6 +8546,24 @@ run_test "export keys functionality" \ -c "EAP-TLS IV is:" \ -s "EAP-TLS IV is:" +# openssl feature tests: check if tls1.3 exists. +requires_openssl_tls1_3 +run_test "TLS1.3: Test openssl tls1_3 feature" \ + "$O_NEXT_SRV -tls1_3 -msg" \ + "$O_NEXT_CLI -tls1_3 -msg" \ + 0 \ + -c "TLS 1.3" \ + -s "TLS 1.3" + +# gnutls feature tests: check if tls1.3 exists. +requires_gnutls_tls1_3 +run_test "TLS1.3: Test gnutls tls1_3 feature" \ + "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3" \ + "$G_NEXT_CLI localhost --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3 -V" \ + 0 \ + -s "Version: TLS1.3" \ + -c "Version: TLS1.3" + # TLS1.3 test cases # TODO: remove or rewrite this test case if #4832 is resolved. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 From e043d15d75e81fef9c93aba0639a7dba165b4062 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Thu, 12 Aug 2021 06:22:32 +0100 Subject: [PATCH 265/966] Turn comments of 1.3 record transforms into Doxygen documentation Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 4 ++-- library/ssl_misc.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 34353daffb..960a262e43 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1342,8 +1342,8 @@ struct mbedtls_ssl_context * it references. */ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - /* The application data transform in TLS 1.3. - * This pointer owns the transform it references. */ + /*! The application data transform in TLS 1.3. + * This pointer owns the transform it references. */ mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_application); #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 174bad88b5..0b64e010bc 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -563,8 +563,8 @@ struct mbedtls_ssl_handshake_params #endif /* MBEDTLS_SSL_PROTO_DTLS */ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - /* TLS 1.3 transforms for 0-RTT and encrypted handshake messages. - * Those pointers own the transforms they reference. */ + /*! TLS 1.3 transforms for 0-RTT and encrypted handshake messages. + * Those pointers own the transforms they reference. */ mbedtls_ssl_transform *transform_handshake; mbedtls_ssl_transform *transform_earlydata; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From 8ca26923eb71d7ea9615c468bac6f75fa5341eaa Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Fri, 23 Jul 2021 19:24:23 +0100 Subject: [PATCH 266/966] Add TLS 1.3 ciphersuites Signed-off-by: Hanno Becker --- include/mbedtls/ssl_ciphersuites.h | 7 ++++ library/ssl_ciphersuites.c | 56 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/include/mbedtls/ssl_ciphersuites.h b/include/mbedtls/ssl_ciphersuites.h index 812560c8a1..18e7c98767 100644 --- a/include/mbedtls/ssl_ciphersuites.h +++ b/include/mbedtls/ssl_ciphersuites.h @@ -256,6 +256,13 @@ extern "C" { #define MBEDTLS_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 0xCCAD /**< TLS 1.2 */ #define MBEDTLS_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256 0xCCAE /**< TLS 1.2 */ +/* RFC 8446, Appendix B.4 */ +#define MBEDTLS_TLS1_3_AES_128_GCM_SHA256 0x1301 /**< TLS 1.3 */ +#define MBEDTLS_TLS1_3_AES_256_GCM_SHA384 0x1302 /**< TLS 1.3 */ +#define MBEDTLS_TLS1_3_CHACHA20_POLY1305_SHA256 0x1303 /**< TLS 1.3 */ +#define MBEDTLS_TLS1_3_AES_128_CCM_SHA256 0x1304 /**< TLS 1.3 */ +#define MBEDTLS_TLS1_3_AES_128_CCM_8_SHA256 0x1305 /**< TLS 1.3 */ + /* Reminder: update mbedtls_ssl_premaster_secret when adding a new key exchange. * Reminder: update MBEDTLS_KEY_EXCHANGE__xxx below */ diff --git a/library/ssl_ciphersuites.c b/library/ssl_ciphersuites.c index a3ee157d50..1df1b26b2c 100644 --- a/library/ssl_ciphersuites.c +++ b/library/ssl_ciphersuites.c @@ -52,6 +52,15 @@ static const int ciphersuite_preference[] = #if defined(MBEDTLS_SSL_CIPHERSUITES) MBEDTLS_SSL_CIPHERSUITES, #else +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + /* TLS 1.3 ciphersuites */ + MBEDTLS_TLS1_3_AES_128_GCM_SHA256, + MBEDTLS_TLS1_3_AES_256_GCM_SHA384, + MBEDTLS_TLS1_3_CHACHA20_POLY1305_SHA256, + MBEDTLS_TLS1_3_AES_128_CCM_SHA256, + MBEDTLS_TLS1_3_AES_128_CCM_8_SHA256, +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* Chacha-Poly ephemeral suites */ MBEDTLS_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, MBEDTLS_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, @@ -283,6 +292,53 @@ static const int ciphersuite_preference[] = static const mbedtls_ssl_ciphersuite_t ciphersuite_definitions[] = { +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +#if defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_SHA512_C) + { MBEDTLS_TLS1_3_AES_256_GCM_SHA384, "TLS1-3-AES-256-GCM-SHA384", + MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_NONE, /* Key exchange not part of ciphersuite in TLS 1.3 */ + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + 0 }, +#endif /* MBEDTLS_SHA512_C */ +#if defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS1_3_AES_128_GCM_SHA256, "TLS1-3-AES-128-GCM-SHA256", + MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_NONE, /* Key exchange not part of ciphersuite in TLS 1.3 */ + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + 0 }, +#endif /* MBEDTLS_SHA256_C */ +#endif /* MBEDTLS_GCM_C */ +#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS1_3_AES_128_CCM_SHA256, "TLS1-3-AES-128-CCM-SHA256", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_NONE, /* Key exchange not part of ciphersuite in TLS 1.3 */ + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + 0 }, + { MBEDTLS_TLS1_3_AES_128_CCM_8_SHA256, "TLS1-3-AES-128-CCM-8-SHA256", + MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_NONE, /* Key exchange not part of ciphersuite in TLS 1.3 */ + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + MBEDTLS_CIPHERSUITE_SHORT_TAG }, +#endif /* MBEDTLS_SHA256_C && MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ +#if defined(MBEDTLS_CHACHAPOLY_C) && defined(MBEDTLS_SHA256_C) + { MBEDTLS_TLS1_3_CHACHA20_POLY1305_SHA256, + "TLS1-3-CHACHA20-POLY1305-SHA256", + MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_NONE, /* Key exchange not part of ciphersuite in TLS 1.3 */ + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, + 0 // field not used in TLS 1.3 implementation + }, +#endif /* MBEDTLS_CHACHAPOLY_C && MBEDTLS_SHA256_C */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_CHACHAPOLY_C) && \ defined(MBEDTLS_SHA256_C) && \ defined(MBEDTLS_SSL_PROTO_TLS1_2) From e486b2d7bb5dda556590562fad909dc2c2b66642 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Fri, 23 Jul 2021 19:24:30 +0100 Subject: [PATCH 267/966] Document use of mbedtls_ssl_conf_ciphersuites() for TLS 1.3 Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 221cee3379..f49bf2d98a 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -2521,21 +2521,45 @@ int mbedtls_ssl_session_save( const mbedtls_ssl_session *session, * order. First in the list has the highest preference. * (Overrides all version-specific lists) * - * The ciphersuites array is not copied, and must remain - * valid for the lifetime of the ssl_config. + * For TLS 1.2, the notion of ciphersuite determines both + * the key exchange mechanism and the suite of symmetric + * algorithms to be used during and after the handshake. * - * Note: By default, the server chooses its preferred + * For TLS 1.3 (in development), the notion of ciphersuite + * only determines the suite of symmetric algorithmc to be + * used during and after the handshake, while key exchange + * mechanisms are configured separately. + * + * In Mbed TLS, ciphersuites for both TLS 1.2 and TLS 1.3 + * are configured via this function. For users of TLS 1.3, + * there will be separate API for the configuration of key + * exchange mechanisms. + * + * The list of ciphersuites passed to this function may + * contain a mixture of TLS 1.2 and TLS 1.3 ciphersuite + * identifiers. This is useful if negotiation of TLS 1.3 + * should be attempted, but a fallback to TLS 1.2 would + * be tolerated. + * + * \note By default, the server chooses its preferred * ciphersuite among those that the client supports. If * mbedtls_ssl_conf_preference_order() is called to prefer * the client's preferences, the server instead chooses * the client's preferred ciphersuite among those that * the server supports. * - * \param conf SSL configuration - * \param ciphersuites 0-terminated list of allowed ciphersuites + * \warning The ciphersuites array \p ciphersuites is not copied. + * It must remain valid for the lifetime the SSL + * configuration \p conf. + * + * \param conf The SSL configuration to modify. + * \param ciphersuites A 0-terminated list of IANA identifiers of supported + * ciphersuites, accessible through \c MBEDTLS_TLS_XXX + * and \c MBEDTLS_TLS1_3_XXX macros defined in + * ssl_ciphersuites.h. */ void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, - const int *ciphersuites ); + const int *ciphersuites ); #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) #define MBEDTLS_SSL_UNEXPECTED_CID_IGNORE 0 From ae336852c59973c4642a10009b9db3160cc71215 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 24 Jul 2021 05:27:16 +0100 Subject: [PATCH 268/966] Add ssl-opt.sh run to TLS 1.3 test in all.sh Signed-off-by: Hanno Becker --- tests/scripts/all.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 5d2710cadc..16926390c4 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2454,6 +2454,8 @@ component_test_tls13_experimental_with_padding () { make msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with padding" make test + msg "ssl-opt.sh (TLS 1.3 experimental)" + if_build_succeeded tests/ssl-opt.sh } component_build_mingw () { From e2defad0bb9c72acc104e8f07b6c7ec252f4aa51 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 24 Jul 2021 05:59:17 +0100 Subject: [PATCH 269/966] Fix indentation of pre-existing code-block in ssl_tls.c Signed-off-by: Hanno Becker --- library/ssl_tls.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 2306c712c7..97bb7b6470 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6337,20 +6337,20 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, #endif #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C) - if( endpoint == MBEDTLS_SSL_IS_SERVER ) - { - const unsigned char dhm_p[] = - MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN; - const unsigned char dhm_g[] = - MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN; + if( endpoint == MBEDTLS_SSL_IS_SERVER ) + { + const unsigned char dhm_p[] = + MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN; + const unsigned char dhm_g[] = + MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN; - if ( ( ret = mbedtls_ssl_conf_dh_param_bin( conf, - dhm_p, sizeof( dhm_p ), - dhm_g, sizeof( dhm_g ) ) ) != 0 ) - { - return( ret ); - } - } + if ( ( ret = mbedtls_ssl_conf_dh_param_bin( conf, + dhm_p, sizeof( dhm_p ), + dhm_g, sizeof( dhm_g ) ) ) != 0 ) + { + return( ret ); + } + } #endif /* From 71f1ed66c2a6c5177be777871b058a11a650795a Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 24 Jul 2021 06:01:47 +0100 Subject: [PATCH 270/966] Add identifiers and API for configuration of TLS 1.3 key exchanges Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 76 +++++++++++++++++++++++++++++++++++++++++++ library/ssl_tls.c | 15 +++++++++ 2 files changed, 91 insertions(+) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index f49bf2d98a..029fa42926 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -169,6 +169,30 @@ /** Invalid value in SSL config */ #define MBEDTLS_ERR_SSL_BAD_CONFIG -0x5E80 +/* + * TLS 1.3 Key Exchange Modes + * + * Mbed TLS internal identifiers for use with the SSL configuration API + * mbedtls_ssl_conf_tls13_key_exchange_modes(). + */ + +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_NONE 0 +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ( 1u << 0 ) +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ( 1u << 1 ) +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ( 1u << 2 ) + +/* Convenience macros for sets of key exchanges. */ +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL \ + ( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK | \ + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL | \ + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL \ + ( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK | \ + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL \ + ( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL | \ + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) + /* * Various constants */ @@ -1069,6 +1093,11 @@ struct mbedtls_ssl_config /** Allowed ciphersuites for (D)TLS 1.2 (0-terminated) */ const int *MBEDTLS_PRIVATE(ciphersuite_list); +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + /** Allowed TLS 1.3 key exchange modes. */ + int MBEDTLS_PRIVATE(tls13_kex_modes); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /** Callback for printing debug output */ void (*MBEDTLS_PRIVATE(f_dbg))(void *, int, const char *, int, const char *); void *MBEDTLS_PRIVATE(p_dbg); /*!< context for the debug function */ @@ -2561,6 +2590,53 @@ int mbedtls_ssl_session_save( const mbedtls_ssl_session *session, void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, const int *ciphersuites ); +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +/** + * \brief Set the supported key exchange modes for TLS 1.3 connections. + * + * In contrast to TLS 1.2, the ciphersuite concept in TLS 1.3 does not + * include the choice of key exchange mechanism. It is therefore not + * covered by the API mbedtls_ssl_conf_ciphersuites(). See the + * documentation of mbedtls_ssl_conf_ciphersuites() for more + * information on the ciphersuite concept in TLS 1.2 and TLS 1.3. + * + * The present function is specific to TLS 1.3 and allows users to + * configure the set of supported key exchange mechanisms in TLS 1.3. + * + * \param conf The SSL configuration the change should apply to. + * \param kex_modes A bitwise combination of one or more of the following: + * - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK + * This flag enables pure-PSK key exchanges. + * - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL + * This flag enables combined PSK-ephemeral key exchanges. + * - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL + * This flag enables pure-ephemeral key exchanges. + * For convenience, the following pre-defined macros are + * available for combinations of the above: + * - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL + * Includes all of pure-PSK, PSK-ephemeral and pure-ephemeral. + * - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL + * Includes both pure-PSK and combined PSK-ephemeral + * key exchanges, but excludes pure-ephemeral key exchanges. + * - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL + * Includes both pure-ephemeral and combined PSK-ephemeral + * key exchanges. + * + * \note If a PSK-based key exchange mode shall be supported, applications + * must also use the APIs mbedtls_ssl_conf_psk() or + * mbedtls_ssl_conf_psk_cb() or mbedtls_ssl_conf_psk_opaque() + * to configure the PSKs to be used. + * + * \note If an ECDHE-based key exchange mode shall be supported, + * server-side applications must also provide a certificate via + * mbedtls_ssl_conf_own_cert(). + * + */ + +void mbedtls_ssl_conf_tls13_key_exchange_modes( mbedtls_ssl_config* conf, + const int kex_modes ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) #define MBEDTLS_SSL_UNEXPECTED_CID_IGNORE 0 #define MBEDTLS_SSL_UNEXPECTED_CID_FAIL 1 diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 97bb7b6470..4933980cd9 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3548,6 +3548,14 @@ void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, conf->ciphersuite_list = ciphersuites; } +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +void mbedtls_ssl_conf_tls13_key_exchange_modes( mbedtls_ssl_config* conf, + const int kex_modes ) +{ + conf->tls13_kex_modes = kex_modes; +} +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_X509_CRT_PARSE_C) void mbedtls_ssl_conf_cert_profile( mbedtls_ssl_config *conf, const mbedtls_x509_crt_profile *profile ) @@ -6353,6 +6361,13 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, } #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + /* + * Allow all TLS 1.3 key exchange modes by default. + */ + conf->tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* * Preset-specific defaults */ From 2c0f697fbc74795152932466d2c47e0813459724 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 24 Jul 2021 06:27:16 +0100 Subject: [PATCH 271/966] Support TLS 1.3 key exchange config in ssl_client2/ssl_server2 Signed-off-by: Hanno Becker --- programs/ssl/ssl_client2.c | 56 ++++++++++++++++++++++++++++++++------ programs/ssl/ssl_server2.c | 30 ++++++++++++++++++++ 2 files changed, 77 insertions(+), 9 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 86c314c35d..f40897397c 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -65,6 +65,7 @@ int main( void ) #define DFL_ECJPAKE_PW NULL #define DFL_EC_MAX_OPS -1 #define DFL_FORCE_CIPHER 0 +#define DFL_TLS13_KEX_MODES MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL #define DFL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION_DISABLED #define DFL_ALLOW_LEGACY -2 #define DFL_RENEGOTIATE 0 @@ -335,6 +336,14 @@ int main( void ) #define USAGE_SERIALIZATION "" #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +#define USAGE_TLS13_KEY_EXCHANGE_MODES \ + " tls13_kex_modes=%%s default: all\n" \ + " options: psk, psk_ephemeral, ephemeral, psk_all, all\n" +#else +#define USAGE_TLS13_KEY_EXCHANGE_MODES "" +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* USAGE is arbitrarily split to stay under the portable string literal * length limit: 4095 bytes in C99. */ #define USAGE1 \ @@ -403,18 +412,19 @@ int main( void ) #endif /* !MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #define USAGE4 \ - " allow_sha1=%%d default: 0\n" \ - " min_version=%%s default: (library default: tls1_2)\n" \ - " max_version=%%s default: (library default: tls1_2)\n" \ - " force_version=%%s default: \"\" (none)\n" \ + " allow_sha1=%%d default: 0\n" \ + " min_version=%%s default: (library default: tls1_2)\n" \ + " max_version=%%s default: (library default: tls1_2)\n" \ + " force_version=%%s default: \"\" (none)\n" \ " options: tls1_2, dtls1_2" TLS1_3_VERSION_OPTIONS \ - "\n\n" \ - " force_ciphersuite= default: all enabled\n"\ - " query_config= return 0 if the specified\n" \ + "\n\n" \ + " force_ciphersuite= default: all enabled\n" \ + USAGE_TLS13_KEY_EXCHANGE_MODES \ + " query_config= return 0 if the specified\n" \ " configuration macro is defined and 1\n" \ " otherwise. The expansion of the macro\n" \ - " is printed if it is defined\n" \ - USAGE_SERIALIZATION \ + " is printed if it is defined\n" \ + USAGE_SERIALIZATION \ " acceptable ciphersuite names:\n" #define ALPN_LIST_SIZE 10 @@ -453,6 +463,9 @@ struct options const char *ecjpake_pw; /* the EC J-PAKE password */ int ec_max_ops; /* EC consecutive operations limit */ int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + int tls13_kex_modes; /* supported TLS 1.3 key exchange modes */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ int renegotiation; /* enable / disable renegotiation */ int allow_legacy; /* allow legacy renegotiation */ int renegotiate; /* attempt renegotiation? */ @@ -814,6 +827,9 @@ int main( int argc, char *argv[] ) opt.ecjpake_pw = DFL_ECJPAKE_PW; opt.ec_max_ops = DFL_EC_MAX_OPS; opt.force_ciphersuite[0]= DFL_FORCE_CIPHER; +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + opt.tls13_kex_modes = DFL_TLS13_KEX_MODES; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ opt.renegotiation = DFL_RENEGOTIATION; opt.allow_legacy = DFL_ALLOW_LEGACY; opt.renegotiate = DFL_RENEGOTIATE; @@ -1072,6 +1088,24 @@ int main( int argc, char *argv[] ) default: goto usage; } } +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + else if( strcmp( p, "tls13_kex_modes" ) == 0 ) + { + if( strcmp( q, "psk_pure" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; + else if( strcmp(q, "psk_ephemeral" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; + else if( strcmp(q, "ephemeral_pure" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; + else if( strcmp(q, "ephemeral_all" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL; + else if( strcmp( q, "psk_all" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL; + else if( strcmp( q, "all" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL; + else goto usage; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ else if( strcmp( p, "min_version" ) == 0 ) { if( strcmp( q, "tls1_2" ) == 0 || @@ -1748,6 +1782,10 @@ int main( int argc, char *argv[] ) if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER ) mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite ); +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + mbedtls_ssl_conf_tls13_key_exchange_modes( &conf, opt.tls13_kex_modes ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + if( opt.allow_legacy != DFL_ALLOW_LEGACY ) mbedtls_ssl_conf_legacy_renegotiation( &conf, opt.allow_legacy ); #if defined(MBEDTLS_SSL_RENEGOTIATION) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 83bd617c68..25cdb40c77 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -95,6 +95,7 @@ int main( void ) #define DFL_ECJPAKE_PW NULL #define DFL_PSK_LIST NULL #define DFL_FORCE_CIPHER 0 +#define DFL_TLS13_KEX_MODES MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL #define DFL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION_DISABLED #define DFL_ALLOW_LEGACY -2 #define DFL_RENEGOTIATE 0 @@ -564,6 +565,9 @@ struct options char *psk_list; /* list of PSK id/key pairs for callback */ const char *ecjpake_pw; /* the EC J-PAKE password */ int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + int tls13_kex_modes; /* supported TLS 1.3 key exchange modes */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ int renegotiation; /* enable / disable renegotiation */ int allow_legacy; /* allow legacy renegotiation */ int renegotiate; /* attempt renegotiation? */ @@ -1478,6 +1482,9 @@ int main( int argc, char *argv[] ) opt.psk_list = DFL_PSK_LIST; opt.ecjpake_pw = DFL_ECJPAKE_PW; opt.force_ciphersuite[0]= DFL_FORCE_CIPHER; +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + opt.tls13_kex_modes = DFL_TLS13_KEX_MODES; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ opt.renegotiation = DFL_RENEGOTIATION; opt.allow_legacy = DFL_ALLOW_LEGACY; opt.renegotiate = DFL_RENEGOTIATE; @@ -1714,6 +1721,25 @@ int main( int argc, char *argv[] ) if( opt.exchanges < 0 ) goto usage; } +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + else if( strcmp( p, "tls13_kex_modes" ) == 0 ) + { + if( strcmp( q, "psk_pure" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; + else if( strcmp(q, "psk_ephemeral" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; + else if( strcmp(q, "ephemeral_pure" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; + else if( strcmp(q, "ephemeral_all" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL; + else if( strcmp( q, "psk_all" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL; + else if( strcmp( q, "all" ) == 0 ) + opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL; + else goto usage; + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + else if( strcmp( p, "min_version" ) == 0 ) { if( strcmp( q, "tls1_2" ) == 0 || @@ -2610,6 +2636,10 @@ int main( int argc, char *argv[] ) if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER ) mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite ); +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + mbedtls_ssl_conf_tls13_key_exchange_modes( &conf, opt.tls13_kex_modes ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + if( opt.allow_legacy != DFL_ALLOW_LEGACY ) mbedtls_ssl_conf_legacy_renegotiation( &conf, opt.allow_legacy ); #if defined(MBEDTLS_SSL_RENEGOTIATION) From 932064d6603ef632d525e329a30c339934bd38b3 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 24 Jul 2021 06:45:50 +0100 Subject: [PATCH 272/966] Add ssl-opt.sh tests for ssl_client/server TLS 1.3 kex parameters Those tests are so far only checking that ssl_client2/ssl_server2 recognize the arguments, nothing more. Signed-off-by: Hanno Becker --- tests/ssl-opt.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 01265ae9b3..56c4a5fba7 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1453,6 +1453,40 @@ run_test "SHA-256 allowed by default in client certificate" \ "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \ 0 +# Dummy TLS 1.3 test +# Currently only checking that passing TLS 1.3 key exchange modes to +# ssl_client2/ssl_server2 example programs works. +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +run_test "TLS 1.3, key exchange mode parameter passing: PSK only" \ + "$P_SRV tls13_kex_modes=psk_pure" \ + "$P_CLI tls13_kex_modes=psk_pure" \ + 0 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +run_test "TLS 1.3, key exchange mode parameter passing: PSK-ephemeral only" \ + "$P_SRV tls13_kex_modes=psk_ephemeral" \ + "$P_CLI tls13_kex_modes=psk_ephemeral" \ + 0 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +run_test "TLS 1.3, key exchange mode parameter passing: Pure-ephemeral only" \ + "$P_SRV tls13_kex_modes=ephemeral_pure" \ + "$P_CLI tls13_kex_modes=ephemeral_pure" \ + 0 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +run_test "TLS 1.3, key exchange mode parameter passing: All ephemeral" \ + "$P_SRV tls13_kex_modes=ephemeral_all" \ + "$P_CLI tls13_kex_modes=ephemeral_all" \ + 0 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +run_test "TLS 1.3, key exchange mode parameter passing: All PSK" \ + "$P_SRV tls13_kex_modes=psk_all" \ + "$P_CLI tls13_kex_modes=psk_all" \ + 0 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +run_test "TLS 1.3, key exchange mode parameter passing: All" \ + "$P_SRV tls13_kex_modes=all" \ + "$P_CLI tls13_kex_modes=all" \ + 0 + # Tests for datagram packing run_test "DTLS: multiple records in same datagram, client and server" \ "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \ From a2535931acfb8ad0b0b3aa977ce4a740b00711c9 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 2 Aug 2021 21:20:54 +0100 Subject: [PATCH 273/966] Add Doxygen documentation for TLS 1.3 key exchange macros Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 029fa42926..327184c2de 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -176,22 +176,27 @@ * mbedtls_ssl_conf_tls13_key_exchange_modes(). */ -#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_NONE 0 -#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ( 1u << 0 ) -#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ( 1u << 1 ) -#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ( 1u << 2 ) +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ( 1u << 0 ) /*!< Pure-PSK TLS 1.3 key exchange, + * encompassing both externally agreed PSKs + * as well as resumption PSKs. */ +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ( 1u << 1 ) /*!< Pure-Ephemeral TLS 1.3 key exchanges, + * including for example ECDHE and DHE + * key exchanges. */ +#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ( 1u << 2 ) /*!< PSK-Ephemeral TLS 1.3 key exchanges, + * using both a PSK and an ephemeral + * key exchange. */ /* Convenience macros for sets of key exchanges. */ #define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL \ ( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK | \ MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL | \ - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) /*!< All TLS 1.3 key exchanges */ #define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL \ ( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK | \ - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) /*!< All PSK-based TLS 1.3 key exchanges */ #define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL \ ( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL | \ - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) /*!< All ephemeral TLS 1.3 key exchanges */ /* * Various constants From d4fa9bc7104d9996da72e2b1af2e6ccc6bb06806 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 2 Aug 2021 21:21:05 +0100 Subject: [PATCH 274/966] Remove outdated mentioning of version-specific ciphersuite config Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 327184c2de..997cd686d8 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -2553,7 +2553,6 @@ int mbedtls_ssl_session_save( const mbedtls_ssl_session *session, /** * \brief Set the list of allowed ciphersuites and the preference * order. First in the list has the highest preference. - * (Overrides all version-specific lists) * * For TLS 1.2, the notion of ciphersuite determines both * the key exchange mechanism and the suite of symmetric From 674f9480cf97f12d5cc26955c3f3b2a359f6e8a6 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 2 Aug 2021 21:21:19 +0100 Subject: [PATCH 275/966] Fix typo: algorithmc -> algorithms Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 997cd686d8..5d0cf3edb5 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -2559,7 +2559,7 @@ int mbedtls_ssl_session_save( const mbedtls_ssl_session *session, * algorithms to be used during and after the handshake. * * For TLS 1.3 (in development), the notion of ciphersuite - * only determines the suite of symmetric algorithmc to be + * only determines the suite of symmetric algorithms to be * used during and after the handshake, while key exchange * mechanisms are configured separately. * From 5d045a8b89a34b8dc5e8f68f478eacb5156c2a82 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 2 Aug 2021 21:21:30 +0100 Subject: [PATCH 276/966] Stick to 'ephemeral' instead of ECDHE for TLS 1.3 key exchanges Signed-off-by: Hanno Becker --- include/mbedtls/ssl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 5d0cf3edb5..70dc501c0b 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -2631,7 +2631,7 @@ void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, * mbedtls_ssl_conf_psk_cb() or mbedtls_ssl_conf_psk_opaque() * to configure the PSKs to be used. * - * \note If an ECDHE-based key exchange mode shall be supported, + * \note If a pure-ephemeral key exchange mode shall be supported, * server-side applications must also provide a certificate via * mbedtls_ssl_conf_own_cert(). * From 30319f1f889863afd60a87a292602992297d3c6c Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 2 Aug 2021 21:21:55 +0100 Subject: [PATCH 277/966] Remove misplaced comment in TLS 1.3 ciphersuite definitions Signed-off-by: Hanno Becker --- library/ssl_ciphersuites.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/ssl_ciphersuites.c b/library/ssl_ciphersuites.c index 1df1b26b2c..9a416c811d 100644 --- a/library/ssl_ciphersuites.c +++ b/library/ssl_ciphersuites.c @@ -334,8 +334,7 @@ static const mbedtls_ssl_ciphersuite_t ciphersuite_definitions[] = MBEDTLS_KEY_EXCHANGE_NONE, /* Key exchange not part of ciphersuite in TLS 1.3 */ MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, - 0 // field not used in TLS 1.3 implementation - }, + 0 }, #endif /* MBEDTLS_CHACHAPOLY_C && MBEDTLS_SHA256_C */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From cfa4d4b3f5b229ec8491d9bb72435d306db6039f Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 2 Aug 2021 21:22:06 +0100 Subject: [PATCH 278/966] ssl_client2: Adjust usage string to recognized cmd line parameter Signed-off-by: Hanno Becker --- programs/ssl/ssl_client2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index f40897397c..223b7bff2f 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -339,7 +339,7 @@ int main( void ) #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #define USAGE_TLS13_KEY_EXCHANGE_MODES \ " tls13_kex_modes=%%s default: all\n" \ - " options: psk, psk_ephemeral, ephemeral, psk_all, all\n" + " options: psk_pure, psk_ephemeral, ephemeral_pure, ephemeral_all, psk_all, all\n" #else #define USAGE_TLS13_KEY_EXCHANGE_MODES "" #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From a9e4e6fd6f3648400b5f26913cfec349a91570b7 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 2 Aug 2021 21:22:28 +0100 Subject: [PATCH 279/966] ssl_server2: Add usage string for TLS 1.3 key exchange modes Signed-off-by: Hanno Becker --- programs/ssl/ssl_server2.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 25cdb40c77..87558f54cb 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -433,6 +433,15 @@ int main( void ) #define USAGE_SERIALIZATION "" #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +#define USAGE_TLS13_KEY_EXCHANGE_MODES \ + " tls13_kex_modes=%%s default: all\n" \ + " options: psk_pure, psk_ephemeral, ephemeral_pure, ephemeral_all, psk_all, all\n" +#else +#define USAGE_TLS13_KEY_EXCHANGE_MODES "" +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + + /* USAGE is arbitrarily split to stay under the portable string literal * length limit: 4095 bytes in C99. */ #define USAGE1 \ @@ -496,18 +505,19 @@ int main( void ) #define USAGE4 \ USAGE_SSL_ASYNC \ USAGE_SNI \ - " allow_sha1=%%d default: 0\n" \ - " min_version=%%s default: (library default: tls1_2)\n" \ - " max_version=%%s default: (library default: tls1_2)\n" \ - " force_version=%%s default: \"\" (none)\n" \ + " allow_sha1=%%d default: 0\n" \ + " min_version=%%s default: (library default: tls1_2)\n" \ + " max_version=%%s default: (library default: tls1_2)\n" \ + " force_version=%%s default: \"\" (none)\n" \ " options: tls1_2, dtls1_2" TLS1_3_VERSION_OPTIONS \ - "\n\n" \ - " force_ciphersuite= default: all enabled\n" \ - " query_config= return 0 if the specified\n" \ + "\n\n" \ + " force_ciphersuite= default: all enabled\n" \ + USAGE_TLS13_KEY_EXCHANGE_MODES \ + " query_config= return 0 if the specified\n" \ " configuration macro is defined and 1\n" \ " otherwise. The expansion of the macro\n" \ - " is printed if it is defined\n" \ - USAGE_SERIALIZATION \ + " is printed if it is defined\n" \ + USAGE_SERIALIZATION \ " acceptable ciphersuite names:\n" #define ALPN_LIST_SIZE 10 From 7dd2f504b3ebeda92cdf7e80135db2026b0356bd Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sat, 24 Apr 2021 13:35:41 +0200 Subject: [PATCH 280/966] Allow configuring MBEDTLS_TLS_EXT_CID at compile time The numerical identifier of the CID extension hasn't been settled yet and different implementations use values from different drafts. Allow configuring the value at compile time. Signed-off-by: Gilles Peskine --- ChangeLog.d/tls_ext_cid-config.txt | 3 +++ include/mbedtls/mbedtls_config.h | 11 +++++++++++ include/mbedtls/ssl.h | 8 +++++++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 ChangeLog.d/tls_ext_cid-config.txt diff --git a/ChangeLog.d/tls_ext_cid-config.txt b/ChangeLog.d/tls_ext_cid-config.txt new file mode 100644 index 0000000000..b7b1e72443 --- /dev/null +++ b/ChangeLog.d/tls_ext_cid-config.txt @@ -0,0 +1,3 @@ +Features + * The identifier of the CID TLS extension can be configured by defining + MBEDTLS_TLS_EXT_CID at compile time. diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index a60db7e930..d470c0054b 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -3194,6 +3194,17 @@ //#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ //#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ +/** \def MBEDTLS_TLS_EXT_CID + * + * At the time of writing, the CID extension has not been assigned its + * final value. Set this configuration option to make Mbed TLS use a + * different value. + * + * A future minor revision of Mbed TLS may change the default value of + * this option to match evolving standards and usage. + */ +//#define MBEDTLS_TLS_EXT_CID 254 + /** * Complete list of ciphersuites to use, in order of preference. * diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 221cee3379..167d741a03 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -425,8 +425,14 @@ /* The value of the CID extension is still TBD as of * draft-ietf-tls-dtls-connection-id-05 - * (https://tools.ietf.org/html/draft-ietf-tls-dtls-connection-id-05) */ + * (https://tools.ietf.org/html/draft-ietf-tls-dtls-connection-id-05). + * + * A future minor revision of Mbed TLS may change the default value of + * this option to match evolving standards and usage. + */ +#if !defined(MBEDTLS_TLS_EXT_CID) #define MBEDTLS_TLS_EXT_CID 254 /* TBD */ +#endif #define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */ From fb86ac70f5ca4c19d39bf219c9dcd1499db2c281 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 16 Aug 2021 10:32:40 +0100 Subject: [PATCH 281/966] Comment Match.__str__ and use format() to simplify calculation Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 591389b960..5dc38fc523 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -77,15 +77,16 @@ class Match(): # pylint: disable=too-few-public-methods self.name = name def __str__(self): - ln_str = str(self.pos[0]) - gutter_len = max(4, len(ln_str)) - gutter = (gutter_len - len(ln_str)) * " " + ln_str + """ + Return a formatted code listing representation of the erroneous line. + """ + gutter = format(self.pos[0], "4d") underline = self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^" return ( - " {0} |\n".format(gutter_len * " ") + + " {0} |\n".format(" " * len(gutter)) + " {0} | {1}".format(gutter, self.line) + - " {0} | {1}\n".format(gutter_len * " ", underline) + " {0} | {1}\n".format(" " * len(gutter), underline) ) class Problem(): # pylint: disable=too-few-public-methods From 8246eb8fb61dd577625f2a35f0aa200154757f15 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 16 Aug 2021 10:37:24 +0100 Subject: [PATCH 282/966] Fix English typos in comments of check_names and list-identifiers Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 9 +++++---- tests/scripts/list-identifiers.sh | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 5dc38fc523..113854c28c 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -39,7 +39,7 @@ NameChecker performs the following checks: - Typo checking: All words that begin with MBED exist as macros or constants. The script returns 0 on success, 1 on test failure, and 2 if there is a script -error error. Must be run from Mbed TLS root. +error. It must be run from Mbed TLS root. """ import argparse @@ -429,8 +429,9 @@ class CodeParser(): def parse_identifiers(self, include, exclude=None): """ - Parse all lines of a header where a function identifier is declared, - based on some huersitics. Highly dependent on formatting style. + Parse all lines of a header where a function/enum/struct/union/typedef + identifier is declared, based on some heuristics. Highly dependent on + formatting style. Note: .match() checks at the beginning of the string (implicit ^), while .search() checks throughout. @@ -509,7 +510,7 @@ class CodeParser(): line = previous_line.strip() + " " + line.strip() previous_line = "" - # Skip parsing if line has a space in front = hueristic to + # Skip parsing if line has a space in front = heuristic to # skip function argument lines (highly subject to formatting # changes) if line[0] == " ": diff --git a/tests/scripts/list-identifiers.sh b/tests/scripts/list-identifiers.sh index 781c609fc1..9b930802f5 100755 --- a/tests/scripts/list-identifiers.sh +++ b/tests/scripts/list-identifiers.sh @@ -56,9 +56,9 @@ else cat < Date: Mon, 16 Aug 2021 10:39:24 +0100 Subject: [PATCH 283/966] Remove unnecessary try/catch in list_internal_identifiers The try/catch was used to catch Exceptions and exit with code 1, a legacy from check_names.py which uses the pattern to exit with code 2. But code 1 is the default for the Python runtime anyway, so it is redundant and can be removed. Signed-off-by: Yuto Takano --- tests/scripts/list_internal_identifiers.py | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/scripts/list_internal_identifiers.py b/tests/scripts/list_internal_identifiers.py index f18491bad9..d1b55138f1 100755 --- a/tests/scripts/list_internal_identifiers.py +++ b/tests/scripts/list_internal_identifiers.py @@ -44,21 +44,16 @@ def main(): parser.parse_args() - try: - name_check = CodeParser(logging.getLogger()) - result = name_check.parse_identifiers([ - "include/mbedtls/*_internal.h", - "library/*.h" - ]) - result.sort(key=lambda x: x.name) + name_check = CodeParser(logging.getLogger()) + result = name_check.parse_identifiers([ + "include/mbedtls/*_internal.h", + "library/*.h" + ]) + result.sort(key=lambda x: x.name) - identifiers = ["{}\n".format(match.name) for match in result] - with open("identifiers", "w", encoding="utf-8") as f: - f.writelines(identifiers) - - except Exception: # pylint: disable=broad-except - traceback.print_exc() - sys.exit(1) + identifiers = ["{}\n".format(match.name) for match in result] + with open("identifiers", "w", encoding="utf-8") as f: + f.writelines(identifiers) if __name__ == "__main__": main() From 9d9c6dc46e00889c93f565da6d6fe08490414444 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 16 Aug 2021 10:43:45 +0100 Subject: [PATCH 284/966] Align the item counts in check_names for ease of reading Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 113854c28c..b12f406443 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -258,11 +258,12 @@ class CodeParser(): actual_macros.append(macro) self.log.debug("Found:") - self.log.debug(" {} Total Macros".format(len(all_macros))) - self.log.debug(" {} Non-identifier Macros".format(len(actual_macros))) - self.log.debug(" {} Enum Constants".format(len(enum_consts))) - self.log.debug(" {} Identifiers".format(len(identifiers))) - self.log.debug(" {} Exported Symbols".format(len(symbols))) + # Aligns the counts on the assumption that none exceeds 4 digits + self.log.debug(" {:4} Total Macros".format(len(all_macros))) + self.log.debug(" {:4} Non-identifier Macros".format(len(actual_macros))) + self.log.debug(" {:4} Enum Constants".format(len(enum_consts))) + self.log.debug(" {:4} Identifiers".format(len(identifiers))) + self.log.debug(" {:4} Exported Symbols".format(len(symbols))) return { "macros": actual_macros, "enum_consts": enum_consts, From 90bc026913b50e7ebe200ac9a2935367b774e485 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 16 Aug 2021 11:34:10 +0100 Subject: [PATCH 285/966] Exclusively use re.search() to avoid confusion with .match() Also fix newline being removed when lines were concatenated Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 42 +++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index b12f406443..c0fc20fccc 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -407,16 +407,16 @@ class CodeParser(): # Match typedefs and brackets only when they are at the # beginning of the line -- if they are indented, they might # be sub-structures within structs, etc. - if state == 0 and re.match(r"^(typedef +)?enum +{", line): + if state == 0 and re.search(r"^(typedef +)?enum +{", line): state = 1 - elif state == 0 and re.match(r"^(typedef +)?enum", line): + elif state == 0 and re.search(r"^(typedef +)?enum", line): state = 2 - elif state == 2 and re.match(r"^{", line): + elif state == 2 and re.search(r"^{", line): state = 1 - elif state == 1 and re.match(r"^}", line): + elif state == 1 and re.search(r"^}", line): state = 0 - elif state == 1 and not re.match(r" *#", line): - enum_const = re.match(r" *(?P\w+)", line) + elif state == 1 and not re.search(r"^ *#", line): + enum_const = re.search(r"^ *(?P\w+)", line) if not enum_const: continue @@ -433,8 +433,6 @@ class CodeParser(): Parse all lines of a header where a function/enum/struct/union/typedef identifier is declared, based on some heuristics. Highly dependent on formatting style. - Note: .match() checks at the beginning of the string (implicit ^), while - .search() checks throughout. Args: * include: A List of glob expressions to look for files through. @@ -459,12 +457,12 @@ class CodeParser(): ) exclusion_lines = re.compile( r"^(" - r"extern +\"C\"|" - r"(typedef +)?(struct|union|enum)( *{)?$|" - r"} *;?$|" - r"$|" - r"//|" - r"#" + r"extern +\"C\"|" + r"(typedef +)?(struct|union|enum)( *{)?$|" + r"} *;?$|" + r"$|" + r"//|" + r"#" r")" ) @@ -493,7 +491,7 @@ class CodeParser(): previous_line = "" continue - if exclusion_lines.match(line): + if exclusion_lines.search(line): previous_line = "" continue @@ -501,14 +499,14 @@ class CodeParser(): # characters (or underscore, asterisk, or, open bracket), # and nothing else, high chance it's a declaration that # continues on the next line - if re.match(r"^([\w\*\(]+\s+)+$", line): + if re.search(r"^([\w\*\(]+\s+)+$", line): previous_line += line continue # If previous line seemed to start an unfinished declaration # (as above), concat and treat them as one. if previous_line: - line = previous_line.strip() + " " + line.strip() + line = previous_line.strip() + " " + line.strip() + "\n" previous_line = "" # Skip parsing if line has a space in front = heuristic to @@ -626,8 +624,8 @@ class CodeParser(): ).stdout for line in nm_output.splitlines(): - if not nm_undefined_regex.match(line): - symbol = nm_valid_regex.match(line) + if not nm_undefined_regex.search(line): + symbol = nm_valid_regex.search(line) if (symbol and not symbol.group("symbol").startswith(exclusions)): symbols.append(symbol.group("symbol")) else: @@ -718,10 +716,10 @@ class NameChecker(): problems = [] for item_match in self.parse_result[group_to_check]: - if not re.match(check_pattern, item_match.name): + if not re.search(check_pattern, item_match.name): problems.append(PatternMismatch(check_pattern, item_match)) - # Double underscore is a reserved identifier, never to be used - if re.match(r".*__.*", item_match.name): + # Double underscore should not be used for names + if re.search(r".*__.*", item_match.name): problems.append(PatternMismatch("double underscore", item_match)) self.output_check_result( From 6adb2879602f109830855467bc530a2c014e9b10 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 16 Aug 2021 11:38:34 +0100 Subject: [PATCH 286/966] Move duplicated behaviour in get_files to own function Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index c0fc20fccc..10ed5bba39 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -290,26 +290,20 @@ class CodeParser(): # exclude_wildcards may be None. Also, consider the global exclusions. exclude_wildcards = (exclude_wildcards or []) + self.excluded_files - # Perform set union on the glob results. Memoise individual sets. + # Internal function to hit the memoisation cache or add to it the result + # of a glob operation. Used both for inclusion and exclusion since the + # only difference between them is whether they perform set union or + # difference on the return value of this function. + def hit_cache(wildcard): + if wildcard not in self.files: + self.files[wildcard] = set(glob.glob(wildcard, recursive=True)) + return self.files[wildcard] + for include_wildcard in include_wildcards: - if include_wildcard not in self.files: - self.files[include_wildcard] = set(glob.glob( - include_wildcard, - recursive=True - )) + accumulator = accumulator.union(hit_cache(include_wildcard)) - accumulator = accumulator.union(self.files[include_wildcard]) - - # Perform set difference to exclude. Also use the same memo since their - # behaviour is pretty much identical and it can benefit from the cache. for exclude_wildcard in exclude_wildcards: - if exclude_wildcard not in self.files: - self.files[exclude_wildcard] = set(glob.glob( - exclude_wildcard, - recursive=True - )) - - accumulator = accumulator.difference(self.files[exclude_wildcard]) + accumulator = accumulator.difference(hit_cache(exclude_wildcard)) return list(accumulator) From 814fffbd72bfa2bcc3bd4716c03ecf9e0110113b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 16 Aug 2021 18:20:36 +0100 Subject: [PATCH 287/966] Remove overly strict final checks Signed-off-by: Paul Elliott --- library/psa_crypto.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 95f9740633..e40e370a00 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3749,11 +3749,8 @@ exit: return( status ); } -static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation, - size_t output_size ) +static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation ) { - size_t finish_output_size; - if( operation->id == 0 || !operation->nonce_set ) return( PSA_ERROR_BAD_STATE ); @@ -3761,13 +3758,6 @@ static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation, operation->body_remaining != 0 ) ) return( PSA_ERROR_INVALID_ARGUMENT ); - finish_output_size = operation->is_encrypt ? - PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type, operation->alg ) : - PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type, operation->alg ); - - if( output_size < finish_output_size ) - return( PSA_ERROR_BUFFER_TOO_SMALL ); - return( PSA_SUCCESS ); } @@ -3785,7 +3775,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, *ciphertext_length = 0; *tag_length = tag_size; - status = psa_aead_final_checks( operation, ciphertext_size ); + status = psa_aead_final_checks( operation ); if( status != PSA_SUCCESS ) goto exit; @@ -3831,7 +3821,7 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, *plaintext_length = 0; - status = psa_aead_final_checks( operation, plaintext_size ); + status = psa_aead_final_checks( operation ); if( status != PSA_SUCCESS ) goto exit; From 66696b5591e18d308389e0d9123765cf38d75542 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 16 Aug 2021 18:42:41 +0100 Subject: [PATCH 288/966] Improve nonce length checks Add the missing nonce length checks (this function is being used by oneshot functions as well as multipart, and thus all cipher suites are being used) and cover the case where a NULL buffer gets passed in. Extended the set nonce test to cover this. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 17 +++++++++++++++- tests/suites/test_suite_psa_crypto.data | 22 ++++++++++++++------- tests/suites/test_suite_psa_crypto.function | 20 +++++++++++++++---- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index d877638ecf..92c5ccf9ea 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -141,6 +141,21 @@ static psa_status_t mbedtls_aead_check_nonce_length( mbedtls_psa_aead_operation_t *operation, size_t nonce_length ) { +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { + if( nonce_length == 0 ) + return( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + if( nonce_length < 7 || nonce_length > 13 ) + return( PSA_ERROR_NOT_SUPPORTED ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { @@ -428,7 +443,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; if( mbedtls_aead_check_nonce_length( operation, nonce_length ) - != PSA_SUCCESS ) + != PSA_SUCCESS || nonce == NULL ) { return( PSA_ERROR_INVALID_ARGUMENT ); } diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index d223537900..f2355d60b8 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2598,33 +2598,41 @@ PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:12:"":"":PSA_SUCCESS +PSA Multipart Set Nonce, AES - GCM, IV = 0 (NULL) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:1:"":"":PSA_ERROR_INVALID_ARGUMENT + PSA Multipart Set Nonce, AES - GCM, IV = 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:0:"":"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce, AES - GCM, IV = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:0:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Set Nonce, AES - GCM, IV = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):20:0:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 12 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:0:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 8 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:0:"":"":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 (NULL) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:1:"":"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"":"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:0:"":"":PSA_ERROR_INVALID_ARGUMENT PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 10 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index b8023eeb1a..58e43870b8 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3771,6 +3771,7 @@ exit: void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, int alg_arg, int nonce_len, + int allow_null_nonce_buffer, data_t *additional_data, data_t *input_data, int expected_status_arg ) @@ -3829,11 +3830,22 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, PSA_ASSERT( status ); - ASSERT_ALLOC( nonce_buffer, nonce_len ); - - for( index = 0; index < nonce_len - 1; ++index) + if( nonce_len == 0 ) { - nonce_buffer[index] = 'a' + index; + if( !allow_null_nonce_buffer ) + { + /* Arbitrary size buffer, to test zero length valid buffer. */ + ASSERT_ALLOC( nonce_buffer, 4 ); + } + } + else + { + ASSERT_ALLOC( nonce_buffer, nonce_len ); + + for( index = 0; index < nonce_len - 1; ++index) + { + nonce_buffer[index] = 'a' + index; + } } status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_len ); From 0dc86b5a2ac807deaa26fa6a7975ac1d5b4ec1d9 Mon Sep 17 00:00:00 2001 From: Archana Date: Wed, 14 Jul 2021 13:59:48 +0530 Subject: [PATCH 289/966] Remove dependency of builtin keys on storage The psa_open_key API depends on MBEDTLS_PSA_CRYPTO_STORAGE_C. This is unnecessary for builtin keys and so is fixed. Updated an open_fail test vector keeping with the same. Signed-off-by: Archana --- library/psa_crypto_slot_management.c | 7 ++++--- tests/suites/test_suite_psa_crypto_slot_management.data | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c index 4131e3cc47..32a6bb259e 100644 --- a/library/psa_crypto_slot_management.c +++ b/library/psa_crypto_slot_management.c @@ -470,7 +470,8 @@ psa_status_t psa_validate_key_persistence( psa_key_lifetime_t lifetime ) psa_status_t psa_open_key( mbedtls_svc_key_id_t key, psa_key_handle_t *handle ) { -#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) +#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) || \ + defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS) psa_status_t status; psa_key_slot_t *slot; @@ -488,11 +489,11 @@ psa_status_t psa_open_key( mbedtls_svc_key_id_t key, psa_key_handle_t *handle ) return( psa_unlock_key_slot( slot ) ); -#else /* defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) */ +#else /* MBEDTLS_PSA_CRYPTO_STORAGE_C || MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */ (void) key; *handle = PSA_KEY_HANDLE_INIT; return( PSA_ERROR_NOT_SUPPORTED ); -#endif /* !defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) */ +#endif /* MBEDTLS_PSA_CRYPTO_STORAGE_C || MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */ } psa_status_t psa_close_key( psa_key_handle_t handle ) diff --git a/tests/suites/test_suite_psa_crypto_slot_management.data b/tests/suites/test_suite_psa_crypto_slot_management.data index 68b196d32a..1477734165 100644 --- a/tests/suites/test_suite_psa_crypto_slot_management.data +++ b/tests/suites/test_suite_psa_crypto_slot_management.data @@ -160,7 +160,7 @@ depends_on:MBEDTLS_PSA_CRYPTO_STORAGE_C create_fail:PSA_KEY_LIFETIME_PERSISTENT:PSA_KEY_ID_USER_MAX + 1:PSA_ERROR_INVALID_ARGUMENT Open not supported -depends_on:!MBEDTLS_PSA_CRYPTO_STORAGE_C +depends_on:!MBEDTLS_PSA_CRYPTO_STORAGE_C:!MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS open_fail:1:PSA_ERROR_NOT_SUPPORTED Create not supported From f7fce9200c73bbbfc92116a94f8d1d856422096e Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 17 Aug 2021 13:16:08 +0800 Subject: [PATCH 290/966] Remove rsa_pss_rsae_sha256 from preset_sig_algs. To keep consistent with ssl_{clien2t,server2}. Change-Id: I08dbe47a3d9b778ba3acad283f608fef4e63c626 CustomizedGitHooks: yes Signed-off-by: Jerry Yu --- library/ssl_tls.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 07d468ca72..f97b47376e 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6292,10 +6292,6 @@ static uint16_t ssl_preset_default_sig_algs[] = { MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512, #endif /* MBEDTLS_SHA512_C && MBEDTLS_ECP_DP_SECP521R1_ENABLED */ #endif /* MBEDTLS_ECDSA_C */ - /* RSA algorithms */ -#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) - MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256, -#endif MBEDTLS_TLS13_SIG_NONE }; From 7899de839cf26941be5525402078752839cdf6d7 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 17 Aug 2021 13:09:23 +0800 Subject: [PATCH 291/966] fix comments and format issues Change-Id: I927d97f9d788389d6abb9edbda0f7c3e2f8e9b63 CustomizedGitHooks: yes Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 9 +++++---- library/ssl_tls.c | 9 +-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index c62f730b3e..c867e025c4 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1184,7 +1184,7 @@ struct mbedtls_ssl_config const int *MBEDTLS_PRIVATE(sig_hashes); /*!< allowed signature hashes */ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - const uint16_t* MBEDTLS_PRIVATE(tls13_sig_algs); /*!< allowed signature algorithms in TLS 1.3 */ + const uint16_t *MBEDTLS_PRIVATE(tls13_sig_algs); /*!< allowed signature algorithms for TLS 1.3 */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif @@ -3036,9 +3036,10 @@ void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, * \brief Configure allowed signature algorithms for use in TLS 1.3 * * \param conf The SSL configuration to use. - * \param sig_algs A 0-terminated list of IANA values for TLS 1.3 signature algorithms, - * with the most preferred algorithm listed first. Supported values - * are available as \c MBEDTLS_TLS13_SIG_XXX. + * \param sig_algs List of allowed IANA values for TLS 1.3 signature algorithms, + * terminated by \c MBEDTLS_TLS13_SIG_NONE. The list must remain + * available throughout the liftime of the conf object. Supported + * values are available as \c MBEDTLS_TLS13_SIG_XXXX */ void mbedtls_ssl_conf_sig_algs( mbedtls_ssl_config *conf, const uint16_t* sig_algs ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index f97b47376e..909a32a594 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3935,14 +3935,7 @@ void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, } #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -/** - * \brief Configure allowed signature algorithms for use in TLS 1.3 - * - * \param conf The SSL configuration to use. - * \param sig_algs A 0-terminated list of IANA values for TLS 1.3 signature algorithms, - * with the most preferred algorithm listed first. Supported values - * are available as \c MBEDTLS_TLS13_SIG_XXX. - */ +/* Configure allowed signature algorithms for use in TLS 1.3 */ void mbedtls_ssl_conf_sig_algs( mbedtls_ssl_config *conf, const uint16_t* sig_algs ) { From 5473be29142350fdb8b6f9b2c4c16319b8e5a169 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 17 Aug 2021 10:14:01 +0100 Subject: [PATCH 292/966] Use a class variable for `quiet` instead of passing it around Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 10ed5bba39..16d5aba8b5 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -93,8 +93,9 @@ class Problem(): # pylint: disable=too-few-public-methods """ A parent class representing a form of static analysis error. """ + # Class variable to control the quietness of all problems + quiet = False def __init__(self): - self.quiet = False self.textwrapper = textwrap.TextWrapper() self.textwrapper.width = 80 self.textwrapper.initial_indent = " > " @@ -644,8 +645,9 @@ class NameChecker(): * quiet: whether to hide detailed problem explanation. """ self.log.info("=============") + Problem.quiet = quiet problems = 0 - problems += self.check_symbols_declared_in_header(quiet) + problems += self.check_symbols_declared_in_header() pattern_checks = [ ("macros", MACRO_PATTERN), @@ -653,9 +655,9 @@ class NameChecker(): ("identifiers", IDENTIFIER_PATTERN) ] for group, check_pattern in pattern_checks: - problems += self.check_match_pattern(quiet, group, check_pattern) + problems += self.check_match_pattern(group, check_pattern) - problems += self.check_for_typos(quiet) + problems += self.check_for_typos() self.log.info("=============") if problems > 0: @@ -669,15 +671,12 @@ class NameChecker(): self.log.info("PASS") return 0 - def check_symbols_declared_in_header(self, quiet): + def check_symbols_declared_in_header(self): """ Perform a check that all detected symbols in the library object files are properly declared in headers. Assumes parse_names_in_source() was called before this. - Args: - * quiet: whether to hide detailed problem explanation. - Returns the number of problems that need fixing. """ problems = [] @@ -692,16 +691,15 @@ class NameChecker(): if not found_symbol_declared: problems.append(SymbolNotInHeader(symbol)) - self.output_check_result(quiet, "All symbols in header", problems) + self.output_check_result("All symbols in header", problems) return len(problems) - def check_match_pattern(self, quiet, group_to_check, check_pattern): + def check_match_pattern(self, group_to_check, check_pattern): """ Perform a check that all items of a group conform to a regex pattern. Assumes parse_names_in_source() was called before this. Args: - * quiet: whether to hide detailed problem explanation. * group_to_check: string key to index into self.parse_result. * check_pattern: the regex to check against. @@ -717,20 +715,16 @@ class NameChecker(): problems.append(PatternMismatch("double underscore", item_match)) self.output_check_result( - quiet, "Naming patterns of {}".format(group_to_check), problems) return len(problems) - def check_for_typos(self, quiet): + def check_for_typos(self): """ Perform a check that all words in the soure code beginning with MBED are either defined as macros, or as enum constants. Assumes parse_names_in_source() was called before this. - Args: - * quiet: whether to hide detailed problem explanation. - Returns the number of problems that need fixing. """ problems = [] @@ -757,23 +751,21 @@ class NameChecker(): if not found and not typo_exclusion.search(name_match.name): problems.append(Typo(name_match)) - self.output_check_result(quiet, "Likely typos", problems) + self.output_check_result("Likely typos", problems) return len(problems) - def output_check_result(self, quiet, name, problems): + def output_check_result(self, name, problems): """ Write out the PASS/FAIL status of a performed check depending on whether there were problems. Args: - * quiet: whether to hide detailed problem explanation. * name: the name of the test * problems: a List of encountered Problems """ if problems: self.log.info("{}: FAIL\n".format(name)) for problem in problems: - problem.quiet = quiet self.log.warning(str(problem)) else: self.log.info("{}: PASS".format(name)) From b1417b4554bd7b52d6b413035df1a886c3ef6152 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 17 Aug 2021 10:30:20 +0100 Subject: [PATCH 293/966] Use Enums for the enum-parsing state machine Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 16d5aba8b5..ecb00454a6 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -49,6 +49,7 @@ import os import sys import traceback import re +import enum import shutil import subprocess import logging @@ -390,27 +391,33 @@ class CodeParser(): files = self.get_files(include, exclude) self.log.debug("Looking for enum consts in {} files".format(len(files))) + # Emulate a finite state machine to parse enum declarations. + # OUTSIDE_KEYWORD = outside the enum keyword + # IN_BRACES = inside enum opening braces + # IN_BETWEEN = between enum keyword and opening braces + states = enum.Enum("FSM", ["OUTSIDE_KEYWORD", "IN_BRACES", "IN_BETWEEN"]) enum_consts = [] for header_file in files: - # Emulate a finite state machine to parse enum declarations. - # 0 = not in enum - # 1 = inside enum - # 2 = almost inside enum - state = 0 + state = states.OUTSIDE_KEYWORD with open(header_file, "r", encoding="utf-8") as header: for line_no, line in enumerate(header): # Match typedefs and brackets only when they are at the # beginning of the line -- if they are indented, they might # be sub-structures within structs, etc. - if state == 0 and re.search(r"^(typedef +)?enum +{", line): - state = 1 - elif state == 0 and re.search(r"^(typedef +)?enum", line): - state = 2 - elif state == 2 and re.search(r"^{", line): - state = 1 - elif state == 1 and re.search(r"^}", line): - state = 0 - elif state == 1 and not re.search(r"^ *#", line): + if (state == states.OUTSIDE_KEYWORD and + re.search(r"^(typedef +)?enum +{", line)): + state = states.IN_BRACES + elif (state == states.OUTSIDE_KEYWORD and + re.search(r"^(typedef +)?enum", line)): + state = states.IN_BETWEEN + elif (state == states.IN_BETWEEN and + re.search(r"^{", line)): + state = states.IN_BRACES + elif (state == states.IN_BRACES and + re.search(r"^}", line)): + state = states.OUTSIDE_KEYWORD + elif (state == states.IN_BRACES and + not re.search(r"^ *#", line)): enum_const = re.search(r"^ *(?P\w+)", line) if not enum_const: continue @@ -418,7 +425,9 @@ class CodeParser(): enum_consts.append(Match( header_file, line, - (line_no, enum_const.start(), enum_const.end()), + (line_no, + enum_const.start("enum_const"), + enum_const.end("enum_const")), enum_const.group("enum_const"))) return enum_consts @@ -426,8 +435,8 @@ class CodeParser(): def parse_identifiers(self, include, exclude=None): """ Parse all lines of a header where a function/enum/struct/union/typedef - identifier is declared, based on some heuristics. Highly dependent on - formatting style. + identifier is declared, based on some regex and heuristics. Highly + dependent on formatting style. Args: * include: A List of glob expressions to look for files through. @@ -469,7 +478,8 @@ class CodeParser(): with open(header_file, "r", encoding="utf-8") as header: in_block_comment = False # The previous line variable is used for concatenating lines - # when identifiers are formatted and spread across multiple. + # when identifiers are formatted and spread across multiple + # lines. previous_line = "" for line_no, line in enumerate(header): From 704b0f77e1eeed77d7653edb20e5df0ef8ae7ba0 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 17 Aug 2021 10:41:23 +0100 Subject: [PATCH 294/966] Use .span() for positions, and separate line_no argument in Match This reverts a previous change where line_no was removed and put into a triple tuple. It was discovered that re.Match.span() conveniently returns (start, end), so separating line_no again makes the code cleaner. The legibility of the code heavily outweighs the issues pointed out by Pylint (hence disabled). Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index ecb00454a6..604dfd4162 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -67,13 +67,15 @@ class Match(): # pylint: disable=too-few-public-methods Fields: * filename: the file that the match was in. * line: the full line containing the match. - * pos: a tuple of (line_no, start, end) positions on the file line where the - match is. + * line_no: the line number. + * pos: a tuple of (start, end) positions on the line where the match is. * name: the match itself. """ - def __init__(self, filename, line, pos, name): + def __init__(self, filename, line, line_no, pos, name): + # pylint: disable=too-many-arguments self.filename = filename self.line = line + self.line_no = line_no self.pos = pos self.name = name @@ -81,8 +83,8 @@ class Match(): # pylint: disable=too-few-public-methods """ Return a formatted code listing representation of the erroneous line. """ - gutter = format(self.pos[0], "4d") - underline = self.pos[1] * " " + (self.pos[2] - self.pos[1]) * "^" + gutter = format(self.line_no, "4d") + underline = self.pos[0] * " " + (self.pos[1] - self.pos[0]) * "^" return ( " {0} |\n".format(" " * len(gutter)) + @@ -338,7 +340,8 @@ class CodeParser(): macros.append(Match( header_file, line, - (line_no, macro.start(), macro.end()), + line_no, + macro.span("macro"), macro.group("macro"))) return macros @@ -372,9 +375,9 @@ class CodeParser(): mbed_words.append(Match( filename, line, - (line_no, name.start(), name.end()), - name.group(0) - )) + line_no, + name.span(0), + name.group(0))) return mbed_words @@ -425,9 +428,8 @@ class CodeParser(): enum_consts.append(Match( header_file, line, - (line_no, - enum_const.start("enum_const"), - enum_const.end("enum_const")), + line_no, + enum_const.span("enum_const"), enum_const.group("enum_const"))) return enum_consts @@ -533,7 +535,8 @@ class CodeParser(): identifiers.append(Match( header_file, line, - (line_no, identifier.start(), identifier.end()), + line_no, + identifier.span(), group)) return identifiers @@ -722,7 +725,8 @@ class NameChecker(): problems.append(PatternMismatch(check_pattern, item_match)) # Double underscore should not be used for names if re.search(r".*__.*", item_match.name): - problems.append(PatternMismatch("double underscore", item_match)) + problems.append( + PatternMismatch("no double underscore allowed", item_match)) self.output_check_result( "Naming patterns of {}".format(group_to_check), From 4b7d23dfa6cf6806c8bcd500000b5ea749f22ae5 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 17 Aug 2021 10:48:22 +0100 Subject: [PATCH 295/966] Separate make clean and make lib in check_names Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 604dfd4162..3f65b44d0c 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -569,8 +569,15 @@ class CodeParser(): ) my_environment = os.environ.copy() my_environment["CFLAGS"] = "-fno-asynchronous-unwind-tables" + # Run make clean separately to lib to prevent unwanted behavior when + # make is invoked with parallelism. subprocess.run( - ["make", "clean", "lib"], + ["make", "clean"], + universal_newlines=True, + check=True + ) + subprocess.run( + ["make", "lib"], env=my_environment, universal_newlines=True, stdout=subprocess.PIPE, From 3590691bad2d8f1a4cef47edc00114a8ba4faab6 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 17 Aug 2021 11:05:43 +0100 Subject: [PATCH 296/966] Fix issues raised by Pylint 2.4.4 on CI Locally they were unreported by Pylint 2.9.2. Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 3f65b44d0c..a5cbd70cae 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -408,7 +408,7 @@ class CodeParser(): # beginning of the line -- if they are indented, they might # be sub-structures within structs, etc. if (state == states.OUTSIDE_KEYWORD and - re.search(r"^(typedef +)?enum +{", line)): + re.search(r"^(typedef +)?enum +{", line)): state = states.IN_BRACES elif (state == states.OUTSIDE_KEYWORD and re.search(r"^(typedef +)?enum", line)): @@ -461,9 +461,10 @@ class CodeParser(): # Match names of typedef instances, after closing bracket. r"}? *(\w+)[;[].*" ) + # The regex below is indented for clarity. exclusion_lines = re.compile( r"^(" - r"extern +\"C\"|" + r"extern +\"C\"|" # pylint: disable=bad-continuation r"(typedef +)?(struct|union|enum)( *{)?$|" r"} *;?$|" r"$|" From 7276f13c9385fdaba52be47a6a528a9e7217dd35 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 17 Aug 2021 18:25:48 +0800 Subject: [PATCH 297/966] fix comments for sig_algs parser Change-Id: I68bd691c4b67fb18ff9d55ead34f5517b1b981de Signed-off-by: Jerry Yu --- programs/ssl/ssl_client2.c | 2 +- programs/ssl/ssl_server2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 17b1ccf939..08f993466d 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1482,7 +1482,7 @@ int main( int argc, char *argv[] ) p = (char *) opt.sig_algs; i = 0; - /* Leave room for a final NULL in signature algorithm list */ + /* Leave room for a final MBEDTLS_TLS13_SIG_NONE in signature algorithm list(sig_alg_list) */ while( i < SIG_ALG_LIST_SIZE - 1 && *p != '\0' ) { q = p; diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index c7110e850e..d5ec6a7cd4 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -2205,7 +2205,7 @@ int main( int argc, char *argv[] ) p = (char *) opt.sig_algs; i = 0; - /* Leave room for a final NULL in signature algorithm list */ + /* Leave room for a final MBEDTLS_TLS13_SIG_NONE in signature algorithm list(sig_alg_list) */ while( i < SIG_ALG_LIST_SIZE - 1 && *p != '\0' ) { q = p; From 71432096042951b894fb300a7cc7b59c7a69c8f9 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Tue, 17 Aug 2021 12:44:16 +0100 Subject: [PATCH 298/966] Remove unused imports in list_internal_identifiers.py Signed-off-by: Yuto Takano --- tests/scripts/list_internal_identifiers.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/scripts/list_internal_identifiers.py b/tests/scripts/list_internal_identifiers.py index d1b55138f1..779a16ffbc 100755 --- a/tests/scripts/list_internal_identifiers.py +++ b/tests/scripts/list_internal_identifiers.py @@ -30,8 +30,6 @@ Must be run from Mbed TLS root. import argparse import logging -import traceback -import sys from check_names import CodeParser def main(): From 8c51b73c86beca145271acdfa400631e5456fd7d Mon Sep 17 00:00:00 2001 From: lhuang04 Date: Sat, 14 Aug 2021 05:56:07 -0700 Subject: [PATCH 299/966] Update CMake version for CMP0090 Summary: [CMP0090](https://cmake.org/cmake/help/latest/policy/CMP0090.html) was introduced in CMake version 3.15. The CMake version guard should be greater or equal to 3.15. My cmake version is 3.14.5, and run into the following error. ``` cmake --version cmake version 3.14.5 ``` ``` CMake Error at CMakeLists.txt:338 (cmake_policy): Policy "CMP0090" is not known to this version of CMake. -- Configuring incomplete, errors occurred! Test Plan: ``` cmake ``` Signed-off-by: lhuang04 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf74af53c4..210aba4893 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,7 +330,7 @@ install( DESTINATION "cmake" FILE "MbedTLSTargets.cmake") -if(CMAKE_VERSION VERSION_GREATER 3.14) +if(CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15) # Do not export the package by default cmake_policy(SET CMP0090 NEW) From 447a3bee1774e260d53dd3df47ebbe00f9a26f82 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 18 Aug 2021 09:55:32 +0800 Subject: [PATCH 300/966] fix wrong typo and format issues Change-Id: I99a4c7d28c26bfcc43bc8947485d1dfafb6974dc Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 2 +- programs/ssl/ssl_client2.c | 2 +- programs/ssl/ssl_server2.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index c867e025c4..f537e864a9 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -3038,7 +3038,7 @@ void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, * \param conf The SSL configuration to use. * \param sig_algs List of allowed IANA values for TLS 1.3 signature algorithms, * terminated by \c MBEDTLS_TLS13_SIG_NONE. The list must remain - * available throughout the liftime of the conf object. Supported + * available throughout the lifetime of the conf object. Supported * values are available as \c MBEDTLS_TLS13_SIG_XXXX */ void mbedtls_ssl_conf_sig_algs( mbedtls_ssl_config *conf, diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 08f993466d..1400961b8c 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1482,7 +1482,7 @@ int main( int argc, char *argv[] ) p = (char *) opt.sig_algs; i = 0; - /* Leave room for a final MBEDTLS_TLS13_SIG_NONE in signature algorithm list(sig_alg_list) */ + /* Leave room for a final MBEDTLS_TLS13_SIG_NONE in signature algorithm list (sig_alg_list). */ while( i < SIG_ALG_LIST_SIZE - 1 && *p != '\0' ) { q = p; diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index d5ec6a7cd4..b9a789e729 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -2205,7 +2205,7 @@ int main( int argc, char *argv[] ) p = (char *) opt.sig_algs; i = 0; - /* Leave room for a final MBEDTLS_TLS13_SIG_NONE in signature algorithm list(sig_alg_list) */ + /* Leave room for a final MBEDTLS_TLS13_SIG_NONE in signature algorithm list (sig_alg_list). */ while( i < SIG_ALG_LIST_SIZE - 1 && *p != '\0' ) { q = p; From 5f831719994c94606933a70bc275194efc87b0f4 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Wed, 18 Aug 2021 18:03:24 +0100 Subject: [PATCH 301/966] Fix listing line number wrongly using start char pos Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index a5cbd70cae..0eba96740c 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -144,14 +144,14 @@ class PatternMismatch(Problem): # pylint: disable=too-few-public-methods if self.quiet: return ( "{0}:{1}:{2}" - .format(self.match.filename, self.match.pos[0], self.match.name) + .format(self.match.filename, self.match.line_no, self.match.name) ) return self.textwrapper.fill( "{0}:{1}: '{2}' does not match the required pattern '{3}'." .format( self.match.filename, - self.match.pos[0], + self.match.line_no, self.match.name, self.pattern ) @@ -173,14 +173,14 @@ class Typo(Problem): # pylint: disable=too-few-public-methods if self.quiet: return ( "{0}:{1}:{2}" - .format(self.match.filename, self.match.pos[0], self.match.name) + .format(self.match.filename, self.match.line_no, self.match.name) ) return self.textwrapper.fill( "{0}:{1}: '{2}' looks like a typo. It was not found in any " "macros or any enums. If this is not a typo, put " "//no-check-names after it." - .format(self.match.filename, self.match.pos[0], self.match.name) + .format(self.match.filename, self.match.line_no, self.match.name) ) + "\n" + str(self.match) class CodeParser(): From 50dde56543f28fe138f55afea72ce161f61ddf27 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Tue, 22 Jun 2021 15:51:53 +0100 Subject: [PATCH 302/966] Implement byte reading macros into library/ To improve readability by saving horizontal and vertical space. Removed unecessary & 0xFF. Byte reading macros implemented in library/common.h, All files containing "& 0xff" were modified. Comments/Documentation not yet added to the macro definitions. Fixes #4274 Signed-off-by: Joe Subbiani --- library/common.h | 10 ++++++++++ library/ctr_drbg.c | 8 ++++---- library/nist_kw.c | 2 +- library/psa_crypto.c | 4 ++-- library/psa_its_file.c | 16 ++++++++-------- library/ssl_msg.c | 14 +++++++------- library/ssl_ticket.c | 4 ++-- 7 files changed, 34 insertions(+), 24 deletions(-) diff --git a/library/common.h b/library/common.h index 9e4b0312b1..baef72d480 100644 --- a/library/common.h +++ b/library/common.h @@ -66,4 +66,14 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c */ #define MBEDTLS_ALLOW_PRIVATE_ACCESS +/** Byte Reading Macros + * + * To tidy up code and save horizontal and vertical space, use byte + * reading macros to cast + */ +#define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) +#define BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) ) +#define BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) ) +#define BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) + #endif /* MBEDTLS_LIBRARY_COMMON_H */ diff --git a/library/ctr_drbg.c b/library/ctr_drbg.c index b664fb0fc7..d52d9ef254 100644 --- a/library/ctr_drbg.c +++ b/library/ctr_drbg.c @@ -152,10 +152,10 @@ static int block_cipher_df( unsigned char *output, * (Total is padded to a multiple of 16-bytes with zeroes) */ p = buf + MBEDTLS_CTR_DRBG_BLOCKSIZE; - *p++ = ( data_len >> 24 ) & 0xff; - *p++ = ( data_len >> 16 ) & 0xff; - *p++ = ( data_len >> 8 ) & 0xff; - *p++ = ( data_len ) & 0xff; + *p++ = BYTE_3( data_len ); + *p++ = BYTE_2( data_len ); + *p++ = BYTE_1( data_len ); + *p++ = BYTE_0( data_len ); p += 3; *p++ = MBEDTLS_CTR_DRBG_SEEDLEN; memcpy( p, data, data_len ); diff --git a/library/nist_kw.c b/library/nist_kw.c index 5054ca206b..3fff2b7f85 100644 --- a/library/nist_kw.c +++ b/library/nist_kw.c @@ -169,7 +169,7 @@ static void calc_a_xor_t( unsigned char A[KW_SEMIBLOCK_LENGTH], uint64_t t ) size_t i = 0; for( i = 0; i < sizeof( t ); i++ ) { - A[i] ^= ( t >> ( ( sizeof( t ) - 1 - i ) * 8 ) ) & 0xff; + A[i] ^= BYTE_0( t >> ( ( sizeof( t ) - 1 - i ) * 8 ) ); } } diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 3574b9842a..b46e023e5d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -4506,8 +4506,8 @@ static psa_status_t psa_tls12_prf_psk_to_ms_set_key( * uint16 with the value N, and the PSK itself. */ - *cur++ = ( data_length >> 8 ) & 0xff; - *cur++ = ( data_length >> 0 ) & 0xff; + *cur++ = BYTE_1( data_length ); + *cur++ = BYTE_0( data_length ); memset( cur, 0, data_length ); cur += data_length; *cur++ = pms[0]; diff --git a/library/psa_its_file.c b/library/psa_its_file.c index 492be1c711..66043b502e 100644 --- a/library/psa_its_file.c +++ b/library/psa_its_file.c @@ -191,14 +191,14 @@ psa_status_t psa_its_set( psa_storage_uid_t uid, size_t n; memcpy( header.magic, PSA_ITS_MAGIC_STRING, PSA_ITS_MAGIC_LENGTH ); - header.size[0] = data_length & 0xff; - header.size[1] = ( data_length >> 8 ) & 0xff; - header.size[2] = ( data_length >> 16 ) & 0xff; - header.size[3] = ( data_length >> 24 ) & 0xff; - header.flags[0] = create_flags & 0xff; - header.flags[1] = ( create_flags >> 8 ) & 0xff; - header.flags[2] = ( create_flags >> 16 ) & 0xff; - header.flags[3] = ( create_flags >> 24 ) & 0xff; + header.size[0] = BYTE_0( data_length ); + header.size[1] = BYTE_1( data_length ); + header.size[2] = BYTE_2( data_length ); + header.size[3] = BYTE_3( data_length ); + header.flags[0] = BYTE_0( create_flags ); + header.flags[1] = BYTE_1( create_flags ); + header.flags[2] = BYTE_2( create_flags ); + header.flags[3] = BYTE_3( create_flags ); psa_its_fill_filename( uid, filename ); stream = fopen( PSA_ITS_STORAGE_TEMP, "wb" ); diff --git a/library/ssl_msg.c b/library/ssl_msg.c index a03f19251d..1fd9420c24 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2254,14 +2254,14 @@ int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl ) * copy beginning of headers then fill fragmentation fields. * Handshake headers: type(1) len(3) seq(2) f_off(3) f_len(3) */ memcpy( ssl->out_msg, cur->p, 6 ); + + ssl->out_msg[6] = BYTE_2( frag_off ); + ssl->out_msg[7] = BYTE_1( frag_off ); + ssl->out_msg[8] = BYTE_0( frag_off ); - ssl->out_msg[6] = ( ( frag_off >> 16 ) & 0xff ); - ssl->out_msg[7] = ( ( frag_off >> 8 ) & 0xff ); - ssl->out_msg[8] = ( ( frag_off ) & 0xff ); - - ssl->out_msg[ 9] = ( ( cur_hs_frag_len >> 16 ) & 0xff ); - ssl->out_msg[10] = ( ( cur_hs_frag_len >> 8 ) & 0xff ); - ssl->out_msg[11] = ( ( cur_hs_frag_len ) & 0xff ); + ssl->out_msg[ 9] = BYTE_2( cur_hs_frag_len ); + ssl->out_msg[10] = BYTE_1( cur_hs_frag_len ); + ssl->out_msg[11] = BYTE_0( cur_hs_frag_len ); MBEDTLS_SSL_DEBUG_BUF( 3, "handshake header", ssl->out_msg, 12 ); diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c index 940e1a67a2..29d8345750 100644 --- a/library/ssl_ticket.c +++ b/library/ssl_ticket.c @@ -245,8 +245,8 @@ int mbedtls_ssl_ticket_write( void *p_ticket, { goto cleanup; } - state_len_bytes[0] = ( clear_len >> 8 ) & 0xff; - state_len_bytes[1] = ( clear_len ) & 0xff; + state_len_bytes[0] = BYTE_1( clear_len ); + state_len_bytes[1] = BYTE_0( clear_len ); /* Encrypt and authenticate */ if( ( ret = mbedtls_cipher_auth_encrypt_ext( &key->ctx, From 3b394509da07fd7b78a9d9396d838bd588c6ba59 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 23 Jun 2021 11:23:44 +0100 Subject: [PATCH 303/966] Move BYTES_TO_U32_LE to common.h The macro BYTES_TO_U32_LE appears in poly1305.c and chacha20.c. Removes duplicate code and save vertical space the macro has been moved to common.h. Improves maintainability. Signed-off-by: Joe Subbiani --- library/chacha20.c | 7 ------- library/common.h | 14 ++++++++++++-- library/poly1305.c | 7 ------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/library/chacha20.c b/library/chacha20.c index 78467d3fc6..9862ea535a 100644 --- a/library/chacha20.c +++ b/library/chacha20.c @@ -54,13 +54,6 @@ #define CHACHA20_VALIDATE( cond ) \ MBEDTLS_INTERNAL_VALIDATE( cond ) -#define BYTES_TO_U32_LE( data, offset ) \ - ( (uint32_t) (data)[offset] \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 ) \ - ) - #define ROTL32( value, amount ) \ ( (uint32_t) ( (value) << (amount) ) | ( (value) >> ( 32 - (amount) ) ) ) diff --git a/library/common.h b/library/common.h index baef72d480..500e5d4c7d 100644 --- a/library/common.h +++ b/library/common.h @@ -71,9 +71,19 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * To tidy up code and save horizontal and vertical space, use byte * reading macros to cast */ -#define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) -#define BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) ) +#define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) +#define BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) ) #define BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) ) #define BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) +/** + * + */ +#define BYTES_TO_U32_LE( data, offset ) \ + ( (uint32_t) (data)[offset] \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 ) \ + ) + #endif /* MBEDTLS_LIBRARY_COMMON_H */ diff --git a/library/poly1305.c b/library/poly1305.c index 492d1457d4..a30b1707ed 100644 --- a/library/poly1305.c +++ b/library/poly1305.c @@ -52,13 +52,6 @@ #define POLY1305_BLOCK_SIZE_BYTES ( 16U ) -#define BYTES_TO_U32_LE( data, offset ) \ - ( (uint32_t) (data)[offset] \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 ) \ - ) - /* * Our implementation is tuned for 32-bit platforms with a 64-bit multiplier. * However we provided an alternative for platforms without such a multiplier. From 30d974c232cfdff6b91856c99ac8c11de3135915 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 23 Jun 2021 11:49:03 +0100 Subject: [PATCH 304/966] Move UINT32_BE macros to common.h 32-bit integer manipulation macros (big edian): GET_UINT32_BE and PUT_UINT32_BE appear in several files in library/. Removes duplicate code and save vertical space the macro has been moved to common.h. Improves maintainability. Signed-off-by: Joe Subbiani --- library/camellia.c | 23 ----------------------- library/common.h | 23 +++++++++++++++++++++++ library/des.c | 23 ----------------------- library/gcm.c | 23 ----------------------- library/nist_kw.c | 20 -------------------- library/sha1.c | 23 ----------------------- library/sha256.c | 23 ----------------------- 7 files changed, 23 insertions(+), 135 deletions(-) diff --git a/library/camellia.c b/library/camellia.c index f7e013611b..0817b1d292 100644 --- a/library/camellia.c +++ b/library/camellia.c @@ -49,29 +49,6 @@ #define CAMELLIA_VALIDATE( cond ) \ MBEDTLS_INTERNAL_VALIDATE( cond ) -/* - * 32-bit integer manipulation macros (big endian) - */ -#ifndef GET_UINT32_BE -#define GET_UINT32_BE(n,b,i) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ - | ( (uint32_t) (b)[(i) + 1] << 16 ) \ - | ( (uint32_t) (b)[(i) + 2] << 8 ) \ - | ( (uint32_t) (b)[(i) + 3] ); \ -} -#endif - -#ifndef PUT_UINT32_BE -#define PUT_UINT32_BE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} -#endif - static const unsigned char SIGMA_CHARS[6][8] = { { 0xa0, 0x9e, 0x66, 0x7f, 0x3b, 0xcc, 0x90, 0x8b }, diff --git a/library/common.h b/library/common.h index 500e5d4c7d..b3b70dc62f 100644 --- a/library/common.h +++ b/library/common.h @@ -76,6 +76,29 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #define BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) ) #define BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} +#endif + /** * */ diff --git a/library/des.c b/library/des.c index eddf55e789..36ea277760 100644 --- a/library/des.c +++ b/library/des.c @@ -43,29 +43,6 @@ #if !defined(MBEDTLS_DES_ALT) -/* - * 32-bit integer manipulation macros (big endian) - */ -#ifndef GET_UINT32_BE -#define GET_UINT32_BE(n,b,i) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ - | ( (uint32_t) (b)[(i) + 1] << 16 ) \ - | ( (uint32_t) (b)[(i) + 2] << 8 ) \ - | ( (uint32_t) (b)[(i) + 3] ); \ -} -#endif - -#ifndef PUT_UINT32_BE -#define PUT_UINT32_BE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} -#endif - /* * Expanded DES S-boxes */ diff --git a/library/gcm.c b/library/gcm.c index 835b1b2853..c8254876dd 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -58,29 +58,6 @@ #define GCM_VALIDATE( cond ) \ MBEDTLS_INTERNAL_VALIDATE( cond ) -/* - * 32-bit integer manipulation macros (big endian) - */ -#ifndef GET_UINT32_BE -#define GET_UINT32_BE(n,b,i) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ - | ( (uint32_t) (b)[(i) + 1] << 16 ) \ - | ( (uint32_t) (b)[(i) + 2] << 8 ) \ - | ( (uint32_t) (b)[(i) + 3] ); \ -} -#endif - -#ifndef PUT_UINT32_BE -#define PUT_UINT32_BE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} -#endif - /* * Initialize a context */ diff --git a/library/nist_kw.c b/library/nist_kw.c index 3fff2b7f85..c0eed674c1 100644 --- a/library/nist_kw.c +++ b/library/nist_kw.c @@ -77,26 +77,6 @@ static const unsigned char NIST_KW_ICV1[] = {0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, /*! The 32-bit default integrity check value (ICV) for KWP mode. */ static const unsigned char NIST_KW_ICV2[] = {0xA6, 0x59, 0x59, 0xA6}; -#ifndef GET_UINT32_BE -#define GET_UINT32_BE(n,b,i) \ -do { \ - (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ - | ( (uint32_t) (b)[(i) + 1] << 16 ) \ - | ( (uint32_t) (b)[(i) + 2] << 8 ) \ - | ( (uint32_t) (b)[(i) + 3] ); \ -} while( 0 ) -#endif - -#ifndef PUT_UINT32_BE -#define PUT_UINT32_BE(n,b,i) \ -do { \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} while( 0 ) -#endif - /* * Initialize context */ diff --git a/library/sha1.c b/library/sha1.c index 545d093109..9beaee5a54 100644 --- a/library/sha1.c +++ b/library/sha1.c @@ -48,29 +48,6 @@ #if !defined(MBEDTLS_SHA1_ALT) -/* - * 32-bit integer manipulation macros (big endian) - */ -#ifndef GET_UINT32_BE -#define GET_UINT32_BE(n,b,i) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ - | ( (uint32_t) (b)[(i) + 1] << 16 ) \ - | ( (uint32_t) (b)[(i) + 2] << 8 ) \ - | ( (uint32_t) (b)[(i) + 3] ); \ -} -#endif - -#ifndef PUT_UINT32_BE -#define PUT_UINT32_BE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} -#endif - void mbedtls_sha1_init( mbedtls_sha1_context *ctx ) { SHA1_VALIDATE( ctx != NULL ); diff --git a/library/sha256.c b/library/sha256.c index 6ec6da296a..f548c672ea 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -50,29 +50,6 @@ #if !defined(MBEDTLS_SHA256_ALT) -/* - * 32-bit integer manipulation macros (big endian) - */ -#ifndef GET_UINT32_BE -#define GET_UINT32_BE(n,b,i) \ -do { \ - (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ - | ( (uint32_t) (b)[(i) + 1] << 16 ) \ - | ( (uint32_t) (b)[(i) + 2] << 8 ) \ - | ( (uint32_t) (b)[(i) + 3] ); \ -} while( 0 ) -#endif - -#ifndef PUT_UINT32_BE -#define PUT_UINT32_BE(n,b,i) \ -do { \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} while( 0 ) -#endif - void mbedtls_sha256_init( mbedtls_sha256_context *ctx ) { SHA256_VALIDATE( ctx != NULL ); From 54c6134ff7de2ccc5d5cc2ef55f766d9a3a1fbdb Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 23 Jun 2021 12:16:47 +0100 Subject: [PATCH 305/966] Move UINT32_LE macros to common.h 32-bit integer manipulation macros (little edian): GET_UINT32_LE and PUT_UINT32_LE appear in several files in library/. Removes duplicate code and save vertical space the macro has been moved to common.h. Improves maintainability. Also provided brief comment in common.h for BYTES_TO_U32_LE. comment/documentation will probably need to be edited further for all recent additions to library/common.h Signed-off-by: Joe Subbiani --- library/aes.c | 23 ----------------------- library/aria.c | 23 ----------------------- library/common.h | 25 ++++++++++++++++++++++++- library/md5.c | 23 ----------------------- library/psa_crypto_storage.c | 23 ----------------------- library/ripemd160.c | 23 ----------------------- 6 files changed, 24 insertions(+), 116 deletions(-) diff --git a/library/aes.c b/library/aes.c index a15a80924a..7b4fb869e0 100644 --- a/library/aes.c +++ b/library/aes.c @@ -57,29 +57,6 @@ #define AES_VALIDATE( cond ) \ MBEDTLS_INTERNAL_VALIDATE( cond ) -/* - * 32-bit integer manipulation macros (little endian) - */ -#ifndef GET_UINT32_LE -#define GET_UINT32_LE(n,b,i) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] ) \ - | ( (uint32_t) (b)[(i) + 1] << 8 ) \ - | ( (uint32_t) (b)[(i) + 2] << 16 ) \ - | ( (uint32_t) (b)[(i) + 3] << 24 ); \ -} -#endif - -#ifndef PUT_UINT32_LE -#define PUT_UINT32_LE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ - (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ -} -#endif - #if defined(MBEDTLS_PADLOCK_C) && \ ( defined(MBEDTLS_HAVE_X86) || defined(MBEDTLS_PADLOCK_ALIGN16) ) static int aes_padlock_ace = -1; diff --git a/library/aria.c b/library/aria.c index a5786b37ab..d7d2bea7c8 100644 --- a/library/aria.c +++ b/library/aria.c @@ -55,29 +55,6 @@ #define ARIA_VALIDATE( cond ) \ MBEDTLS_INTERNAL_VALIDATE( cond ) -/* - * 32-bit integer manipulation macros (little endian) - */ -#ifndef GET_UINT32_LE -#define GET_UINT32_LE( n, b, i ) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] ) \ - | ( (uint32_t) (b)[(i) + 1] << 8 ) \ - | ( (uint32_t) (b)[(i) + 2] << 16 ) \ - | ( (uint32_t) (b)[(i) + 3] << 24 ); \ -} -#endif - -#ifndef PUT_UINT32_LE -#define PUT_UINT32_LE( n, b, i ) \ -{ \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ - (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ -} -#endif - /* * modify byte order: ( A B C D ) -> ( B A D C ), i.e. swap pairs of bytes * diff --git a/library/common.h b/library/common.h index b3b70dc62f..c2cf633c99 100644 --- a/library/common.h +++ b/library/common.h @@ -99,8 +99,31 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c } #endif +/* + * 32-bit integer manipulation macros (little endian) + */ +#ifndef GET_UINT32_LE +#define GET_UINT32_LE(n,b,i) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] ) \ + | ( (uint32_t) (b)[(i) + 1] << 8 ) \ + | ( (uint32_t) (b)[(i) + 2] << 16 ) \ + | ( (uint32_t) (b)[(i) + 3] << 24 ); \ +} +#endif + +#ifndef PUT_UINT32_LE +#define PUT_UINT32_LE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ + (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ +} +#endif + /** - * + * 32-bit integer conversion from bytes (little endian) */ #define BYTES_TO_U32_LE( data, offset ) \ ( (uint32_t) (data)[offset] \ diff --git a/library/md5.c b/library/md5.c index d7f8cee468..d8f637da83 100644 --- a/library/md5.c +++ b/library/md5.c @@ -43,29 +43,6 @@ #if !defined(MBEDTLS_MD5_ALT) -/* - * 32-bit integer manipulation macros (little endian) - */ -#ifndef GET_UINT32_LE -#define GET_UINT32_LE(n,b,i) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] ) \ - | ( (uint32_t) (b)[(i) + 1] << 8 ) \ - | ( (uint32_t) (b)[(i) + 2] << 16 ) \ - | ( (uint32_t) (b)[(i) + 3] << 24 ); \ -} -#endif - -#ifndef PUT_UINT32_LE -#define PUT_UINT32_LE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ - (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ -} -#endif - void mbedtls_md5_init( mbedtls_md5_context *ctx ) { memset( ctx, 0, sizeof( mbedtls_md5_context ) ); diff --git a/library/psa_crypto_storage.c b/library/psa_crypto_storage.c index 09cbab4c4d..36b518350c 100644 --- a/library/psa_crypto_storage.c +++ b/library/psa_crypto_storage.c @@ -230,29 +230,6 @@ static psa_status_t psa_crypto_storage_get_data_length( return( PSA_SUCCESS ); } -/* - * 32-bit integer manipulation macros (little endian) - */ -#ifndef GET_UINT32_LE -#define GET_UINT32_LE( n, b, i ) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] ) \ - | ( (uint32_t) (b)[(i) + 1] << 8 ) \ - | ( (uint32_t) (b)[(i) + 2] << 16 ) \ - | ( (uint32_t) (b)[(i) + 3] << 24 ); \ -} -#endif - -#ifndef PUT_UINT32_LE -#define PUT_UINT32_LE( n, b, i ) \ -{ \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ - (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ -} -#endif - /* * 16-bit integer manipulation macros (little endian) */ diff --git a/library/ripemd160.c b/library/ripemd160.c index d2ccbbec47..d60654e952 100644 --- a/library/ripemd160.c +++ b/library/ripemd160.c @@ -44,29 +44,6 @@ #if !defined(MBEDTLS_RIPEMD160_ALT) -/* - * 32-bit integer manipulation macros (little endian) - */ -#ifndef GET_UINT32_LE -#define GET_UINT32_LE(n,b,i) \ -{ \ - (n) = ( (uint32_t) (b)[(i) ] ) \ - | ( (uint32_t) (b)[(i) + 1] << 8 ) \ - | ( (uint32_t) (b)[(i) + 2] << 16 ) \ - | ( (uint32_t) (b)[(i) + 3] << 24 ); \ -} -#endif - -#ifndef PUT_UINT32_LE -#define PUT_UINT32_LE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ - (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ -} -#endif - void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx ) { memset( ctx, 0, sizeof( mbedtls_ripemd160_context ) ); From c4f3d5b38e4e1e88237f67380246c5f2fdeec7fd Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 23 Jun 2021 17:58:41 +0100 Subject: [PATCH 306/966] Add do-while protection to macros missed do-while around function-like macros (UINT32_BE and UINT_LE macros) originally present in the indivdual files, before being moved to common.h. Signed-off-by: Joe Subbiani --- library/common.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/common.h b/library/common.h index c2cf633c99..56514b3436 100644 --- a/library/common.h +++ b/library/common.h @@ -81,22 +81,22 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c */ #ifndef GET_UINT32_BE #define GET_UINT32_BE(n,b,i) \ -{ \ +do { \ (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ | ( (uint32_t) (b)[(i) + 1] << 16 ) \ | ( (uint32_t) (b)[(i) + 2] << 8 ) \ | ( (uint32_t) (b)[(i) + 3] ); \ -} +} while( 0 ) #endif #ifndef PUT_UINT32_BE #define PUT_UINT32_BE(n,b,i) \ -{ \ +do { \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} +} while( 0 ) #endif /* @@ -104,22 +104,22 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c */ #ifndef GET_UINT32_LE #define GET_UINT32_LE(n,b,i) \ -{ \ +do { \ (n) = ( (uint32_t) (b)[(i) ] ) \ | ( (uint32_t) (b)[(i) + 1] << 8 ) \ | ( (uint32_t) (b)[(i) + 2] << 16 ) \ | ( (uint32_t) (b)[(i) + 3] << 24 ); \ -} +} while( 0 ) #endif #ifndef PUT_UINT32_LE #define PUT_UINT32_LE(n,b,i) \ -{ \ +do { \ (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ -} +} while( 0 ) #endif /** From 6f2bb0c8efd7fb3a74ececd00b9ca507f5494efe Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 24 Jun 2021 09:06:23 +0100 Subject: [PATCH 307/966] Remove trailing whitespace Trailing white spaces causing check_files.py to fail Signed-off-by: Joe Subbiani --- library/common.h | 6 +++--- library/ssl_msg.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/common.h b/library/common.h index 56514b3436..b6b7d01d9d 100644 --- a/library/common.h +++ b/library/common.h @@ -67,8 +67,8 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #define MBEDTLS_ALLOW_PRIVATE_ACCESS /** Byte Reading Macros - * - * To tidy up code and save horizontal and vertical space, use byte + * + * To tidy up code and save horizontal and vertical space, use byte * reading macros to cast */ #define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) @@ -122,7 +122,7 @@ do { \ } while( 0 ) #endif -/** +/** * 32-bit integer conversion from bytes (little endian) */ #define BYTES_TO_U32_LE( data, offset ) \ diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 1fd9420c24..f3dbba82b9 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2254,7 +2254,7 @@ int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl ) * copy beginning of headers then fill fragmentation fields. * Handshake headers: type(1) len(3) seq(2) f_off(3) f_len(3) */ memcpy( ssl->out_msg, cur->p, 6 ); - + ssl->out_msg[6] = BYTE_2( frag_off ); ssl->out_msg[7] = BYTE_1( frag_off ); ssl->out_msg[8] = BYTE_0( frag_off ); From 9aaec54e57e3ec869ad47ed0f6b67761b74f17fd Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 24 Jun 2021 11:00:08 +0100 Subject: [PATCH 308/966] Undo use of BYTE_x macro The use of the BYTE_x macro in nist_kw did not seem appropriate in hind sight as it is working with a character array not an int Signed-off-by: Joe Subbiani --- library/nist_kw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/nist_kw.c b/library/nist_kw.c index c0eed674c1..174a1eef13 100644 --- a/library/nist_kw.c +++ b/library/nist_kw.c @@ -149,7 +149,7 @@ static void calc_a_xor_t( unsigned char A[KW_SEMIBLOCK_LENGTH], uint64_t t ) size_t i = 0; for( i = 0; i < sizeof( t ); i++ ) { - A[i] ^= BYTE_0( t >> ( ( sizeof( t ) - 1 - i ) * 8 ) ); + A[i] ^= ( t >> ( ( sizeof( t ) - 1 - i ) * 8 ) ) & 0xff; } } From 5ecac217f01aee0f73cffcb30e8b32f00921299f Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 24 Jun 2021 13:00:03 +0100 Subject: [PATCH 309/966] Prefixed macros with MBEDTLS As per tests/scripts/check-names.sh, macros in library/ header files should be prefixed with MBEDTLS_ The macro functions in common.h where also indented to comply with the same test Signed-off-by: Joe Subbiani --- library/aes.c | 34 ++++++++--------- library/aria.c | 34 ++++++++--------- library/camellia.c | 22 +++++------ library/chacha20.c | 22 +++++------ library/common.h | 74 ++++++++++++++++++------------------ library/ctr_drbg.c | 8 ++-- library/des.c | 20 +++++----- library/gcm.c | 34 ++++++++--------- library/md5.c | 44 ++++++++++----------- library/nist_kw.c | 4 +- library/poly1305.c | 24 ++++++------ library/psa_crypto.c | 4 +- library/psa_crypto_storage.c | 24 ++++++------ library/psa_its_file.c | 16 ++++---- library/ripemd160.c | 46 +++++++++++----------- library/sha1.c | 46 +++++++++++----------- library/sha256.c | 24 ++++++------ library/ssl_msg.c | 12 +++--- library/ssl_ticket.c | 4 +- 19 files changed, 248 insertions(+), 248 deletions(-) diff --git a/library/aes.c b/library/aes.c index 7b4fb869e0..db726fe36b 100644 --- a/library/aes.c +++ b/library/aes.c @@ -567,7 +567,7 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, for( i = 0; i < ( keybits >> 5 ); i++ ) { - GET_UINT32_LE( RK[i], key, i << 2 ); + MBEDTLS_GET_UINT32_LE( RK[i], key, i << 2 ); } switch( ctx->nr ) @@ -850,10 +850,10 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, uint32_t Y[4]; } t; - GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++; - GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++; - GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++; - GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++; + MBEDTLS_GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++; + MBEDTLS_GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++; + MBEDTLS_GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++; + MBEDTLS_GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++; for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- ) { @@ -887,10 +887,10 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, ( (uint32_t) FSb[ ( t.Y[1] >> 16 ) & 0xFF ] << 16 ) ^ ( (uint32_t) FSb[ ( t.Y[2] >> 24 ) & 0xFF ] << 24 ); - PUT_UINT32_LE( t.X[0], output, 0 ); - PUT_UINT32_LE( t.X[1], output, 4 ); - PUT_UINT32_LE( t.X[2], output, 8 ); - PUT_UINT32_LE( t.X[3], output, 12 ); + MBEDTLS_PUT_UINT32_LE( t.X[0], output, 0 ); + MBEDTLS_PUT_UINT32_LE( t.X[1], output, 4 ); + MBEDTLS_PUT_UINT32_LE( t.X[2], output, 8 ); + MBEDTLS_PUT_UINT32_LE( t.X[3], output, 12 ); mbedtls_platform_zeroize( &t, sizeof( t ) ); @@ -914,10 +914,10 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, uint32_t Y[4]; } t; - GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++; - GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++; - GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++; - GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++; + MBEDTLS_GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++; + MBEDTLS_GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++; + MBEDTLS_GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++; + MBEDTLS_GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++; for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- ) { @@ -951,10 +951,10 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, ( (uint32_t) RSb[ ( t.Y[1] >> 16 ) & 0xFF ] << 16 ) ^ ( (uint32_t) RSb[ ( t.Y[0] >> 24 ) & 0xFF ] << 24 ); - PUT_UINT32_LE( t.X[0], output, 0 ); - PUT_UINT32_LE( t.X[1], output, 4 ); - PUT_UINT32_LE( t.X[2], output, 8 ); - PUT_UINT32_LE( t.X[3], output, 12 ); + MBEDTLS_PUT_UINT32_LE( t.X[0], output, 0 ); + MBEDTLS_PUT_UINT32_LE( t.X[1], output, 4 ); + MBEDTLS_PUT_UINT32_LE( t.X[2], output, 8 ); + MBEDTLS_PUT_UINT32_LE( t.X[3], output, 12 ); mbedtls_platform_zeroize( &t, sizeof( t ) ); diff --git a/library/aria.c b/library/aria.c index d7d2bea7c8..a6319d3e29 100644 --- a/library/aria.c +++ b/library/aria.c @@ -385,7 +385,7 @@ static void aria_fe_xor( uint32_t r[4], const uint32_t p[4], * Big endian 128-bit rotation: r = a ^ (b <<< n), used only in key setup. * * We chose to store bytes into 32-bit words in little-endian format (see - * GET/PUT_UINT32_LE) so we need to reverse bytes here. + * GET/MBEDTLS_PUT_UINT32_LE) so we need to reverse bytes here. */ static void aria_rot128( uint32_t r[4], const uint32_t a[4], const uint32_t b[4], uint8_t n ) @@ -433,21 +433,21 @@ int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx, return( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA ); /* Copy key to W0 (and potential remainder to W1) */ - GET_UINT32_LE( w[0][0], key, 0 ); - GET_UINT32_LE( w[0][1], key, 4 ); - GET_UINT32_LE( w[0][2], key, 8 ); - GET_UINT32_LE( w[0][3], key, 12 ); + MBEDTLS_GET_UINT32_LE( w[0][0], key, 0 ); + MBEDTLS_GET_UINT32_LE( w[0][1], key, 4 ); + MBEDTLS_GET_UINT32_LE( w[0][2], key, 8 ); + MBEDTLS_GET_UINT32_LE( w[0][3], key, 12 ); memset( w[1], 0, 16 ); if( keybits >= 192 ) { - GET_UINT32_LE( w[1][0], key, 16 ); // 192 bit key - GET_UINT32_LE( w[1][1], key, 20 ); + MBEDTLS_GET_UINT32_LE( w[1][0], key, 16 ); // 192 bit key + MBEDTLS_GET_UINT32_LE( w[1][1], key, 20 ); } if( keybits == 256 ) { - GET_UINT32_LE( w[1][2], key, 24 ); // 256 bit key - GET_UINT32_LE( w[1][3], key, 28 ); + MBEDTLS_GET_UINT32_LE( w[1][2], key, 24 ); // 256 bit key + MBEDTLS_GET_UINT32_LE( w[1][3], key, 28 ); } i = ( keybits - 128 ) >> 6; // index: 0, 1, 2 @@ -524,10 +524,10 @@ int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, ARIA_VALIDATE_RET( input != NULL ); ARIA_VALIDATE_RET( output != NULL ); - GET_UINT32_LE( a, input, 0 ); - GET_UINT32_LE( b, input, 4 ); - GET_UINT32_LE( c, input, 8 ); - GET_UINT32_LE( d, input, 12 ); + MBEDTLS_GET_UINT32_LE( a, input, 0 ); + MBEDTLS_GET_UINT32_LE( b, input, 4 ); + MBEDTLS_GET_UINT32_LE( c, input, 8 ); + MBEDTLS_GET_UINT32_LE( d, input, 12 ); i = 0; while( 1 ) @@ -559,10 +559,10 @@ int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, c ^= ctx->rk[i][2]; d ^= ctx->rk[i][3]; - PUT_UINT32_LE( a, output, 0 ); - PUT_UINT32_LE( b, output, 4 ); - PUT_UINT32_LE( c, output, 8 ); - PUT_UINT32_LE( d, output, 12 ); + MBEDTLS_PUT_UINT32_LE( a, output, 0 ); + MBEDTLS_PUT_UINT32_LE( b, output, 4 ); + MBEDTLS_PUT_UINT32_LE( c, output, 8 ); + MBEDTLS_PUT_UINT32_LE( d, output, 12 ); return( 0 ); } diff --git a/library/camellia.c b/library/camellia.c index 0817b1d292..9aab7ab675 100644 --- a/library/camellia.c +++ b/library/camellia.c @@ -353,8 +353,8 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, * Prepare SIGMA values */ for( i = 0; i < 6; i++ ) { - GET_UINT32_BE( SIGMA[i][0], SIGMA_CHARS[i], 0 ); - GET_UINT32_BE( SIGMA[i][1], SIGMA_CHARS[i], 4 ); + MBEDTLS_GET_UINT32_BE( SIGMA[i][0], SIGMA_CHARS[i], 0 ); + MBEDTLS_GET_UINT32_BE( SIGMA[i][1], SIGMA_CHARS[i], 4 ); } /* @@ -365,7 +365,7 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, /* Store KL, KR */ for( i = 0; i < 8; i++ ) - GET_UINT32_BE( KC[i], t, i * 4 ); + MBEDTLS_GET_UINT32_BE( KC[i], t, i * 4 ); /* Generate KA */ for( i = 0; i < 4; ++i ) @@ -491,10 +491,10 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, NR = ctx->nr; RK = ctx->rk; - GET_UINT32_BE( X[0], input, 0 ); - GET_UINT32_BE( X[1], input, 4 ); - GET_UINT32_BE( X[2], input, 8 ); - GET_UINT32_BE( X[3], input, 12 ); + MBEDTLS_GET_UINT32_BE( X[0], input, 0 ); + MBEDTLS_GET_UINT32_BE( X[1], input, 4 ); + MBEDTLS_GET_UINT32_BE( X[2], input, 8 ); + MBEDTLS_GET_UINT32_BE( X[3], input, 12 ); X[0] ^= *RK++; X[1] ^= *RK++; @@ -529,10 +529,10 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, X[0] ^= *RK++; X[1] ^= *RK++; - PUT_UINT32_BE( X[2], output, 0 ); - PUT_UINT32_BE( X[3], output, 4 ); - PUT_UINT32_BE( X[0], output, 8 ); - PUT_UINT32_BE( X[1], output, 12 ); + MBEDTLS_PUT_UINT32_BE( X[2], output, 0 ); + MBEDTLS_PUT_UINT32_BE( X[3], output, 4 ); + MBEDTLS_PUT_UINT32_BE( X[0], output, 8 ); + MBEDTLS_PUT_UINT32_BE( X[1], output, 12 ); return( 0 ); } diff --git a/library/chacha20.c b/library/chacha20.c index 9862ea535a..d0d5741c7b 100644 --- a/library/chacha20.c +++ b/library/chacha20.c @@ -205,14 +205,14 @@ int mbedtls_chacha20_setkey( mbedtls_chacha20_context *ctx, ctx->state[3] = 0x6b206574; /* Set key */ - ctx->state[4] = BYTES_TO_U32_LE( key, 0 ); - ctx->state[5] = BYTES_TO_U32_LE( key, 4 ); - ctx->state[6] = BYTES_TO_U32_LE( key, 8 ); - ctx->state[7] = BYTES_TO_U32_LE( key, 12 ); - ctx->state[8] = BYTES_TO_U32_LE( key, 16 ); - ctx->state[9] = BYTES_TO_U32_LE( key, 20 ); - ctx->state[10] = BYTES_TO_U32_LE( key, 24 ); - ctx->state[11] = BYTES_TO_U32_LE( key, 28 ); + ctx->state[4] = MBEDTLS_BYTES_TO_U32_LE( key, 0 ); + ctx->state[5] = MBEDTLS_BYTES_TO_U32_LE( key, 4 ); + ctx->state[6] = MBEDTLS_BYTES_TO_U32_LE( key, 8 ); + ctx->state[7] = MBEDTLS_BYTES_TO_U32_LE( key, 12 ); + ctx->state[8] = MBEDTLS_BYTES_TO_U32_LE( key, 16 ); + ctx->state[9] = MBEDTLS_BYTES_TO_U32_LE( key, 20 ); + ctx->state[10] = MBEDTLS_BYTES_TO_U32_LE( key, 24 ); + ctx->state[11] = MBEDTLS_BYTES_TO_U32_LE( key, 28 ); return( 0 ); } @@ -228,9 +228,9 @@ int mbedtls_chacha20_starts( mbedtls_chacha20_context* ctx, ctx->state[12] = counter; /* Nonce */ - ctx->state[13] = BYTES_TO_U32_LE( nonce, 0 ); - ctx->state[14] = BYTES_TO_U32_LE( nonce, 4 ); - ctx->state[15] = BYTES_TO_U32_LE( nonce, 8 ); + ctx->state[13] = MBEDTLS_BYTES_TO_U32_LE( nonce, 0 ); + ctx->state[14] = MBEDTLS_BYTES_TO_U32_LE( nonce, 4 ); + ctx->state[15] = MBEDTLS_BYTES_TO_U32_LE( nonce, 8 ); mbedtls_platform_zeroize( ctx->keystream8, sizeof( ctx->keystream8 ) ); diff --git a/library/common.h b/library/common.h index b6b7d01d9d..6dbc808d34 100644 --- a/library/common.h +++ b/library/common.h @@ -71,61 +71,61 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * To tidy up code and save horizontal and vertical space, use byte * reading macros to cast */ -#define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) -#define BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) ) -#define BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) ) -#define BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) +#define MBEDTLS_BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) +#define MBEDTLS_BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) ) +#define MBEDTLS_BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) ) +#define MBEDTLS_BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) /* * 32-bit integer manipulation macros (big endian) */ -#ifndef GET_UINT32_BE -#define GET_UINT32_BE(n,b,i) \ -do { \ - (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ - | ( (uint32_t) (b)[(i) + 1] << 16 ) \ - | ( (uint32_t) (b)[(i) + 2] << 8 ) \ - | ( (uint32_t) (b)[(i) + 3] ); \ -} while( 0 ) +#ifndef MBEDTLS_GET_UINT32_BE +#define MBEDTLS_GET_UINT32_BE(n,b,i) \ + do { \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ + } while( 0 ) #endif -#ifndef PUT_UINT32_BE -#define PUT_UINT32_BE(n,b,i) \ -do { \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} while( 0 ) +#ifndef MBEDTLS_PUT_UINT32_BE +#define MBEDTLS_PUT_UINT32_BE(n,b,i) \ + do { \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ + } while( 0 ) #endif /* * 32-bit integer manipulation macros (little endian) */ -#ifndef GET_UINT32_LE -#define GET_UINT32_LE(n,b,i) \ -do { \ - (n) = ( (uint32_t) (b)[(i) ] ) \ - | ( (uint32_t) (b)[(i) + 1] << 8 ) \ - | ( (uint32_t) (b)[(i) + 2] << 16 ) \ - | ( (uint32_t) (b)[(i) + 3] << 24 ); \ -} while( 0 ) +#ifndef MBEDTLS_GET_UINT32_LE +#define MBEDTLS_GET_UINT32_LE(n,b,i) \ + do { \ + (n) = ( (uint32_t) (b)[(i) ] ) \ + | ( (uint32_t) (b)[(i) + 1] << 8 ) \ + | ( (uint32_t) (b)[(i) + 2] << 16 ) \ + | ( (uint32_t) (b)[(i) + 3] << 24 ); \ + } while( 0 ) #endif -#ifndef PUT_UINT32_LE -#define PUT_UINT32_LE(n,b,i) \ -do { \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ - (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ -} while( 0 ) +#ifndef MBEDTLS_PUT_UINT32_LE +#define MBEDTLS_PUT_UINT32_LE(n,b,i) \ + do { \ + (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ + (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ + } while( 0 ) #endif /** * 32-bit integer conversion from bytes (little endian) */ -#define BYTES_TO_U32_LE( data, offset ) \ +#define MBEDTLS_BYTES_TO_U32_LE( data, offset ) \ ( (uint32_t) (data)[offset] \ | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \ | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \ diff --git a/library/ctr_drbg.c b/library/ctr_drbg.c index d52d9ef254..68b32a366b 100644 --- a/library/ctr_drbg.c +++ b/library/ctr_drbg.c @@ -152,10 +152,10 @@ static int block_cipher_df( unsigned char *output, * (Total is padded to a multiple of 16-bytes with zeroes) */ p = buf + MBEDTLS_CTR_DRBG_BLOCKSIZE; - *p++ = BYTE_3( data_len ); - *p++ = BYTE_2( data_len ); - *p++ = BYTE_1( data_len ); - *p++ = BYTE_0( data_len ); + *p++ = MBEDTLS_BYTE_3( data_len ); + *p++ = MBEDTLS_BYTE_2( data_len ); + *p++ = MBEDTLS_BYTE_1( data_len ); + *p++ = MBEDTLS_BYTE_0( data_len ); p += 3; *p++ = MBEDTLS_CTR_DRBG_SEEDLEN; memcpy( p, data, data_len ); diff --git a/library/des.c b/library/des.c index 36ea277760..9281747de8 100644 --- a/library/des.c +++ b/library/des.c @@ -400,8 +400,8 @@ void mbedtls_des_setkey( uint32_t SK[32], const unsigned char key[MBEDTLS_DES_KE int i; uint32_t X, Y, T; - GET_UINT32_BE( X, key, 0 ); - GET_UINT32_BE( Y, key, 4 ); + MBEDTLS_GET_UINT32_BE( X, key, 0 ); + MBEDTLS_GET_UINT32_BE( Y, key, 4 ); /* * Permuted Choice 1 @@ -610,8 +610,8 @@ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, SK = ctx->sk; - GET_UINT32_BE( X, input, 0 ); - GET_UINT32_BE( Y, input, 4 ); + MBEDTLS_GET_UINT32_BE( X, input, 0 ); + MBEDTLS_GET_UINT32_BE( Y, input, 4 ); DES_IP( X, Y ); @@ -623,8 +623,8 @@ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, DES_FP( Y, X ); - PUT_UINT32_BE( Y, output, 0 ); - PUT_UINT32_BE( X, output, 4 ); + MBEDTLS_PUT_UINT32_BE( Y, output, 0 ); + MBEDTLS_PUT_UINT32_BE( X, output, 4 ); return( 0 ); } @@ -697,8 +697,8 @@ int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, SK = ctx->sk; - GET_UINT32_BE( X, input, 0 ); - GET_UINT32_BE( Y, input, 4 ); + MBEDTLS_GET_UINT32_BE( X, input, 0 ); + MBEDTLS_GET_UINT32_BE( Y, input, 4 ); DES_IP( X, Y ); @@ -722,8 +722,8 @@ int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, DES_FP( Y, X ); - PUT_UINT32_BE( Y, output, 0 ); - PUT_UINT32_BE( X, output, 4 ); + MBEDTLS_PUT_UINT32_BE( Y, output, 0 ); + MBEDTLS_PUT_UINT32_BE( X, output, 4 ); return( 0 ); } diff --git a/library/gcm.c b/library/gcm.c index c8254876dd..3caeed26de 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -88,12 +88,12 @@ static int gcm_gen_table( mbedtls_gcm_context *ctx ) return( ret ); /* pack h as two 64-bits ints, big-endian */ - GET_UINT32_BE( hi, h, 0 ); - GET_UINT32_BE( lo, h, 4 ); + MBEDTLS_GET_UINT32_BE( hi, h, 0 ); + MBEDTLS_GET_UINT32_BE( lo, h, 4 ); vh = (uint64_t) hi << 32 | lo; - GET_UINT32_BE( hi, h, 8 ); - GET_UINT32_BE( lo, h, 12 ); + MBEDTLS_GET_UINT32_BE( hi, h, 8 ); + MBEDTLS_GET_UINT32_BE( lo, h, 12 ); vl = (uint64_t) hi << 32 | lo; /* 8 = 1000 corresponds to 1 in GF(2^128) */ @@ -200,10 +200,10 @@ static void gcm_mult( mbedtls_gcm_context *ctx, const unsigned char x[16], if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) ) { unsigned char h[16]; - PUT_UINT32_BE( ctx->HH[8] >> 32, h, 0 ); - PUT_UINT32_BE( ctx->HH[8], h, 4 ); - PUT_UINT32_BE( ctx->HL[8] >> 32, h, 8 ); - PUT_UINT32_BE( ctx->HL[8], h, 12 ); + MBEDTLS_PUT_UINT32_BE( ctx->HH[8] >> 32, h, 0 ); + MBEDTLS_PUT_UINT32_BE( ctx->HH[8], h, 4 ); + MBEDTLS_PUT_UINT32_BE( ctx->HL[8] >> 32, h, 8 ); + MBEDTLS_PUT_UINT32_BE( ctx->HL[8], h, 12 ); mbedtls_aesni_gcm_mult( output, x, h ); return; @@ -239,10 +239,10 @@ static void gcm_mult( mbedtls_gcm_context *ctx, const unsigned char x[16], zl ^= ctx->HL[hi]; } - PUT_UINT32_BE( zh >> 32, output, 0 ); - PUT_UINT32_BE( zh, output, 4 ); - PUT_UINT32_BE( zl >> 32, output, 8 ); - PUT_UINT32_BE( zl, output, 12 ); + MBEDTLS_PUT_UINT32_BE( zh >> 32, output, 0 ); + MBEDTLS_PUT_UINT32_BE( zh, output, 4 ); + MBEDTLS_PUT_UINT32_BE( zl >> 32, output, 8 ); + MBEDTLS_PUT_UINT32_BE( zl, output, 12 ); } int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, @@ -278,7 +278,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, else { memset( work_buf, 0x00, 16 ); - PUT_UINT32_BE( iv_len * 8, work_buf, 12 ); + MBEDTLS_PUT_UINT32_BE( iv_len * 8, work_buf, 12 ); p = iv; while( iv_len > 0 ) @@ -546,10 +546,10 @@ int mbedtls_gcm_finish( mbedtls_gcm_context *ctx, { memset( work_buf, 0x00, 16 ); - PUT_UINT32_BE( ( orig_add_len >> 32 ), work_buf, 0 ); - PUT_UINT32_BE( ( orig_add_len ), work_buf, 4 ); - PUT_UINT32_BE( ( orig_len >> 32 ), work_buf, 8 ); - PUT_UINT32_BE( ( orig_len ), work_buf, 12 ); + MBEDTLS_PUT_UINT32_BE( ( orig_add_len >> 32 ), work_buf, 0 ); + MBEDTLS_PUT_UINT32_BE( ( orig_add_len ), work_buf, 4 ); + MBEDTLS_PUT_UINT32_BE( ( orig_len >> 32 ), work_buf, 8 ); + MBEDTLS_PUT_UINT32_BE( ( orig_len ), work_buf, 12 ); for( i = 0; i < 16; i++ ) ctx->buf[i] ^= work_buf[i]; diff --git a/library/md5.c b/library/md5.c index d8f637da83..e8d00216f0 100644 --- a/library/md5.c +++ b/library/md5.c @@ -87,22 +87,22 @@ int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, uint32_t X[16], A, B, C, D; } local; - GET_UINT32_LE( local.X[ 0], data, 0 ); - GET_UINT32_LE( local.X[ 1], data, 4 ); - GET_UINT32_LE( local.X[ 2], data, 8 ); - GET_UINT32_LE( local.X[ 3], data, 12 ); - GET_UINT32_LE( local.X[ 4], data, 16 ); - GET_UINT32_LE( local.X[ 5], data, 20 ); - GET_UINT32_LE( local.X[ 6], data, 24 ); - GET_UINT32_LE( local.X[ 7], data, 28 ); - GET_UINT32_LE( local.X[ 8], data, 32 ); - GET_UINT32_LE( local.X[ 9], data, 36 ); - GET_UINT32_LE( local.X[10], data, 40 ); - GET_UINT32_LE( local.X[11], data, 44 ); - GET_UINT32_LE( local.X[12], data, 48 ); - GET_UINT32_LE( local.X[13], data, 52 ); - GET_UINT32_LE( local.X[14], data, 56 ); - GET_UINT32_LE( local.X[15], data, 60 ); + MBEDTLS_GET_UINT32_LE( local.X[ 0], data, 0 ); + MBEDTLS_GET_UINT32_LE( local.X[ 1], data, 4 ); + MBEDTLS_GET_UINT32_LE( local.X[ 2], data, 8 ); + MBEDTLS_GET_UINT32_LE( local.X[ 3], data, 12 ); + MBEDTLS_GET_UINT32_LE( local.X[ 4], data, 16 ); + MBEDTLS_GET_UINT32_LE( local.X[ 5], data, 20 ); + MBEDTLS_GET_UINT32_LE( local.X[ 6], data, 24 ); + MBEDTLS_GET_UINT32_LE( local.X[ 7], data, 28 ); + MBEDTLS_GET_UINT32_LE( local.X[ 8], data, 32 ); + MBEDTLS_GET_UINT32_LE( local.X[ 9], data, 36 ); + MBEDTLS_GET_UINT32_LE( local.X[10], data, 40 ); + MBEDTLS_GET_UINT32_LE( local.X[11], data, 44 ); + MBEDTLS_GET_UINT32_LE( local.X[12], data, 48 ); + MBEDTLS_GET_UINT32_LE( local.X[13], data, 52 ); + MBEDTLS_GET_UINT32_LE( local.X[14], data, 56 ); + MBEDTLS_GET_UINT32_LE( local.X[15], data, 60 ); #define S(x,n) \ ( ( (x) << (n) ) | ( ( (x) & 0xFFFFFFFF) >> ( 32 - (n) ) ) ) @@ -307,8 +307,8 @@ int mbedtls_md5_finish( mbedtls_md5_context *ctx, | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); - PUT_UINT32_LE( low, ctx->buffer, 56 ); - PUT_UINT32_LE( high, ctx->buffer, 60 ); + MBEDTLS_PUT_UINT32_LE( low, ctx->buffer, 56 ); + MBEDTLS_PUT_UINT32_LE( high, ctx->buffer, 60 ); if( ( ret = mbedtls_internal_md5_process( ctx, ctx->buffer ) ) != 0 ) return( ret ); @@ -316,10 +316,10 @@ int mbedtls_md5_finish( mbedtls_md5_context *ctx, /* * Output final state */ - PUT_UINT32_LE( ctx->state[0], output, 0 ); - PUT_UINT32_LE( ctx->state[1], output, 4 ); - PUT_UINT32_LE( ctx->state[2], output, 8 ); - PUT_UINT32_LE( ctx->state[3], output, 12 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[0], output, 0 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[1], output, 4 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[2], output, 8 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[3], output, 12 ); return( 0 ); } diff --git a/library/nist_kw.c b/library/nist_kw.c index 174a1eef13..b8f9239992 100644 --- a/library/nist_kw.c +++ b/library/nist_kw.c @@ -223,7 +223,7 @@ int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, } memcpy( output, NIST_KW_ICV2, KW_SEMIBLOCK_LENGTH / 2 ); - PUT_UINT32_BE( ( in_len & 0xffffffff ), output, + MBEDTLS_PUT_UINT32_BE( ( in_len & 0xffffffff ), output, KW_SEMIBLOCK_LENGTH / 2 ); memcpy( output + KW_SEMIBLOCK_LENGTH, input, in_len ); @@ -454,7 +454,7 @@ int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; } - GET_UINT32_BE( Plen, A, KW_SEMIBLOCK_LENGTH / 2 ); + MBEDTLS_GET_UINT32_BE( Plen, A, KW_SEMIBLOCK_LENGTH / 2 ); /* * Plen is the length of the plaintext, when the input is valid. diff --git a/library/poly1305.c b/library/poly1305.c index a30b1707ed..3c0b7c6aa9 100644 --- a/library/poly1305.c +++ b/library/poly1305.c @@ -122,10 +122,10 @@ static void poly1305_process( mbedtls_poly1305_context *ctx, for( i = 0U; i < nblocks; i++ ) { /* The input block is treated as a 128-bit little-endian integer */ - d0 = BYTES_TO_U32_LE( input, offset + 0 ); - d1 = BYTES_TO_U32_LE( input, offset + 4 ); - d2 = BYTES_TO_U32_LE( input, offset + 8 ); - d3 = BYTES_TO_U32_LE( input, offset + 12 ); + d0 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 0 ); + d1 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 4 ); + d2 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 8 ); + d3 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 12 ); /* Compute: acc += (padded) block as a 130-bit integer */ d0 += (uint64_t) acc0; @@ -290,15 +290,15 @@ int mbedtls_poly1305_starts( mbedtls_poly1305_context *ctx, POLY1305_VALIDATE_RET( key != NULL ); /* r &= 0x0ffffffc0ffffffc0ffffffc0fffffff */ - ctx->r[0] = BYTES_TO_U32_LE( key, 0 ) & 0x0FFFFFFFU; - ctx->r[1] = BYTES_TO_U32_LE( key, 4 ) & 0x0FFFFFFCU; - ctx->r[2] = BYTES_TO_U32_LE( key, 8 ) & 0x0FFFFFFCU; - ctx->r[3] = BYTES_TO_U32_LE( key, 12 ) & 0x0FFFFFFCU; + ctx->r[0] = MBEDTLS_BYTES_TO_U32_LE( key, 0 ) & 0x0FFFFFFFU; + ctx->r[1] = MBEDTLS_BYTES_TO_U32_LE( key, 4 ) & 0x0FFFFFFCU; + ctx->r[2] = MBEDTLS_BYTES_TO_U32_LE( key, 8 ) & 0x0FFFFFFCU; + ctx->r[3] = MBEDTLS_BYTES_TO_U32_LE( key, 12 ) & 0x0FFFFFFCU; - ctx->s[0] = BYTES_TO_U32_LE( key, 16 ); - ctx->s[1] = BYTES_TO_U32_LE( key, 20 ); - ctx->s[2] = BYTES_TO_U32_LE( key, 24 ); - ctx->s[3] = BYTES_TO_U32_LE( key, 28 ); + ctx->s[0] = MBEDTLS_BYTES_TO_U32_LE( key, 16 ); + ctx->s[1] = MBEDTLS_BYTES_TO_U32_LE( key, 20 ); + ctx->s[2] = MBEDTLS_BYTES_TO_U32_LE( key, 24 ); + ctx->s[3] = MBEDTLS_BYTES_TO_U32_LE( key, 28 ); /* Initial accumulator state */ ctx->acc[0] = 0U; diff --git a/library/psa_crypto.c b/library/psa_crypto.c index b46e023e5d..95aa0d5316 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -4506,8 +4506,8 @@ static psa_status_t psa_tls12_prf_psk_to_ms_set_key( * uint16 with the value N, and the PSK itself. */ - *cur++ = BYTE_1( data_length ); - *cur++ = BYTE_0( data_length ); + *cur++ = MBEDTLS_BYTE_1( data_length ); + *cur++ = MBEDTLS_BYTE_0( data_length ); memset( cur, 0, data_length ); cur += data_length; *cur++ = pms[0]; diff --git a/library/psa_crypto_storage.c b/library/psa_crypto_storage.c index 36b518350c..3646953a57 100644 --- a/library/psa_crypto_storage.c +++ b/library/psa_crypto_storage.c @@ -275,14 +275,14 @@ void psa_format_key_data_for_storage( const uint8_t *data, (psa_persistent_key_storage_format *) storage_data; memcpy( storage_format->magic, PSA_KEY_STORAGE_MAGIC_HEADER, PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH ); - PUT_UINT32_LE( 0, storage_format->version, 0 ); - PUT_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 ); + MBEDTLS_PUT_UINT32_LE( 0, storage_format->version, 0 ); + MBEDTLS_PUT_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 ); PUT_UINT16_LE( (uint16_t) attr->type, storage_format->type, 0 ); PUT_UINT16_LE( (uint16_t) attr->bits, storage_format->bits, 0 ); - PUT_UINT32_LE( attr->policy.usage, storage_format->policy, 0 ); - PUT_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) ); - PUT_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) ); - PUT_UINT32_LE( data_length, storage_format->data_len, 0 ); + MBEDTLS_PUT_UINT32_LE( attr->policy.usage, storage_format->policy, 0 ); + MBEDTLS_PUT_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) ); + MBEDTLS_PUT_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) ); + MBEDTLS_PUT_UINT32_LE( data_length, storage_format->data_len, 0 ); memcpy( storage_format->key_data, data, data_length ); } @@ -312,11 +312,11 @@ psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data, if( status != PSA_SUCCESS ) return( status ); - GET_UINT32_LE( version, storage_format->version, 0 ); + MBEDTLS_GET_UINT32_LE( version, storage_format->version, 0 ); if( version != 0 ) return( PSA_ERROR_DATA_INVALID ); - GET_UINT32_LE( *key_data_length, storage_format->data_len, 0 ); + MBEDTLS_GET_UINT32_LE( *key_data_length, storage_format->data_len, 0 ); if( *key_data_length > ( storage_data_length - sizeof(*storage_format) ) || *key_data_length > PSA_CRYPTO_MAX_STORAGE_SIZE ) return( PSA_ERROR_DATA_INVALID ); @@ -333,12 +333,12 @@ psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data, memcpy( *key_data, storage_format->key_data, *key_data_length ); } - GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 ); + MBEDTLS_GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 ); GET_UINT16_LE( attr->type, storage_format->type, 0 ); GET_UINT16_LE( attr->bits, storage_format->bits, 0 ); - GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 ); - GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) ); - GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) ); + MBEDTLS_GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 ); + MBEDTLS_GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) ); + MBEDTLS_GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) ); return( PSA_SUCCESS ); } diff --git a/library/psa_its_file.c b/library/psa_its_file.c index 66043b502e..c3b19a74ac 100644 --- a/library/psa_its_file.c +++ b/library/psa_its_file.c @@ -191,14 +191,14 @@ psa_status_t psa_its_set( psa_storage_uid_t uid, size_t n; memcpy( header.magic, PSA_ITS_MAGIC_STRING, PSA_ITS_MAGIC_LENGTH ); - header.size[0] = BYTE_0( data_length ); - header.size[1] = BYTE_1( data_length ); - header.size[2] = BYTE_2( data_length ); - header.size[3] = BYTE_3( data_length ); - header.flags[0] = BYTE_0( create_flags ); - header.flags[1] = BYTE_1( create_flags ); - header.flags[2] = BYTE_2( create_flags ); - header.flags[3] = BYTE_3( create_flags ); + header.size[0] = MBEDTLS_BYTE_0( data_length ); + header.size[1] = MBEDTLS_BYTE_1( data_length ); + header.size[2] = MBEDTLS_BYTE_2( data_length ); + header.size[3] = MBEDTLS_BYTE_3( data_length ); + header.flags[0] = MBEDTLS_BYTE_0( create_flags ); + header.flags[1] = MBEDTLS_BYTE_1( create_flags ); + header.flags[2] = MBEDTLS_BYTE_2( create_flags ); + header.flags[3] = MBEDTLS_BYTE_3( create_flags ); psa_its_fill_filename( uid, filename ); stream = fopen( PSA_ITS_STORAGE_TEMP, "wb" ); diff --git a/library/ripemd160.c b/library/ripemd160.c index d60654e952..2bed107230 100644 --- a/library/ripemd160.c +++ b/library/ripemd160.c @@ -92,22 +92,22 @@ int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx, uint32_t A, B, C, D, E, Ap, Bp, Cp, Dp, Ep, X[16]; } local; - GET_UINT32_LE( local.X[ 0], data, 0 ); - GET_UINT32_LE( local.X[ 1], data, 4 ); - GET_UINT32_LE( local.X[ 2], data, 8 ); - GET_UINT32_LE( local.X[ 3], data, 12 ); - GET_UINT32_LE( local.X[ 4], data, 16 ); - GET_UINT32_LE( local.X[ 5], data, 20 ); - GET_UINT32_LE( local.X[ 6], data, 24 ); - GET_UINT32_LE( local.X[ 7], data, 28 ); - GET_UINT32_LE( local.X[ 8], data, 32 ); - GET_UINT32_LE( local.X[ 9], data, 36 ); - GET_UINT32_LE( local.X[10], data, 40 ); - GET_UINT32_LE( local.X[11], data, 44 ); - GET_UINT32_LE( local.X[12], data, 48 ); - GET_UINT32_LE( local.X[13], data, 52 ); - GET_UINT32_LE( local.X[14], data, 56 ); - GET_UINT32_LE( local.X[15], data, 60 ); + MBEDTLS_GET_UINT32_LE( local.X[ 0], data, 0 ); + MBEDTLS_GET_UINT32_LE( local.X[ 1], data, 4 ); + MBEDTLS_GET_UINT32_LE( local.X[ 2], data, 8 ); + MBEDTLS_GET_UINT32_LE( local.X[ 3], data, 12 ); + MBEDTLS_GET_UINT32_LE( local.X[ 4], data, 16 ); + MBEDTLS_GET_UINT32_LE( local.X[ 5], data, 20 ); + MBEDTLS_GET_UINT32_LE( local.X[ 6], data, 24 ); + MBEDTLS_GET_UINT32_LE( local.X[ 7], data, 28 ); + MBEDTLS_GET_UINT32_LE( local.X[ 8], data, 32 ); + MBEDTLS_GET_UINT32_LE( local.X[ 9], data, 36 ); + MBEDTLS_GET_UINT32_LE( local.X[10], data, 40 ); + MBEDTLS_GET_UINT32_LE( local.X[11], data, 44 ); + MBEDTLS_GET_UINT32_LE( local.X[12], data, 48 ); + MBEDTLS_GET_UINT32_LE( local.X[13], data, 52 ); + MBEDTLS_GET_UINT32_LE( local.X[14], data, 56 ); + MBEDTLS_GET_UINT32_LE( local.X[15], data, 60 ); local.A = local.Ap = ctx->state[0]; local.B = local.Bp = ctx->state[1]; @@ -354,8 +354,8 @@ int mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); - PUT_UINT32_LE( low, msglen, 0 ); - PUT_UINT32_LE( high, msglen, 4 ); + MBEDTLS_PUT_UINT32_LE( low, msglen, 0 ); + MBEDTLS_PUT_UINT32_LE( high, msglen, 4 ); last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); @@ -368,11 +368,11 @@ int mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, if( ret != 0 ) return( ret ); - PUT_UINT32_LE( ctx->state[0], output, 0 ); - PUT_UINT32_LE( ctx->state[1], output, 4 ); - PUT_UINT32_LE( ctx->state[2], output, 8 ); - PUT_UINT32_LE( ctx->state[3], output, 12 ); - PUT_UINT32_LE( ctx->state[4], output, 16 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[0], output, 0 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[1], output, 4 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[2], output, 8 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[3], output, 12 ); + MBEDTLS_PUT_UINT32_LE( ctx->state[4], output, 16 ); return( 0 ); } diff --git a/library/sha1.c b/library/sha1.c index 9beaee5a54..da61f65fca 100644 --- a/library/sha1.c +++ b/library/sha1.c @@ -103,22 +103,22 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, SHA1_VALIDATE_RET( ctx != NULL ); SHA1_VALIDATE_RET( (const unsigned char *)data != NULL ); - GET_UINT32_BE( local.W[ 0], data, 0 ); - GET_UINT32_BE( local.W[ 1], data, 4 ); - GET_UINT32_BE( local.W[ 2], data, 8 ); - GET_UINT32_BE( local.W[ 3], data, 12 ); - GET_UINT32_BE( local.W[ 4], data, 16 ); - GET_UINT32_BE( local.W[ 5], data, 20 ); - GET_UINT32_BE( local.W[ 6], data, 24 ); - GET_UINT32_BE( local.W[ 7], data, 28 ); - GET_UINT32_BE( local.W[ 8], data, 32 ); - GET_UINT32_BE( local.W[ 9], data, 36 ); - GET_UINT32_BE( local.W[10], data, 40 ); - GET_UINT32_BE( local.W[11], data, 44 ); - GET_UINT32_BE( local.W[12], data, 48 ); - GET_UINT32_BE( local.W[13], data, 52 ); - GET_UINT32_BE( local.W[14], data, 56 ); - GET_UINT32_BE( local.W[15], data, 60 ); + MBEDTLS_GET_UINT32_BE( local.W[ 0], data, 0 ); + MBEDTLS_GET_UINT32_BE( local.W[ 1], data, 4 ); + MBEDTLS_GET_UINT32_BE( local.W[ 2], data, 8 ); + MBEDTLS_GET_UINT32_BE( local.W[ 3], data, 12 ); + MBEDTLS_GET_UINT32_BE( local.W[ 4], data, 16 ); + MBEDTLS_GET_UINT32_BE( local.W[ 5], data, 20 ); + MBEDTLS_GET_UINT32_BE( local.W[ 6], data, 24 ); + MBEDTLS_GET_UINT32_BE( local.W[ 7], data, 28 ); + MBEDTLS_GET_UINT32_BE( local.W[ 8], data, 32 ); + MBEDTLS_GET_UINT32_BE( local.W[ 9], data, 36 ); + MBEDTLS_GET_UINT32_BE( local.W[10], data, 40 ); + MBEDTLS_GET_UINT32_BE( local.W[11], data, 44 ); + MBEDTLS_GET_UINT32_BE( local.W[12], data, 48 ); + MBEDTLS_GET_UINT32_BE( local.W[13], data, 52 ); + MBEDTLS_GET_UINT32_BE( local.W[14], data, 56 ); + MBEDTLS_GET_UINT32_BE( local.W[15], data, 60 ); #define S(x,n) (((x) << (n)) | (((x) & 0xFFFFFFFF) >> (32 - (n)))) @@ -362,8 +362,8 @@ int mbedtls_sha1_finish( mbedtls_sha1_context *ctx, | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); - PUT_UINT32_BE( high, ctx->buffer, 56 ); - PUT_UINT32_BE( low, ctx->buffer, 60 ); + MBEDTLS_PUT_UINT32_BE( high, ctx->buffer, 56 ); + MBEDTLS_PUT_UINT32_BE( low, ctx->buffer, 60 ); if( ( ret = mbedtls_internal_sha1_process( ctx, ctx->buffer ) ) != 0 ) return( ret ); @@ -371,11 +371,11 @@ int mbedtls_sha1_finish( mbedtls_sha1_context *ctx, /* * Output final state */ - PUT_UINT32_BE( ctx->state[0], output, 0 ); - PUT_UINT32_BE( ctx->state[1], output, 4 ); - PUT_UINT32_BE( ctx->state[2], output, 8 ); - PUT_UINT32_BE( ctx->state[3], output, 12 ); - PUT_UINT32_BE( ctx->state[4], output, 16 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[0], output, 0 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[1], output, 4 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[2], output, 8 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[3], output, 12 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[4], output, 16 ); return( 0 ); } diff --git a/library/sha256.c b/library/sha256.c index f548c672ea..fb66340b20 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -190,7 +190,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, for( i = 0; i < 64; i++ ) { if( i < 16 ) - GET_UINT32_BE( local.W[i], data, 4 * i ); + MBEDTLS_GET_UINT32_BE( local.W[i], data, 4 * i ); else R( i ); @@ -205,7 +205,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, } #else /* MBEDTLS_SHA256_SMALLER */ for( i = 0; i < 16; i++ ) - GET_UINT32_BE( local.W[i], data, 4 * i ); + MBEDTLS_GET_UINT32_BE( local.W[i], data, 4 * i ); for( i = 0; i < 16; i += 8 ) { @@ -355,8 +355,8 @@ int mbedtls_sha256_finish( mbedtls_sha256_context *ctx, | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); - PUT_UINT32_BE( high, ctx->buffer, 56 ); - PUT_UINT32_BE( low, ctx->buffer, 60 ); + MBEDTLS_PUT_UINT32_BE( high, ctx->buffer, 56 ); + MBEDTLS_PUT_UINT32_BE( low, ctx->buffer, 60 ); if( ( ret = mbedtls_internal_sha256_process( ctx, ctx->buffer ) ) != 0 ) return( ret ); @@ -364,18 +364,18 @@ int mbedtls_sha256_finish( mbedtls_sha256_context *ctx, /* * Output final state */ - PUT_UINT32_BE( ctx->state[0], output, 0 ); - PUT_UINT32_BE( ctx->state[1], output, 4 ); - PUT_UINT32_BE( ctx->state[2], output, 8 ); - PUT_UINT32_BE( ctx->state[3], output, 12 ); - PUT_UINT32_BE( ctx->state[4], output, 16 ); - PUT_UINT32_BE( ctx->state[5], output, 20 ); - PUT_UINT32_BE( ctx->state[6], output, 24 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[0], output, 0 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[1], output, 4 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[2], output, 8 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[3], output, 12 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[4], output, 16 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[5], output, 20 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[6], output, 24 ); #if defined(MBEDTLS_SHA224_C) if( ctx->is224 == 0 ) #endif - PUT_UINT32_BE( ctx->state[7], output, 28 ); + MBEDTLS_PUT_UINT32_BE( ctx->state[7], output, 28 ); return( 0 ); } diff --git a/library/ssl_msg.c b/library/ssl_msg.c index f3dbba82b9..77904e0a1b 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2255,13 +2255,13 @@ int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl ) * Handshake headers: type(1) len(3) seq(2) f_off(3) f_len(3) */ memcpy( ssl->out_msg, cur->p, 6 ); - ssl->out_msg[6] = BYTE_2( frag_off ); - ssl->out_msg[7] = BYTE_1( frag_off ); - ssl->out_msg[8] = BYTE_0( frag_off ); + ssl->out_msg[6] = MBEDTLS_BYTE_2( frag_off ); + ssl->out_msg[7] = MBEDTLS_BYTE_1( frag_off ); + ssl->out_msg[8] = MBEDTLS_BYTE_0( frag_off ); - ssl->out_msg[ 9] = BYTE_2( cur_hs_frag_len ); - ssl->out_msg[10] = BYTE_1( cur_hs_frag_len ); - ssl->out_msg[11] = BYTE_0( cur_hs_frag_len ); + ssl->out_msg[ 9] = MBEDTLS_BYTE_2( cur_hs_frag_len ); + ssl->out_msg[10] = MBEDTLS_BYTE_1( cur_hs_frag_len ); + ssl->out_msg[11] = MBEDTLS_BYTE_0( cur_hs_frag_len ); MBEDTLS_SSL_DEBUG_BUF( 3, "handshake header", ssl->out_msg, 12 ); diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c index 29d8345750..a7a55f1a75 100644 --- a/library/ssl_ticket.c +++ b/library/ssl_ticket.c @@ -245,8 +245,8 @@ int mbedtls_ssl_ticket_write( void *p_ticket, { goto cleanup; } - state_len_bytes[0] = BYTE_1( clear_len ); - state_len_bytes[1] = BYTE_0( clear_len ); + state_len_bytes[0] = MBEDTLS_BYTE_1( clear_len ); + state_len_bytes[1] = MBEDTLS_BYTE_0( clear_len ); /* Encrypt and authenticate */ if( ( ret = mbedtls_cipher_auth_encrypt_ext( &key->ctx, From 33f953d8104bd0a069fb77d0ecbc13d33d927fe5 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 24 Jun 2021 16:49:38 +0100 Subject: [PATCH 310/966] Byte Reading Macros Changelog Signed-off-by: Joe Subbiani --- ChangeLog.d/issue4274.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 ChangeLog.d/issue4274.txt diff --git a/ChangeLog.d/issue4274.txt b/ChangeLog.d/issue4274.txt new file mode 100644 index 0000000000..3e59ca5be1 --- /dev/null +++ b/ChangeLog.d/issue4274.txt @@ -0,0 +1,9 @@ +Changes + * Create 4 byte reading macros in library/common.h, used in files + within the same directory: MBEDTLS_BYTE_0... MBEDTLS_BYTE_3. + * Move the (PUT and GET) UINT32_ (BE and LE) macro functions into + library/common.h. Rename with the prefix MBEDTLS_ to satisfy + test/scripts/check-names.sh (e.g MBEDTLS_PUT_UINT32_LE). + * Move BYTES_TO_U32_LE macro function to library/common.h, also given + the prefix MBEDTLS_. + Fixes #4274. \ No newline at end of file From c46997377afb35a2fc4881cd202c8c4fe5667479 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 25 Jun 2021 09:20:07 +0100 Subject: [PATCH 311/966] Fix formatting - Byte reading macros changelog Missing newline at the end of changelog.d/issue4274 Signed-off-by: Joe Subbiani --- ChangeLog.d/issue4274.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ChangeLog.d/issue4274.txt b/ChangeLog.d/issue4274.txt index 3e59ca5be1..f0952f4307 100644 --- a/ChangeLog.d/issue4274.txt +++ b/ChangeLog.d/issue4274.txt @@ -1,9 +1,9 @@ -Changes - * Create 4 byte reading macros in library/common.h, used in files - within the same directory: MBEDTLS_BYTE_0... MBEDTLS_BYTE_3. - * Move the (PUT and GET) UINT32_ (BE and LE) macro functions into - library/common.h. Rename with the prefix MBEDTLS_ to satisfy - test/scripts/check-names.sh (e.g MBEDTLS_PUT_UINT32_LE). - * Move BYTES_TO_U32_LE macro function to library/common.h, also given - the prefix MBEDTLS_. - Fixes #4274. \ No newline at end of file +Changes + * Create 4 byte reading macros in library/common.h, used in files + within the same directory: MBEDTLS_BYTE_0... MBEDTLS_BYTE_3. + * Move the (PUT and GET) UINT32_ (BE and LE) macro functions into + library/common.h. Rename with the prefix MBEDTLS_ to satisfy + test/scripts/check-names.sh (e.g MBEDTLS_PUT_UINT32_LE). + * Move BYTES_TO_U32_LE macro function to library/common.h, also given + the prefix MBEDTLS_. + Fixes #4274. From 9fa9ac3612c0c542fa91c0fae003dcb37c1586a8 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Mon, 5 Jul 2021 15:37:39 +0100 Subject: [PATCH 312/966] Move GET/PUT_UINT16_LE macros to common.h Although these only appear in one file: psa_crypto_storage.c it is tidy to give it the same prefix as the UINT32 macros and to store them in the fame file Signed-off-by: Joe Subbiani --- library/common.h | 31 ++++++++++++++++++++++++++----- library/psa_crypto_storage.c | 27 ++++----------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/library/common.h b/library/common.h index 6dbc808d34..e85cbf28d0 100644 --- a/library/common.h +++ b/library/common.h @@ -80,7 +80,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * 32-bit integer manipulation macros (big endian) */ #ifndef MBEDTLS_GET_UINT32_BE -#define MBEDTLS_GET_UINT32_BE(n,b,i) \ +#define MBEDTLS_GET_UINT32_BE(n,b,i) \ do { \ (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ | ( (uint32_t) (b)[(i) + 1] << 16 ) \ @@ -90,7 +90,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif #ifndef MBEDTLS_PUT_UINT32_BE -#define MBEDTLS_PUT_UINT32_BE(n,b,i) \ +#define MBEDTLS_PUT_UINT32_BE(n,b,i) \ do { \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ @@ -103,7 +103,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * 32-bit integer manipulation macros (little endian) */ #ifndef MBEDTLS_GET_UINT32_LE -#define MBEDTLS_GET_UINT32_LE(n,b,i) \ +#define MBEDTLS_GET_UINT32_LE(n,b,i) \ do { \ (n) = ( (uint32_t) (b)[(i) ] ) \ | ( (uint32_t) (b)[(i) + 1] << 8 ) \ @@ -113,7 +113,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif #ifndef MBEDTLS_PUT_UINT32_LE -#define MBEDTLS_PUT_UINT32_LE(n,b,i) \ +#define MBEDTLS_PUT_UINT32_LE(n,b,i) \ do { \ (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ @@ -125,11 +125,32 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c /** * 32-bit integer conversion from bytes (little endian) */ -#define MBEDTLS_BYTES_TO_U32_LE( data, offset ) \ +#define MBEDTLS_BYTES_TO_U32_LE( data, offset ) \ ( (uint32_t) (data)[offset] \ | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \ | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \ | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 ) \ ) + +/* + * 16-bit integer manipulation macros (little endian) + */ +#ifndef MBEDTLS_GET_UINT16_LE +#define MBEDTLS_GET_UINT16_LE( n, b, i ) \ +{ \ + (n) = ( (uint16_t) (b)[(i) ] ) \ + | ( (uint16_t) (b)[(i) + 1] << 8 ); \ +} +#endif + +#ifndef MBEDTLS_PUT_UINT16_LE +#define MBEDTLS_PUT_UINT16_LE( n, b, i ) \ +{ \ + (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ +} +#endif + + #endif /* MBEDTLS_LIBRARY_COMMON_H */ diff --git a/library/psa_crypto_storage.c b/library/psa_crypto_storage.c index 3646953a57..07c2cdf600 100644 --- a/library/psa_crypto_storage.c +++ b/library/psa_crypto_storage.c @@ -230,25 +230,6 @@ static psa_status_t psa_crypto_storage_get_data_length( return( PSA_SUCCESS ); } -/* - * 16-bit integer manipulation macros (little endian) - */ -#ifndef GET_UINT16_LE -#define GET_UINT16_LE( n, b, i ) \ -{ \ - (n) = ( (uint16_t) (b)[(i) ] ) \ - | ( (uint16_t) (b)[(i) + 1] << 8 ); \ -} -#endif - -#ifndef PUT_UINT16_LE -#define PUT_UINT16_LE( n, b, i ) \ -{ \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ -} -#endif - /** * Persistent key storage magic header. */ @@ -277,8 +258,8 @@ void psa_format_key_data_for_storage( const uint8_t *data, memcpy( storage_format->magic, PSA_KEY_STORAGE_MAGIC_HEADER, PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH ); MBEDTLS_PUT_UINT32_LE( 0, storage_format->version, 0 ); MBEDTLS_PUT_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 ); - PUT_UINT16_LE( (uint16_t) attr->type, storage_format->type, 0 ); - PUT_UINT16_LE( (uint16_t) attr->bits, storage_format->bits, 0 ); + MBEDTLS_PUT_UINT16_LE( (uint16_t) attr->type, storage_format->type, 0 ); + MBEDTLS_PUT_UINT16_LE( (uint16_t) attr->bits, storage_format->bits, 0 ); MBEDTLS_PUT_UINT32_LE( attr->policy.usage, storage_format->policy, 0 ); MBEDTLS_PUT_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) ); MBEDTLS_PUT_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) ); @@ -334,8 +315,8 @@ psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data, } MBEDTLS_GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 ); - GET_UINT16_LE( attr->type, storage_format->type, 0 ); - GET_UINT16_LE( attr->bits, storage_format->bits, 0 ); + MBEDTLS_GET_UINT16_LE( attr->type, storage_format->type, 0 ); + MBEDTLS_GET_UINT16_LE( attr->bits, storage_format->bits, 0 ); MBEDTLS_GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 ); MBEDTLS_GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) ); MBEDTLS_GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) ); From 394bdd662b7facd32cfbb8ccd24cc0593f38ac0d Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 7 Jul 2021 15:16:56 +0100 Subject: [PATCH 313/966] Document common.h and remove changelog Added documenttion comments to common.h and removed the changelog as it is not really necessary for refactoring. Also modified a comment in aria.c to be clearer Signed-off-by: Joe Subbiani --- ChangeLog.d/issue4274.txt | 9 ------- library/aria.c | 3 ++- library/common.h | 50 +++++++++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 15 deletions(-) delete mode 100644 ChangeLog.d/issue4274.txt diff --git a/ChangeLog.d/issue4274.txt b/ChangeLog.d/issue4274.txt deleted file mode 100644 index f0952f4307..0000000000 --- a/ChangeLog.d/issue4274.txt +++ /dev/null @@ -1,9 +0,0 @@ -Changes - * Create 4 byte reading macros in library/common.h, used in files - within the same directory: MBEDTLS_BYTE_0... MBEDTLS_BYTE_3. - * Move the (PUT and GET) UINT32_ (BE and LE) macro functions into - library/common.h. Rename with the prefix MBEDTLS_ to satisfy - test/scripts/check-names.sh (e.g MBEDTLS_PUT_UINT32_LE). - * Move BYTES_TO_U32_LE macro function to library/common.h, also given - the prefix MBEDTLS_. - Fixes #4274. diff --git a/library/aria.c b/library/aria.c index a6319d3e29..f4aa64107a 100644 --- a/library/aria.c +++ b/library/aria.c @@ -385,7 +385,8 @@ static void aria_fe_xor( uint32_t r[4], const uint32_t p[4], * Big endian 128-bit rotation: r = a ^ (b <<< n), used only in key setup. * * We chose to store bytes into 32-bit words in little-endian format (see - * GET/MBEDTLS_PUT_UINT32_LE) so we need to reverse bytes here. + * MBEDTLS_GET_UINT32_LE / MBEDTLS_PUT_UINT32_LE ) so we need to reverse + * bytes here. */ static void aria_rot128( uint32_t r[4], const uint32_t a[4], const uint32_t b[4], uint8_t n ) diff --git a/library/common.h b/library/common.h index e85cbf28d0..5115465e88 100644 --- a/library/common.h +++ b/library/common.h @@ -68,15 +68,36 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c /** Byte Reading Macros * - * To tidy up code and save horizontal and vertical space, use byte - * reading macros to cast + * Obtain the most significant byte of x using 0xff + * Using MBEDTLS_BYTE_a will shift a*8 bits + * to retrieve the next byte of information */ #define MBEDTLS_BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) #define MBEDTLS_BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) ) #define MBEDTLS_BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) ) #define MBEDTLS_BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) -/* +/** + * 32-bit integer manipulation macros + * + * \brief Using GET- + * From input data, take the most significant bytes + * and concatonate them as you shift along + * Using PUT- + * Read from a 32 bit integer and store each byte + * in memory, offset by a byte each, resulting in + * each byte being adjacent in memory. + * + * \param n 32 bit integer where data is accessed via + * PUT or stored using GET + * \param b const unsigned char array of data to be + * manipulated + * \param i offset in bytes, In the case of UINT32, i + * would increment by 4 every use assuming + * the data is being stored in the same location + */ + +/** * 32-bit integer manipulation macros (big endian) */ #ifndef MBEDTLS_GET_UINT32_BE @@ -99,7 +120,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c } while( 0 ) #endif -/* +/** * 32-bit integer manipulation macros (little endian) */ #ifndef MBEDTLS_GET_UINT32_LE @@ -132,8 +153,27 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 ) \ ) +/** + * 16-bit integer manipulation macros + * + * \brief Using GET- + * From input data, take the most significant bytes + * and concatonate them as you shift along + * Using PUT- + * Read from a 16 bit integer and store each byte + * in memory, offset by a byte each, resulting in + * each byte being adjacent in memory. + * + * \param n 16 bit integer where data is accessed via + * PUT or stored using GET + * \param b const unsigned char array of data to be + * manipulated + * \param i offset in bytes, In the case of UINT16, i + * would increment by 2 every use assuming + * the data is being stored in the same location + */ -/* +/** * 16-bit integer manipulation macros (little endian) */ #ifndef MBEDTLS_GET_UINT16_LE From 6a5063149756e1d5d12b0497867f5c22aaa8100e Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 7 Jul 2021 16:56:29 +0100 Subject: [PATCH 314/966] GET macros use a target variable The GET macros used to write to a macro parameter, but now they can be used to assign a value to the desired variable rather than pass it in as an argument and have it modified in the macro function. Due to this MBEDTLS_BYTES_TO_U32_LE is the same as MBEDTLS_GET_UINT32_LE and was there for replaced in the appropriate files and removed from common.h Signed-off-by: Joe Subbiani --- library/aes.c | 18 ++--- library/aria.c | 24 +++--- library/camellia.c | 14 ++-- library/chacha20.c | 22 ++--- library/common.h | 151 +++++++++++++++++++++-------------- library/des.c | 12 +-- library/gcm.c | 8 +- library/md5.c | 32 ++++---- library/nist_kw.c | 2 +- library/poly1305.c | 24 +++--- library/psa_crypto_storage.c | 16 ++-- library/ripemd160.c | 32 ++++---- library/sha1.c | 32 ++++---- library/sha256.c | 4 +- 14 files changed, 211 insertions(+), 180 deletions(-) diff --git a/library/aes.c b/library/aes.c index db726fe36b..7a44a78408 100644 --- a/library/aes.c +++ b/library/aes.c @@ -567,7 +567,7 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, for( i = 0; i < ( keybits >> 5 ); i++ ) { - MBEDTLS_GET_UINT32_LE( RK[i], key, i << 2 ); + RK[i] = MBEDTLS_GET_UINT32_LE( key, i << 2 ); } switch( ctx->nr ) @@ -850,10 +850,10 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, uint32_t Y[4]; } t; - MBEDTLS_GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++; - MBEDTLS_GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++; - MBEDTLS_GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++; - MBEDTLS_GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++; + t.X[0] = MBEDTLS_GET_UINT32_LE( input, 0 ); t.X[0] ^= *RK++; + t.X[1] = MBEDTLS_GET_UINT32_LE( input, 4 ); t.X[1] ^= *RK++; + t.X[2] = MBEDTLS_GET_UINT32_LE( input, 8 ); t.X[2] ^= *RK++; + t.X[3] = MBEDTLS_GET_UINT32_LE( input, 12 ); t.X[3] ^= *RK++; for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- ) { @@ -914,10 +914,10 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, uint32_t Y[4]; } t; - MBEDTLS_GET_UINT32_LE( t.X[0], input, 0 ); t.X[0] ^= *RK++; - MBEDTLS_GET_UINT32_LE( t.X[1], input, 4 ); t.X[1] ^= *RK++; - MBEDTLS_GET_UINT32_LE( t.X[2], input, 8 ); t.X[2] ^= *RK++; - MBEDTLS_GET_UINT32_LE( t.X[3], input, 12 ); t.X[3] ^= *RK++; + t.X[0] = MBEDTLS_GET_UINT32_LE( input, 0 ); t.X[0] ^= *RK++; + t.X[1] = MBEDTLS_GET_UINT32_LE( input, 4 ); t.X[1] ^= *RK++; + t.X[2] = MBEDTLS_GET_UINT32_LE( input, 8 ); t.X[2] ^= *RK++; + t.X[3] = MBEDTLS_GET_UINT32_LE( input, 12 ); t.X[3] ^= *RK++; for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- ) { diff --git a/library/aria.c b/library/aria.c index f4aa64107a..320f7758ac 100644 --- a/library/aria.c +++ b/library/aria.c @@ -434,21 +434,21 @@ int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx, return( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA ); /* Copy key to W0 (and potential remainder to W1) */ - MBEDTLS_GET_UINT32_LE( w[0][0], key, 0 ); - MBEDTLS_GET_UINT32_LE( w[0][1], key, 4 ); - MBEDTLS_GET_UINT32_LE( w[0][2], key, 8 ); - MBEDTLS_GET_UINT32_LE( w[0][3], key, 12 ); + w[0][0] = MBEDTLS_GET_UINT32_LE( key, 0 ); + w[0][1] = MBEDTLS_GET_UINT32_LE( key, 4 ); + w[0][2] = MBEDTLS_GET_UINT32_LE( key, 8 ); + w[0][3] = MBEDTLS_GET_UINT32_LE( key, 12 ); memset( w[1], 0, 16 ); if( keybits >= 192 ) { - MBEDTLS_GET_UINT32_LE( w[1][0], key, 16 ); // 192 bit key - MBEDTLS_GET_UINT32_LE( w[1][1], key, 20 ); + w[1][0] = MBEDTLS_GET_UINT32_LE( key, 16 ); // 192 bit key + w[1][1] = MBEDTLS_GET_UINT32_LE( key, 20 ); } if( keybits == 256 ) { - MBEDTLS_GET_UINT32_LE( w[1][2], key, 24 ); // 256 bit key - MBEDTLS_GET_UINT32_LE( w[1][3], key, 28 ); + w[1][2] = MBEDTLS_GET_UINT32_LE( key, 24 ); // 256 bit key + w[1][3] = MBEDTLS_GET_UINT32_LE( key, 28 ); } i = ( keybits - 128 ) >> 6; // index: 0, 1, 2 @@ -525,10 +525,10 @@ int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, ARIA_VALIDATE_RET( input != NULL ); ARIA_VALIDATE_RET( output != NULL ); - MBEDTLS_GET_UINT32_LE( a, input, 0 ); - MBEDTLS_GET_UINT32_LE( b, input, 4 ); - MBEDTLS_GET_UINT32_LE( c, input, 8 ); - MBEDTLS_GET_UINT32_LE( d, input, 12 ); + a = MBEDTLS_GET_UINT32_LE( input, 0 ); + b = MBEDTLS_GET_UINT32_LE( input, 4 ); + c = MBEDTLS_GET_UINT32_LE( input, 8 ); + d = MBEDTLS_GET_UINT32_LE( input, 12 ); i = 0; while( 1 ) diff --git a/library/camellia.c b/library/camellia.c index 9aab7ab675..4d6b468e5d 100644 --- a/library/camellia.c +++ b/library/camellia.c @@ -353,8 +353,8 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, * Prepare SIGMA values */ for( i = 0; i < 6; i++ ) { - MBEDTLS_GET_UINT32_BE( SIGMA[i][0], SIGMA_CHARS[i], 0 ); - MBEDTLS_GET_UINT32_BE( SIGMA[i][1], SIGMA_CHARS[i], 4 ); + SIGMA[i][0] = MBEDTLS_GET_UINT32_BE( SIGMA_CHARS[i], 0 ); + SIGMA[i][1] = MBEDTLS_GET_UINT32_BE( SIGMA_CHARS[i], 4 ); } /* @@ -365,7 +365,7 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, /* Store KL, KR */ for( i = 0; i < 8; i++ ) - MBEDTLS_GET_UINT32_BE( KC[i], t, i * 4 ); + KC[i] = MBEDTLS_GET_UINT32_BE( t, i * 4 ); /* Generate KA */ for( i = 0; i < 4; ++i ) @@ -491,10 +491,10 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, NR = ctx->nr; RK = ctx->rk; - MBEDTLS_GET_UINT32_BE( X[0], input, 0 ); - MBEDTLS_GET_UINT32_BE( X[1], input, 4 ); - MBEDTLS_GET_UINT32_BE( X[2], input, 8 ); - MBEDTLS_GET_UINT32_BE( X[3], input, 12 ); + X[0] = MBEDTLS_GET_UINT32_BE( input, 0 ); + X[1] = MBEDTLS_GET_UINT32_BE( input, 4 ); + X[2] = MBEDTLS_GET_UINT32_BE( input, 8 ); + X[3] = MBEDTLS_GET_UINT32_BE( input, 12 ); X[0] ^= *RK++; X[1] ^= *RK++; diff --git a/library/chacha20.c b/library/chacha20.c index d0d5741c7b..7015f99d59 100644 --- a/library/chacha20.c +++ b/library/chacha20.c @@ -205,14 +205,14 @@ int mbedtls_chacha20_setkey( mbedtls_chacha20_context *ctx, ctx->state[3] = 0x6b206574; /* Set key */ - ctx->state[4] = MBEDTLS_BYTES_TO_U32_LE( key, 0 ); - ctx->state[5] = MBEDTLS_BYTES_TO_U32_LE( key, 4 ); - ctx->state[6] = MBEDTLS_BYTES_TO_U32_LE( key, 8 ); - ctx->state[7] = MBEDTLS_BYTES_TO_U32_LE( key, 12 ); - ctx->state[8] = MBEDTLS_BYTES_TO_U32_LE( key, 16 ); - ctx->state[9] = MBEDTLS_BYTES_TO_U32_LE( key, 20 ); - ctx->state[10] = MBEDTLS_BYTES_TO_U32_LE( key, 24 ); - ctx->state[11] = MBEDTLS_BYTES_TO_U32_LE( key, 28 ); + ctx->state[4] = MBEDTLS_GET_UINT32_LE( key, 0 ); + ctx->state[5] = MBEDTLS_GET_UINT32_LE( key, 4 ); + ctx->state[6] = MBEDTLS_GET_UINT32_LE( key, 8 ); + ctx->state[7] = MBEDTLS_GET_UINT32_LE( key, 12 ); + ctx->state[8] = MBEDTLS_GET_UINT32_LE( key, 16 ); + ctx->state[9] = MBEDTLS_GET_UINT32_LE( key, 20 ); + ctx->state[10] = MBEDTLS_GET_UINT32_LE( key, 24 ); + ctx->state[11] = MBEDTLS_GET_UINT32_LE( key, 28 ); return( 0 ); } @@ -228,9 +228,9 @@ int mbedtls_chacha20_starts( mbedtls_chacha20_context* ctx, ctx->state[12] = counter; /* Nonce */ - ctx->state[13] = MBEDTLS_BYTES_TO_U32_LE( nonce, 0 ); - ctx->state[14] = MBEDTLS_BYTES_TO_U32_LE( nonce, 4 ); - ctx->state[15] = MBEDTLS_BYTES_TO_U32_LE( nonce, 8 ); + ctx->state[13] = MBEDTLS_GET_UINT32_LE( nonce, 0 ); + ctx->state[14] = MBEDTLS_GET_UINT32_LE( nonce, 4 ); + ctx->state[15] = MBEDTLS_GET_UINT32_LE( nonce, 8 ); mbedtls_platform_zeroize( ctx->keystream8, sizeof( ctx->keystream8 ) ); diff --git a/library/common.h b/library/common.h index 5115465e88..4ecc0162bf 100644 --- a/library/common.h +++ b/library/common.h @@ -78,38 +78,45 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #define MBEDTLS_BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) /** - * 32-bit integer manipulation macros + * 32-bit integer manipulation GET macros (big endian) * - * \brief Using GET- - * From input data, take the most significant bytes - * and concatonate them as you shift along - * Using PUT- - * Read from a 32 bit integer and store each byte - * in memory, offset by a byte each, resulting in - * each byte being adjacent in memory. + * \brief Use this to assign an unsigned 32 bit integer + * by taking data stored adjacent in memory that + * can be accessed via on offset + * Big Endian is used when wanting to + * transmit the most signifcant bits first * - * \param n 32 bit integer where data is accessed via - * PUT or stored using GET + * \param data The data used to translate to a 32 bit + * integer + * \param offset the shift in bytes to access the next byte + * of data + */ +#ifndef MBEDTLS_GET_UINT32_BE +#define MBEDTLS_GET_UINT32_BE( data , offset ) \ + ( \ + ( (uint32_t) ( data )[( offset ) ] << 24 ) \ + | ( (uint32_t) ( data )[( offset ) + 1] << 16 ) \ + | ( (uint32_t) ( data )[( offset ) + 2] << 8 ) \ + | ( (uint32_t) ( data )[( offset ) + 3] ) \ + ) +#endif + +/** + * 32-bit integer manipulation PUT macros (big endian) + * + * \brief Read from a 32 bit integer and store each byte + * in memory, offset by a specified amount, resulting + * in each byte being adjacent in memory. + * Big Endian is used when wanting to + * transmit the most signifcant bits first + * + * \param n 32 bit integer where data is accessed * \param b const unsigned char array of data to be * manipulated * \param i offset in bytes, In the case of UINT32, i * would increment by 4 every use assuming * the data is being stored in the same location */ - -/** - * 32-bit integer manipulation macros (big endian) - */ -#ifndef MBEDTLS_GET_UINT32_BE -#define MBEDTLS_GET_UINT32_BE(n,b,i) \ - do { \ - (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ - | ( (uint32_t) (b)[(i) + 1] << 16 ) \ - | ( (uint32_t) (b)[(i) + 2] << 8 ) \ - | ( (uint32_t) (b)[(i) + 3] ); \ - } while( 0 ) -#endif - #ifndef MBEDTLS_PUT_UINT32_BE #define MBEDTLS_PUT_UINT32_BE(n,b,i) \ do { \ @@ -121,18 +128,45 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * 32-bit integer manipulation macros (little endian) + * 32-bit integer manipulation GET macros (little endian) + * + * \brief Use this to assign an unsigned 32 bit integer + * by taking data stored adjacent in memory that + * can be accessed via on offset + * Little Endian is used when wanting to + * transmit the least signifcant bits first + * + * \param data The data used to translate to a 32 bit + * integer + * \param offset the shift in bytes to access the next byte + * of data */ #ifndef MBEDTLS_GET_UINT32_LE -#define MBEDTLS_GET_UINT32_LE(n,b,i) \ - do { \ - (n) = ( (uint32_t) (b)[(i) ] ) \ - | ( (uint32_t) (b)[(i) + 1] << 8 ) \ - | ( (uint32_t) (b)[(i) + 2] << 16 ) \ - | ( (uint32_t) (b)[(i) + 3] << 24 ); \ - } while( 0 ) +#define MBEDTLS_GET_UINT32_LE( data, offset ) \ + ( \ + ( (uint32_t) ( data )[( offset ) ] ) \ + | ( (uint32_t) ( data )[( offset ) + 1] << 8 ) \ + | ( (uint32_t) ( data )[( offset ) + 2] << 16 ) \ + | ( (uint32_t) ( data )[( offset ) + 3] << 24 ) \ + ) #endif +/** + * 32-bit integer manipulation PUT macros (little endian) + * + * \brief Read from a 32 bit integer and store each byte + * in memory, offset by a specified amount, resulting + * in each byte being adjacent in memory. + * Little Endian is used when wanting to + * transmit the least signifcant bits first + * + * \param n 32 bit integer where data is accessed + * \param b const unsigned char array of data to be + * manipulated + * \param i offset in bytes, In the case of UINT32, i + * would increment by 4 every use assuming + * the data is being stored in the same location + */ #ifndef MBEDTLS_PUT_UINT32_LE #define MBEDTLS_PUT_UINT32_LE(n,b,i) \ do { \ @@ -144,46 +178,43 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * 32-bit integer conversion from bytes (little endian) + * 16-bit integer manipulation GET macros (little endian) + * + * \brief Use this to assign an unsigned 16 bit integer + * by taking data stored adjacent in memory that + * can be accessed via on offset + * Little Endian is used when wanting to + * transmit the least signifcant bits first + * + * \param data The data used to translate to a 16 bit + * integer + * \param offset the shit in bytes to access the next byte + * of data */ -#define MBEDTLS_BYTES_TO_U32_LE( data, offset ) \ - ( (uint32_t) (data)[offset] \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \ - | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 ) \ +#ifndef MBEDTLS_GET_UINT16_LE +#define MBEDTLS_GET_UINT16_LE( data, offset ) \ + ( \ + ( (uint16_t) ( data )[( offset ) ] ) \ + | ( (uint16_t) ( data )[( offset ) + 1] << 8 ) \ ) +#endif /** - * 16-bit integer manipulation macros + * 16-bit integer manipulation PUT macros (little endian) * - * \brief Using GET- - * From input data, take the most significant bytes - * and concatonate them as you shift along - * Using PUT- - * Read from a 16 bit integer and store each byte - * in memory, offset by a byte each, resulting in - * each byte being adjacent in memory. + * \brief Read from a 16 bit integer and store each byte + * in memory, offset by a specified amount, resulting + * in each byte being adjacent in memory. + * Little Endian is used when wanting to + * transmit the least signifcant bits first * - * \param n 16 bit integer where data is accessed via - * PUT or stored using GET + * \param n 16 bit integer where data is accessed * \param b const unsigned char array of data to be * manipulated * \param i offset in bytes, In the case of UINT16, i * would increment by 2 every use assuming * the data is being stored in the same location */ - -/** - * 16-bit integer manipulation macros (little endian) - */ -#ifndef MBEDTLS_GET_UINT16_LE -#define MBEDTLS_GET_UINT16_LE( n, b, i ) \ -{ \ - (n) = ( (uint16_t) (b)[(i) ] ) \ - | ( (uint16_t) (b)[(i) + 1] << 8 ); \ -} -#endif - #ifndef MBEDTLS_PUT_UINT16_LE #define MBEDTLS_PUT_UINT16_LE( n, b, i ) \ { \ diff --git a/library/des.c b/library/des.c index 9281747de8..7f90faa044 100644 --- a/library/des.c +++ b/library/des.c @@ -400,8 +400,8 @@ void mbedtls_des_setkey( uint32_t SK[32], const unsigned char key[MBEDTLS_DES_KE int i; uint32_t X, Y, T; - MBEDTLS_GET_UINT32_BE( X, key, 0 ); - MBEDTLS_GET_UINT32_BE( Y, key, 4 ); + X = MBEDTLS_GET_UINT32_BE( key, 0 ); + Y = MBEDTLS_GET_UINT32_BE( key, 4 ); /* * Permuted Choice 1 @@ -610,8 +610,8 @@ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, SK = ctx->sk; - MBEDTLS_GET_UINT32_BE( X, input, 0 ); - MBEDTLS_GET_UINT32_BE( Y, input, 4 ); + X = MBEDTLS_GET_UINT32_BE( input, 0 ); + Y = MBEDTLS_GET_UINT32_BE( input, 4 ); DES_IP( X, Y ); @@ -697,8 +697,8 @@ int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, SK = ctx->sk; - MBEDTLS_GET_UINT32_BE( X, input, 0 ); - MBEDTLS_GET_UINT32_BE( Y, input, 4 ); + X = MBEDTLS_GET_UINT32_BE( input, 0 ); + Y = MBEDTLS_GET_UINT32_BE( input, 4 ); DES_IP( X, Y ); diff --git a/library/gcm.c b/library/gcm.c index 3caeed26de..910646b281 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -88,12 +88,12 @@ static int gcm_gen_table( mbedtls_gcm_context *ctx ) return( ret ); /* pack h as two 64-bits ints, big-endian */ - MBEDTLS_GET_UINT32_BE( hi, h, 0 ); - MBEDTLS_GET_UINT32_BE( lo, h, 4 ); + hi = MBEDTLS_GET_UINT32_BE( h, 0 ); + lo = MBEDTLS_GET_UINT32_BE( h, 4 ); vh = (uint64_t) hi << 32 | lo; - MBEDTLS_GET_UINT32_BE( hi, h, 8 ); - MBEDTLS_GET_UINT32_BE( lo, h, 12 ); + hi = MBEDTLS_GET_UINT32_BE( h, 8 ); + lo = MBEDTLS_GET_UINT32_BE( h, 12 ); vl = (uint64_t) hi << 32 | lo; /* 8 = 1000 corresponds to 1 in GF(2^128) */ diff --git a/library/md5.c b/library/md5.c index e8d00216f0..a9bbcb488b 100644 --- a/library/md5.c +++ b/library/md5.c @@ -87,22 +87,22 @@ int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, uint32_t X[16], A, B, C, D; } local; - MBEDTLS_GET_UINT32_LE( local.X[ 0], data, 0 ); - MBEDTLS_GET_UINT32_LE( local.X[ 1], data, 4 ); - MBEDTLS_GET_UINT32_LE( local.X[ 2], data, 8 ); - MBEDTLS_GET_UINT32_LE( local.X[ 3], data, 12 ); - MBEDTLS_GET_UINT32_LE( local.X[ 4], data, 16 ); - MBEDTLS_GET_UINT32_LE( local.X[ 5], data, 20 ); - MBEDTLS_GET_UINT32_LE( local.X[ 6], data, 24 ); - MBEDTLS_GET_UINT32_LE( local.X[ 7], data, 28 ); - MBEDTLS_GET_UINT32_LE( local.X[ 8], data, 32 ); - MBEDTLS_GET_UINT32_LE( local.X[ 9], data, 36 ); - MBEDTLS_GET_UINT32_LE( local.X[10], data, 40 ); - MBEDTLS_GET_UINT32_LE( local.X[11], data, 44 ); - MBEDTLS_GET_UINT32_LE( local.X[12], data, 48 ); - MBEDTLS_GET_UINT32_LE( local.X[13], data, 52 ); - MBEDTLS_GET_UINT32_LE( local.X[14], data, 56 ); - MBEDTLS_GET_UINT32_LE( local.X[15], data, 60 ); + local.X[ 0] = MBEDTLS_GET_UINT32_LE( data, 0 ); + local.X[ 1] = MBEDTLS_GET_UINT32_LE( data, 4 ); + local.X[ 2] = MBEDTLS_GET_UINT32_LE( data, 8 ); + local.X[ 3] = MBEDTLS_GET_UINT32_LE( data, 12 ); + local.X[ 4] = MBEDTLS_GET_UINT32_LE( data, 16 ); + local.X[ 5] = MBEDTLS_GET_UINT32_LE( data, 20 ); + local.X[ 6] = MBEDTLS_GET_UINT32_LE( data, 24 ); + local.X[ 7] = MBEDTLS_GET_UINT32_LE( data, 28 ); + local.X[ 8] = MBEDTLS_GET_UINT32_LE( data, 32 ); + local.X[ 9] = MBEDTLS_GET_UINT32_LE( data, 36 ); + local.X[10] = MBEDTLS_GET_UINT32_LE( data, 40 ); + local.X[11] = MBEDTLS_GET_UINT32_LE( data, 44 ); + local.X[12] = MBEDTLS_GET_UINT32_LE( data, 48 ); + local.X[13] = MBEDTLS_GET_UINT32_LE( data, 52 ); + local.X[14] = MBEDTLS_GET_UINT32_LE( data, 56 ); + local.X[15] = MBEDTLS_GET_UINT32_LE( data, 60 ); #define S(x,n) \ ( ( (x) << (n) ) | ( ( (x) & 0xFFFFFFFF) >> ( 32 - (n) ) ) ) diff --git a/library/nist_kw.c b/library/nist_kw.c index b8f9239992..e2ab2566f5 100644 --- a/library/nist_kw.c +++ b/library/nist_kw.c @@ -454,7 +454,7 @@ int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; } - MBEDTLS_GET_UINT32_BE( Plen, A, KW_SEMIBLOCK_LENGTH / 2 ); + Plen = MBEDTLS_GET_UINT32_BE( A, KW_SEMIBLOCK_LENGTH / 2 ); /* * Plen is the length of the plaintext, when the input is valid. diff --git a/library/poly1305.c b/library/poly1305.c index 3c0b7c6aa9..f19574253c 100644 --- a/library/poly1305.c +++ b/library/poly1305.c @@ -122,10 +122,10 @@ static void poly1305_process( mbedtls_poly1305_context *ctx, for( i = 0U; i < nblocks; i++ ) { /* The input block is treated as a 128-bit little-endian integer */ - d0 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 0 ); - d1 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 4 ); - d2 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 8 ); - d3 = MBEDTLS_BYTES_TO_U32_LE( input, offset + 12 ); + d0 = MBEDTLS_GET_UINT32_LE( input, offset + 0 ); + d1 = MBEDTLS_GET_UINT32_LE( input, offset + 4 ); + d2 = MBEDTLS_GET_UINT32_LE( input, offset + 8 ); + d3 = MBEDTLS_GET_UINT32_LE( input, offset + 12 ); /* Compute: acc += (padded) block as a 130-bit integer */ d0 += (uint64_t) acc0; @@ -290,15 +290,15 @@ int mbedtls_poly1305_starts( mbedtls_poly1305_context *ctx, POLY1305_VALIDATE_RET( key != NULL ); /* r &= 0x0ffffffc0ffffffc0ffffffc0fffffff */ - ctx->r[0] = MBEDTLS_BYTES_TO_U32_LE( key, 0 ) & 0x0FFFFFFFU; - ctx->r[1] = MBEDTLS_BYTES_TO_U32_LE( key, 4 ) & 0x0FFFFFFCU; - ctx->r[2] = MBEDTLS_BYTES_TO_U32_LE( key, 8 ) & 0x0FFFFFFCU; - ctx->r[3] = MBEDTLS_BYTES_TO_U32_LE( key, 12 ) & 0x0FFFFFFCU; + ctx->r[0] = MBEDTLS_GET_UINT32_LE( key, 0 ) & 0x0FFFFFFFU; + ctx->r[1] = MBEDTLS_GET_UINT32_LE( key, 4 ) & 0x0FFFFFFCU; + ctx->r[2] = MBEDTLS_GET_UINT32_LE( key, 8 ) & 0x0FFFFFFCU; + ctx->r[3] = MBEDTLS_GET_UINT32_LE( key, 12 ) & 0x0FFFFFFCU; - ctx->s[0] = MBEDTLS_BYTES_TO_U32_LE( key, 16 ); - ctx->s[1] = MBEDTLS_BYTES_TO_U32_LE( key, 20 ); - ctx->s[2] = MBEDTLS_BYTES_TO_U32_LE( key, 24 ); - ctx->s[3] = MBEDTLS_BYTES_TO_U32_LE( key, 28 ); + ctx->s[0] = MBEDTLS_GET_UINT32_LE( key, 16 ); + ctx->s[1] = MBEDTLS_GET_UINT32_LE( key, 20 ); + ctx->s[2] = MBEDTLS_GET_UINT32_LE( key, 24 ); + ctx->s[3] = MBEDTLS_GET_UINT32_LE( key, 28 ); /* Initial accumulator state */ ctx->acc[0] = 0U; diff --git a/library/psa_crypto_storage.c b/library/psa_crypto_storage.c index 07c2cdf600..c6660b9553 100644 --- a/library/psa_crypto_storage.c +++ b/library/psa_crypto_storage.c @@ -293,11 +293,11 @@ psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data, if( status != PSA_SUCCESS ) return( status ); - MBEDTLS_GET_UINT32_LE( version, storage_format->version, 0 ); + version = MBEDTLS_GET_UINT32_LE( storage_format->version, 0 ); if( version != 0 ) return( PSA_ERROR_DATA_INVALID ); - MBEDTLS_GET_UINT32_LE( *key_data_length, storage_format->data_len, 0 ); + *key_data_length = MBEDTLS_GET_UINT32_LE( storage_format->data_len, 0 ); if( *key_data_length > ( storage_data_length - sizeof(*storage_format) ) || *key_data_length > PSA_CRYPTO_MAX_STORAGE_SIZE ) return( PSA_ERROR_DATA_INVALID ); @@ -314,12 +314,12 @@ psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data, memcpy( *key_data, storage_format->key_data, *key_data_length ); } - MBEDTLS_GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 ); - MBEDTLS_GET_UINT16_LE( attr->type, storage_format->type, 0 ); - MBEDTLS_GET_UINT16_LE( attr->bits, storage_format->bits, 0 ); - MBEDTLS_GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 ); - MBEDTLS_GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) ); - MBEDTLS_GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) ); + attr->lifetime = MBEDTLS_GET_UINT32_LE( storage_format->lifetime, 0 ); + attr->type = MBEDTLS_GET_UINT16_LE( storage_format->type, 0 ); + attr->bits = MBEDTLS_GET_UINT16_LE( storage_format->bits, 0 ); + attr->policy.usage = MBEDTLS_GET_UINT32_LE( storage_format->policy, 0 ); + attr->policy.alg = MBEDTLS_GET_UINT32_LE( storage_format->policy, sizeof( uint32_t ) ); + attr->policy.alg2 = MBEDTLS_GET_UINT32_LE( storage_format->policy, 2 * sizeof( uint32_t ) ); return( PSA_SUCCESS ); } diff --git a/library/ripemd160.c b/library/ripemd160.c index 2bed107230..41d8387226 100644 --- a/library/ripemd160.c +++ b/library/ripemd160.c @@ -92,22 +92,22 @@ int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx, uint32_t A, B, C, D, E, Ap, Bp, Cp, Dp, Ep, X[16]; } local; - MBEDTLS_GET_UINT32_LE( local.X[ 0], data, 0 ); - MBEDTLS_GET_UINT32_LE( local.X[ 1], data, 4 ); - MBEDTLS_GET_UINT32_LE( local.X[ 2], data, 8 ); - MBEDTLS_GET_UINT32_LE( local.X[ 3], data, 12 ); - MBEDTLS_GET_UINT32_LE( local.X[ 4], data, 16 ); - MBEDTLS_GET_UINT32_LE( local.X[ 5], data, 20 ); - MBEDTLS_GET_UINT32_LE( local.X[ 6], data, 24 ); - MBEDTLS_GET_UINT32_LE( local.X[ 7], data, 28 ); - MBEDTLS_GET_UINT32_LE( local.X[ 8], data, 32 ); - MBEDTLS_GET_UINT32_LE( local.X[ 9], data, 36 ); - MBEDTLS_GET_UINT32_LE( local.X[10], data, 40 ); - MBEDTLS_GET_UINT32_LE( local.X[11], data, 44 ); - MBEDTLS_GET_UINT32_LE( local.X[12], data, 48 ); - MBEDTLS_GET_UINT32_LE( local.X[13], data, 52 ); - MBEDTLS_GET_UINT32_LE( local.X[14], data, 56 ); - MBEDTLS_GET_UINT32_LE( local.X[15], data, 60 ); + local.X[ 0] = MBEDTLS_GET_UINT32_LE( data, 0 ); + local.X[ 1] = MBEDTLS_GET_UINT32_LE( data, 4 ); + local.X[ 2] = MBEDTLS_GET_UINT32_LE( data, 8 ); + local.X[ 3] = MBEDTLS_GET_UINT32_LE( data, 12 ); + local.X[ 4] = MBEDTLS_GET_UINT32_LE( data, 16 ); + local.X[ 5] = MBEDTLS_GET_UINT32_LE( data, 20 ); + local.X[ 6] = MBEDTLS_GET_UINT32_LE( data, 24 ); + local.X[ 7] = MBEDTLS_GET_UINT32_LE( data, 28 ); + local.X[ 8] = MBEDTLS_GET_UINT32_LE( data, 32 ); + local.X[ 9] = MBEDTLS_GET_UINT32_LE( data, 36 ); + local.X[10] = MBEDTLS_GET_UINT32_LE( data, 40 ); + local.X[11] = MBEDTLS_GET_UINT32_LE( data, 44 ); + local.X[12] = MBEDTLS_GET_UINT32_LE( data, 48 ); + local.X[13] = MBEDTLS_GET_UINT32_LE( data, 52 ); + local.X[14] = MBEDTLS_GET_UINT32_LE( data, 56 ); + local.X[15] = MBEDTLS_GET_UINT32_LE( data, 60 ); local.A = local.Ap = ctx->state[0]; local.B = local.Bp = ctx->state[1]; diff --git a/library/sha1.c b/library/sha1.c index da61f65fca..6fc9371231 100644 --- a/library/sha1.c +++ b/library/sha1.c @@ -103,22 +103,22 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, SHA1_VALIDATE_RET( ctx != NULL ); SHA1_VALIDATE_RET( (const unsigned char *)data != NULL ); - MBEDTLS_GET_UINT32_BE( local.W[ 0], data, 0 ); - MBEDTLS_GET_UINT32_BE( local.W[ 1], data, 4 ); - MBEDTLS_GET_UINT32_BE( local.W[ 2], data, 8 ); - MBEDTLS_GET_UINT32_BE( local.W[ 3], data, 12 ); - MBEDTLS_GET_UINT32_BE( local.W[ 4], data, 16 ); - MBEDTLS_GET_UINT32_BE( local.W[ 5], data, 20 ); - MBEDTLS_GET_UINT32_BE( local.W[ 6], data, 24 ); - MBEDTLS_GET_UINT32_BE( local.W[ 7], data, 28 ); - MBEDTLS_GET_UINT32_BE( local.W[ 8], data, 32 ); - MBEDTLS_GET_UINT32_BE( local.W[ 9], data, 36 ); - MBEDTLS_GET_UINT32_BE( local.W[10], data, 40 ); - MBEDTLS_GET_UINT32_BE( local.W[11], data, 44 ); - MBEDTLS_GET_UINT32_BE( local.W[12], data, 48 ); - MBEDTLS_GET_UINT32_BE( local.W[13], data, 52 ); - MBEDTLS_GET_UINT32_BE( local.W[14], data, 56 ); - MBEDTLS_GET_UINT32_BE( local.W[15], data, 60 ); + local.W[ 0] = MBEDTLS_GET_UINT32_BE( data, 0 ); + local.W[ 1] = MBEDTLS_GET_UINT32_BE( data, 4 ); + local.W[ 2] = MBEDTLS_GET_UINT32_BE( data, 8 ); + local.W[ 3] = MBEDTLS_GET_UINT32_BE( data, 12 ); + local.W[ 4] = MBEDTLS_GET_UINT32_BE( data, 16 ); + local.W[ 5] = MBEDTLS_GET_UINT32_BE( data, 20 ); + local.W[ 6] = MBEDTLS_GET_UINT32_BE( data, 24 ); + local.W[ 7] = MBEDTLS_GET_UINT32_BE( data, 28 ); + local.W[ 8] = MBEDTLS_GET_UINT32_BE( data, 32 ); + local.W[ 9] = MBEDTLS_GET_UINT32_BE( data, 36 ); + local.W[10] = MBEDTLS_GET_UINT32_BE( data, 40 ); + local.W[11] = MBEDTLS_GET_UINT32_BE( data, 44 ); + local.W[12] = MBEDTLS_GET_UINT32_BE( data, 48 ); + local.W[13] = MBEDTLS_GET_UINT32_BE( data, 52 ); + local.W[14] = MBEDTLS_GET_UINT32_BE( data, 56 ); + local.W[15] = MBEDTLS_GET_UINT32_BE( data, 60 ); #define S(x,n) (((x) << (n)) | (((x) & 0xFFFFFFFF) >> (32 - (n)))) diff --git a/library/sha256.c b/library/sha256.c index fb66340b20..c3573f85fd 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -190,7 +190,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, for( i = 0; i < 64; i++ ) { if( i < 16 ) - MBEDTLS_GET_UINT32_BE( local.W[i], data, 4 * i ); + local.W[i] = MBEDTLS_GET_UINT32_BE( data, 4 * i ); else R( i ); @@ -205,7 +205,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, } #else /* MBEDTLS_SHA256_SMALLER */ for( i = 0; i < 16; i++ ) - MBEDTLS_GET_UINT32_BE( local.W[i], data, 4 * i ); + local.W[i] = MBEDTLS_GET_UINT32_BE( data, 4 * i ); for( i = 0; i < 16; i += 8 ) { From cd84d76e9b1a3b2c82d5975561aea493777abd51 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 8 Jul 2021 14:59:52 +0100 Subject: [PATCH 315/966] Add Character byte reading macros These cast to an unsigned char rather than a uint8_t like with MBEDTLS_BYTE_x These save alot of space and will improve maintence by replacing the appropriate code with MBEDTLS_CHAR_x Signed-off-by: Joe Subbiani --- library/aes.c | 196 +++++++++++++++++++-------------------- library/aria.c | 32 +++---- library/asn1write.c | 18 ++-- library/camellia.c | 16 ++-- library/ccm.c | 6 +- library/common.h | 9 ++ library/ecjpake.c | 18 ++-- library/ssl_cli.c | 131 ++++++++++++-------------- library/ssl_msg.c | 12 +-- library/ssl_srv.c | 94 +++++++++---------- library/ssl_tls.c | 120 ++++++++++++------------ library/ssl_tls13_keys.c | 6 +- 12 files changed, 328 insertions(+), 330 deletions(-) diff --git a/library/aes.c b/library/aes.c index 7a44a78408..1eb3e204d8 100644 --- a/library/aes.c +++ b/library/aes.c @@ -386,7 +386,7 @@ static void aes_gen_tables( void ) { pow[i] = x; log[x] = i; - x = ( x ^ XTIME( x ) ) & 0xFF; + x = MBEDTLS_BYTE_0( x ^ XTIME( x ) ); } /* @@ -395,7 +395,7 @@ static void aes_gen_tables( void ) for( i = 0, x = 1; i < 10; i++ ) { RCON[i] = (uint32_t) x; - x = XTIME( x ) & 0xFF; + x = MBEDTLS_BYTE_0( XTIME( x ) ); } /* @@ -408,10 +408,10 @@ static void aes_gen_tables( void ) { x = pow[255 - log[i]]; - y = x; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF; - x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF; - x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF; - x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF; + y = x; y = MBEDTLS_BYTE_0( ( y << 1 ) | ( y >> 7 ) ); + x ^= y; y = MBEDTLS_BYTE_0( ( y << 1 ) | ( y >> 7 ) ); + x ^= y; y = MBEDTLS_BYTE_0( ( y << 1 ) | ( y >> 7 ) ); + x ^= y; y = MBEDTLS_BYTE_0( ( y << 1 ) | ( y >> 7 ) ); x ^= y ^ 0x63; FSb[i] = (unsigned char) x; @@ -424,8 +424,8 @@ static void aes_gen_tables( void ) for( i = 0; i < 256; i++ ) { x = FSb[i]; - y = XTIME( x ) & 0xFF; - z = ( y ^ x ) & 0xFF; + y = MBEDTLS_BYTE_0( XTIME( x ) ); + z = MBEDTLS_BYTE_0( y ^ x ); FT0[i] = ( (uint32_t) y ) ^ ( (uint32_t) x << 8 ) ^ @@ -577,10 +577,10 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, for( i = 0; i < 10; i++, RK += 4 ) { RK[4] = RK[0] ^ RCON[i] ^ - ( (uint32_t) FSb[ ( RK[3] >> 8 ) & 0xFF ] ) ^ - ( (uint32_t) FSb[ ( RK[3] >> 16 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) FSb[ ( RK[3] >> 24 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) FSb[ ( RK[3] ) & 0xFF ] << 24 ); + ( (uint32_t) FSb[ MBEDTLS_BYTE_1( RK[3] ) ] ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_2( RK[3] ) ] << 8 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_3( RK[3] ) ] << 16 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_0( RK[3] ) ] << 24 ); RK[5] = RK[1] ^ RK[4]; RK[6] = RK[2] ^ RK[5]; @@ -593,10 +593,10 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, for( i = 0; i < 8; i++, RK += 6 ) { RK[6] = RK[0] ^ RCON[i] ^ - ( (uint32_t) FSb[ ( RK[5] >> 8 ) & 0xFF ] ) ^ - ( (uint32_t) FSb[ ( RK[5] >> 16 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) FSb[ ( RK[5] >> 24 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) FSb[ ( RK[5] ) & 0xFF ] << 24 ); + ( (uint32_t) FSb[ MBEDTLS_BYTE_1( RK[5] ) ] ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_2( RK[5] ) ] << 8 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_3( RK[5] ) ] << 16 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_0( RK[5] ) ] << 24 ); RK[7] = RK[1] ^ RK[6]; RK[8] = RK[2] ^ RK[7]; @@ -611,20 +611,20 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, for( i = 0; i < 7; i++, RK += 8 ) { RK[8] = RK[0] ^ RCON[i] ^ - ( (uint32_t) FSb[ ( RK[7] >> 8 ) & 0xFF ] ) ^ - ( (uint32_t) FSb[ ( RK[7] >> 16 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) FSb[ ( RK[7] >> 24 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) FSb[ ( RK[7] ) & 0xFF ] << 24 ); + ( (uint32_t) FSb[ MBEDTLS_BYTE_1( RK[7] ) ] ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_2( RK[7] ) ] << 8 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_3( RK[7] ) ] << 16 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_0( RK[7] ) ] << 24 ); RK[9] = RK[1] ^ RK[8]; RK[10] = RK[2] ^ RK[9]; RK[11] = RK[3] ^ RK[10]; RK[12] = RK[4] ^ - ( (uint32_t) FSb[ ( RK[11] ) & 0xFF ] ) ^ - ( (uint32_t) FSb[ ( RK[11] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) FSb[ ( RK[11] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) FSb[ ( RK[11] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) FSb[ MBEDTLS_BYTE_0( RK[11] ) ] ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_1( RK[11] ) ] << 8 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_2( RK[11] ) ] << 16 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_3( RK[11] ) ] << 24 ); RK[13] = RK[5] ^ RK[12]; RK[14] = RK[6] ^ RK[13]; @@ -690,10 +690,10 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, { for( j = 0; j < 4; j++, SK++ ) { - *RK++ = AES_RT0( FSb[ ( *SK ) & 0xFF ] ) ^ - AES_RT1( FSb[ ( *SK >> 8 ) & 0xFF ] ) ^ - AES_RT2( FSb[ ( *SK >> 16 ) & 0xFF ] ) ^ - AES_RT3( FSb[ ( *SK >> 24 ) & 0xFF ] ); + *RK++ = AES_RT0( FSb[ MBEDTLS_BYTE_0( *SK ) ] ) ^ + AES_RT1( FSb[ MBEDTLS_BYTE_1( *SK ) ] ) ^ + AES_RT2( FSb[ MBEDTLS_BYTE_2( *SK ) ] ) ^ + AES_RT3( FSb[ MBEDTLS_BYTE_3( *SK ) ] ); } } @@ -786,52 +786,52 @@ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, } #endif /* MBEDTLS_CIPHER_MODE_XTS */ -#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ - do \ - { \ - (X0) = *RK++ ^ AES_FT0( ( (Y0) ) & 0xFF ) ^ \ - AES_FT1( ( (Y1) >> 8 ) & 0xFF ) ^ \ - AES_FT2( ( (Y2) >> 16 ) & 0xFF ) ^ \ - AES_FT3( ( (Y3) >> 24 ) & 0xFF ); \ - \ - (X1) = *RK++ ^ AES_FT0( ( (Y1) ) & 0xFF ) ^ \ - AES_FT1( ( (Y2) >> 8 ) & 0xFF ) ^ \ - AES_FT2( ( (Y3) >> 16 ) & 0xFF ) ^ \ - AES_FT3( ( (Y0) >> 24 ) & 0xFF ); \ - \ - (X2) = *RK++ ^ AES_FT0( ( (Y2) ) & 0xFF ) ^ \ - AES_FT1( ( (Y3) >> 8 ) & 0xFF ) ^ \ - AES_FT2( ( (Y0) >> 16 ) & 0xFF ) ^ \ - AES_FT3( ( (Y1) >> 24 ) & 0xFF ); \ - \ - (X3) = *RK++ ^ AES_FT0( ( (Y3) ) & 0xFF ) ^ \ - AES_FT1( ( (Y0) >> 8 ) & 0xFF ) ^ \ - AES_FT2( ( (Y1) >> 16 ) & 0xFF ) ^ \ - AES_FT3( ( (Y2) >> 24 ) & 0xFF ); \ +#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ + do \ + { \ + (X0) = *RK++ ^ AES_FT0( MBEDTLS_BYTE_0( Y0 ) ) ^ \ + AES_FT1( MBEDTLS_BYTE_1( Y1 ) ) ^ \ + AES_FT2( MBEDTLS_BYTE_2( Y2 ) ) ^ \ + AES_FT3( MBEDTLS_BYTE_3( Y3 ) ); \ + \ + (X1) = *RK++ ^ AES_FT0( MBEDTLS_BYTE_0( Y1 ) ) ^ \ + AES_FT1( MBEDTLS_BYTE_1( Y2 ) ) ^ \ + AES_FT2( MBEDTLS_BYTE_2( Y3 ) ) ^ \ + AES_FT3( MBEDTLS_BYTE_3( Y0 ) ); \ + \ + (X2) = *RK++ ^ AES_FT0( MBEDTLS_BYTE_0( Y2 ) ) ^ \ + AES_FT1( MBEDTLS_BYTE_1( Y3 ) ) ^ \ + AES_FT2( MBEDTLS_BYTE_2( Y0 ) ) ^ \ + AES_FT3( MBEDTLS_BYTE_3( Y1 ) ); \ + \ + (X3) = *RK++ ^ AES_FT0( MBEDTLS_BYTE_0( Y3 ) ) ^ \ + AES_FT1( MBEDTLS_BYTE_1( Y0 ) ) ^ \ + AES_FT2( MBEDTLS_BYTE_2( Y1 ) ) ^ \ + AES_FT3( MBEDTLS_BYTE_3( Y2 ) ); \ } while( 0 ) #define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ do \ { \ - (X0) = *RK++ ^ AES_RT0( ( (Y0) ) & 0xFF ) ^ \ - AES_RT1( ( (Y3) >> 8 ) & 0xFF ) ^ \ - AES_RT2( ( (Y2) >> 16 ) & 0xFF ) ^ \ - AES_RT3( ( (Y1) >> 24 ) & 0xFF ); \ + (X0) = *RK++ ^ AES_RT0( MBEDTLS_BYTE_0( Y0 ) ) ^ \ + AES_RT1( MBEDTLS_BYTE_1( Y3 ) ) ^ \ + AES_RT2( MBEDTLS_BYTE_2( Y2 ) ) ^ \ + AES_RT3( MBEDTLS_BYTE_3( Y1 ) ); \ \ - (X1) = *RK++ ^ AES_RT0( ( (Y1) ) & 0xFF ) ^ \ - AES_RT1( ( (Y0) >> 8 ) & 0xFF ) ^ \ - AES_RT2( ( (Y3) >> 16 ) & 0xFF ) ^ \ - AES_RT3( ( (Y2) >> 24 ) & 0xFF ); \ + (X1) = *RK++ ^ AES_RT0( MBEDTLS_BYTE_0( Y1 ) ) ^ \ + AES_RT1( MBEDTLS_BYTE_1( Y0 ) ) ^ \ + AES_RT2( MBEDTLS_BYTE_2( Y3 ) ) ^ \ + AES_RT3( MBEDTLS_BYTE_3( Y2 ) ); \ \ - (X2) = *RK++ ^ AES_RT0( ( (Y2) ) & 0xFF ) ^ \ - AES_RT1( ( (Y1) >> 8 ) & 0xFF ) ^ \ - AES_RT2( ( (Y0) >> 16 ) & 0xFF ) ^ \ - AES_RT3( ( (Y3) >> 24 ) & 0xFF ); \ + (X2) = *RK++ ^ AES_RT0( MBEDTLS_BYTE_0( Y2 ) ) ^ \ + AES_RT1( MBEDTLS_BYTE_1( Y1 ) ) ^ \ + AES_RT2( MBEDTLS_BYTE_2( Y0 ) ) ^ \ + AES_RT3( MBEDTLS_BYTE_3( Y3 ) ); \ \ - (X3) = *RK++ ^ AES_RT0( ( (Y3) ) & 0xFF ) ^ \ - AES_RT1( ( (Y2) >> 8 ) & 0xFF ) ^ \ - AES_RT2( ( (Y1) >> 16 ) & 0xFF ) ^ \ - AES_RT3( ( (Y0) >> 24 ) & 0xFF ); \ + (X3) = *RK++ ^ AES_RT0( MBEDTLS_BYTE_0( Y3 ) ) ^ \ + AES_RT1( MBEDTLS_BYTE_1( Y2 ) ) ^ \ + AES_RT2( MBEDTLS_BYTE_2( Y1 ) ) ^ \ + AES_RT3( MBEDTLS_BYTE_3( Y0 ) ); \ } while( 0 ) /* @@ -864,28 +864,28 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, AES_FROUND( t.Y[0], t.Y[1], t.Y[2], t.Y[3], t.X[0], t.X[1], t.X[2], t.X[3] ); t.X[0] = *RK++ ^ \ - ( (uint32_t) FSb[ ( t.Y[0] ) & 0xFF ] ) ^ - ( (uint32_t) FSb[ ( t.Y[1] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) FSb[ ( t.Y[2] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) FSb[ ( t.Y[3] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) FSb[ MBEDTLS_BYTE_0( t.Y[0] ) ] ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_1( t.Y[1] ) ] << 8 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_2( t.Y[2] ) ] << 16 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_3( t.Y[3] ) ] << 24 ); t.X[1] = *RK++ ^ \ - ( (uint32_t) FSb[ ( t.Y[1] ) & 0xFF ] ) ^ - ( (uint32_t) FSb[ ( t.Y[2] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) FSb[ ( t.Y[3] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) FSb[ ( t.Y[0] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) FSb[ MBEDTLS_BYTE_0( t.Y[1] ) ] ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_1( t.Y[2] ) ] << 8 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_2( t.Y[3] ) ] << 16 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_3( t.Y[0] ) ] << 24 ); t.X[2] = *RK++ ^ \ - ( (uint32_t) FSb[ ( t.Y[2] ) & 0xFF ] ) ^ - ( (uint32_t) FSb[ ( t.Y[3] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) FSb[ ( t.Y[0] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) FSb[ ( t.Y[1] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) FSb[ MBEDTLS_BYTE_0( t.Y[2] ) ] ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_1( t.Y[3] ) ] << 8 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_2( t.Y[0] ) ] << 16 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_3( t.Y[1] ) ] << 24 ); t.X[3] = *RK++ ^ \ - ( (uint32_t) FSb[ ( t.Y[3] ) & 0xFF ] ) ^ - ( (uint32_t) FSb[ ( t.Y[0] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) FSb[ ( t.Y[1] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) FSb[ ( t.Y[2] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) FSb[ MBEDTLS_BYTE_0( t.Y[3] ) ] ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_1( t.Y[0] ) ] << 8 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_2( t.Y[1] ) ] << 16 ) ^ + ( (uint32_t) FSb[ MBEDTLS_BYTE_3( t.Y[2] ) ] << 24 ); MBEDTLS_PUT_UINT32_LE( t.X[0], output, 0 ); MBEDTLS_PUT_UINT32_LE( t.X[1], output, 4 ); @@ -928,28 +928,28 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, AES_RROUND( t.Y[0], t.Y[1], t.Y[2], t.Y[3], t.X[0], t.X[1], t.X[2], t.X[3] ); t.X[0] = *RK++ ^ \ - ( (uint32_t) RSb[ ( t.Y[0] ) & 0xFF ] ) ^ - ( (uint32_t) RSb[ ( t.Y[3] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) RSb[ ( t.Y[2] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) RSb[ ( t.Y[1] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) RSb[ MBEDTLS_BYTE_0( t.Y[0] ) ] ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_1( t.Y[3] ) ] << 8 ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_2( t.Y[2] ) ] << 16 ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_3( t.Y[1] ) ] << 24 ); t.X[1] = *RK++ ^ \ - ( (uint32_t) RSb[ ( t.Y[1] ) & 0xFF ] ) ^ - ( (uint32_t) RSb[ ( t.Y[0] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) RSb[ ( t.Y[3] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) RSb[ ( t.Y[2] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) RSb[ MBEDTLS_BYTE_0( t.Y[1] ) ] ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_1( t.Y[0] ) ] << 8 ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_2( t.Y[3] ) ] << 16 ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_3( t.Y[2] ) ] << 24 ); t.X[2] = *RK++ ^ \ - ( (uint32_t) RSb[ ( t.Y[2] ) & 0xFF ] ) ^ - ( (uint32_t) RSb[ ( t.Y[1] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) RSb[ ( t.Y[0] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) RSb[ ( t.Y[3] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) RSb[ MBEDTLS_BYTE_0( t.Y[2] ) ] ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_1( t.Y[1] ) ] << 8 ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_2( t.Y[0] ) ] << 16 ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_3( t.Y[3] ) ] << 24 ); t.X[3] = *RK++ ^ \ - ( (uint32_t) RSb[ ( t.Y[3] ) & 0xFF ] ) ^ - ( (uint32_t) RSb[ ( t.Y[2] >> 8 ) & 0xFF ] << 8 ) ^ - ( (uint32_t) RSb[ ( t.Y[1] >> 16 ) & 0xFF ] << 16 ) ^ - ( (uint32_t) RSb[ ( t.Y[0] >> 24 ) & 0xFF ] << 24 ); + ( (uint32_t) RSb[ MBEDTLS_BYTE_0( t.Y[3] ) ] ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_1( t.Y[2] ) ] << 8 ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_2( t.Y[1] ) ] << 16 ) ^ + ( (uint32_t) RSb[ MBEDTLS_BYTE_3( t.Y[0] ) ] << 24 ); MBEDTLS_PUT_UINT32_LE( t.X[0], output, 0 ); MBEDTLS_PUT_UINT32_LE( t.X[1], output, 4 ); diff --git a/library/aria.c b/library/aria.c index 320f7758ac..6bfdfbdce2 100644 --- a/library/aria.c +++ b/library/aria.c @@ -212,22 +212,22 @@ static inline void aria_sl( uint32_t *a, uint32_t *b, const uint8_t sa[256], const uint8_t sb[256], const uint8_t sc[256], const uint8_t sd[256] ) { - *a = ( (uint32_t) sa[ *a & 0xFF] ) ^ - (((uint32_t) sb[(*a >> 8) & 0xFF]) << 8) ^ - (((uint32_t) sc[(*a >> 16) & 0xFF]) << 16) ^ - (((uint32_t) sd[ *a >> 24 ]) << 24); - *b = ( (uint32_t) sa[ *b & 0xFF] ) ^ - (((uint32_t) sb[(*b >> 8) & 0xFF]) << 8) ^ - (((uint32_t) sc[(*b >> 16) & 0xFF]) << 16) ^ - (((uint32_t) sd[ *b >> 24 ]) << 24); - *c = ( (uint32_t) sa[ *c & 0xFF] ) ^ - (((uint32_t) sb[(*c >> 8) & 0xFF]) << 8) ^ - (((uint32_t) sc[(*c >> 16) & 0xFF]) << 16) ^ - (((uint32_t) sd[ *c >> 24 ]) << 24); - *d = ( (uint32_t) sa[ *d & 0xFF] ) ^ - (((uint32_t) sb[(*d >> 8) & 0xFF]) << 8) ^ - (((uint32_t) sc[(*d >> 16) & 0xFF]) << 16) ^ - (((uint32_t) sd[ *d >> 24 ]) << 24); + *a = ( (uint32_t) sa[ MBEDTLS_BYTE_0( *a ) ] ) ^ + (((uint32_t) sb[ MBEDTLS_BYTE_1( *a ) ]) << 8) ^ + (((uint32_t) sc[ MBEDTLS_BYTE_2( *a ) ]) << 16) ^ + (((uint32_t) sd[ *a >> 24 ]) << 24); + *b = ( (uint32_t) sa[ MBEDTLS_BYTE_0( *b ) ] ) ^ + (((uint32_t) sb[ MBEDTLS_BYTE_1( *b ) ]) << 8) ^ + (((uint32_t) sc[ MBEDTLS_BYTE_2( *b ) ]) << 16) ^ + (((uint32_t) sd[ *b >> 24 ]) << 24); + *c = ( (uint32_t) sa[ MBEDTLS_BYTE_0( *c ) ] ) ^ + (((uint32_t) sb[ MBEDTLS_BYTE_1( *c ) ]) << 8) ^ + (((uint32_t) sc[ MBEDTLS_BYTE_2( *c ) ]) << 16) ^ + (((uint32_t) sd[ *c >> 24 ]) << 24); + *d = ( (uint32_t) sa[ MBEDTLS_BYTE_0( *d ) ] ) ^ + (((uint32_t) sb[ MBEDTLS_BYTE_1( *d ) ]) << 8) ^ + (((uint32_t) sc[ MBEDTLS_BYTE_2( *d ) ]) << 16) ^ + (((uint32_t) sd[ *d >> 24 ]) << 24); } /* diff --git a/library/asn1write.c b/library/asn1write.c index 0289e89491..8555767fe2 100644 --- a/library/asn1write.c +++ b/library/asn1write.c @@ -60,8 +60,8 @@ int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start, size_ if( *p - start < 3 ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); - *--(*p) = ( len ) & 0xFF; - *--(*p) = ( len >> 8 ) & 0xFF; + *--(*p) = MBEDTLS_CHAR_0( len ); + *--(*p) = MBEDTLS_CHAR_1( len ); *--(*p) = 0x82; return( 3 ); } @@ -71,9 +71,9 @@ int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start, size_ if( *p - start < 4 ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); - *--(*p) = ( len ) & 0xFF; - *--(*p) = ( len >> 8 ) & 0xFF; - *--(*p) = ( len >> 16 ) & 0xFF; + *--(*p) = MBEDTLS_CHAR_0( len ); + *--(*p) = MBEDTLS_CHAR_1( len ); + *--(*p) = MBEDTLS_CHAR_2( len ); *--(*p) = 0x83; return( 4 ); } @@ -85,10 +85,10 @@ int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start, size_ if( *p - start < 5 ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); - *--(*p) = ( len ) & 0xFF; - *--(*p) = ( len >> 8 ) & 0xFF; - *--(*p) = ( len >> 16 ) & 0xFF; - *--(*p) = ( len >> 24 ) & 0xFF; + *--(*p) = MBEDTLS_CHAR_0( len ); + *--(*p) = MBEDTLS_CHAR_1( len ); + *--(*p) = MBEDTLS_CHAR_2( len ); + *--(*p) = MBEDTLS_CHAR_3( len ); *--(*p) = 0x84; return( 5 ); } diff --git a/library/camellia.c b/library/camellia.c index 4d6b468e5d..29d730ab53 100644 --- a/library/camellia.c +++ b/library/camellia.c @@ -278,14 +278,14 @@ static void camellia_feistel( const uint32_t x[2], const uint32_t k[2], I0 = x[0] ^ k[0]; I1 = x[1] ^ k[1]; - I0 = ((uint32_t) SBOX1((I0 >> 24) & 0xFF) << 24) | - ((uint32_t) SBOX2((I0 >> 16) & 0xFF) << 16) | - ((uint32_t) SBOX3((I0 >> 8) & 0xFF) << 8) | - ((uint32_t) SBOX4((I0 ) & 0xFF) ); - I1 = ((uint32_t) SBOX2((I1 >> 24) & 0xFF) << 24) | - ((uint32_t) SBOX3((I1 >> 16) & 0xFF) << 16) | - ((uint32_t) SBOX4((I1 >> 8) & 0xFF) << 8) | - ((uint32_t) SBOX1((I1 ) & 0xFF) ); + I0 = ((uint32_t) SBOX1( MBEDTLS_BYTE_3( I0 )) << 24) | + ((uint32_t) SBOX2( MBEDTLS_BYTE_2( I0 )) << 16) | + ((uint32_t) SBOX3( MBEDTLS_BYTE_1( I0 )) << 8) | + ((uint32_t) SBOX4( MBEDTLS_BYTE_0( I0 )) ); + I1 = ((uint32_t) SBOX2( MBEDTLS_BYTE_3( I1 )) << 24) | + ((uint32_t) SBOX3( MBEDTLS_BYTE_2( I1 )) << 16) | + ((uint32_t) SBOX4( MBEDTLS_BYTE_1( I1 )) << 8) | + ((uint32_t) SBOX1( MBEDTLS_BYTE_0( I1 )) ); I0 ^= (I1 << 8) | (I1 >> 24); I1 ^= (I0 << 16) | (I0 >> 16); diff --git a/library/ccm.c b/library/ccm.c index 424ee77b69..95d90dc61a 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -200,7 +200,7 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, memcpy( b + 1, iv, iv_len ); for( i = 0, len_left = length; i < q; i++, len_left >>= 8 ) - b[15-i] = (unsigned char)( len_left & 0xFF ); + b[15-i] = MBEDTLS_CHAR_0( len_left ); if( len_left > 0 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); @@ -221,8 +221,8 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, src = add; memset( b, 0, 16 ); - b[0] = (unsigned char)( ( add_len >> 8 ) & 0xFF ); - b[1] = (unsigned char)( ( add_len ) & 0xFF ); + b[0] = MBEDTLS_CHAR_1( add_len ); + b[1] = MBEDTLS_CHAR_0( add_len ); use_len = len_left < 16 - 2 ? len_left : 16 - 2; memcpy( b + 2, src, use_len ); diff --git a/library/common.h b/library/common.h index 4ecc0162bf..56c3002653 100644 --- a/library/common.h +++ b/library/common.h @@ -77,6 +77,15 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #define MBEDTLS_BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) ) #define MBEDTLS_BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) +#define MBEDTLS_CHAR_0( x ) ( (unsigned char) ( ( x ) & 0xff ) ) +#define MBEDTLS_CHAR_1( x ) ( (unsigned char) ( ( ( x ) >> 8 ) & 0xff ) ) +#define MBEDTLS_CHAR_2( x ) ( (unsigned char) ( ( ( x ) >> 16 ) & 0xff ) ) +#define MBEDTLS_CHAR_3( x ) ( (unsigned char) ( ( ( x ) >> 24 ) & 0xff ) ) +#define MBEDTLS_CHAR_4( x ) ( (unsigned char) ( ( ( x ) >> 32 ) & 0xff ) ) +#define MBEDTLS_CHAR_5( x ) ( (unsigned char) ( ( ( x ) >> 40 ) & 0xff ) ) +#define MBEDTLS_CHAR_6( x ) ( (unsigned char) ( ( ( x ) >> 48 ) & 0xff ) ) +#define MBEDTLS_CHAR_7( x ) ( (unsigned char) ( ( ( x ) >> 56 ) & 0xff ) ) + /** * 32-bit integer manipulation GET macros (big endian) * diff --git a/library/ecjpake.c b/library/ecjpake.c index d229311420..7305dfeee1 100644 --- a/library/ecjpake.c +++ b/library/ecjpake.c @@ -180,10 +180,10 @@ static int ecjpake_write_len_point( unsigned char **p, if( ret != 0 ) return( ret ); - (*p)[0] = (unsigned char)( ( len >> 24 ) & 0xFF ); - (*p)[1] = (unsigned char)( ( len >> 16 ) & 0xFF ); - (*p)[2] = (unsigned char)( ( len >> 8 ) & 0xFF ); - (*p)[3] = (unsigned char)( ( len ) & 0xFF ); + (*p)[0] = MBEDTLS_CHAR_3( len ); + (*p)[1] = MBEDTLS_CHAR_2( len ); + (*p)[2] = MBEDTLS_CHAR_1( len ); + (*p)[3] = MBEDTLS_CHAR_0( len ); *p += 4 + len; @@ -223,10 +223,10 @@ static int ecjpake_hash( const mbedtls_md_info_t *md_info, if( end - p < 4 ) return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); - *p++ = (unsigned char)( ( id_len >> 24 ) & 0xFF ); - *p++ = (unsigned char)( ( id_len >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( id_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( id_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_3( id_len ); + *p++ = MBEDTLS_CHAR_2( id_len ); + *p++ = MBEDTLS_CHAR_1( id_len ); + *p++ = MBEDTLS_CHAR_0( id_len ); if( end < p || (size_t)( end - p ) < id_len ) return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); @@ -366,7 +366,7 @@ static int ecjpake_zkp_write( const mbedtls_md_info_t *md_info, goto cleanup; } - *(*p)++ = (unsigned char)( len & 0xFF ); + *(*p)++ = MBEDTLS_CHAR_0( len ); MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &h, *p, len ) ); /* r */ *p += len; diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 59c5460429..7d65479efb 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -136,18 +136,18 @@ static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl, * } ServerNameList; * */ - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SERVERNAME >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SERVERNAME ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SERVERNAME ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SERVERNAME ); - *p++ = (unsigned char)( ( (hostname_len + 5) >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( (hostname_len + 5) ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( hostname_len + 5); + *p++ = MBEDTLS_CHAR_0( hostname_len + 5); - *p++ = (unsigned char)( ( (hostname_len + 3) >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( (hostname_len + 3) ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( hostname_len + 3 ); + *p++ = MBEDTLS_CHAR_0( hostname_len + 3 ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ) & 0xFF ); - *p++ = (unsigned char)( ( hostname_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( hostname_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ); + *p++ = MBEDTLS_CHAR_1( hostname_len ); + *p++ = MBEDTLS_CHAR_0( hostname_len ); memcpy( p, ssl->hostname, hostname_len ); @@ -181,14 +181,12 @@ static int ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, /* * Secure renegotiation */ - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO >> 8 ) - & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ) - & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); *p++ = 0x00; - *p++ = ( ssl->verify_data_len + 1 ) & 0xFF; - *p++ = ssl->verify_data_len & 0xFF; + *p++ = MBEDTLS_CHAR_0( ssl->verify_data_len + 1 ); + *p++ = MBEDTLS_CHAR_0( ssl->verify_data_len ); memcpy( p, ssl->own_verify_data, ssl->verify_data_len ); @@ -283,14 +281,14 @@ static int ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, * SignatureAndHashAlgorithm * supported_signature_algorithms<2..2^16-2>; */ - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SIG_ALG >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SIG_ALG ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SIG_ALG ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SIG_ALG ); - *p++ = (unsigned char)( ( ( sig_alg_len + 2 ) >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ( sig_alg_len + 2 ) ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( sig_alg_len + 2 ); + *p++ = MBEDTLS_CHAR_0( sig_alg_len + 2 ); - *p++ = (unsigned char)( ( sig_alg_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( sig_alg_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( sig_alg_len ); + *p++ = MBEDTLS_CHAR_0( sig_alg_len ); *olen = 6 + sig_alg_len; @@ -358,16 +356,14 @@ static int ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl, elliptic_curve_list[elliptic_curve_len++] = info->tls_id & 0xFF; } - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES >> 8 ) - & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ) - & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); - *p++ = (unsigned char)( ( ( elliptic_curve_len + 2 ) >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ( elliptic_curve_len + 2 ) ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( elliptic_curve_len + 2 ); + *p++ = MBEDTLS_CHAR_0( elliptic_curve_len + 2 ); - *p++ = (unsigned char)( ( ( elliptic_curve_len ) >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ( elliptic_curve_len ) ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( elliptic_curve_len ); + *p++ = MBEDTLS_CHAR_0( elliptic_curve_len ); *olen = 6 + elliptic_curve_len; @@ -388,10 +384,8 @@ static int ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, ( "client hello, adding supported_point_formats extension" ) ); MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS >> 8 ) - & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ) - & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); *p++ = 0x00; *p++ = 2; @@ -427,8 +421,8 @@ static int ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); /* * We may need to send ClientHello multiple times for Hello verification. @@ -470,8 +464,8 @@ static int ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, memcpy( p + 2, ssl->handshake->ecjpake_cache, kkpp_len ); } - *p++ = (unsigned char)( ( kkpp_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( kkpp_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( kkpp_len ); + *p++ = MBEDTLS_CHAR_0( kkpp_len ); *olen = kkpp_len + 4; @@ -510,11 +504,11 @@ static int ssl_write_cid_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, (unsigned)( ssl->own_cid_len + 5 ) ); /* Add extension ID + size */ - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_CID >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_CID ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_CID ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_CID ); ext_len = (size_t) ssl->own_cid_len + 1; - *p++ = (unsigned char)( ( ext_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ext_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( ext_len ); + *p++ = MBEDTLS_CHAR_0( ext_len ); *p++ = (uint8_t) ssl->own_cid_len; memcpy( p, ssl->own_cid, ssl->own_cid_len ); @@ -543,10 +537,8 @@ static int ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 5 ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH >> 8 ) - & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ) - & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); *p++ = 0x00; *p++ = 1; @@ -577,8 +569,8 @@ static int ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); *p++ = 0x00; *p++ = 0x00; @@ -607,10 +599,8 @@ static int ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET >> 8 ) - & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ) - & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); *p++ = 0x00; *p++ = 0x00; @@ -641,11 +631,11 @@ static int ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, /* The addition is safe here since the ticket length is 16 bit. */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 + tlen ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SESSION_TICKET ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SESSION_TICKET ); - *p++ = (unsigned char)( ( tlen >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( tlen ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( tlen ); + *p++ = MBEDTLS_CHAR_0( tlen ); *olen = 4; @@ -685,8 +675,8 @@ static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 + alpnlen ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ALPN ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ALPN ); /* * opaque ProtocolName<1..2^8-1>; @@ -713,12 +703,12 @@ static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl, *olen = p - buf; /* List length = olen - 2 (ext_type) - 2 (ext_len) - 2 (list_len) */ - buf[4] = (unsigned char)( ( ( *olen - 6 ) >> 8 ) & 0xFF ); - buf[5] = (unsigned char)( ( ( *olen - 6 ) ) & 0xFF ); + buf[4] = MBEDTLS_CHAR_1( *olen - 6 ); + buf[5] = MBEDTLS_CHAR_0( *olen - 6 ); /* Extension length = olen - 2 (ext_type) - 2 (ext_len) */ - buf[2] = (unsigned char)( ( ( *olen - 4 ) >> 8 ) & 0xFF ); - buf[3] = (unsigned char)( ( ( *olen - 4 ) ) & 0xFF ); + buf[2] = MBEDTLS_CHAR_1( *olen - 4 ); + buf[3] = MBEDTLS_CHAR_0( *olen - 4 ); return( 0 ); } @@ -770,12 +760,12 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, ext_len + 4 ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_USE_SRTP >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_USE_SRTP ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_USE_SRTP ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_USE_SRTP ); - *p++ = (unsigned char)( ( ( ext_len & 0xFF00 ) >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ext_len & 0xFF ); + *p++ = MBEDTLS_CHAR_1( ext_len & 0xFF00 ); + *p++ = MBEDTLS_CHAR_0( ext_len ); /* protection profile length: 2*(ssl->conf->dtls_srtp_profile_list_len) */ /* micro-optimization: @@ -786,8 +776,7 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, * >> 8 ) & 0xFF ); */ *p++ = 0; - *p++ = (unsigned char)( ( 2 * ssl->conf->dtls_srtp_profile_list_len ) - & 0xFF ); + *p++ = MBEDTLS_CHAR_0( 2 * ssl->conf->dtls_srtp_profile_list_len ); for( protection_profiles_index=0; protection_profiles_index < ssl->conf->dtls_srtp_profile_list_len; @@ -799,8 +788,8 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, { MBEDTLS_SSL_DEBUG_MSG( 3, ( "ssl_write_use_srtp_ext, add profile: %04x", profile_value ) ); - *p++ = ( ( profile_value >> 8 ) & 0xFF ); - *p++ = ( profile_value & 0xFF ); + *p++ = MBEDTLS_BYTE_1( profile_value ); + *p++ = MBEDTLS_BYTE_0( profile_value ); } else { @@ -1334,8 +1323,8 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) { /* No need to check for space here, because the extension * writing functions already took care of that. */ - *p++ = (unsigned char)( ( ext_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ext_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( ext_len ); + *p++ = MBEDTLS_CHAR_0( ext_len ); p += ext_len; } diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 77904e0a1b..e0c50bcce1 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -454,15 +454,15 @@ static void ssl_extract_add_data_from_record( unsigned char* add_data, *cur = rec->cid_len; cur++; - cur[0] = ( ad_len_field >> 8 ) & 0xFF; - cur[1] = ( ad_len_field >> 0 ) & 0xFF; + cur[0] = MBEDTLS_CHAR_1( ad_len_field ); + cur[1] = MBEDTLS_CHAR_0( ad_len_field ); cur += 2; } else #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ { - cur[0] = ( ad_len_field >> 8 ) & 0xFF; - cur[1] = ( ad_len_field >> 0 ) & 0xFF; + cur[0] = MBEDTLS_CHAR_1( ad_len_field ); + cur[1] = MBEDTLS_CHAR_0( ad_len_field ); cur += 2; } @@ -2481,8 +2481,8 @@ int mbedtls_ssl_write_handshake_msg_ext( mbedtls_ssl_context *ssl, /* Write message_seq and update it, except for HelloRequest */ if( hs_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) { - ssl->out_msg[4] = ( ssl->handshake->out_msg_seq >> 8 ) & 0xFF; - ssl->out_msg[5] = ( ssl->handshake->out_msg_seq ) & 0xFF; + ssl->out_msg[4] = MBEDTLS_CHAR_1( ssl->handshake->out_msg_seq ); + ssl->out_msg[5] = MBEDTLS_CHAR_0( ssl->handshake->out_msg_seq ); ++( ssl->handshake->out_msg_seq ); } else diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 3d6739342d..253ab56959 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1848,8 +1848,8 @@ read_record_header: for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) for( i = 0; ciphersuites[i] != 0; i++ ) { - if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) || - p[1] != ( ( ciphersuites[i] ) & 0xFF ) ) + if( p[0] != MBEDTLS_BYTE_1( ciphersuites[i] ) || + p[1] != MBEDTLS_BYTE_0( ciphersuites[i] )) continue; got_common_suite = 1; @@ -1865,8 +1865,8 @@ read_record_header: for( i = 0; ciphersuites[i] != 0; i++ ) for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) { - if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) || - p[1] != ( ( ciphersuites[i] ) & 0xFF ) ) + if( p[0] != MBEDTLS_BYTE_1( ciphersuites[i] ) || + p[1] != MBEDTLS_BYTE_0( ciphersuites[i] )) continue; got_common_suite = 1; @@ -1971,11 +1971,11 @@ static void ssl_write_cid_ext( mbedtls_ssl_context *ssl, * } ConnectionId; */ - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_CID >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_CID ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_CID ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_CID ); ext_len = (size_t) ssl->own_cid_len + 1; - *p++ = (unsigned char)( ( ext_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ext_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( ext_len ); + *p++ = MBEDTLS_CHAR_0( ext_len ); *p++ = (uint8_t) ssl->own_cid_len; memcpy( p, ssl->own_cid, ssl->own_cid_len ); @@ -2016,8 +2016,8 @@ static void ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding encrypt then mac extension" ) ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); *p++ = 0x00; *p++ = 0x00; @@ -2042,8 +2042,8 @@ static void ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding extended master secret " "extension" ) ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); *p++ = 0x00; *p++ = 0x00; @@ -2067,8 +2067,8 @@ static void ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding session ticket extension" ) ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SESSION_TICKET ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SESSION_TICKET ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SESSION_TICKET ); *p++ = 0x00; *p++ = 0x00; @@ -2091,8 +2091,8 @@ static void ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, secure renegotiation extension" ) ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); #if defined(MBEDTLS_SSL_RENEGOTIATION) if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) @@ -2132,8 +2132,8 @@ static void ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, max_fragment_length extension" ) ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); *p++ = 0x00; *p++ = 1; @@ -2162,8 +2162,8 @@ static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, supported_point_formats extension" ) ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); *p++ = 0x00; *p++ = 2; @@ -2200,8 +2200,8 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, return; } - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); + *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); ret = mbedtls_ecjpake_write_round_one( &ssl->handshake->ecjpake_ctx, p + 2, end - p - 2, &kkpp_len, @@ -2212,8 +2212,8 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, return; } - *p++ = (unsigned char)( ( kkpp_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( kkpp_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( kkpp_len ); + *p++ = MBEDTLS_CHAR_0( kkpp_len ); *olen = kkpp_len + 4; } @@ -2238,18 +2238,18 @@ static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl, * 6 . 6 protocol name length * 7 . 7+n protocol name */ - buf[0] = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN >> 8 ) & 0xFF ); - buf[1] = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN ) & 0xFF ); + buf[0] = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ALPN ); + buf[1] = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ALPN ); *olen = 7 + strlen( ssl->alpn_chosen ); - buf[2] = (unsigned char)( ( ( *olen - 4 ) >> 8 ) & 0xFF ); - buf[3] = (unsigned char)( ( ( *olen - 4 ) ) & 0xFF ); + buf[2] = MBEDTLS_CHAR_1( *olen - 4 ); + buf[3] = MBEDTLS_CHAR_0( *olen - 4 ); - buf[4] = (unsigned char)( ( ( *olen - 6 ) >> 8 ) & 0xFF ); - buf[5] = (unsigned char)( ( ( *olen - 6 ) ) & 0xFF ); + buf[4] = MBEDTLS_CHAR_1( *olen - 6 ); + buf[5] = MBEDTLS_CHAR_0( *olen - 6 ); - buf[6] = (unsigned char)( ( ( *olen - 7 ) ) & 0xFF ); + buf[6] = MBEDTLS_CHAR_0( *olen - 7 ); memcpy( buf + 7, ssl->alpn_chosen, *olen - 7 ); } @@ -2294,15 +2294,15 @@ static void ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, } /* extension */ - buf[0] = (unsigned char)( ( MBEDTLS_TLS_EXT_USE_SRTP >> 8 ) & 0xFF ); - buf[1] = (unsigned char)( ( MBEDTLS_TLS_EXT_USE_SRTP ) & 0xFF ); + buf[0] = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_USE_SRTP ); + buf[1] = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_USE_SRTP ); /* * total length 5 and mki value: only one profile(2 bytes) * and length(2 bytes) and srtp_mki ) */ ext_len = 5 + mki_len; - buf[2] = (unsigned char)( ( ext_len >> 8 ) & 0xFF ); - buf[3] = (unsigned char)( ext_len & 0xFF ); + buf[2] = MBEDTLS_CHAR_1( ext_len ); + buf[3] = MBEDTLS_CHAR_0( ext_len ); /* protection profile length: 2 */ buf[4] = 0x00; @@ -2311,8 +2311,8 @@ static void ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, ssl->dtls_srtp_info.chosen_dtls_srtp_profile ); if( profile_value != MBEDTLS_TLS_SRTP_UNSET ) { - buf[6] = (unsigned char)( ( profile_value >> 8 ) & 0xFF ); - buf[7] = (unsigned char)( profile_value & 0xFF ); + buf[6] = MBEDTLS_CHAR_1( profile_value ); + buf[7] = MBEDTLS_CHAR_0( profile_value ); } else { @@ -2648,8 +2648,8 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) if( ext_len > 0 ) { - *p++ = (unsigned char)( ( ext_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ext_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( ext_len ); + *p++ = MBEDTLS_CHAR_0( ext_len ); p += ext_len; } @@ -3478,8 +3478,8 @@ static int ssl_decrypt_encrypted_pms( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } - if( *p++ != ( ( len >> 8 ) & 0xFF ) || - *p++ != ( ( len ) & 0xFF ) ) + if( *p++ != MBEDTLS_CHAR_1( len ) || + *p++ != MBEDTLS_CHAR_0( len ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); @@ -4223,13 +4223,13 @@ static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl ) tlen = 0; } - ssl->out_msg[4] = ( lifetime >> 24 ) & 0xFF; - ssl->out_msg[5] = ( lifetime >> 16 ) & 0xFF; - ssl->out_msg[6] = ( lifetime >> 8 ) & 0xFF; - ssl->out_msg[7] = ( lifetime ) & 0xFF; + ssl->out_msg[4] = MBEDTLS_CHAR_3( lifetime ); + ssl->out_msg[5] = MBEDTLS_CHAR_2( lifetime ); + ssl->out_msg[6] = MBEDTLS_CHAR_1( lifetime ); + ssl->out_msg[7] = MBEDTLS_CHAR_0( lifetime ); - ssl->out_msg[8] = (unsigned char)( ( tlen >> 8 ) & 0xFF ); - ssl->out_msg[9] = (unsigned char)( ( tlen ) & 0xFF ); + ssl->out_msg[8] = MBEDTLS_CHAR_1( tlen ); + ssl->out_msg[9] = MBEDTLS_CHAR_0( tlen ); ssl->out_msglen = 10 + tlen; diff --git a/library/ssl_tls.c b/library/ssl_tls.c index f8cad4aeca..0655dc57eb 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -4582,8 +4582,8 @@ static unsigned char ssl_serialized_session_header[] = { MBEDTLS_VERSION_MAJOR, MBEDTLS_VERSION_MINOR, MBEDTLS_VERSION_PATCH, - ( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG >> 8 ) & 0xFF, - ( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG >> 0 ) & 0xFF, + MBEDTLS_CHAR_1( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), + MBEDTLS_CHAR_0( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), }; /* @@ -4664,14 +4664,14 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, { start = (uint64_t) session->start; - *p++ = (unsigned char)( ( start >> 56 ) & 0xFF ); - *p++ = (unsigned char)( ( start >> 48 ) & 0xFF ); - *p++ = (unsigned char)( ( start >> 40 ) & 0xFF ); - *p++ = (unsigned char)( ( start >> 32 ) & 0xFF ); - *p++ = (unsigned char)( ( start >> 24 ) & 0xFF ); - *p++ = (unsigned char)( ( start >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( start >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( start ) & 0xFF ); + *p++ = MBEDTLS_CHAR_7( start ); + *p++ = MBEDTLS_CHAR_6( start ); + *p++ = MBEDTLS_CHAR_5( start ); + *p++ = MBEDTLS_CHAR_4( start ); + *p++ = MBEDTLS_CHAR_3( start ); + *p++ = MBEDTLS_CHAR_2( start ); + *p++ = MBEDTLS_CHAR_1( start ); + *p++ = MBEDTLS_CHAR_0( start ); } #endif /* MBEDTLS_HAVE_TIME */ @@ -4687,22 +4687,22 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, if( used <= buf_len ) { - *p++ = (unsigned char)( ( session->ciphersuite >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( session->ciphersuite ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( session->ciphersuite ); + *p++ = MBEDTLS_CHAR_0( session->ciphersuite ); - *p++ = (unsigned char)( session->compression & 0xFF ); + *p++ = MBEDTLS_CHAR_0( session->compression ); - *p++ = (unsigned char)( session->id_len & 0xFF ); + *p++ = MBEDTLS_CHAR_0( session->id_len ); memcpy( p, session->id, 32 ); p += 32; memcpy( p, session->master, 48 ); p += 48; - *p++ = (unsigned char)( ( session->verify_result >> 24 ) & 0xFF ); - *p++ = (unsigned char)( ( session->verify_result >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( session->verify_result >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( session->verify_result ) & 0xFF ); + *p++ = MBEDTLS_CHAR_3( session->verify_result ); + *p++ = MBEDTLS_CHAR_2( session->verify_result ); + *p++ = MBEDTLS_CHAR_1( session->verify_result ); + *p++ = MBEDTLS_CHAR_0( session->verify_result ); } /* @@ -4719,9 +4719,9 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, if( used <= buf_len ) { - *p++ = (unsigned char)( ( cert_len >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( cert_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( cert_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_2( cert_len ); + *p++ = MBEDTLS_CHAR_1( cert_len ); + *p++ = MBEDTLS_CHAR_0( cert_len ); if( session->peer_cert != NULL ) { @@ -4762,9 +4762,9 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, if( used <= buf_len ) { - *p++ = (unsigned char)( ( session->ticket_len >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( session->ticket_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( session->ticket_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_2( session->ticket_len ); + *p++ = MBEDTLS_CHAR_1( session->ticket_len ); + *p++ = MBEDTLS_CHAR_0( session->ticket_len ); if( session->ticket != NULL ) { @@ -4772,10 +4772,10 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, p += session->ticket_len; } - *p++ = (unsigned char)( ( session->ticket_lifetime >> 24 ) & 0xFF ); - *p++ = (unsigned char)( ( session->ticket_lifetime >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( session->ticket_lifetime >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( session->ticket_lifetime ) & 0xFF ); + *p++ = MBEDTLS_CHAR_3( session->ticket_lifetime ); + *p++ = MBEDTLS_CHAR_2( session->ticket_lifetime ); + *p++ = MBEDTLS_CHAR_1( session->ticket_lifetime ); + *p++ = MBEDTLS_CHAR_0( session->ticket_lifetime ); } #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ @@ -4793,7 +4793,7 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, used += 1; if( used <= buf_len ) - *p++ = (unsigned char)( ( session->encrypt_then_mac ) & 0xFF ); + *p++ = MBEDTLS_CHAR_0( session->encrypt_then_mac ); #endif return( used ); @@ -5568,11 +5568,11 @@ static unsigned char ssl_serialized_context_header[] = { MBEDTLS_VERSION_MAJOR, MBEDTLS_VERSION_MINOR, MBEDTLS_VERSION_PATCH, - ( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG >> 8 ) & 0xFF, - ( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG >> 0 ) & 0xFF, - ( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG >> 16 ) & 0xFF, - ( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG >> 8 ) & 0xFF, - ( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG >> 0 ) & 0xFF, + MBEDTLS_CHAR_1( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), + MBEDTLS_CHAR_0( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), + MBEDTLS_CHAR_2( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), + MBEDTLS_CHAR_1( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), + MBEDTLS_CHAR_0( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), }; /* @@ -5713,10 +5713,10 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 4 + session_len; if( used <= buf_len ) { - *p++ = (unsigned char)( ( session_len >> 24 ) & 0xFF ); - *p++ = (unsigned char)( ( session_len >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( session_len >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( session_len ) & 0xFF ); + *p++ = MBEDTLS_CHAR_3( session_len ); + *p++ = MBEDTLS_CHAR_2( session_len ); + *p++ = MBEDTLS_CHAR_1( session_len ); + *p++ = MBEDTLS_CHAR_0( session_len ); ret = ssl_session_save( ssl->session, 1, p, session_len, &session_len ); @@ -5757,33 +5757,33 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 4; if( used <= buf_len ) { - *p++ = (unsigned char)( ( ssl->badmac_seen >> 24 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->badmac_seen >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->badmac_seen >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->badmac_seen ) & 0xFF ); + *p++ = MBEDTLS_CHAR_3( ssl->badmac_seen ); + *p++ = MBEDTLS_CHAR_2( ssl->badmac_seen ); + *p++ = MBEDTLS_CHAR_1( ssl->badmac_seen ); + *p++ = MBEDTLS_CHAR_0( ssl->badmac_seen ); } #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) used += 16; if( used <= buf_len ) { - *p++ = (unsigned char)( ( ssl->in_window_top >> 56 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window_top >> 48 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window_top >> 40 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window_top >> 32 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window_top >> 24 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window_top >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window_top >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window_top ) & 0xFF ); + *p++ = MBEDTLS_CHAR_7( ssl->in_window_top ); + *p++ = MBEDTLS_CHAR_6( ssl->in_window_top ); + *p++ = MBEDTLS_CHAR_5( ssl->in_window_top ); + *p++ = MBEDTLS_CHAR_4( ssl->in_window_top ); + *p++ = MBEDTLS_CHAR_3( ssl->in_window_top ); + *p++ = MBEDTLS_CHAR_2( ssl->in_window_top ); + *p++ = MBEDTLS_CHAR_1( ssl->in_window_top ); + *p++ = MBEDTLS_CHAR_0( ssl->in_window_top ); - *p++ = (unsigned char)( ( ssl->in_window >> 56 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window >> 48 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window >> 40 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window >> 32 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window >> 24 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window >> 16 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->in_window ) & 0xFF ); + *p++ = MBEDTLS_CHAR_7( ssl->in_window ); + *p++ = MBEDTLS_CHAR_6( ssl->in_window ); + *p++ = MBEDTLS_CHAR_5( ssl->in_window ); + *p++ = MBEDTLS_CHAR_4( ssl->in_window ); + *p++ = MBEDTLS_CHAR_3( ssl->in_window ); + *p++ = MBEDTLS_CHAR_2( ssl->in_window ); + *p++ = MBEDTLS_CHAR_1( ssl->in_window ); + *p++ = MBEDTLS_CHAR_0( ssl->in_window ); } #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ @@ -5806,8 +5806,8 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 2; if( used <= buf_len ) { - *p++ = (unsigned char)( ( ssl->mtu >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( ssl->mtu ) & 0xFF ); + *p++ = MBEDTLS_CHAR_1( ssl->mtu ); + *p++ = MBEDTLS_CHAR_0( ssl->mtu ); } #endif /* MBEDTLS_SSL_PROTO_DTLS */ diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 902f99ea81..9e629cb0b3 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -113,17 +113,17 @@ static void ssl_tls1_3_hkdf_encode_label( #endif *p++ = 0; - *p++ = (unsigned char)( ( desired_length >> 0 ) & 0xFF ); + *p++ = MBEDTLS_CHAR_0( desired_length ); /* Add label incl. prefix */ - *p++ = (unsigned char)( total_label_len & 0xFF ); + *p++ = MBEDTLS_CHAR_0( total_label_len ); memcpy( p, tls1_3_label_prefix, sizeof(tls1_3_label_prefix) ); p += sizeof(tls1_3_label_prefix); memcpy( p, label, llen ); p += llen; /* Add context value */ - *p++ = (unsigned char)( clen & 0xFF ); + *p++ = MBEDTLS_CHAR_0( clen ); if( clen != 0 ) memcpy( p, ctx, clen ); From 635231a71ef0a055bad5dd46e66bfdcff1027c98 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 14 Jul 2021 11:53:07 +0100 Subject: [PATCH 316/966] Improve common.h macro documentation Imrpoved the descriptions of the macros and parameters and changing the name of the MBEDTLS_PUT_UINT... macro parameters to be more descriptive Signed-off-by: Joe Subbiani --- library/common.h | 140 ++++++++++++++++++----------------------------- 1 file changed, 52 insertions(+), 88 deletions(-) diff --git a/library/common.h b/library/common.h index 56c3002653..f7a9c9da6d 100644 --- a/library/common.h +++ b/library/common.h @@ -87,18 +87,13 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #define MBEDTLS_CHAR_7( x ) ( (unsigned char) ( ( ( x ) >> 56 ) & 0xff ) ) /** - * 32-bit integer manipulation GET macros (big endian) + * Get the unsigned 32 bits integer corresponding to four bytes in + * big-endian order (MSB first). * - * \brief Use this to assign an unsigned 32 bit integer - * by taking data stored adjacent in memory that - * can be accessed via on offset - * Big Endian is used when wanting to - * transmit the most signifcant bits first - * - * \param data The data used to translate to a 32 bit - * integer - * \param offset the shift in bytes to access the next byte - * of data + * \param data Base address of the memory to get the four bytes from. + * \param offset Offset from \p base of the first and most significant + * byte of the four bytes to build the 32 bits unsigned + * integer from. */ #ifndef MBEDTLS_GET_UINT32_BE #define MBEDTLS_GET_UINT32_BE( data , offset ) \ @@ -111,44 +106,32 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * 32-bit integer manipulation PUT macros (big endian) + * Put in memory a 32 bits unsigned integer in big-endian order. * - * \brief Read from a 32 bit integer and store each byte - * in memory, offset by a specified amount, resulting - * in each byte being adjacent in memory. - * Big Endian is used when wanting to - * transmit the most signifcant bits first - * - * \param n 32 bit integer where data is accessed - * \param b const unsigned char array of data to be - * manipulated - * \param i offset in bytes, In the case of UINT32, i - * would increment by 4 every use assuming - * the data is being stored in the same location + * \param n 32 bits unsigned integer to put in memory + * \param data Base address of the memory where to put the 32 + * bits unsigned integer in. + * \param offset Offset from \p base where to put the most significant + * byte of the 32 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT32_BE -#define MBEDTLS_PUT_UINT32_BE(n,b,i) \ - do { \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ +#define MBEDTLS_PUT_UINT32_BE( n, data, offset ) \ + do { \ + ( data )[( offset ) ] = (unsigned char) ( (n) >> 24 ); \ + ( data )[( offset ) + 1] = (unsigned char) ( (n) >> 16 ); \ + ( data )[( offset ) + 2] = (unsigned char) ( (n) >> 8 ); \ + ( data )[( offset ) + 3] = (unsigned char) ( (n) ); \ } while( 0 ) #endif /** - * 32-bit integer manipulation GET macros (little endian) + * Get the unsigned 32 bits integer corresponding to four bytes in + * little-endian order (LSB first). * - * \brief Use this to assign an unsigned 32 bit integer - * by taking data stored adjacent in memory that - * can be accessed via on offset - * Little Endian is used when wanting to - * transmit the least signifcant bits first - * - * \param data The data used to translate to a 32 bit - * integer - * \param offset the shift in bytes to access the next byte - * of data + * \param data Base address of the memory to get the four bytes from. + * \param offset Offset from \p base of the first and least significant + * byte of the four bytes to build the 32 bits unsigned + * integer from. */ #ifndef MBEDTLS_GET_UINT32_LE #define MBEDTLS_GET_UINT32_LE( data, offset ) \ @@ -161,44 +144,32 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * 32-bit integer manipulation PUT macros (little endian) + * Put in memory a 32 bits unsigned integer in little-endian order. * - * \brief Read from a 32 bit integer and store each byte - * in memory, offset by a specified amount, resulting - * in each byte being adjacent in memory. - * Little Endian is used when wanting to - * transmit the least signifcant bits first - * - * \param n 32 bit integer where data is accessed - * \param b const unsigned char array of data to be - * manipulated - * \param i offset in bytes, In the case of UINT32, i - * would increment by 4 every use assuming - * the data is being stored in the same location + * \param n 32 bits unsigned integer to put in memory + * \param data Base address of the memory where to put the 32 + * bits unsigned integer in. + * \param offset Offset from \p base where to put the least significant + * byte of the 32 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT32_LE -#define MBEDTLS_PUT_UINT32_LE(n,b,i) \ - do { \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ - (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ +#define MBEDTLS_PUT_UINT32_LE( n, data, offset ) \ + do { \ + ( data )[( offset ) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + ( data )[( offset ) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + ( data )[( offset ) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ + ( data )[( offset ) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ } while( 0 ) #endif /** - * 16-bit integer manipulation GET macros (little endian) + * Get the unsigned 16 bits integer corresponding to four bytes in + * little-endian order (LSB first). * - * \brief Use this to assign an unsigned 16 bit integer - * by taking data stored adjacent in memory that - * can be accessed via on offset - * Little Endian is used when wanting to - * transmit the least signifcant bits first - * - * \param data The data used to translate to a 16 bit - * integer - * \param offset the shit in bytes to access the next byte - * of data + * \param data Base address of the memory to get the four bytes from. + * \param offset Offset from \p base of the first and least significant + * byte of the four bytes to build the 16 bits unsigned + * integer from. */ #ifndef MBEDTLS_GET_UINT16_LE #define MBEDTLS_GET_UINT16_LE( data, offset ) \ @@ -209,26 +180,19 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * 16-bit integer manipulation PUT macros (little endian) + * Put in memory a 16 bits unsigned integer in little-endian order. * - * \brief Read from a 16 bit integer and store each byte - * in memory, offset by a specified amount, resulting - * in each byte being adjacent in memory. - * Little Endian is used when wanting to - * transmit the least signifcant bits first - * - * \param n 16 bit integer where data is accessed - * \param b const unsigned char array of data to be - * manipulated - * \param i offset in bytes, In the case of UINT16, i - * would increment by 2 every use assuming - * the data is being stored in the same location + * \param n 16 bits unsigned integer to put in memory + * \param data Base address of the memory where to put the 16 + * bits unsigned integer in. + * \param offset Offset from \p base where to put the least significant + * byte of the 16 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT16_LE -#define MBEDTLS_PUT_UINT16_LE( n, b, i ) \ -{ \ - (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ +#define MBEDTLS_PUT_UINT16_LE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + ( data )[( offset ) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ } #endif From 54550f7fca255769c4a2d9f5e089caddde4b0c6c Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 14 Jul 2021 11:59:48 +0100 Subject: [PATCH 317/966] Replace 3 byte shift with appropriate macro aria.c has a shift by 3 bytes, but does not use the 0xff masking. aparently this is not a problem and it is tidier to use the maco. Signed-off-by: Joe Subbiani --- library/aria.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/aria.c b/library/aria.c index 6bfdfbdce2..bc05c4a319 100644 --- a/library/aria.c +++ b/library/aria.c @@ -215,19 +215,19 @@ static inline void aria_sl( uint32_t *a, uint32_t *b, *a = ( (uint32_t) sa[ MBEDTLS_BYTE_0( *a ) ] ) ^ (((uint32_t) sb[ MBEDTLS_BYTE_1( *a ) ]) << 8) ^ (((uint32_t) sc[ MBEDTLS_BYTE_2( *a ) ]) << 16) ^ - (((uint32_t) sd[ *a >> 24 ]) << 24); + (((uint32_t) sd[ MBEDTLS_BYTE_3( *a ) ]) << 24); *b = ( (uint32_t) sa[ MBEDTLS_BYTE_0( *b ) ] ) ^ (((uint32_t) sb[ MBEDTLS_BYTE_1( *b ) ]) << 8) ^ (((uint32_t) sc[ MBEDTLS_BYTE_2( *b ) ]) << 16) ^ - (((uint32_t) sd[ *b >> 24 ]) << 24); + (((uint32_t) sd[ MBEDTLS_BYTE_3( *b ) ]) << 24); *c = ( (uint32_t) sa[ MBEDTLS_BYTE_0( *c ) ] ) ^ (((uint32_t) sb[ MBEDTLS_BYTE_1( *c ) ]) << 8) ^ (((uint32_t) sc[ MBEDTLS_BYTE_2( *c ) ]) << 16) ^ - (((uint32_t) sd[ *c >> 24 ]) << 24); + (((uint32_t) sd[ MBEDTLS_BYTE_3( *c ) ]) << 24); *d = ( (uint32_t) sa[ MBEDTLS_BYTE_0( *d ) ] ) ^ (((uint32_t) sb[ MBEDTLS_BYTE_1( *d ) ]) << 8) ^ (((uint32_t) sc[ MBEDTLS_BYTE_2( *d ) ]) << 16) ^ - (((uint32_t) sd[ *d >> 24 ]) << 24); + (((uint32_t) sd[ MBEDTLS_BYTE_3( *d ) ]) << 24); } /* From f5462d989c8674805d3566cf4d85029da0f18717 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Tue, 13 Jul 2021 12:13:19 +0100 Subject: [PATCH 318/966] Remove trailing whitespaces Signed-off-by: Joe Subbiani --- library/common.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/library/common.h b/library/common.h index f7a9c9da6d..87f0d66bc7 100644 --- a/library/common.h +++ b/library/common.h @@ -87,12 +87,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #define MBEDTLS_CHAR_7( x ) ( (unsigned char) ( ( ( x ) >> 56 ) & 0xff ) ) /** - * Get the unsigned 32 bits integer corresponding to four bytes in + * Get the unsigned 32 bits integer corresponding to four bytes in * big-endian order (MSB first). * * \param data Base address of the memory to get the four bytes from. - * \param offset Offset from \p base of the first and most significant - * byte of the four bytes to build the 32 bits unsigned + * \param offset Offset from \p base of the first and most significant + * byte of the four bytes to build the 32 bits unsigned * integer from. */ #ifndef MBEDTLS_GET_UINT32_BE @@ -108,10 +108,10 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c /** * Put in memory a 32 bits unsigned integer in big-endian order. * - * \param n 32 bits unsigned integer to put in memory - * \param data Base address of the memory where to put the 32 + * \param n 32 bits unsigned integer to put in memory. + * \param data Base address of the memory where to put the 32 * bits unsigned integer in. - * \param offset Offset from \p base where to put the most significant + * \param offset Offset from \p base where to put the most significant * byte of the 32 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT32_BE @@ -125,12 +125,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * Get the unsigned 32 bits integer corresponding to four bytes in + * Get the unsigned 32 bits integer corresponding to four bytes in * little-endian order (LSB first). * * \param data Base address of the memory to get the four bytes from. - * \param offset Offset from \p base of the first and least significant - * byte of the four bytes to build the 32 bits unsigned + * \param offset Offset from \p base of the first and least significant + * byte of the four bytes to build the 32 bits unsigned * integer from. */ #ifndef MBEDTLS_GET_UINT32_LE @@ -146,10 +146,10 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c /** * Put in memory a 32 bits unsigned integer in little-endian order. * - * \param n 32 bits unsigned integer to put in memory - * \param data Base address of the memory where to put the 32 + * \param n 32 bits unsigned integer to put in memory. + * \param data Base address of the memory where to put the 32 * bits unsigned integer in. - * \param offset Offset from \p base where to put the least significant + * \param offset Offset from \p base where to put the least significant * byte of the 32 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT32_LE @@ -163,12 +163,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * Get the unsigned 16 bits integer corresponding to four bytes in + * Get the unsigned 16 bits integer corresponding to four bytes in * little-endian order (LSB first). * * \param data Base address of the memory to get the four bytes from. - * \param offset Offset from \p base of the first and least significant - * byte of the four bytes to build the 16 bits unsigned + * \param offset Offset from \p base of the first and least significant + * byte of the four bytes to build the 16 bits unsigned * integer from. */ #ifndef MBEDTLS_GET_UINT16_LE @@ -182,10 +182,10 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c /** * Put in memory a 16 bits unsigned integer in little-endian order. * - * \param n 16 bits unsigned integer to put in memory - * \param data Base address of the memory where to put the 16 + * \param n 16 bits unsigned integer to put in memory. + * \param data Base address of the memory where to put the 16 * bits unsigned integer in. - * \param offset Offset from \p base where to put the least significant + * \param offset Offset from \p base where to put the least significant * byte of the 16 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT16_LE From bf7ea84f83d7fbef2103cae2564fe7258e6847c9 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 14 Jul 2021 12:05:51 +0100 Subject: [PATCH 319/966] Replace "four bytes" with "two bytes" in macro documentation When writing the documentation 4 bytes was written instead of 2 for MBEDTLS_UINT16_LE Signed-off-by: Joe Subbiani --- library/common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/common.h b/library/common.h index 87f0d66bc7..28017f9742 100644 --- a/library/common.h +++ b/library/common.h @@ -163,12 +163,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * Get the unsigned 16 bits integer corresponding to four bytes in + * Get the unsigned 16 bits integer corresponding to two bytes in * little-endian order (LSB first). * - * \param data Base address of the memory to get the four bytes from. + * \param data Base address of the memory to get the two bytes from. * \param offset Offset from \p base of the first and least significant - * byte of the four bytes to build the 16 bits unsigned + * byte of the two bytes to build the 16 bits unsigned * integer from. */ #ifndef MBEDTLS_GET_UINT16_LE From 2194dc477a65c0c18f592168b5e5f765c475bc9c Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 14 Jul 2021 12:31:31 +0100 Subject: [PATCH 320/966] Replace MBEDTLS_CHAR_x with MBEDTLS_BYTE_x The CHAR macros casted to an unsigned char which in this project is garunteed to be 8 bits - the same as uint8_t (which BYTE casts to) therefore, instances of CHAR have been swapped with BYTE and the number of macros have been cut down Signed-off-by: Joe Subbiani --- library/asn1write.c | 18 +++--- library/ccm.c | 6 +- library/common.h | 17 +++--- library/ecjpake.c | 18 +++--- library/ssl_cli.c | 116 ++++++++++++++++++------------------- library/ssl_msg.c | 4 +- library/ssl_srv.c | 86 ++++++++++++++-------------- library/ssl_tls.c | 120 +++++++++++++++++++-------------------- library/ssl_tls13_keys.c | 6 +- 9 files changed, 194 insertions(+), 197 deletions(-) diff --git a/library/asn1write.c b/library/asn1write.c index 8555767fe2..dc61854137 100644 --- a/library/asn1write.c +++ b/library/asn1write.c @@ -60,8 +60,8 @@ int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start, size_ if( *p - start < 3 ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); - *--(*p) = MBEDTLS_CHAR_0( len ); - *--(*p) = MBEDTLS_CHAR_1( len ); + *--(*p) = MBEDTLS_BYTE_0( len ); + *--(*p) = MBEDTLS_BYTE_1( len ); *--(*p) = 0x82; return( 3 ); } @@ -71,9 +71,9 @@ int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start, size_ if( *p - start < 4 ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); - *--(*p) = MBEDTLS_CHAR_0( len ); - *--(*p) = MBEDTLS_CHAR_1( len ); - *--(*p) = MBEDTLS_CHAR_2( len ); + *--(*p) = MBEDTLS_BYTE_0( len ); + *--(*p) = MBEDTLS_BYTE_1( len ); + *--(*p) = MBEDTLS_BYTE_2( len ); *--(*p) = 0x83; return( 4 ); } @@ -85,10 +85,10 @@ int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start, size_ if( *p - start < 5 ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); - *--(*p) = MBEDTLS_CHAR_0( len ); - *--(*p) = MBEDTLS_CHAR_1( len ); - *--(*p) = MBEDTLS_CHAR_2( len ); - *--(*p) = MBEDTLS_CHAR_3( len ); + *--(*p) = MBEDTLS_BYTE_0( len ); + *--(*p) = MBEDTLS_BYTE_1( len ); + *--(*p) = MBEDTLS_BYTE_2( len ); + *--(*p) = MBEDTLS_BYTE_3( len ); *--(*p) = 0x84; return( 5 ); } diff --git a/library/ccm.c b/library/ccm.c index 95d90dc61a..0188075f5e 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -200,7 +200,7 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, memcpy( b + 1, iv, iv_len ); for( i = 0, len_left = length; i < q; i++, len_left >>= 8 ) - b[15-i] = MBEDTLS_CHAR_0( len_left ); + b[15-i] = MBEDTLS_BYTE_0( len_left ); if( len_left > 0 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); @@ -221,8 +221,8 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, src = add; memset( b, 0, 16 ); - b[0] = MBEDTLS_CHAR_1( add_len ); - b[1] = MBEDTLS_CHAR_0( add_len ); + b[0] = MBEDTLS_BYTE_1( add_len ); + b[1] = MBEDTLS_BYTE_0( add_len ); use_len = len_left < 16 - 2 ? len_left : 16 - 2; memcpy( b + 2, src, use_len ); diff --git a/library/common.h b/library/common.h index 28017f9742..e0f8b99baa 100644 --- a/library/common.h +++ b/library/common.h @@ -25,6 +25,8 @@ #include "mbedtls/build_info.h" +#include + /** Helper to define a function as static except when building invasive tests. * * If a function is only used inside its own source file and should be @@ -72,19 +74,14 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * Using MBEDTLS_BYTE_a will shift a*8 bits * to retrieve the next byte of information */ -#define MBEDTLS_BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) +#define MBEDTLS_BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) #define MBEDTLS_BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) ) #define MBEDTLS_BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) ) #define MBEDTLS_BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) ) - -#define MBEDTLS_CHAR_0( x ) ( (unsigned char) ( ( x ) & 0xff ) ) -#define MBEDTLS_CHAR_1( x ) ( (unsigned char) ( ( ( x ) >> 8 ) & 0xff ) ) -#define MBEDTLS_CHAR_2( x ) ( (unsigned char) ( ( ( x ) >> 16 ) & 0xff ) ) -#define MBEDTLS_CHAR_3( x ) ( (unsigned char) ( ( ( x ) >> 24 ) & 0xff ) ) -#define MBEDTLS_CHAR_4( x ) ( (unsigned char) ( ( ( x ) >> 32 ) & 0xff ) ) -#define MBEDTLS_CHAR_5( x ) ( (unsigned char) ( ( ( x ) >> 40 ) & 0xff ) ) -#define MBEDTLS_CHAR_6( x ) ( (unsigned char) ( ( ( x ) >> 48 ) & 0xff ) ) -#define MBEDTLS_CHAR_7( x ) ( (unsigned char) ( ( ( x ) >> 56 ) & 0xff ) ) +#define MBEDTLS_BYTE_4( x ) ( (uint8_t) ( ( ( x ) >> 32 ) & 0xff ) ) +#define MBEDTLS_BYTE_5( x ) ( (uint8_t) ( ( ( x ) >> 40 ) & 0xff ) ) +#define MBEDTLS_BYTE_6( x ) ( (uint8_t) ( ( ( x ) >> 48 ) & 0xff ) ) +#define MBEDTLS_BYTE_7( x ) ( (uint8_t) ( ( ( x ) >> 56 ) & 0xff ) ) /** * Get the unsigned 32 bits integer corresponding to four bytes in diff --git a/library/ecjpake.c b/library/ecjpake.c index 7305dfeee1..a599b1ba48 100644 --- a/library/ecjpake.c +++ b/library/ecjpake.c @@ -180,10 +180,10 @@ static int ecjpake_write_len_point( unsigned char **p, if( ret != 0 ) return( ret ); - (*p)[0] = MBEDTLS_CHAR_3( len ); - (*p)[1] = MBEDTLS_CHAR_2( len ); - (*p)[2] = MBEDTLS_CHAR_1( len ); - (*p)[3] = MBEDTLS_CHAR_0( len ); + (*p)[0] = MBEDTLS_BYTE_3( len ); + (*p)[1] = MBEDTLS_BYTE_2( len ); + (*p)[2] = MBEDTLS_BYTE_1( len ); + (*p)[3] = MBEDTLS_BYTE_0( len ); *p += 4 + len; @@ -223,10 +223,10 @@ static int ecjpake_hash( const mbedtls_md_info_t *md_info, if( end - p < 4 ) return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); - *p++ = MBEDTLS_CHAR_3( id_len ); - *p++ = MBEDTLS_CHAR_2( id_len ); - *p++ = MBEDTLS_CHAR_1( id_len ); - *p++ = MBEDTLS_CHAR_0( id_len ); + *p++ = MBEDTLS_BYTE_3( id_len ); + *p++ = MBEDTLS_BYTE_2( id_len ); + *p++ = MBEDTLS_BYTE_1( id_len ); + *p++ = MBEDTLS_BYTE_0( id_len ); if( end < p || (size_t)( end - p ) < id_len ) return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); @@ -366,7 +366,7 @@ static int ecjpake_zkp_write( const mbedtls_md_info_t *md_info, goto cleanup; } - *(*p)++ = MBEDTLS_CHAR_0( len ); + *(*p)++ = MBEDTLS_BYTE_0( len ); MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &h, *p, len ) ); /* r */ *p += len; diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 7d65479efb..9e0db96c48 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -136,18 +136,18 @@ static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl, * } ServerNameList; * */ - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SERVERNAME ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SERVERNAME ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SERVERNAME ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SERVERNAME ); - *p++ = MBEDTLS_CHAR_1( hostname_len + 5); - *p++ = MBEDTLS_CHAR_0( hostname_len + 5); + *p++ = MBEDTLS_BYTE_1( hostname_len + 5); + *p++ = MBEDTLS_BYTE_0( hostname_len + 5); - *p++ = MBEDTLS_CHAR_1( hostname_len + 3 ); - *p++ = MBEDTLS_CHAR_0( hostname_len + 3 ); + *p++ = MBEDTLS_BYTE_1( hostname_len + 3 ); + *p++ = MBEDTLS_BYTE_0( hostname_len + 3 ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ); - *p++ = MBEDTLS_CHAR_1( hostname_len ); - *p++ = MBEDTLS_CHAR_0( hostname_len ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ); + *p++ = MBEDTLS_BYTE_1( hostname_len ); + *p++ = MBEDTLS_BYTE_0( hostname_len ); memcpy( p, ssl->hostname, hostname_len ); @@ -181,12 +181,12 @@ static int ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, /* * Secure renegotiation */ - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); *p++ = 0x00; - *p++ = MBEDTLS_CHAR_0( ssl->verify_data_len + 1 ); - *p++ = MBEDTLS_CHAR_0( ssl->verify_data_len ); + *p++ = MBEDTLS_BYTE_0( ssl->verify_data_len + 1 ); + *p++ = MBEDTLS_BYTE_0( ssl->verify_data_len ); memcpy( p, ssl->own_verify_data, ssl->verify_data_len ); @@ -281,14 +281,14 @@ static int ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, * SignatureAndHashAlgorithm * supported_signature_algorithms<2..2^16-2>; */ - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SIG_ALG ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SIG_ALG ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SIG_ALG ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SIG_ALG ); - *p++ = MBEDTLS_CHAR_1( sig_alg_len + 2 ); - *p++ = MBEDTLS_CHAR_0( sig_alg_len + 2 ); + *p++ = MBEDTLS_BYTE_1( sig_alg_len + 2 ); + *p++ = MBEDTLS_BYTE_0( sig_alg_len + 2 ); - *p++ = MBEDTLS_CHAR_1( sig_alg_len ); - *p++ = MBEDTLS_CHAR_0( sig_alg_len ); + *p++ = MBEDTLS_BYTE_1( sig_alg_len ); + *p++ = MBEDTLS_BYTE_0( sig_alg_len ); *olen = 6 + sig_alg_len; @@ -356,14 +356,14 @@ static int ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl, elliptic_curve_list[elliptic_curve_len++] = info->tls_id & 0xFF; } - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); - *p++ = MBEDTLS_CHAR_1( elliptic_curve_len + 2 ); - *p++ = MBEDTLS_CHAR_0( elliptic_curve_len + 2 ); + *p++ = MBEDTLS_BYTE_1( elliptic_curve_len + 2 ); + *p++ = MBEDTLS_BYTE_0( elliptic_curve_len + 2 ); - *p++ = MBEDTLS_CHAR_1( elliptic_curve_len ); - *p++ = MBEDTLS_CHAR_0( elliptic_curve_len ); + *p++ = MBEDTLS_BYTE_1( elliptic_curve_len ); + *p++ = MBEDTLS_BYTE_0( elliptic_curve_len ); *olen = 6 + elliptic_curve_len; @@ -384,8 +384,8 @@ static int ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, ( "client hello, adding supported_point_formats extension" ) ); MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); *p++ = 0x00; *p++ = 2; @@ -421,8 +421,8 @@ static int ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); /* * We may need to send ClientHello multiple times for Hello verification. @@ -464,8 +464,8 @@ static int ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, memcpy( p + 2, ssl->handshake->ecjpake_cache, kkpp_len ); } - *p++ = MBEDTLS_CHAR_1( kkpp_len ); - *p++ = MBEDTLS_CHAR_0( kkpp_len ); + *p++ = MBEDTLS_BYTE_1( kkpp_len ); + *p++ = MBEDTLS_BYTE_0( kkpp_len ); *olen = kkpp_len + 4; @@ -504,11 +504,11 @@ static int ssl_write_cid_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, (unsigned)( ssl->own_cid_len + 5 ) ); /* Add extension ID + size */ - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_CID ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_CID ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_CID ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_CID ); ext_len = (size_t) ssl->own_cid_len + 1; - *p++ = MBEDTLS_CHAR_1( ext_len ); - *p++ = MBEDTLS_CHAR_0( ext_len ); + *p++ = MBEDTLS_BYTE_1( ext_len ); + *p++ = MBEDTLS_BYTE_0( ext_len ); *p++ = (uint8_t) ssl->own_cid_len; memcpy( p, ssl->own_cid, ssl->own_cid_len ); @@ -537,8 +537,8 @@ static int ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 5 ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); *p++ = 0x00; *p++ = 1; @@ -569,8 +569,8 @@ static int ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); *p++ = 0x00; *p++ = 0x00; @@ -599,8 +599,8 @@ static int ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); *p++ = 0x00; *p++ = 0x00; @@ -631,11 +631,11 @@ static int ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, /* The addition is safe here since the ticket length is 16 bit. */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 + tlen ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SESSION_TICKET ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SESSION_TICKET ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SESSION_TICKET ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SESSION_TICKET ); - *p++ = MBEDTLS_CHAR_1( tlen ); - *p++ = MBEDTLS_CHAR_0( tlen ); + *p++ = MBEDTLS_BYTE_1( tlen ); + *p++ = MBEDTLS_BYTE_0( tlen ); *olen = 4; @@ -675,8 +675,8 @@ static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 + alpnlen ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ALPN ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ALPN ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ALPN ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ALPN ); /* * opaque ProtocolName<1..2^8-1>; @@ -703,12 +703,12 @@ static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl, *olen = p - buf; /* List length = olen - 2 (ext_type) - 2 (ext_len) - 2 (list_len) */ - buf[4] = MBEDTLS_CHAR_1( *olen - 6 ); - buf[5] = MBEDTLS_CHAR_0( *olen - 6 ); + buf[4] = MBEDTLS_BYTE_1( *olen - 6 ); + buf[5] = MBEDTLS_BYTE_0( *olen - 6 ); /* Extension length = olen - 2 (ext_type) - 2 (ext_len) */ - buf[2] = MBEDTLS_CHAR_1( *olen - 4 ); - buf[3] = MBEDTLS_CHAR_0( *olen - 4 ); + buf[2] = MBEDTLS_BYTE_1( *olen - 4 ); + buf[3] = MBEDTLS_BYTE_0( *olen - 4 ); return( 0 ); } @@ -760,12 +760,12 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, ext_len + 4 ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_USE_SRTP ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_USE_SRTP ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_USE_SRTP ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_USE_SRTP ); - *p++ = MBEDTLS_CHAR_1( ext_len & 0xFF00 ); - *p++ = MBEDTLS_CHAR_0( ext_len ); + *p++ = MBEDTLS_BYTE_1( ext_len & 0xFF00 ); + *p++ = MBEDTLS_BYTE_0( ext_len ); /* protection profile length: 2*(ssl->conf->dtls_srtp_profile_list_len) */ /* micro-optimization: @@ -776,7 +776,7 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, * >> 8 ) & 0xFF ); */ *p++ = 0; - *p++ = MBEDTLS_CHAR_0( 2 * ssl->conf->dtls_srtp_profile_list_len ); + *p++ = MBEDTLS_BYTE_0( 2 * ssl->conf->dtls_srtp_profile_list_len ); for( protection_profiles_index=0; protection_profiles_index < ssl->conf->dtls_srtp_profile_list_len; @@ -1323,8 +1323,8 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) { /* No need to check for space here, because the extension * writing functions already took care of that. */ - *p++ = MBEDTLS_CHAR_1( ext_len ); - *p++ = MBEDTLS_CHAR_0( ext_len ); + *p++ = MBEDTLS_BYTE_1( ext_len ); + *p++ = MBEDTLS_BYTE_0( ext_len ); p += ext_len; } diff --git a/library/ssl_msg.c b/library/ssl_msg.c index e0c50bcce1..989c59874f 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2481,8 +2481,8 @@ int mbedtls_ssl_write_handshake_msg_ext( mbedtls_ssl_context *ssl, /* Write message_seq and update it, except for HelloRequest */ if( hs_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) { - ssl->out_msg[4] = MBEDTLS_CHAR_1( ssl->handshake->out_msg_seq ); - ssl->out_msg[5] = MBEDTLS_CHAR_0( ssl->handshake->out_msg_seq ); + ssl->out_msg[4] = MBEDTLS_BYTE_1( ssl->handshake->out_msg_seq ); + ssl->out_msg[5] = MBEDTLS_BYTE_0( ssl->handshake->out_msg_seq ); ++( ssl->handshake->out_msg_seq ); } else diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 253ab56959..96b08ab8f6 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1971,11 +1971,11 @@ static void ssl_write_cid_ext( mbedtls_ssl_context *ssl, * } ConnectionId; */ - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_CID ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_CID ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_CID ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_CID ); ext_len = (size_t) ssl->own_cid_len + 1; - *p++ = MBEDTLS_CHAR_1( ext_len ); - *p++ = MBEDTLS_CHAR_0( ext_len ); + *p++ = MBEDTLS_BYTE_1( ext_len ); + *p++ = MBEDTLS_BYTE_0( ext_len ); *p++ = (uint8_t) ssl->own_cid_len; memcpy( p, ssl->own_cid, ssl->own_cid_len ); @@ -2016,8 +2016,8 @@ static void ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding encrypt then mac extension" ) ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); *p++ = 0x00; *p++ = 0x00; @@ -2042,8 +2042,8 @@ static void ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding extended master secret " "extension" ) ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); *p++ = 0x00; *p++ = 0x00; @@ -2067,8 +2067,8 @@ static void ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding session ticket extension" ) ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SESSION_TICKET ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SESSION_TICKET ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SESSION_TICKET ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SESSION_TICKET ); *p++ = 0x00; *p++ = 0x00; @@ -2091,8 +2091,8 @@ static void ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, secure renegotiation extension" ) ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); #if defined(MBEDTLS_SSL_RENEGOTIATION) if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) @@ -2132,8 +2132,8 @@ static void ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, max_fragment_length extension" ) ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); *p++ = 0x00; *p++ = 1; @@ -2162,8 +2162,8 @@ static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, supported_point_formats extension" ) ); - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); *p++ = 0x00; *p++ = 2; @@ -2200,8 +2200,8 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, return; } - *p++ = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); - *p++ = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); ret = mbedtls_ecjpake_write_round_one( &ssl->handshake->ecjpake_ctx, p + 2, end - p - 2, &kkpp_len, @@ -2212,8 +2212,8 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, return; } - *p++ = MBEDTLS_CHAR_1( kkpp_len ); - *p++ = MBEDTLS_CHAR_0( kkpp_len ); + *p++ = MBEDTLS_BYTE_1( kkpp_len ); + *p++ = MBEDTLS_BYTE_0( kkpp_len ); *olen = kkpp_len + 4; } @@ -2238,18 +2238,18 @@ static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl, * 6 . 6 protocol name length * 7 . 7+n protocol name */ - buf[0] = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_ALPN ); - buf[1] = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_ALPN ); + buf[0] = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ALPN ); + buf[1] = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ALPN ); *olen = 7 + strlen( ssl->alpn_chosen ); - buf[2] = MBEDTLS_CHAR_1( *olen - 4 ); - buf[3] = MBEDTLS_CHAR_0( *olen - 4 ); + buf[2] = MBEDTLS_BYTE_1( *olen - 4 ); + buf[3] = MBEDTLS_BYTE_0( *olen - 4 ); - buf[4] = MBEDTLS_CHAR_1( *olen - 6 ); - buf[5] = MBEDTLS_CHAR_0( *olen - 6 ); + buf[4] = MBEDTLS_BYTE_1( *olen - 6 ); + buf[5] = MBEDTLS_BYTE_0( *olen - 6 ); - buf[6] = MBEDTLS_CHAR_0( *olen - 7 ); + buf[6] = MBEDTLS_BYTE_0( *olen - 7 ); memcpy( buf + 7, ssl->alpn_chosen, *olen - 7 ); } @@ -2294,15 +2294,15 @@ static void ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, } /* extension */ - buf[0] = MBEDTLS_CHAR_1( MBEDTLS_TLS_EXT_USE_SRTP ); - buf[1] = MBEDTLS_CHAR_0( MBEDTLS_TLS_EXT_USE_SRTP ); + buf[0] = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_USE_SRTP ); + buf[1] = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_USE_SRTP ); /* * total length 5 and mki value: only one profile(2 bytes) * and length(2 bytes) and srtp_mki ) */ ext_len = 5 + mki_len; - buf[2] = MBEDTLS_CHAR_1( ext_len ); - buf[3] = MBEDTLS_CHAR_0( ext_len ); + buf[2] = MBEDTLS_BYTE_1( ext_len ); + buf[3] = MBEDTLS_BYTE_0( ext_len ); /* protection profile length: 2 */ buf[4] = 0x00; @@ -2311,8 +2311,8 @@ static void ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, ssl->dtls_srtp_info.chosen_dtls_srtp_profile ); if( profile_value != MBEDTLS_TLS_SRTP_UNSET ) { - buf[6] = MBEDTLS_CHAR_1( profile_value ); - buf[7] = MBEDTLS_CHAR_0( profile_value ); + buf[6] = MBEDTLS_BYTE_1( profile_value ); + buf[7] = MBEDTLS_BYTE_0( profile_value ); } else { @@ -2648,8 +2648,8 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) if( ext_len > 0 ) { - *p++ = MBEDTLS_CHAR_1( ext_len ); - *p++ = MBEDTLS_CHAR_0( ext_len ); + *p++ = MBEDTLS_BYTE_1( ext_len ); + *p++ = MBEDTLS_BYTE_0( ext_len ); p += ext_len; } @@ -3478,8 +3478,8 @@ static int ssl_decrypt_encrypted_pms( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } - if( *p++ != MBEDTLS_CHAR_1( len ) || - *p++ != MBEDTLS_CHAR_0( len ) ) + if( *p++ != MBEDTLS_BYTE_1( len ) || + *p++ != MBEDTLS_BYTE_0( len ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); @@ -4223,13 +4223,13 @@ static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl ) tlen = 0; } - ssl->out_msg[4] = MBEDTLS_CHAR_3( lifetime ); - ssl->out_msg[5] = MBEDTLS_CHAR_2( lifetime ); - ssl->out_msg[6] = MBEDTLS_CHAR_1( lifetime ); - ssl->out_msg[7] = MBEDTLS_CHAR_0( lifetime ); + ssl->out_msg[4] = MBEDTLS_BYTE_3( lifetime ); + ssl->out_msg[5] = MBEDTLS_BYTE_2( lifetime ); + ssl->out_msg[6] = MBEDTLS_BYTE_1( lifetime ); + ssl->out_msg[7] = MBEDTLS_BYTE_0( lifetime ); - ssl->out_msg[8] = MBEDTLS_CHAR_1( tlen ); - ssl->out_msg[9] = MBEDTLS_CHAR_0( tlen ); + ssl->out_msg[8] = MBEDTLS_BYTE_1( tlen ); + ssl->out_msg[9] = MBEDTLS_BYTE_0( tlen ); ssl->out_msglen = 10 + tlen; diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 0655dc57eb..381eb9e03b 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -4582,8 +4582,8 @@ static unsigned char ssl_serialized_session_header[] = { MBEDTLS_VERSION_MAJOR, MBEDTLS_VERSION_MINOR, MBEDTLS_VERSION_PATCH, - MBEDTLS_CHAR_1( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), - MBEDTLS_CHAR_0( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), + MBEDTLS_BYTE_1( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), + MBEDTLS_BYTE_0( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), }; /* @@ -4664,14 +4664,14 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, { start = (uint64_t) session->start; - *p++ = MBEDTLS_CHAR_7( start ); - *p++ = MBEDTLS_CHAR_6( start ); - *p++ = MBEDTLS_CHAR_5( start ); - *p++ = MBEDTLS_CHAR_4( start ); - *p++ = MBEDTLS_CHAR_3( start ); - *p++ = MBEDTLS_CHAR_2( start ); - *p++ = MBEDTLS_CHAR_1( start ); - *p++ = MBEDTLS_CHAR_0( start ); + *p++ = MBEDTLS_BYTE_7( start ); + *p++ = MBEDTLS_BYTE_6( start ); + *p++ = MBEDTLS_BYTE_5( start ); + *p++ = MBEDTLS_BYTE_4( start ); + *p++ = MBEDTLS_BYTE_3( start ); + *p++ = MBEDTLS_BYTE_2( start ); + *p++ = MBEDTLS_BYTE_1( start ); + *p++ = MBEDTLS_BYTE_0( start ); } #endif /* MBEDTLS_HAVE_TIME */ @@ -4687,22 +4687,22 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, if( used <= buf_len ) { - *p++ = MBEDTLS_CHAR_1( session->ciphersuite ); - *p++ = MBEDTLS_CHAR_0( session->ciphersuite ); + *p++ = MBEDTLS_BYTE_1( session->ciphersuite ); + *p++ = MBEDTLS_BYTE_0( session->ciphersuite ); - *p++ = MBEDTLS_CHAR_0( session->compression ); + *p++ = MBEDTLS_BYTE_0( session->compression ); - *p++ = MBEDTLS_CHAR_0( session->id_len ); + *p++ = MBEDTLS_BYTE_0( session->id_len ); memcpy( p, session->id, 32 ); p += 32; memcpy( p, session->master, 48 ); p += 48; - *p++ = MBEDTLS_CHAR_3( session->verify_result ); - *p++ = MBEDTLS_CHAR_2( session->verify_result ); - *p++ = MBEDTLS_CHAR_1( session->verify_result ); - *p++ = MBEDTLS_CHAR_0( session->verify_result ); + *p++ = MBEDTLS_BYTE_3( session->verify_result ); + *p++ = MBEDTLS_BYTE_2( session->verify_result ); + *p++ = MBEDTLS_BYTE_1( session->verify_result ); + *p++ = MBEDTLS_BYTE_0( session->verify_result ); } /* @@ -4719,9 +4719,9 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, if( used <= buf_len ) { - *p++ = MBEDTLS_CHAR_2( cert_len ); - *p++ = MBEDTLS_CHAR_1( cert_len ); - *p++ = MBEDTLS_CHAR_0( cert_len ); + *p++ = MBEDTLS_BYTE_2( cert_len ); + *p++ = MBEDTLS_BYTE_1( cert_len ); + *p++ = MBEDTLS_BYTE_0( cert_len ); if( session->peer_cert != NULL ) { @@ -4762,9 +4762,9 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, if( used <= buf_len ) { - *p++ = MBEDTLS_CHAR_2( session->ticket_len ); - *p++ = MBEDTLS_CHAR_1( session->ticket_len ); - *p++ = MBEDTLS_CHAR_0( session->ticket_len ); + *p++ = MBEDTLS_BYTE_2( session->ticket_len ); + *p++ = MBEDTLS_BYTE_1( session->ticket_len ); + *p++ = MBEDTLS_BYTE_0( session->ticket_len ); if( session->ticket != NULL ) { @@ -4772,10 +4772,10 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, p += session->ticket_len; } - *p++ = MBEDTLS_CHAR_3( session->ticket_lifetime ); - *p++ = MBEDTLS_CHAR_2( session->ticket_lifetime ); - *p++ = MBEDTLS_CHAR_1( session->ticket_lifetime ); - *p++ = MBEDTLS_CHAR_0( session->ticket_lifetime ); + *p++ = MBEDTLS_BYTE_3( session->ticket_lifetime ); + *p++ = MBEDTLS_BYTE_2( session->ticket_lifetime ); + *p++ = MBEDTLS_BYTE_1( session->ticket_lifetime ); + *p++ = MBEDTLS_BYTE_0( session->ticket_lifetime ); } #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ @@ -4793,7 +4793,7 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, used += 1; if( used <= buf_len ) - *p++ = MBEDTLS_CHAR_0( session->encrypt_then_mac ); + *p++ = MBEDTLS_BYTE_0( session->encrypt_then_mac ); #endif return( used ); @@ -5568,11 +5568,11 @@ static unsigned char ssl_serialized_context_header[] = { MBEDTLS_VERSION_MAJOR, MBEDTLS_VERSION_MINOR, MBEDTLS_VERSION_PATCH, - MBEDTLS_CHAR_1( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), - MBEDTLS_CHAR_0( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), - MBEDTLS_CHAR_2( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), - MBEDTLS_CHAR_1( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), - MBEDTLS_CHAR_0( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), + MBEDTLS_BYTE_1( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), + MBEDTLS_BYTE_0( SSL_SERIALIZED_SESSION_CONFIG_BITFLAG ), + MBEDTLS_BYTE_2( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), + MBEDTLS_BYTE_1( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), + MBEDTLS_BYTE_0( SSL_SERIALIZED_CONTEXT_CONFIG_BITFLAG ), }; /* @@ -5713,10 +5713,10 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 4 + session_len; if( used <= buf_len ) { - *p++ = MBEDTLS_CHAR_3( session_len ); - *p++ = MBEDTLS_CHAR_2( session_len ); - *p++ = MBEDTLS_CHAR_1( session_len ); - *p++ = MBEDTLS_CHAR_0( session_len ); + *p++ = MBEDTLS_BYTE_3( session_len ); + *p++ = MBEDTLS_BYTE_2( session_len ); + *p++ = MBEDTLS_BYTE_1( session_len ); + *p++ = MBEDTLS_BYTE_0( session_len ); ret = ssl_session_save( ssl->session, 1, p, session_len, &session_len ); @@ -5757,33 +5757,33 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 4; if( used <= buf_len ) { - *p++ = MBEDTLS_CHAR_3( ssl->badmac_seen ); - *p++ = MBEDTLS_CHAR_2( ssl->badmac_seen ); - *p++ = MBEDTLS_CHAR_1( ssl->badmac_seen ); - *p++ = MBEDTLS_CHAR_0( ssl->badmac_seen ); + *p++ = MBEDTLS_BYTE_3( ssl->badmac_seen ); + *p++ = MBEDTLS_BYTE_2( ssl->badmac_seen ); + *p++ = MBEDTLS_BYTE_1( ssl->badmac_seen ); + *p++ = MBEDTLS_BYTE_0( ssl->badmac_seen ); } #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) used += 16; if( used <= buf_len ) { - *p++ = MBEDTLS_CHAR_7( ssl->in_window_top ); - *p++ = MBEDTLS_CHAR_6( ssl->in_window_top ); - *p++ = MBEDTLS_CHAR_5( ssl->in_window_top ); - *p++ = MBEDTLS_CHAR_4( ssl->in_window_top ); - *p++ = MBEDTLS_CHAR_3( ssl->in_window_top ); - *p++ = MBEDTLS_CHAR_2( ssl->in_window_top ); - *p++ = MBEDTLS_CHAR_1( ssl->in_window_top ); - *p++ = MBEDTLS_CHAR_0( ssl->in_window_top ); + *p++ = MBEDTLS_BYTE_7( ssl->in_window_top ); + *p++ = MBEDTLS_BYTE_6( ssl->in_window_top ); + *p++ = MBEDTLS_BYTE_5( ssl->in_window_top ); + *p++ = MBEDTLS_BYTE_4( ssl->in_window_top ); + *p++ = MBEDTLS_BYTE_3( ssl->in_window_top ); + *p++ = MBEDTLS_BYTE_2( ssl->in_window_top ); + *p++ = MBEDTLS_BYTE_1( ssl->in_window_top ); + *p++ = MBEDTLS_BYTE_0( ssl->in_window_top ); - *p++ = MBEDTLS_CHAR_7( ssl->in_window ); - *p++ = MBEDTLS_CHAR_6( ssl->in_window ); - *p++ = MBEDTLS_CHAR_5( ssl->in_window ); - *p++ = MBEDTLS_CHAR_4( ssl->in_window ); - *p++ = MBEDTLS_CHAR_3( ssl->in_window ); - *p++ = MBEDTLS_CHAR_2( ssl->in_window ); - *p++ = MBEDTLS_CHAR_1( ssl->in_window ); - *p++ = MBEDTLS_CHAR_0( ssl->in_window ); + *p++ = MBEDTLS_BYTE_7( ssl->in_window ); + *p++ = MBEDTLS_BYTE_6( ssl->in_window ); + *p++ = MBEDTLS_BYTE_5( ssl->in_window ); + *p++ = MBEDTLS_BYTE_4( ssl->in_window ); + *p++ = MBEDTLS_BYTE_3( ssl->in_window ); + *p++ = MBEDTLS_BYTE_2( ssl->in_window ); + *p++ = MBEDTLS_BYTE_1( ssl->in_window ); + *p++ = MBEDTLS_BYTE_0( ssl->in_window ); } #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ @@ -5806,8 +5806,8 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 2; if( used <= buf_len ) { - *p++ = MBEDTLS_CHAR_1( ssl->mtu ); - *p++ = MBEDTLS_CHAR_0( ssl->mtu ); + *p++ = MBEDTLS_BYTE_1( ssl->mtu ); + *p++ = MBEDTLS_BYTE_0( ssl->mtu ); } #endif /* MBEDTLS_SSL_PROTO_DTLS */ diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 9e629cb0b3..7aec21dffe 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -113,17 +113,17 @@ static void ssl_tls1_3_hkdf_encode_label( #endif *p++ = 0; - *p++ = MBEDTLS_CHAR_0( desired_length ); + *p++ = MBEDTLS_BYTE_0( desired_length ); /* Add label incl. prefix */ - *p++ = MBEDTLS_CHAR_0( total_label_len ); + *p++ = MBEDTLS_BYTE_0( total_label_len ); memcpy( p, tls1_3_label_prefix, sizeof(tls1_3_label_prefix) ); p += sizeof(tls1_3_label_prefix); memcpy( p, label, llen ); p += llen; /* Add context value */ - *p++ = MBEDTLS_CHAR_0( clen ); + *p++ = MBEDTLS_BYTE_0( clen ); if( clen != 0 ) memcpy( p, ctx, clen ); From 99edd6c8105740b58ad3261da7ed47c42658b36e Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 16 Jul 2021 12:29:49 +0100 Subject: [PATCH 321/966] Add UINT64 GET and PUT macros Copy over the GET/PUT_UINT64_LE/BE macros from aes.c and sha512.c Add the MBEDTLS_ prefix to all 4 macros. Modify the GET_UINT64 macros to no longer take a target variable as a parameter, so when the macro function is called it must be assigned to a variable in the same statement. Signed-off-by: Joe Subbiani --- library/aes.c | 37 +++----------------- library/common.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ library/sha512.c | 39 +++------------------ 3 files changed, 99 insertions(+), 68 deletions(-) diff --git a/library/aes.c b/library/aes.c index 1eb3e204d8..8e3358c494 100644 --- a/library/aes.c +++ b/library/aes.c @@ -1074,35 +1074,6 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, #if defined(MBEDTLS_CIPHER_MODE_XTS) -/* Endianess with 64 bits values */ -#ifndef GET_UINT64_LE -#define GET_UINT64_LE(n,b,i) \ -{ \ - (n) = ( (uint64_t) (b)[(i) + 7] << 56 ) \ - | ( (uint64_t) (b)[(i) + 6] << 48 ) \ - | ( (uint64_t) (b)[(i) + 5] << 40 ) \ - | ( (uint64_t) (b)[(i) + 4] << 32 ) \ - | ( (uint64_t) (b)[(i) + 3] << 24 ) \ - | ( (uint64_t) (b)[(i) + 2] << 16 ) \ - | ( (uint64_t) (b)[(i) + 1] << 8 ) \ - | ( (uint64_t) (b)[(i) ] ); \ -} -#endif - -#ifndef PUT_UINT64_LE -#define PUT_UINT64_LE(n,b,i) \ -{ \ - (b)[(i) + 7] = (unsigned char) ( (n) >> 56 ); \ - (b)[(i) + 6] = (unsigned char) ( (n) >> 48 ); \ - (b)[(i) + 5] = (unsigned char) ( (n) >> 40 ); \ - (b)[(i) + 4] = (unsigned char) ( (n) >> 32 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) ] = (unsigned char) ( (n) ); \ -} -#endif - typedef unsigned char mbedtls_be128[16]; /* @@ -1118,14 +1089,14 @@ static void mbedtls_gf128mul_x_ble( unsigned char r[16], { uint64_t a, b, ra, rb; - GET_UINT64_LE( a, x, 0 ); - GET_UINT64_LE( b, x, 8 ); + a = MBEDTLS_GET_UINT64_LE( x, 0 ); + b = MBEDTLS_GET_UINT64_LE( x, 8 ); ra = ( a << 1 ) ^ 0x0087 >> ( 8 - ( ( b >> 63 ) << 3 ) ); rb = ( a >> 63 ) | ( b << 1 ); - PUT_UINT64_LE( ra, r, 0 ); - PUT_UINT64_LE( rb, r, 8 ); + MBEDTLS_PUT_UINT64_LE( ra, r, 0 ); + MBEDTLS_PUT_UINT64_LE( rb, r, 8 ); } /* diff --git a/library/common.h b/library/common.h index e0f8b99baa..ce2f04007e 100644 --- a/library/common.h +++ b/library/common.h @@ -193,5 +193,96 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c } #endif +/** + * Get the unsigned 64 bits integer corresponding to eight bytes in + * big-endian order (MSB first). + * + * \param data Base address of the memory to get the eight bytes from. + * \param offset Offset from \p base of the first and most significant + * byte of the eight bytes to build the 64 bits unsigned + * integer from. + */ +#ifndef MBEDTLS_GET_UINT64_BE +#define MBEDTLS_GET_UINT64_BE( data, offset ) \ + ( \ + ( (uint64_t) ( data )[( offset ) ] << 56 ) \ + | ( (uint64_t) ( data )[( offset ) + 1] << 48 ) \ + | ( (uint64_t) ( data )[( offset ) + 2] << 40 ) \ + | ( (uint64_t) ( data )[( offset ) + 3] << 32 ) \ + | ( (uint64_t) ( data )[( offset ) + 4] << 24 ) \ + | ( (uint64_t) ( data )[( offset ) + 5] << 16 ) \ + | ( (uint64_t) ( data )[( offset ) + 6] << 8 ) \ + | ( (uint64_t) ( data )[( offset ) + 7] ) \ + ) +#endif + +/** + * Put in memory a 64 bits unsigned integer in big-endian order. + * + * \param n 64 bits unsigned integer to put in memory. + * \param data Base address of the memory where to put the 64 + * bits unsigned integer in. + * \param offset Offset from \p base where to put the most significant + * byte of the 64 bits unsigned integer \p n. + */ +#ifndef MBEDTLS_PUT_UINT64_BE +#define MBEDTLS_PUT_UINT64_BE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = (unsigned char) ( (n) >> 56 ); \ + ( data )[( offset ) + 1] = (unsigned char) ( (n) >> 48 ); \ + ( data )[( offset ) + 2] = (unsigned char) ( (n) >> 40 ); \ + ( data )[( offset ) + 3] = (unsigned char) ( (n) >> 32 ); \ + ( data )[( offset ) + 4] = (unsigned char) ( (n) >> 24 ); \ + ( data )[( offset ) + 5] = (unsigned char) ( (n) >> 16 ); \ + ( data )[( offset ) + 6] = (unsigned char) ( (n) >> 8 ); \ + ( data )[( offset ) + 7] = (unsigned char) ( (n) ); \ +} +#endif + +/** + * Get the unsigned 64 bits integer corresponding to eight bytes in + * little-endian order (LSB first). + * + * \param data Base address of the memory to get the eight bytes from. + * \param offset Offset from \p base of the first and least significant + * byte of the eight bytes to build the 64 bits unsigned + * integer from. + */ +#ifndef MBEDTLS_GET_UINT64_LE +#define MBEDTLS_GET_UINT64_LE( data, offset ) \ + ( \ + ( (uint64_t) ( data )[( offset ) + 7] << 56 ) \ + | ( (uint64_t) ( data )[( offset ) + 6] << 48 ) \ + | ( (uint64_t) ( data )[( offset ) + 5] << 40 ) \ + | ( (uint64_t) ( data )[( offset ) + 4] << 32 ) \ + | ( (uint64_t) ( data )[( offset ) + 3] << 24 ) \ + | ( (uint64_t) ( data )[( offset ) + 2] << 16 ) \ + | ( (uint64_t) ( data )[( offset ) + 1] << 8 ) \ + | ( (uint64_t) ( data )[( offset ) ] ) \ + ) +#endif + +/** + * Put in memory a 64 bits unsigned integer in little-endian order. + * + * \param n 64 bits unsigned integer to put in memory. + * \param data Base address of the memory where to put the 64 + * bits unsigned integer in. + * \param offset Offset from \p base where to put the least significant + * byte of the 64 bits unsigned integer \p n. + */ +#ifndef MBEDTLS_PUT_UINT64_LE +#define MBEDTLS_PUT_UINT64_LE( n, data, offset ) \ +{ \ + ( data )[( offset ) + 7] = (unsigned char) ( (n) >> 56 ); \ + ( data )[( offset ) + 6] = (unsigned char) ( (n) >> 48 ); \ + ( data )[( offset ) + 5] = (unsigned char) ( (n) >> 40 ); \ + ( data )[( offset ) + 4] = (unsigned char) ( (n) >> 32 ); \ + ( data )[( offset ) + 3] = (unsigned char) ( (n) >> 24 ); \ + ( data )[( offset ) + 2] = (unsigned char) ( (n) >> 16 ); \ + ( data )[( offset ) + 1] = (unsigned char) ( (n) >> 8 ); \ + ( data )[( offset ) ] = (unsigned char) ( (n) ); \ +} +#endif #endif /* MBEDTLS_LIBRARY_COMMON_H */ diff --git a/library/sha512.c b/library/sha512.c index 6511c6e36a..2b4cc547e4 100644 --- a/library/sha512.c +++ b/library/sha512.c @@ -56,44 +56,13 @@ #if !defined(MBEDTLS_SHA512_ALT) -/* - * 64-bit integer manipulation macros (big endian) - */ -#ifndef GET_UINT64_BE -#define GET_UINT64_BE(n,b,i) \ -{ \ - (n) = ( (uint64_t) (b)[(i) ] << 56 ) \ - | ( (uint64_t) (b)[(i) + 1] << 48 ) \ - | ( (uint64_t) (b)[(i) + 2] << 40 ) \ - | ( (uint64_t) (b)[(i) + 3] << 32 ) \ - | ( (uint64_t) (b)[(i) + 4] << 24 ) \ - | ( (uint64_t) (b)[(i) + 5] << 16 ) \ - | ( (uint64_t) (b)[(i) + 6] << 8 ) \ - | ( (uint64_t) (b)[(i) + 7] ); \ -} -#endif /* GET_UINT64_BE */ - -#ifndef PUT_UINT64_BE -#define PUT_UINT64_BE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( (n) >> 56 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 48 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 40 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) >> 32 ); \ - (b)[(i) + 4] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 5] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 6] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 7] = (unsigned char) ( (n) ); \ -} -#endif /* PUT_UINT64_BE */ - #if defined(MBEDTLS_SHA512_SMALLER) static void sha512_put_uint64_be( uint64_t n, unsigned char *b, uint8_t i ) { - PUT_UINT64_BE(n, b, i); + MBEDTLS_PUT_UINT64_BE(n, b, i); } #else -#define sha512_put_uint64_be PUT_UINT64_BE +#define sha512_put_uint64_be MBEDTLS_PUT_UINT64_BE #endif /* MBEDTLS_SHA512_SMALLER */ void mbedtls_sha512_init( mbedtls_sha512_context *ctx ) @@ -261,7 +230,7 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, { if( i < 16 ) { - GET_UINT64_BE( local.W[i], data, i << 3 ); + local.W[i] = MBEDTLS_GET_UINT64_BE( data, i << 3 ); } else { @@ -281,7 +250,7 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, #else /* MBEDTLS_SHA512_SMALLER */ for( i = 0; i < 16; i++ ) { - GET_UINT64_BE( local.W[i], data, i << 3 ); + local.W[i] = MBEDTLS_GET_UINT64_BE( data, i << 3 ); } for( ; i < 80; i++ ) From fbeb692dd09efbb5d81304637e490ad1a2208ce5 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 16 Jul 2021 14:27:50 +0100 Subject: [PATCH 322/966] Use byte reading macros in places not using a byte mask byte shifting opertations throughout library/ were only replaced with the byte reading macros when an 0xff mask was being used. The byte reading macros are now more widley used, however they have not been used in all cases of a byte shift operation, as it detracted from the immediate readability or otherwise did not seem appropriate. Signed-off-by: Joe Subbiani --- library/base64.c | 6 +++--- library/chacha20.c | 8 ++++---- library/chachapoly.c | 32 ++++++++++++++++---------------- library/dhm.c | 4 ++-- library/ecp.c | 4 ++-- library/pkcs12.c | 8 ++++---- library/poly1305.c | 36 ++++++++++++++++++------------------ library/ssl_cli.c | 40 ++++++++++++++++++++-------------------- library/ssl_cookie.c | 8 ++++---- library/ssl_msg.c | 28 ++++++++++++++-------------- library/ssl_srv.c | 30 +++++++++++++++--------------- library/ssl_tls.c | 28 ++++++++++++++-------------- library/x509write_crt.c | 4 ++-- 13 files changed, 118 insertions(+), 118 deletions(-) diff --git a/library/base64.c b/library/base64.c index 1a05226efa..9cf5dd41d4 100644 --- a/library/base64.c +++ b/library/base64.c @@ -319,9 +319,9 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, if( ++n == 4 ) { n = 0; - if( j > 0 ) *p++ = (unsigned char)( x >> 16 ); - if( j > 1 ) *p++ = (unsigned char)( x >> 8 ); - if( j > 2 ) *p++ = (unsigned char)( x ); + if( j > 0 ) *p++ = MBEDTLS_BYTE_2( x ); + if( j > 1 ) *p++ = MBEDTLS_BYTE_1( x ); + if( j > 2 ) *p++ = MBEDTLS_BYTE_0( x ); } } diff --git a/library/chacha20.c b/library/chacha20.c index 7015f99d59..0e057f0e3c 100644 --- a/library/chacha20.c +++ b/library/chacha20.c @@ -164,10 +164,10 @@ static void chacha20_block( const uint32_t initial_state[16], { size_t offset = i * 4U; - keystream[offset ] = (unsigned char)( working_state[i] ); - keystream[offset + 1U] = (unsigned char)( working_state[i] >> 8 ); - keystream[offset + 2U] = (unsigned char)( working_state[i] >> 16 ); - keystream[offset + 3U] = (unsigned char)( working_state[i] >> 24 ); + keystream[offset ] = MBEDTLS_BYTE_0( working_state[i] ); + keystream[offset + 1U] = MBEDTLS_BYTE_1( working_state[i] ); + keystream[offset + 2U] = MBEDTLS_BYTE_2( working_state[i] ); + keystream[offset + 3U] = MBEDTLS_BYTE_3( working_state[i] ); } mbedtls_platform_zeroize( working_state, sizeof( working_state ) ); diff --git a/library/chachapoly.c b/library/chachapoly.c index 77d547731c..696d97bf01 100644 --- a/library/chachapoly.c +++ b/library/chachapoly.c @@ -263,22 +263,22 @@ int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx, /* The lengths of the AAD and ciphertext are processed by * Poly1305 as the final 128-bit block, encoded as little-endian integers. */ - len_block[ 0] = (unsigned char)( ctx->aad_len ); - len_block[ 1] = (unsigned char)( ctx->aad_len >> 8 ); - len_block[ 2] = (unsigned char)( ctx->aad_len >> 16 ); - len_block[ 3] = (unsigned char)( ctx->aad_len >> 24 ); - len_block[ 4] = (unsigned char)( ctx->aad_len >> 32 ); - len_block[ 5] = (unsigned char)( ctx->aad_len >> 40 ); - len_block[ 6] = (unsigned char)( ctx->aad_len >> 48 ); - len_block[ 7] = (unsigned char)( ctx->aad_len >> 56 ); - len_block[ 8] = (unsigned char)( ctx->ciphertext_len ); - len_block[ 9] = (unsigned char)( ctx->ciphertext_len >> 8 ); - len_block[10] = (unsigned char)( ctx->ciphertext_len >> 16 ); - len_block[11] = (unsigned char)( ctx->ciphertext_len >> 24 ); - len_block[12] = (unsigned char)( ctx->ciphertext_len >> 32 ); - len_block[13] = (unsigned char)( ctx->ciphertext_len >> 40 ); - len_block[14] = (unsigned char)( ctx->ciphertext_len >> 48 ); - len_block[15] = (unsigned char)( ctx->ciphertext_len >> 56 ); + len_block[ 0] = MBEDTLS_BYTE_0( ctx->aad_len ); + len_block[ 1] = MBEDTLS_BYTE_1( ctx->aad_len ); + len_block[ 2] = MBEDTLS_BYTE_2( ctx->aad_len ); + len_block[ 3] = MBEDTLS_BYTE_3( ctx->aad_len ); + len_block[ 4] = MBEDTLS_BYTE_4( ctx->aad_len ); + len_block[ 5] = MBEDTLS_BYTE_5( ctx->aad_len ); + len_block[ 6] = MBEDTLS_BYTE_6( ctx->aad_len ); + len_block[ 7] = MBEDTLS_BYTE_7( ctx->aad_len ); + len_block[ 8] = MBEDTLS_BYTE_0( ctx->ciphertext_len ); + len_block[ 9] = MBEDTLS_BYTE_1( ctx->ciphertext_len ); + len_block[10] = MBEDTLS_BYTE_2( ctx->ciphertext_len ); + len_block[11] = MBEDTLS_BYTE_3( ctx->ciphertext_len ); + len_block[12] = MBEDTLS_BYTE_4( ctx->ciphertext_len ); + len_block[13] = MBEDTLS_BYTE_5( ctx->ciphertext_len ); + len_block[14] = MBEDTLS_BYTE_6( ctx->ciphertext_len ); + len_block[15] = MBEDTLS_BYTE_7( ctx->ciphertext_len ); ret = mbedtls_poly1305_update( &ctx->poly1305_ctx, len_block, 16U ); if( ret != 0 ) diff --git a/library/dhm.c b/library/dhm.c index 29ce75598c..2ce0ed4fde 100644 --- a/library/dhm.c +++ b/library/dhm.c @@ -270,8 +270,8 @@ int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( ( X ), \ p + 2, \ ( n ) ) ); \ - *p++ = (unsigned char)( ( n ) >> 8 ); \ - *p++ = (unsigned char)( ( n ) ); \ + *p++ = MBEDTLS_BYTE_1( n ); \ + *p++ = MBEDTLS_BYTE_0( n ); \ p += ( n ); \ } while( 0 ) diff --git a/library/ecp.c b/library/ecp.c index b608ff1bd7..fdfc960069 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -1012,8 +1012,8 @@ int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen, /* * Next two bytes are the namedcurve value */ - buf[0] = curve_info->tls_id >> 8; - buf[1] = curve_info->tls_id & 0xFF; + buf[0] = MBEDTLS_BYTE_1( curve_info->tls_id ); + buf[1] = MBEDTLS_BYTE_0( curve_info->tls_id ); return( 0 ); } diff --git a/library/pkcs12.c b/library/pkcs12.c index 04b1a6dab3..8f64bc6395 100644 --- a/library/pkcs12.c +++ b/library/pkcs12.c @@ -285,8 +285,8 @@ int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen, for( i = v; i > 0; i-- ) { j = salt_block[i - 1] + hash_block[i - 1] + c; - c = (unsigned char) (j >> 8); - salt_block[i - 1] = j & 0xFF; + c = MBEDTLS_BYTE_1( j ); + salt_block[i - 1] = MBEDTLS_BYTE_0( j ); } // pwd_block += B @@ -294,8 +294,8 @@ int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen, for( i = v; i > 0; i-- ) { j = pwd_block[i - 1] + hash_block[i - 1] + c; - c = (unsigned char) (j >> 8); - pwd_block[i - 1] = j & 0xFF; + c = MBEDTLS_BYTE_1( j ); + pwd_block[i - 1] = MBEDTLS_BYTE_0( j ); } } diff --git a/library/poly1305.c b/library/poly1305.c index f19574253c..333aade94a 100644 --- a/library/poly1305.c +++ b/library/poly1305.c @@ -62,8 +62,8 @@ static uint64_t mul64( uint32_t a, uint32_t b ) /* a = al + 2**16 ah, b = bl + 2**16 bh */ const uint16_t al = (uint16_t) a; const uint16_t bl = (uint16_t) b; - const uint16_t ah = a >> 16; - const uint16_t bh = b >> 16; + const uint16_t ah = MBEDTLS_BYTE_2( a ); + const uint16_t bh = MBEDTLS_BYTE_2( b ); /* ab = al*bl + 2**16 (ah*bl + bl*bh) + 2**32 ah*bh */ const uint32_t lo = (uint32_t) al * bl; @@ -250,22 +250,22 @@ static void poly1305_compute_mac( const mbedtls_poly1305_context *ctx, acc3 += ctx->s[3] + (uint32_t) ( d >> 32U ); /* Compute MAC (128 least significant bits of the accumulator) */ - mac[ 0] = (unsigned char)( acc0 ); - mac[ 1] = (unsigned char)( acc0 >> 8 ); - mac[ 2] = (unsigned char)( acc0 >> 16 ); - mac[ 3] = (unsigned char)( acc0 >> 24 ); - mac[ 4] = (unsigned char)( acc1 ); - mac[ 5] = (unsigned char)( acc1 >> 8 ); - mac[ 6] = (unsigned char)( acc1 >> 16 ); - mac[ 7] = (unsigned char)( acc1 >> 24 ); - mac[ 8] = (unsigned char)( acc2 ); - mac[ 9] = (unsigned char)( acc2 >> 8 ); - mac[10] = (unsigned char)( acc2 >> 16 ); - mac[11] = (unsigned char)( acc2 >> 24 ); - mac[12] = (unsigned char)( acc3 ); - mac[13] = (unsigned char)( acc3 >> 8 ); - mac[14] = (unsigned char)( acc3 >> 16 ); - mac[15] = (unsigned char)( acc3 >> 24 ); + mac[ 0] = MBEDTLS_BYTE_0( acc0 ); + mac[ 1] = MBEDTLS_BYTE_1( acc0 ); + mac[ 2] = MBEDTLS_BYTE_2( acc0 ); + mac[ 3] = MBEDTLS_BYTE_3( acc0 ); + mac[ 4] = MBEDTLS_BYTE_0( acc1 ); + mac[ 5] = MBEDTLS_BYTE_1( acc1 ); + mac[ 6] = MBEDTLS_BYTE_2( acc1 ); + mac[ 7] = MBEDTLS_BYTE_3( acc1 ); + mac[ 8] = MBEDTLS_BYTE_0( acc2 ); + mac[ 9] = MBEDTLS_BYTE_1( acc2 ); + mac[10] = MBEDTLS_BYTE_2( acc2 ); + mac[11] = MBEDTLS_BYTE_3( acc2 ); + mac[12] = MBEDTLS_BYTE_0( acc3 ); + mac[13] = MBEDTLS_BYTE_1( acc3 ); + mac[14] = MBEDTLS_BYTE_2( acc3 ); + mac[15] = MBEDTLS_BYTE_3( acc3 ); } void mbedtls_poly1305_init( mbedtls_poly1305_context *ctx ) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 9e0db96c48..729784a6eb 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -352,8 +352,8 @@ static int ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl, grp_id++ ) { info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); - elliptic_curve_list[elliptic_curve_len++] = info->tls_id >> 8; - elliptic_curve_list[elliptic_curve_len++] = info->tls_id & 0xFF; + elliptic_curve_list[elliptic_curve_len++] = MBEDTLS_BYTE_1( info->tls_id ); + elliptic_curve_list[elliptic_curve_len++] = MBEDTLS_BYTE_0( info->tls_id ); } *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); @@ -857,10 +857,10 @@ static int ssl_generate_random( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_HAVE_TIME) t = mbedtls_time( NULL ); - *p++ = (unsigned char)( t >> 24 ); - *p++ = (unsigned char)( t >> 16 ); - *p++ = (unsigned char)( t >> 8 ); - *p++ = (unsigned char)( t ); + *p++ = MBEDTLS_BYTE_3( t ); + *p++ = MBEDTLS_BYTE_2( t ); + *p++ = MBEDTLS_BYTE_1( t ); + *p++ = MBEDTLS_BYTE_0( t ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, current time: %" MBEDTLS_PRINTF_LONGLONG, (long long) t ) ); @@ -1143,8 +1143,8 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); n++; - *p++ = (unsigned char)( ciphersuites[i] >> 8 ); - *p++ = (unsigned char)( ciphersuites[i] ); + *p++ = MBEDTLS_BYTE_1( ciphersuites[i] ); + *p++ = MBEDTLS_BYTE_0( ciphersuites[i] ); } MBEDTLS_SSL_DEBUG_MSG( 3, @@ -1159,8 +1159,8 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "adding EMPTY_RENEGOTIATION_INFO_SCSV" ) ); MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); - *p++ = (unsigned char)( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO >> 8 ); - *p++ = (unsigned char)( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ); + *p++ = MBEDTLS_BYTE_1( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ); + *p++ = MBEDTLS_BYTE_0( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ); n++; } @@ -2745,8 +2745,8 @@ static int ssl_write_encrypted_pms( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_SSL_PROTO_TLS1_2) if( len_bytes == 2 ) { - ssl->out_msg[offset+0] = (unsigned char)( *olen >> 8 ); - ssl->out_msg[offset+1] = (unsigned char)( *olen ); + ssl->out_msg[offset+0] = MBEDTLS_BYTE_1( *olen ); + ssl->out_msg[offset+1] = MBEDTLS_BYTE_0( *olen ); *olen += 2; } #endif @@ -3503,8 +3503,8 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) */ content_len = mbedtls_dhm_get_len( &ssl->handshake->dhm_ctx ); - ssl->out_msg[4] = (unsigned char)( content_len >> 8 ); - ssl->out_msg[5] = (unsigned char)( content_len ); + ssl->out_msg[4] = MBEDTLS_BYTE_1( content_len ); + ssl->out_msg[5] = MBEDTLS_BYTE_0( content_len ); header_len = 6; ret = mbedtls_dhm_make_public( &ssl->handshake->dhm_ctx, @@ -3719,8 +3719,8 @@ ecdh_calc_secret: return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); } - ssl->out_msg[header_len++] = (unsigned char)( content_len >> 8 ); - ssl->out_msg[header_len++] = (unsigned char)( content_len ); + ssl->out_msg[header_len++] = MBEDTLS_BYTE_1( content_len ); + ssl->out_msg[header_len++] = MBEDTLS_BYTE_0( content_len ); memcpy( ssl->out_msg + header_len, ssl->conf->psk_identity, @@ -3771,8 +3771,8 @@ ecdh_calc_secret: return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); } - ssl->out_msg[header_len++] = (unsigned char)( content_len >> 8 ); - ssl->out_msg[header_len++] = (unsigned char)( content_len ); + ssl->out_msg[header_len++] = MBEDTLS_BYTE_1( content_len ); + ssl->out_msg[header_len++] = MBEDTLS_BYTE_0( content_len ); ret = mbedtls_dhm_make_public( &ssl->handshake->dhm_ctx, (int) mbedtls_dhm_get_len( &ssl->handshake->dhm_ctx ), @@ -4054,8 +4054,8 @@ sign: return( ret ); } - ssl->out_msg[4 + offset] = (unsigned char)( n >> 8 ); - ssl->out_msg[5 + offset] = (unsigned char)( n ); + ssl->out_msg[4 + offset] = MBEDTLS_BYTE_1( n ); + ssl->out_msg[5 + offset] = MBEDTLS_BYTE_0( n ); ssl->out_msglen = 6 + n + offset; ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; diff --git a/library/ssl_cookie.c b/library/ssl_cookie.c index 40b8913b8b..4f1c07bde6 100644 --- a/library/ssl_cookie.c +++ b/library/ssl_cookie.c @@ -165,10 +165,10 @@ int mbedtls_ssl_cookie_write( void *p_ctx, t = ctx->serial++; #endif - (*p)[0] = (unsigned char)( t >> 24 ); - (*p)[1] = (unsigned char)( t >> 16 ); - (*p)[2] = (unsigned char)( t >> 8 ); - (*p)[3] = (unsigned char)( t ); + (*p)[0] = MBEDTLS_BYTE_3( t ); + (*p)[1] = MBEDTLS_BYTE_2( t ); + (*p)[2] = MBEDTLS_BYTE_1( t ); + (*p)[3] = MBEDTLS_BYTE_0( t ); *p += 4; #if defined(MBEDTLS_THREADING_C) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 989c59874f..304e7f22b7 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2451,9 +2451,9 @@ int mbedtls_ssl_write_handshake_msg_ext( mbedtls_ssl_context *ssl, */ if( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) { - ssl->out_msg[1] = (unsigned char)( hs_len >> 16 ); - ssl->out_msg[2] = (unsigned char)( hs_len >> 8 ); - ssl->out_msg[3] = (unsigned char)( hs_len ); + ssl->out_msg[1] = MBEDTLS_BYTE_2( hs_len ); + ssl->out_msg[2] = MBEDTLS_BYTE_1( hs_len ); + ssl->out_msg[3] = MBEDTLS_BYTE_0( hs_len ); /* * DTLS has additional fields in the Handshake layer, @@ -2566,8 +2566,8 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) ssl->conf->transport, ssl->out_hdr + 1 ); memcpy( ssl->out_ctr, ssl->cur_out_ctr, 8 ); - ssl->out_len[0] = (unsigned char)( len >> 8 ); - ssl->out_len[1] = (unsigned char)( len ); + ssl->out_len[0] = MBEDTLS_BYTE_1( len ); + ssl->out_len[1] = MBEDTLS_BYTE_0( len ); if( ssl->transform_out != NULL ) { @@ -2607,8 +2607,8 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) memcpy( ssl->out_cid, rec.cid, rec.cid_len ); #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ ssl->out_msglen = len = rec.data_len; - ssl->out_len[0] = (unsigned char)( rec.data_len >> 8 ); - ssl->out_len[1] = (unsigned char)( rec.data_len ); + ssl->out_len[0] = MBEDTLS_BYTE_1( rec.data_len ); + ssl->out_len[1] = MBEDTLS_BYTE_0( rec.data_len ); } protected_record_size = len + mbedtls_ssl_out_hdr_len( ssl ); @@ -3180,12 +3180,12 @@ static int ssl_check_dtls_clihlo_cookie( /* Go back and fill length fields */ obuf[27] = (unsigned char)( *olen - 28 ); - obuf[14] = obuf[22] = (unsigned char)( ( *olen - 25 ) >> 16 ); - obuf[15] = obuf[23] = (unsigned char)( ( *olen - 25 ) >> 8 ); - obuf[16] = obuf[24] = (unsigned char)( ( *olen - 25 ) ); + obuf[14] = obuf[22] = MBEDTLS_BYTE_2( *olen - 25 ); + obuf[15] = obuf[23] = MBEDTLS_BYTE_1( *olen - 25 ); + obuf[16] = obuf[24] = MBEDTLS_BYTE_0( *olen - 25 ); - obuf[11] = (unsigned char)( ( *olen - 13 ) >> 8 ); - obuf[12] = (unsigned char)( ( *olen - 13 ) ); + obuf[11] = MBEDTLS_BYTE_1( *olen - 13 ); + obuf[12] = MBEDTLS_BYTE_0( *olen - 13 ); return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ); } @@ -4565,8 +4565,8 @@ static int ssl_get_next_record( mbedtls_ssl_context *ssl ) ssl->in_hdr[0] = rec.type; ssl->in_msg = rec.buf + rec.data_offset; ssl->in_msglen = rec.data_len; - ssl->in_len[0] = (unsigned char)( rec.data_len >> 8 ); - ssl->in_len[1] = (unsigned char)( rec.data_len ); + ssl->in_len[0] = MBEDTLS_BYTE_1( rec.data_len ); + ssl->in_len[1] = MBEDTLS_BYTE_0( rec.data_len ); return( 0 ); } diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 96b08ab8f6..232846ff08 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -2494,10 +2494,10 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_HAVE_TIME) t = mbedtls_time( NULL ); - *p++ = (unsigned char)( t >> 24 ); - *p++ = (unsigned char)( t >> 16 ); - *p++ = (unsigned char)( t >> 8 ); - *p++ = (unsigned char)( t ); + *p++ = MBEDTLS_BYTE_3( t ); + *p++ = MBEDTLS_BYTE_2( t ); + *p++ = MBEDTLS_BYTE_1( t ); + *p++ = MBEDTLS_BYTE_0( t ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %" MBEDTLS_PRINTF_LONGLONG, (long long) t ) ); @@ -2578,9 +2578,9 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed", ssl->handshake->resume ? "a" : "no" ) ); - *p++ = (unsigned char)( ssl->session_negotiate->ciphersuite >> 8 ); - *p++ = (unsigned char)( ssl->session_negotiate->ciphersuite ); - *p++ = (unsigned char)( ssl->session_negotiate->compression ); + *p++ = MBEDTLS_BYTE_1( ssl->session_negotiate->ciphersuite ); + *p++ = MBEDTLS_BYTE_0( ssl->session_negotiate->ciphersuite ); + *p++ = MBEDTLS_BYTE_0( ssl->session_negotiate->compression ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %s", mbedtls_ssl_get_ciphersuite_name( ssl->session_negotiate->ciphersuite ) ) ); @@ -2785,8 +2785,8 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) #endif } - p[0] = (unsigned char)( sa_len >> 8 ); - p[1] = (unsigned char)( sa_len ); + p[0] = MBEDTLS_BYTE_1( sa_len ); + p[1] = MBEDTLS_BYTE_0( sa_len ); sa_len += 2; p += sa_len; } @@ -2826,8 +2826,8 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) break; } - *p++ = (unsigned char)( dn_size >> 8 ); - *p++ = (unsigned char)( dn_size ); + *p++ = MBEDTLS_BYTE_1( dn_size ); + *p++ = MBEDTLS_BYTE_0( dn_size ); memcpy( p, crt->subject_raw.p, dn_size ); p += dn_size; @@ -2841,8 +2841,8 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) ssl->out_msglen = p - buf; ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; ssl->out_msg[0] = MBEDTLS_SSL_HS_CERTIFICATE_REQUEST; - ssl->out_msg[4 + ct_len + sa_len] = (unsigned char)( total_dn_size >> 8 ); - ssl->out_msg[5 + ct_len + sa_len] = (unsigned char)( total_dn_size ); + ssl->out_msg[4 + ct_len + sa_len] = MBEDTLS_BYTE_1( total_dn_size ); + ssl->out_msg[5 + ct_len + sa_len] = MBEDTLS_BYTE_0( total_dn_size ); ret = mbedtls_ssl_write_handshake_msg( ssl ); @@ -3320,8 +3320,8 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_KEY_EXCHANGE_WITH_SERVER_SIGNATURE_ENABLED) if( signature_len != 0 ) { - ssl->out_msg[ssl->out_msglen++] = (unsigned char)( signature_len >> 8 ); - ssl->out_msg[ssl->out_msglen++] = (unsigned char)( signature_len ); + ssl->out_msg[ssl->out_msglen++] = MBEDTLS_BYTE_1( signature_len ); + ssl->out_msg[ssl->out_msglen++] = MBEDTLS_BYTE_0( signature_len ); MBEDTLS_SSL_DEBUG_BUF( 3, "my signature", ssl->out_msg + ssl->out_msglen, diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 381eb9e03b..33f026f4d1 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -1487,8 +1487,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch if( end - p < 2 ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - *(p++) = (unsigned char)( psk_len >> 8 ); - *(p++) = (unsigned char)( psk_len ); + *(p++) = MBEDTLS_BYTE_1( psk_len ); + *(p++) = MBEDTLS_BYTE_0( psk_len ); if( end < p || (size_t)( end - p ) < psk_len ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); @@ -1528,8 +1528,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_calc_secret", ret ); return( ret ); } - *(p++) = (unsigned char)( len >> 8 ); - *(p++) = (unsigned char)( len ); + *(p++) = MBEDTLS_BYTE_1( len ); + *(p++) = MBEDTLS_BYTE_0( len ); p += len; MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K ); @@ -1550,8 +1550,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch return( ret ); } - *(p++) = (unsigned char)( zlen >> 8 ); - *(p++) = (unsigned char)( zlen ); + *(p++) = MBEDTLS_BYTE_1( zlen ); + *(p++) = MBEDTLS_BYTE_0( zlen ); p += zlen; MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, @@ -1568,8 +1568,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch if( end - p < 2 ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - *(p++) = (unsigned char)( psk_len >> 8 ); - *(p++) = (unsigned char)( psk_len ); + *(p++) = MBEDTLS_BYTE_1( psk_len ); + *(p++) = MBEDTLS_BYTE_0( psk_len ); if( end < p || (size_t)( end - p ) < psk_len ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); @@ -1746,17 +1746,17 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); } - ssl->out_msg[i ] = (unsigned char)( n >> 16 ); - ssl->out_msg[i + 1] = (unsigned char)( n >> 8 ); - ssl->out_msg[i + 2] = (unsigned char)( n ); + ssl->out_msg[i ] = MBEDTLS_BYTE_2( n ); + ssl->out_msg[i + 1] = MBEDTLS_BYTE_1( n ); + ssl->out_msg[i + 2] = MBEDTLS_BYTE_0( n ); i += 3; memcpy( ssl->out_msg + i, crt->raw.p, n ); i += n; crt = crt->next; } - ssl->out_msg[4] = (unsigned char)( ( i - 7 ) >> 16 ); - ssl->out_msg[5] = (unsigned char)( ( i - 7 ) >> 8 ); - ssl->out_msg[6] = (unsigned char)( ( i - 7 ) ); + ssl->out_msg[4] = MBEDTLS_BYTE_2( i - 7 ); + ssl->out_msg[5] = MBEDTLS_BYTE_1( i - 7 ); + ssl->out_msg[6] = MBEDTLS_BYTE_0( i - 7 ); ssl->out_msglen = i; ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; diff --git a/library/x509write_crt.c b/library/x509write_crt.c index c8169f1feb..0daf0683e9 100644 --- a/library/x509write_crt.c +++ b/library/x509write_crt.c @@ -251,8 +251,8 @@ int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx, return( MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE ); c = buf + 5; - ku[0] = (unsigned char)( key_usage ); - ku[1] = (unsigned char)( key_usage >> 8 ); + ku[0] = MBEDTLS_BYTE_0( key_usage ); + ku[1] = MBEDTLS_BYTE_1( key_usage ); ret = mbedtls_asn1_write_named_bitstring( &c, buf, ku, 9 ); if( ret < 0 ) From b6511b04fa8891a92fe45b42315ca9c4ec9439ac Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 16 Jul 2021 15:02:55 +0100 Subject: [PATCH 323/966] Replace instances of byte reading macros with PUT Instances of a group of byte reading macros which are equivilant to MBEDTLS_PUT_UINTx_yz Signed-off-by: Joe Subbiani --- library/chacha20.c | 5 +---- library/chachapoly.c | 18 ++---------------- library/ssl_cookie.c | 5 +---- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/library/chacha20.c b/library/chacha20.c index 0e057f0e3c..658f046901 100644 --- a/library/chacha20.c +++ b/library/chacha20.c @@ -164,10 +164,7 @@ static void chacha20_block( const uint32_t initial_state[16], { size_t offset = i * 4U; - keystream[offset ] = MBEDTLS_BYTE_0( working_state[i] ); - keystream[offset + 1U] = MBEDTLS_BYTE_1( working_state[i] ); - keystream[offset + 2U] = MBEDTLS_BYTE_2( working_state[i] ); - keystream[offset + 3U] = MBEDTLS_BYTE_3( working_state[i] ); + MBEDTLS_PUT_UINT32_LE(working_state[i], keystream, offset); } mbedtls_platform_zeroize( working_state, sizeof( working_state ) ); diff --git a/library/chachapoly.c b/library/chachapoly.c index 696d97bf01..dc75b2030a 100644 --- a/library/chachapoly.c +++ b/library/chachapoly.c @@ -263,22 +263,8 @@ int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx, /* The lengths of the AAD and ciphertext are processed by * Poly1305 as the final 128-bit block, encoded as little-endian integers. */ - len_block[ 0] = MBEDTLS_BYTE_0( ctx->aad_len ); - len_block[ 1] = MBEDTLS_BYTE_1( ctx->aad_len ); - len_block[ 2] = MBEDTLS_BYTE_2( ctx->aad_len ); - len_block[ 3] = MBEDTLS_BYTE_3( ctx->aad_len ); - len_block[ 4] = MBEDTLS_BYTE_4( ctx->aad_len ); - len_block[ 5] = MBEDTLS_BYTE_5( ctx->aad_len ); - len_block[ 6] = MBEDTLS_BYTE_6( ctx->aad_len ); - len_block[ 7] = MBEDTLS_BYTE_7( ctx->aad_len ); - len_block[ 8] = MBEDTLS_BYTE_0( ctx->ciphertext_len ); - len_block[ 9] = MBEDTLS_BYTE_1( ctx->ciphertext_len ); - len_block[10] = MBEDTLS_BYTE_2( ctx->ciphertext_len ); - len_block[11] = MBEDTLS_BYTE_3( ctx->ciphertext_len ); - len_block[12] = MBEDTLS_BYTE_4( ctx->ciphertext_len ); - len_block[13] = MBEDTLS_BYTE_5( ctx->ciphertext_len ); - len_block[14] = MBEDTLS_BYTE_6( ctx->ciphertext_len ); - len_block[15] = MBEDTLS_BYTE_7( ctx->ciphertext_len ); + MBEDTLS_PUT_UINT64_LE(ctx->aad_len, len_block, 0); + MBEDTLS_PUT_UINT64_LE(ctx->ciphertext_len, len_block, 8); ret = mbedtls_poly1305_update( &ctx->poly1305_ctx, len_block, 16U ); if( ret != 0 ) diff --git a/library/ssl_cookie.c b/library/ssl_cookie.c index 4f1c07bde6..986b1410b0 100644 --- a/library/ssl_cookie.c +++ b/library/ssl_cookie.c @@ -165,10 +165,7 @@ int mbedtls_ssl_cookie_write( void *p_ctx, t = ctx->serial++; #endif - (*p)[0] = MBEDTLS_BYTE_3( t ); - (*p)[1] = MBEDTLS_BYTE_2( t ); - (*p)[2] = MBEDTLS_BYTE_1( t ); - (*p)[3] = MBEDTLS_BYTE_0( t ); + MBEDTLS_PUT_UINT32_BE(t, *p, 0); *p += 4; #if defined(MBEDTLS_THREADING_C) From 4919bb46b02a7032518951d5ff5f9168a8876859 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 16 Jul 2021 17:14:07 +0100 Subject: [PATCH 324/966] Remove use of byte reading macro for uint16 Accidently used MBEDTLS_BYTE_16 for a uint16 variable Signed-off-by: Joe Subbiani --- library/poly1305.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/poly1305.c b/library/poly1305.c index 333aade94a..9e90d67b1a 100644 --- a/library/poly1305.c +++ b/library/poly1305.c @@ -61,9 +61,9 @@ static uint64_t mul64( uint32_t a, uint32_t b ) { /* a = al + 2**16 ah, b = bl + 2**16 bh */ const uint16_t al = (uint16_t) a; - const uint16_t bl = (uint16_t) b; - const uint16_t ah = MBEDTLS_BYTE_2( a ); - const uint16_t bh = MBEDTLS_BYTE_2( b ); + const uint16_t bl = (uint16_t) b; + const uint16_t ah = a >> 16; + const uint16_t bh = b >> 16; /* ab = al*bl + 2**16 (ah*bl + bl*bh) + 2**32 ah*bh */ const uint32_t lo = (uint32_t) al * bl; From 51b147add0abc84098c680ad7eac86d6dd3e10d6 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 16 Jul 2021 17:47:17 +0100 Subject: [PATCH 325/966] Remove trailing white space Signed-off-by: Joe Subbiani --- library/poly1305.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/poly1305.c b/library/poly1305.c index 9e90d67b1a..1f35f1d501 100644 --- a/library/poly1305.c +++ b/library/poly1305.c @@ -61,7 +61,7 @@ static uint64_t mul64( uint32_t a, uint32_t b ) { /* a = al + 2**16 ah, b = bl + 2**16 bh */ const uint16_t al = (uint16_t) a; - const uint16_t bl = (uint16_t) b; + const uint16_t bl = (uint16_t) b; const uint16_t ah = a >> 16; const uint16_t bh = b >> 16; From 6dd73645533dfaf489906c5ee30e9bb816b652a6 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Mon, 19 Jul 2021 11:56:54 +0100 Subject: [PATCH 326/966] Replace instances of byte reading macros with PUT Instances of a group of byte reading macros which are equivilant to MBEDTLS_PUT_UINTx_yz Signed-off-by: Joe Subbiani --- library/common.h | 34 ++++++++++++++++++++++++++++++++++ library/poly1305.c | 20 ++++---------------- library/psa_its_file.c | 10 ++-------- library/ssl_cli.c | 15 +++++---------- library/ssl_msg.c | 21 +++++++-------------- library/ssl_srv.c | 34 ++++++++++------------------------ library/ssl_ticket.c | 3 +-- library/x509write_crt.c | 3 +-- 8 files changed, 64 insertions(+), 76 deletions(-) diff --git a/library/common.h b/library/common.h index ce2f04007e..3e8f88bf34 100644 --- a/library/common.h +++ b/library/common.h @@ -193,6 +193,40 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c } #endif +/** + * Get the unsigned 16 bits integer corresponding to two bytes in + * big-endian order (LSB first). + * + * \param data Base address of the memory to get the two bytes from. + * \param offset Offset from \p base of the first and most significant + * byte of the two bytes to build the 16 bits unsigned + * integer from. + */ +#ifndef MBEDTLS_GET_UINT16_BE +#define MBEDTLS_GET_UINT16_BE( data, offset ) \ + ( \ + ( (uint16_t) ( data )[( offset ) ] << 8 ) \ + | ( (uint16_t) ( data )[( offset ) + 1] ) \ + ) +#endif + +/** + * Put in memory a 16 bits unsigned integer in big-endian order. + * + * \param n 16 bits unsigned integer to put in memory. + * \param data Base address of the memory where to put the 16 + * bits unsigned integer in. + * \param offset Offset from \p base where to put the most significant + * byte of the 16 bits unsigned integer \p n. + */ +#ifndef MBEDTLS_PUT_UINT16_BE +#define MBEDTLS_PUT_UINT16_BE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + ( data )[( offset ) + 1] = (unsigned char) ( ( (n) ) & 0xFF ); \ +} +#endif + /** * Get the unsigned 64 bits integer corresponding to eight bytes in * big-endian order (MSB first). diff --git a/library/poly1305.c b/library/poly1305.c index 1f35f1d501..7375a0c572 100644 --- a/library/poly1305.c +++ b/library/poly1305.c @@ -250,22 +250,10 @@ static void poly1305_compute_mac( const mbedtls_poly1305_context *ctx, acc3 += ctx->s[3] + (uint32_t) ( d >> 32U ); /* Compute MAC (128 least significant bits of the accumulator) */ - mac[ 0] = MBEDTLS_BYTE_0( acc0 ); - mac[ 1] = MBEDTLS_BYTE_1( acc0 ); - mac[ 2] = MBEDTLS_BYTE_2( acc0 ); - mac[ 3] = MBEDTLS_BYTE_3( acc0 ); - mac[ 4] = MBEDTLS_BYTE_0( acc1 ); - mac[ 5] = MBEDTLS_BYTE_1( acc1 ); - mac[ 6] = MBEDTLS_BYTE_2( acc1 ); - mac[ 7] = MBEDTLS_BYTE_3( acc1 ); - mac[ 8] = MBEDTLS_BYTE_0( acc2 ); - mac[ 9] = MBEDTLS_BYTE_1( acc2 ); - mac[10] = MBEDTLS_BYTE_2( acc2 ); - mac[11] = MBEDTLS_BYTE_3( acc2 ); - mac[12] = MBEDTLS_BYTE_0( acc3 ); - mac[13] = MBEDTLS_BYTE_1( acc3 ); - mac[14] = MBEDTLS_BYTE_2( acc3 ); - mac[15] = MBEDTLS_BYTE_3( acc3 ); + MBEDTLS_PUT_UINT32_LE( acc0, mac, 0 ); + MBEDTLS_PUT_UINT32_LE( acc1, mac, 4 ); + MBEDTLS_PUT_UINT32_LE( acc2, mac, 8 ); + MBEDTLS_PUT_UINT32_LE( acc3, mac, 12 ); } void mbedtls_poly1305_init( mbedtls_poly1305_context *ctx ) diff --git a/library/psa_its_file.c b/library/psa_its_file.c index c3b19a74ac..c4782cdba3 100644 --- a/library/psa_its_file.c +++ b/library/psa_its_file.c @@ -191,14 +191,8 @@ psa_status_t psa_its_set( psa_storage_uid_t uid, size_t n; memcpy( header.magic, PSA_ITS_MAGIC_STRING, PSA_ITS_MAGIC_LENGTH ); - header.size[0] = MBEDTLS_BYTE_0( data_length ); - header.size[1] = MBEDTLS_BYTE_1( data_length ); - header.size[2] = MBEDTLS_BYTE_2( data_length ); - header.size[3] = MBEDTLS_BYTE_3( data_length ); - header.flags[0] = MBEDTLS_BYTE_0( create_flags ); - header.flags[1] = MBEDTLS_BYTE_1( create_flags ); - header.flags[2] = MBEDTLS_BYTE_2( create_flags ); - header.flags[3] = MBEDTLS_BYTE_3( create_flags ); + MBEDTLS_PUT_UINT32_LE( data_length, header.size, 0 ); + MBEDTLS_PUT_UINT32_LE( create_flags, header.flags, 0 ); psa_its_fill_filename( uid, filename ); stream = fopen( PSA_ITS_STORAGE_TEMP, "wb" ); diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 729784a6eb..3a0e6df6f4 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -703,12 +703,10 @@ static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl, *olen = p - buf; /* List length = olen - 2 (ext_type) - 2 (ext_len) - 2 (list_len) */ - buf[4] = MBEDTLS_BYTE_1( *olen - 6 ); - buf[5] = MBEDTLS_BYTE_0( *olen - 6 ); + MBEDTLS_PUT_UINT16_BE( *olen - 6, buf, 4 ); /* Extension length = olen - 2 (ext_type) - 2 (ext_len) */ - buf[2] = MBEDTLS_BYTE_1( *olen - 4 ); - buf[3] = MBEDTLS_BYTE_0( *olen - 4 ); + MBEDTLS_PUT_UINT16_BE( *olen - 4, buf, 2 ); return( 0 ); } @@ -2745,8 +2743,7 @@ static int ssl_write_encrypted_pms( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_SSL_PROTO_TLS1_2) if( len_bytes == 2 ) { - ssl->out_msg[offset+0] = MBEDTLS_BYTE_1( *olen ); - ssl->out_msg[offset+1] = MBEDTLS_BYTE_0( *olen ); + MBEDTLS_PUT_UINT16_BE( *olen, ssl->out_msg, offset ); *olen += 2; } #endif @@ -3503,8 +3500,7 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) */ content_len = mbedtls_dhm_get_len( &ssl->handshake->dhm_ctx ); - ssl->out_msg[4] = MBEDTLS_BYTE_1( content_len ); - ssl->out_msg[5] = MBEDTLS_BYTE_0( content_len ); + MBEDTLS_PUT_UINT16_BE( content_len, ssl->out_msg, 4 ); header_len = 6; ret = mbedtls_dhm_make_public( &ssl->handshake->dhm_ctx, @@ -4054,8 +4050,7 @@ sign: return( ret ); } - ssl->out_msg[4 + offset] = MBEDTLS_BYTE_1( n ); - ssl->out_msg[5 + offset] = MBEDTLS_BYTE_0( n ); + MBEDTLS_PUT_UINT16_BE( n, ssl->out_msg, offset + 4 ); ssl->out_msglen = 6 + n + offset; ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 304e7f22b7..2fe801a283 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -454,15 +454,13 @@ static void ssl_extract_add_data_from_record( unsigned char* add_data, *cur = rec->cid_len; cur++; - cur[0] = MBEDTLS_CHAR_1( ad_len_field ); - cur[1] = MBEDTLS_CHAR_0( ad_len_field ); + MBEDTLS_PUT_UINT16_BE( ad_len_field, cur, 0 ); cur += 2; } else #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ { - cur[0] = MBEDTLS_CHAR_1( ad_len_field ); - cur[1] = MBEDTLS_CHAR_0( ad_len_field ); + MBEDTLS_PUT_UINT16_BE( ad_len_field, cur, 0 ); cur += 2; } @@ -2481,8 +2479,7 @@ int mbedtls_ssl_write_handshake_msg_ext( mbedtls_ssl_context *ssl, /* Write message_seq and update it, except for HelloRequest */ if( hs_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) { - ssl->out_msg[4] = MBEDTLS_BYTE_1( ssl->handshake->out_msg_seq ); - ssl->out_msg[5] = MBEDTLS_BYTE_0( ssl->handshake->out_msg_seq ); + MBEDTLS_PUT_UINT16_BE( ssl->handshake->out_msg_seq, ssl->out_msg, 4 ); ++( ssl->handshake->out_msg_seq ); } else @@ -2566,8 +2563,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) ssl->conf->transport, ssl->out_hdr + 1 ); memcpy( ssl->out_ctr, ssl->cur_out_ctr, 8 ); - ssl->out_len[0] = MBEDTLS_BYTE_1( len ); - ssl->out_len[1] = MBEDTLS_BYTE_0( len ); + MBEDTLS_PUT_UINT16_BE( len, ssl->out_len, 0); if( ssl->transform_out != NULL ) { @@ -2607,8 +2603,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) memcpy( ssl->out_cid, rec.cid, rec.cid_len ); #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ ssl->out_msglen = len = rec.data_len; - ssl->out_len[0] = MBEDTLS_BYTE_1( rec.data_len ); - ssl->out_len[1] = MBEDTLS_BYTE_0( rec.data_len ); + MBEDTLS_PUT_UINT16_BE( rec.data_len, ssl->out_len, 0 ); } protected_record_size = len + mbedtls_ssl_out_hdr_len( ssl ); @@ -3184,8 +3179,7 @@ static int ssl_check_dtls_clihlo_cookie( obuf[15] = obuf[23] = MBEDTLS_BYTE_1( *olen - 25 ); obuf[16] = obuf[24] = MBEDTLS_BYTE_0( *olen - 25 ); - obuf[11] = MBEDTLS_BYTE_1( *olen - 13 ); - obuf[12] = MBEDTLS_BYTE_0( *olen - 13 ); + MBEDTLS_PUT_UINT16_BE( *olen - 13, obuf, 11 ); return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ); } @@ -4565,8 +4559,7 @@ static int ssl_get_next_record( mbedtls_ssl_context *ssl ) ssl->in_hdr[0] = rec.type; ssl->in_msg = rec.buf + rec.data_offset; ssl->in_msglen = rec.data_len; - ssl->in_len[0] = MBEDTLS_BYTE_1( rec.data_len ); - ssl->in_len[1] = MBEDTLS_BYTE_0( rec.data_len ); + MBEDTLS_PUT_UINT16_BE( rec.data_len, ssl->in_len, 0 ); return( 0 ); } diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 232846ff08..a791b80764 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -2238,16 +2238,13 @@ static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl, * 6 . 6 protocol name length * 7 . 7+n protocol name */ - buf[0] = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ALPN ); - buf[1] = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ALPN ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ALPN, buf, 0); *olen = 7 + strlen( ssl->alpn_chosen ); - buf[2] = MBEDTLS_BYTE_1( *olen - 4 ); - buf[3] = MBEDTLS_BYTE_0( *olen - 4 ); + MBEDTLS_PUT_UINT16_BE( *olen - 4, buf, 2 ); - buf[4] = MBEDTLS_BYTE_1( *olen - 6 ); - buf[5] = MBEDTLS_BYTE_0( *olen - 6 ); + MBEDTLS_PUT_UINT16_BE( *olen - 6, buf, 4 ); buf[6] = MBEDTLS_BYTE_0( *olen - 7 ); @@ -2294,15 +2291,13 @@ static void ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, } /* extension */ - buf[0] = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_USE_SRTP ); - buf[1] = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_USE_SRTP ); + MBEDTLS_PUT_UINT16_BE(MBEDTLS_TLS_EXT_USE_SRTP, buf, 0 ); /* * total length 5 and mki value: only one profile(2 bytes) * and length(2 bytes) and srtp_mki ) */ ext_len = 5 + mki_len; - buf[2] = MBEDTLS_BYTE_1( ext_len ); - buf[3] = MBEDTLS_BYTE_0( ext_len ); + MBEDTLS_PUT_UINT16_BE( ext_len, buf, 2 ); /* protection profile length: 2 */ buf[4] = 0x00; @@ -2311,8 +2306,7 @@ static void ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, ssl->dtls_srtp_info.chosen_dtls_srtp_profile ); if( profile_value != MBEDTLS_TLS_SRTP_UNSET ) { - buf[6] = MBEDTLS_BYTE_1( profile_value ); - buf[7] = MBEDTLS_BYTE_0( profile_value ); + MBEDTLS_PUT_UINT16_BE( profile_value, buf, 6 ); } else { @@ -2785,8 +2779,7 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) #endif } - p[0] = MBEDTLS_BYTE_1( sa_len ); - p[1] = MBEDTLS_BYTE_0( sa_len ); + MBEDTLS_PUT_UINT16_BE( sa_len, p, 0 ); sa_len += 2; p += sa_len; } @@ -2841,8 +2834,7 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) ssl->out_msglen = p - buf; ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; ssl->out_msg[0] = MBEDTLS_SSL_HS_CERTIFICATE_REQUEST; - ssl->out_msg[4 + ct_len + sa_len] = MBEDTLS_BYTE_1( total_dn_size ); - ssl->out_msg[5 + ct_len + sa_len] = MBEDTLS_BYTE_0( total_dn_size ); + MBEDTLS_PUT_UINT16_BE( total_dn_size, ssl->out_msg, 4 + ct_len + sa_len ); ret = mbedtls_ssl_write_handshake_msg( ssl ); @@ -4223,14 +4215,8 @@ static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl ) tlen = 0; } - ssl->out_msg[4] = MBEDTLS_BYTE_3( lifetime ); - ssl->out_msg[5] = MBEDTLS_BYTE_2( lifetime ); - ssl->out_msg[6] = MBEDTLS_BYTE_1( lifetime ); - ssl->out_msg[7] = MBEDTLS_BYTE_0( lifetime ); - - ssl->out_msg[8] = MBEDTLS_BYTE_1( tlen ); - ssl->out_msg[9] = MBEDTLS_BYTE_0( tlen ); - + MBEDTLS_PUT_UINT32_BE( lifetime, ssl->out_msg, 4 ); + MBEDTLS_PUT_UINT16_BE( tlen, ssl->out_msg, 8 ); ssl->out_msglen = 10 + tlen; /* diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c index a7a55f1a75..bce9a1cd71 100644 --- a/library/ssl_ticket.c +++ b/library/ssl_ticket.c @@ -245,8 +245,7 @@ int mbedtls_ssl_ticket_write( void *p_ticket, { goto cleanup; } - state_len_bytes[0] = MBEDTLS_BYTE_1( clear_len ); - state_len_bytes[1] = MBEDTLS_BYTE_0( clear_len ); + MBEDTLS_PUT_UINT16_BE( clear_len, state_len_bytes, 0 ); /* Encrypt and authenticate */ if( ( ret = mbedtls_cipher_auth_encrypt_ext( &key->ctx, diff --git a/library/x509write_crt.c b/library/x509write_crt.c index 0daf0683e9..17b3e7966b 100644 --- a/library/x509write_crt.c +++ b/library/x509write_crt.c @@ -251,8 +251,7 @@ int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx, return( MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE ); c = buf + 5; - ku[0] = MBEDTLS_BYTE_0( key_usage ); - ku[1] = MBEDTLS_BYTE_1( key_usage ); + MBEDTLS_PUT_UINT16_LE( key_usage, ku, 0 ); ret = mbedtls_asn1_write_named_bitstring( &c, buf, ku, 9 ); if( ret < 0 ) From 5241e343ded7655e4baa95a493002ec93ae458c1 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Mon, 19 Jul 2021 15:29:18 +0100 Subject: [PATCH 327/966] Improve consitency throughout library/common.h Replace the contents of MBEDTLS_PUT_UINTx_yz contained inconsitent but similar/duplicate code to the MBEDTLS_BYTE_x macros. Therefore the contents of the macros now utilise the byte reading macros. MBEDTLS_PUT_UINT64_LE's written order was also not consitent with the other PUT macros, so that was modified. Documentation comment said LSB instead of MSB and that has also been resolved. Signed-off-by: Joe Subbiani --- library/common.h | 166 +++++++++++++++++++++++------------------------ 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/library/common.h b/library/common.h index 3e8f88bf34..ba0396c58c 100644 --- a/library/common.h +++ b/library/common.h @@ -93,12 +93,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * integer from. */ #ifndef MBEDTLS_GET_UINT32_BE -#define MBEDTLS_GET_UINT32_BE( data , offset ) \ - ( \ - ( (uint32_t) ( data )[( offset ) ] << 24 ) \ - | ( (uint32_t) ( data )[( offset ) + 1] << 16 ) \ - | ( (uint32_t) ( data )[( offset ) + 2] << 8 ) \ - | ( (uint32_t) ( data )[( offset ) + 3] ) \ +#define MBEDTLS_GET_UINT32_BE( data , offset ) \ + ( \ + ( (uint32_t) ( data )[( offset ) ] << 24 ) \ + | ( (uint32_t) ( data )[( offset ) + 1] << 16 ) \ + | ( (uint32_t) ( data )[( offset ) + 2] << 8 ) \ + | ( (uint32_t) ( data )[( offset ) + 3] ) \ ) #endif @@ -112,13 +112,13 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * byte of the 32 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT32_BE -#define MBEDTLS_PUT_UINT32_BE( n, data, offset ) \ - do { \ - ( data )[( offset ) ] = (unsigned char) ( (n) >> 24 ); \ - ( data )[( offset ) + 1] = (unsigned char) ( (n) >> 16 ); \ - ( data )[( offset ) + 2] = (unsigned char) ( (n) >> 8 ); \ - ( data )[( offset ) + 3] = (unsigned char) ( (n) ); \ - } while( 0 ) +#define MBEDTLS_PUT_UINT32_BE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = MBEDTLS_BYTE_3( n ); \ + ( data )[( offset ) + 1] = MBEDTLS_BYTE_2( n ); \ + ( data )[( offset ) + 2] = MBEDTLS_BYTE_1( n ); \ + ( data )[( offset ) + 3] = MBEDTLS_BYTE_0( n ); \ +} #endif /** @@ -131,12 +131,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * integer from. */ #ifndef MBEDTLS_GET_UINT32_LE -#define MBEDTLS_GET_UINT32_LE( data, offset ) \ - ( \ - ( (uint32_t) ( data )[( offset ) ] ) \ - | ( (uint32_t) ( data )[( offset ) + 1] << 8 ) \ - | ( (uint32_t) ( data )[( offset ) + 2] << 16 ) \ - | ( (uint32_t) ( data )[( offset ) + 3] << 24 ) \ +#define MBEDTLS_GET_UINT32_LE( data, offset ) \ + ( \ + ( (uint32_t) ( data )[( offset ) ] ) \ + | ( (uint32_t) ( data )[( offset ) + 1] << 8 ) \ + | ( (uint32_t) ( data )[( offset ) + 2] << 16 ) \ + | ( (uint32_t) ( data )[( offset ) + 3] << 24 ) \ ) #endif @@ -150,13 +150,13 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * byte of the 32 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT32_LE -#define MBEDTLS_PUT_UINT32_LE( n, data, offset ) \ - do { \ - ( data )[( offset ) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - ( data )[( offset ) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - ( data )[( offset ) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ - ( data )[( offset ) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ - } while( 0 ) +#define MBEDTLS_PUT_UINT32_LE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = MBEDTLS_BYTE_0( n ); \ + ( data )[( offset ) + 1] = MBEDTLS_BYTE_1( n ); \ + ( data )[( offset ) + 2] = MBEDTLS_BYTE_2( n ); \ + ( data )[( offset ) + 3] = MBEDTLS_BYTE_3( n ); \ +} #endif /** @@ -169,10 +169,10 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * integer from. */ #ifndef MBEDTLS_GET_UINT16_LE -#define MBEDTLS_GET_UINT16_LE( data, offset ) \ - ( \ - ( (uint16_t) ( data )[( offset ) ] ) \ - | ( (uint16_t) ( data )[( offset ) + 1] << 8 ) \ +#define MBEDTLS_GET_UINT16_LE( data, offset ) \ + ( \ + ( (uint16_t) ( data )[( offset ) ] ) \ + | ( (uint16_t) ( data )[( offset ) + 1] << 8 ) \ ) #endif @@ -186,16 +186,16 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * byte of the 16 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT16_LE -#define MBEDTLS_PUT_UINT16_LE( n, data, offset ) \ -{ \ - ( data )[( offset ) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ - ( data )[( offset ) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ +#define MBEDTLS_PUT_UINT16_LE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = MBEDTLS_BYTE_0( n ); \ + ( data )[( offset ) + 1] = MBEDTLS_BYTE_1( n ); \ } #endif /** * Get the unsigned 16 bits integer corresponding to two bytes in - * big-endian order (LSB first). + * big-endian order (MSB first). * * \param data Base address of the memory to get the two bytes from. * \param offset Offset from \p base of the first and most significant @@ -203,10 +203,10 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * integer from. */ #ifndef MBEDTLS_GET_UINT16_BE -#define MBEDTLS_GET_UINT16_BE( data, offset ) \ - ( \ - ( (uint16_t) ( data )[( offset ) ] << 8 ) \ - | ( (uint16_t) ( data )[( offset ) + 1] ) \ +#define MBEDTLS_GET_UINT16_BE( data, offset ) \ + ( \ + ( (uint16_t) ( data )[( offset ) ] << 8 ) \ + | ( (uint16_t) ( data )[( offset ) + 1] ) \ ) #endif @@ -220,10 +220,10 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * byte of the 16 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT16_BE -#define MBEDTLS_PUT_UINT16_BE( n, data, offset ) \ -{ \ - ( data )[( offset ) ] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ - ( data )[( offset ) + 1] = (unsigned char) ( ( (n) ) & 0xFF ); \ +#define MBEDTLS_PUT_UINT16_BE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = MBEDTLS_BYTE_1( n ); \ + ( data )[( offset ) + 1] = MBEDTLS_BYTE_0( n ); \ } #endif @@ -237,16 +237,16 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * integer from. */ #ifndef MBEDTLS_GET_UINT64_BE -#define MBEDTLS_GET_UINT64_BE( data, offset ) \ - ( \ - ( (uint64_t) ( data )[( offset ) ] << 56 ) \ - | ( (uint64_t) ( data )[( offset ) + 1] << 48 ) \ - | ( (uint64_t) ( data )[( offset ) + 2] << 40 ) \ - | ( (uint64_t) ( data )[( offset ) + 3] << 32 ) \ - | ( (uint64_t) ( data )[( offset ) + 4] << 24 ) \ - | ( (uint64_t) ( data )[( offset ) + 5] << 16 ) \ - | ( (uint64_t) ( data )[( offset ) + 6] << 8 ) \ - | ( (uint64_t) ( data )[( offset ) + 7] ) \ +#define MBEDTLS_GET_UINT64_BE( data, offset ) \ + ( \ + ( (uint64_t) ( data )[( offset ) ] << 56 ) \ + | ( (uint64_t) ( data )[( offset ) + 1] << 48 ) \ + | ( (uint64_t) ( data )[( offset ) + 2] << 40 ) \ + | ( (uint64_t) ( data )[( offset ) + 3] << 32 ) \ + | ( (uint64_t) ( data )[( offset ) + 4] << 24 ) \ + | ( (uint64_t) ( data )[( offset ) + 5] << 16 ) \ + | ( (uint64_t) ( data )[( offset ) + 6] << 8 ) \ + | ( (uint64_t) ( data )[( offset ) + 7] ) \ ) #endif @@ -260,16 +260,16 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * byte of the 64 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT64_BE -#define MBEDTLS_PUT_UINT64_BE( n, data, offset ) \ -{ \ - ( data )[( offset ) ] = (unsigned char) ( (n) >> 56 ); \ - ( data )[( offset ) + 1] = (unsigned char) ( (n) >> 48 ); \ - ( data )[( offset ) + 2] = (unsigned char) ( (n) >> 40 ); \ - ( data )[( offset ) + 3] = (unsigned char) ( (n) >> 32 ); \ - ( data )[( offset ) + 4] = (unsigned char) ( (n) >> 24 ); \ - ( data )[( offset ) + 5] = (unsigned char) ( (n) >> 16 ); \ - ( data )[( offset ) + 6] = (unsigned char) ( (n) >> 8 ); \ - ( data )[( offset ) + 7] = (unsigned char) ( (n) ); \ +#define MBEDTLS_PUT_UINT64_BE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = MBEDTLS_BYTE_7( n ); \ + ( data )[( offset ) + 1] = MBEDTLS_BYTE_6( n ); \ + ( data )[( offset ) + 2] = MBEDTLS_BYTE_5( n ); \ + ( data )[( offset ) + 3] = MBEDTLS_BYTE_4( n ); \ + ( data )[( offset ) + 4] = MBEDTLS_BYTE_3( n ); \ + ( data )[( offset ) + 5] = MBEDTLS_BYTE_2( n ); \ + ( data )[( offset ) + 6] = MBEDTLS_BYTE_1( n ); \ + ( data )[( offset ) + 7] = MBEDTLS_BYTE_0( n ); \ } #endif @@ -283,16 +283,16 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * integer from. */ #ifndef MBEDTLS_GET_UINT64_LE -#define MBEDTLS_GET_UINT64_LE( data, offset ) \ - ( \ - ( (uint64_t) ( data )[( offset ) + 7] << 56 ) \ - | ( (uint64_t) ( data )[( offset ) + 6] << 48 ) \ - | ( (uint64_t) ( data )[( offset ) + 5] << 40 ) \ - | ( (uint64_t) ( data )[( offset ) + 4] << 32 ) \ - | ( (uint64_t) ( data )[( offset ) + 3] << 24 ) \ - | ( (uint64_t) ( data )[( offset ) + 2] << 16 ) \ - | ( (uint64_t) ( data )[( offset ) + 1] << 8 ) \ - | ( (uint64_t) ( data )[( offset ) ] ) \ +#define MBEDTLS_GET_UINT64_LE( data, offset ) \ + ( \ + ( (uint64_t) ( data )[( offset ) + 7] << 56 ) \ + | ( (uint64_t) ( data )[( offset ) + 6] << 48 ) \ + | ( (uint64_t) ( data )[( offset ) + 5] << 40 ) \ + | ( (uint64_t) ( data )[( offset ) + 4] << 32 ) \ + | ( (uint64_t) ( data )[( offset ) + 3] << 24 ) \ + | ( (uint64_t) ( data )[( offset ) + 2] << 16 ) \ + | ( (uint64_t) ( data )[( offset ) + 1] << 8 ) \ + | ( (uint64_t) ( data )[( offset ) ] ) \ ) #endif @@ -306,16 +306,16 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * byte of the 64 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT64_LE -#define MBEDTLS_PUT_UINT64_LE( n, data, offset ) \ -{ \ - ( data )[( offset ) + 7] = (unsigned char) ( (n) >> 56 ); \ - ( data )[( offset ) + 6] = (unsigned char) ( (n) >> 48 ); \ - ( data )[( offset ) + 5] = (unsigned char) ( (n) >> 40 ); \ - ( data )[( offset ) + 4] = (unsigned char) ( (n) >> 32 ); \ - ( data )[( offset ) + 3] = (unsigned char) ( (n) >> 24 ); \ - ( data )[( offset ) + 2] = (unsigned char) ( (n) >> 16 ); \ - ( data )[( offset ) + 1] = (unsigned char) ( (n) >> 8 ); \ - ( data )[( offset ) ] = (unsigned char) ( (n) ); \ +#define MBEDTLS_PUT_UINT64_LE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = MBEDTLS_BYTE_0( n ); \ + ( data )[( offset ) + 1] = MBEDTLS_BYTE_1( n ); \ + ( data )[( offset ) + 2] = MBEDTLS_BYTE_2( n ); \ + ( data )[( offset ) + 3] = MBEDTLS_BYTE_3( n ); \ + ( data )[( offset ) + 4] = MBEDTLS_BYTE_4( n ); \ + ( data )[( offset ) + 5] = MBEDTLS_BYTE_5( n ); \ + ( data )[( offset ) + 6] = MBEDTLS_BYTE_6( n ); \ + ( data )[( offset ) + 7] = MBEDTLS_BYTE_7( n ); \ } #endif From d0687856afdc603112b39edf5443dfe539eaee40 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 21 Jul 2021 15:22:47 +0100 Subject: [PATCH 328/966] Improve documentation and add more uses of MBEDTLS_PUT minor changes, such as improving the documentation for the byte reading macros, and using MBEDTLS_PUT_UINT16_xy in place of byte reading macro combinations Signed-off-by: Joe Subbiani --- library/ccm.c | 3 +-- library/common.h | 5 ++--- library/ecp.c | 3 +-- library/ssl_cli.c | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index 0188075f5e..a21a37f55f 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -221,8 +221,7 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, src = add; memset( b, 0, 16 ); - b[0] = MBEDTLS_BYTE_1( add_len ); - b[1] = MBEDTLS_BYTE_0( add_len ); + MBEDTLS_PUT_UINT16_BE( add_len, b, 0 ); use_len = len_left < 16 - 2 ? len_left : 16 - 2; memcpy( b + 2, src, use_len ); diff --git a/library/common.h b/library/common.h index ba0396c58c..d740c7338c 100644 --- a/library/common.h +++ b/library/common.h @@ -70,9 +70,8 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c /** Byte Reading Macros * - * Obtain the most significant byte of x using 0xff - * Using MBEDTLS_BYTE_a will shift a*8 bits - * to retrieve the next byte of information + * Given a multi-byte integer \p x, MBEDTLS_BYTE_n retrieves the n-th + * byte from x, where byte 0 is the least significant byte. */ #define MBEDTLS_BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) #define MBEDTLS_BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) ) diff --git a/library/ecp.c b/library/ecp.c index fdfc960069..0212069c83 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -1012,8 +1012,7 @@ int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen, /* * Next two bytes are the namedcurve value */ - buf[0] = MBEDTLS_BYTE_1( curve_info->tls_id ); - buf[1] = MBEDTLS_BYTE_0( curve_info->tls_id ); + MBEDTLS_PUT_UINT16_BE( curve_info->tls_id, buf, 0 ); return( 0 ); } diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 3a0e6df6f4..0e25b6c60a 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -762,7 +762,7 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_USE_SRTP ); - *p++ = MBEDTLS_BYTE_1( ext_len & 0xFF00 ); + *p++ = MBEDTLS_BYTE_1( ext_len ); *p++ = MBEDTLS_BYTE_0( ext_len ); /* protection profile length: 2*(ssl->conf->dtls_srtp_profile_list_len) */ From 9ab1866b0d0adace1c6c7ac65e0d8c586ad5a320 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 21 Jul 2021 16:35:48 +0100 Subject: [PATCH 329/966] Remove trailing whitespace Signed-off-by: Joe Subbiani --- library/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/common.h b/library/common.h index d740c7338c..780ce378de 100644 --- a/library/common.h +++ b/library/common.h @@ -70,7 +70,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c /** Byte Reading Macros * - * Given a multi-byte integer \p x, MBEDTLS_BYTE_n retrieves the n-th + * Given a multi-byte integer \p x, MBEDTLS_BYTE_n retrieves the n-th * byte from x, where byte 0 is the least significant byte. */ #define MBEDTLS_BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) ) From 5d3a3c3ee43a54e5ad2cb2e80200cb770435ae67 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 19 Aug 2021 18:34:41 +0100 Subject: [PATCH 330/966] Fix arguments formatting mistake Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 09fff0c6bd..1dd3b2db92 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1509,7 +1509,7 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( operation->id = PSA_CRYPTO_TRANSPARENT_TEST_DRIVER_ID; status = mbedtls_test_transparent_aead_decrypt_setup( &operation->ctx.transparent_test_driver_ctx, - attributes, + attributes, key_buffer, key_buffer_size, alg ); @@ -1523,7 +1523,7 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; status = mbedtls_psa_aead_decrypt_setup( &operation->ctx.mbedtls_ctx, - attributes, + attributes, key_buffer, key_buffer_size, alg ); From e0a12bd852b07ee7fdec24585646f31c341391be Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 19 Aug 2021 18:55:56 +0100 Subject: [PATCH 331/966] Refactor aead setup functions into single function Move common encrypt / decrypt code into common function, and roll in previously refactored setup checks function, as this is now the only place it is called. Signed-off-by: Paul Elliott --- library/psa_crypto.c | 154 +++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 88 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index e40e370a00..1566a45342 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3401,26 +3401,82 @@ static psa_algorithm_t psa_aead_get_base_algorithm( psa_algorithm_t alg ) return PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( alg ); } -static psa_status_t psa_aead_setup_checks( psa_aead_operation_t *operation, - psa_algorithm_t alg ) +/* Set the key for a multipart authenticated operation. */ +static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, + mbedtls_svc_key_id_t key, + psa_algorithm_t alg ) { + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; + psa_key_slot_t *slot = NULL; + psa_key_usage_t key_usage = 0; + if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) ) { - return( PSA_ERROR_INVALID_ARGUMENT ); + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; } if( operation->id != 0 ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } if( operation->nonce_set || operation->lengths_set || operation->ad_started || operation->body_started ) { - return( PSA_ERROR_BAD_STATE ); + status = PSA_ERROR_BAD_STATE; + goto exit; } - return( PSA_SUCCESS ); + if( operation->is_encrypt ) + key_usage = PSA_KEY_USAGE_ENCRYPT; + else + key_usage = PSA_KEY_USAGE_DECRYPT; + + status = psa_get_and_lock_key_slot_with_policy( key, &slot, key_usage, + alg ); + + if( status != PSA_SUCCESS ) + goto exit; + + psa_key_attributes_t attributes = { + .core = slot->attr + }; + + if( operation->is_encrypt ) + status = psa_driver_wrapper_aead_encrypt_setup( operation, + &attributes, + slot->key.data, + slot->key.bytes, + alg ); + else + status = psa_driver_wrapper_aead_decrypt_setup( operation, + &attributes, + slot->key.data, + slot->key.bytes, + alg ); + + + if( status != PSA_SUCCESS ) + goto exit; + + operation->key_type = psa_get_key_type( &attributes ); + +exit: + + unlock_status = psa_unlock_key_slot( slot ); + + if( status == PSA_SUCCESS ) + { + status = unlock_status; + operation->alg = psa_aead_get_base_algorithm( alg ); + } + else + psa_aead_abort( operation ); + + return( status ); } /* Set the key for a multipart authenticated encryption operation. */ @@ -3428,48 +3484,9 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg ) { - psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; - psa_key_slot_t *slot = NULL; + operation->is_encrypt = 1; - status = psa_aead_setup_checks( operation, alg ); - - if( status != PSA_SUCCESS ) - goto exit; - - status = psa_get_and_lock_key_slot_with_policy( - key, &slot, PSA_KEY_USAGE_ENCRYPT, alg ); - - if( status != PSA_SUCCESS ) - goto exit; - - psa_key_attributes_t attributes = { - .core = slot->attr - }; - - status = psa_driver_wrapper_aead_encrypt_setup( operation, - &attributes, slot->key.data, - slot->key.bytes, alg ); - - if( status != PSA_SUCCESS ) - goto exit; - - operation->key_type = psa_get_key_type( &attributes ); - -exit: - - unlock_status = psa_unlock_key_slot( slot ); - - if( status == PSA_SUCCESS ) - { - status = unlock_status; - operation->alg = psa_aead_get_base_algorithm( alg ); - operation->is_encrypt = 1; - } - else - psa_aead_abort( operation ); - - return( status ); + return( psa_aead_setup( operation, key, alg ) ); } /* Set the key for a multipart authenticated decryption operation. */ @@ -3477,48 +3494,9 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg ) { - psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED; - psa_key_slot_t *slot = NULL; + operation->is_encrypt = 0; - status = psa_aead_setup_checks( operation, alg ); - - if( status != PSA_SUCCESS ) - goto exit; - - status = psa_get_and_lock_key_slot_with_policy( - key, &slot, PSA_KEY_USAGE_DECRYPT, alg ); - - if( status != PSA_SUCCESS ) - goto exit; - - psa_key_attributes_t attributes = { - .core = slot->attr - }; - - status = psa_driver_wrapper_aead_decrypt_setup( operation, - &attributes, slot->key.data, - slot->key.bytes, alg ); - - if( status != PSA_SUCCESS ) - goto exit; - - operation->key_type = psa_get_key_type( &attributes ); - -exit: - - unlock_status = psa_unlock_key_slot( slot ); - - if( status == PSA_SUCCESS ) - { - status = unlock_status; - operation->alg = psa_aead_get_base_algorithm( alg ); - operation->is_encrypt = 0; - } - else - psa_aead_abort( operation ); - - return( status ); + return( psa_aead_setup( operation, key, alg ) ); } /* Generate a random nonce / IV for multipart AEAD operation */ From 36869706e298e86982587c10903a0d7d4acfd049 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 19 Aug 2021 19:17:04 +0100 Subject: [PATCH 332/966] Remove duplicated statements in documentation. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index 38202b6fb4..5ed26d002e 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -159,10 +159,7 @@ psa_status_t mbedtls_psa_aead_decrypt( * mbedtls_psa_aead_encrypt_setup(), the operation is reset by the PSA core by a * call to mbedtls_psa_aead_abort(). The PSA core may call * mbedtls_psa_aead_abort() at any time after the operation has been - * initialized. - * - * After a successful call to mbedtls_psa_aead_encrypt_setup(), the PSA core - * eventually terminates the operation by calling mbedtls_psa_aead_abort(). + * initialized, and is required to when the operation is no longer needed. * * \param[in,out] operation The operation object to set up. It must have * been initialized as per the documentation for @@ -203,10 +200,7 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( * mbedtls_psa_aead_decrypt_setup(), the PSA core resets the operation by a * call to mbedtls_psa_aead_abort(). The PSA core may call * mbedtls_psa_aead_abort() at any time after the operation has been - * initialized. - * - * After a successful call to mbedtls_psa_aead_decrypt_setup(), the PSA core - * eventually terminates the operation by a call to mbedtls_psa_aead_abort(). + * initialized, and is required to when the operation is no longer needed. * * \param[in,out] operation The operation object to set up. It must have * been initialized as per the documentation for From ce0e6a9dea61fa7153c189b2c3b3a07a82e322db Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 17 Aug 2021 15:24:32 +0200 Subject: [PATCH 333/966] Require MESSAGE flag in PSA MAC setup. Signed-off-by: Mateusz Starzyk --- library/psa_crypto.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 3574b9842a..f87323c497 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2329,7 +2329,7 @@ static psa_status_t psa_mac_setup( psa_mac_operation_t *operation, status = psa_get_and_lock_key_slot_with_policy( key, &slot, - is_sign ? PSA_KEY_USAGE_SIGN_HASH : PSA_KEY_USAGE_VERIFY_HASH, + is_sign ? PSA_KEY_USAGE_SIGN_MESSAGE : PSA_KEY_USAGE_VERIFY_MESSAGE, alg ); if( status != PSA_SUCCESS ) goto exit; @@ -2514,8 +2514,9 @@ static psa_status_t psa_mac_compute_internal( mbedtls_svc_key_id_t key, uint8_t operation_mac_size = 0; status = psa_get_and_lock_key_slot_with_policy( - key, &slot, - is_sign ? PSA_KEY_USAGE_SIGN_HASH : PSA_KEY_USAGE_VERIFY_HASH, + key, + &slot, + is_sign ? PSA_KEY_USAGE_SIGN_MESSAGE : PSA_KEY_USAGE_VERIFY_MESSAGE, alg ); if( status != PSA_SUCCESS ) goto exit; From cb0a7cd142257658c116a10c9d2926ba1b46bab6 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 19 Aug 2021 15:11:50 +0200 Subject: [PATCH 334/966] Fix mac_key_policy test function Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_psa_crypto.function | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 150a3f43e3..3fe512e8e7 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -818,7 +818,7 @@ void mac_key_policy( int policy_usage_arg, mbedtls_test_update_key_usage_flags( policy_usage ) ); status = psa_mac_sign_setup( &operation, key, exercise_alg ); - if( ( policy_usage & PSA_KEY_USAGE_SIGN_HASH ) == 0 ) + if( ( mbedtls_test_update_key_usage_flags(policy_usage) & PSA_KEY_USAGE_SIGN_MESSAGE ) == 0 ) TEST_EQUAL( status, PSA_ERROR_NOT_PERMITTED ); else TEST_EQUAL( status, expected_status ); @@ -827,7 +827,7 @@ void mac_key_policy( int policy_usage_arg, memset( mac, 0, sizeof( mac ) ); status = psa_mac_verify_setup( &operation, key, exercise_alg ); - if( ( policy_usage & PSA_KEY_USAGE_VERIFY_HASH ) == 0 ) + if( ( mbedtls_test_update_key_usage_flags(policy_usage) & PSA_KEY_USAGE_VERIFY_MESSAGE ) == 0 ) TEST_EQUAL( status, PSA_ERROR_NOT_PERMITTED ); else TEST_EQUAL( status, expected_status ); From 1f6c3aeb63a40c22af17311ea3a8cf6e3f02e554 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 20 Aug 2021 11:44:44 +0100 Subject: [PATCH 335/966] Tidy up ssl_*.c grouped MBEDTLS_BYTE_x macros exchange groups of the byte reading macros with MBEDTLS_PUT_UINTxyz and then shift the pointer afterwards. Easier to read as you can see how big the data is that you are putting in, and in the case of UINT32 AND UINT64 it saves some vertical space. Signed-off-by: Joe Subbiani --- library/ssl_cli.c | 121 +++++++++++++++++++++++----------------------- library/ssl_srv.c | 59 +++++++++++----------- library/ssl_tls.c | 62 +++++++----------------- 3 files changed, 106 insertions(+), 136 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 0e25b6c60a..df32cfdb67 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -136,18 +136,19 @@ static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl, * } ServerNameList; * */ - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SERVERNAME ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SERVERNAME ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SERVERNAME, p, 0 ); + p += 2; - *p++ = MBEDTLS_BYTE_1( hostname_len + 5); - *p++ = MBEDTLS_BYTE_0( hostname_len + 5); + MBEDTLS_PUT_UINT16_BE( hostname_len + 5, p, 0 ); + p += 2; - *p++ = MBEDTLS_BYTE_1( hostname_len + 3 ); - *p++ = MBEDTLS_BYTE_0( hostname_len + 3 ); + MBEDTLS_PUT_UINT16_BE( hostname_len + 3, p, 0 ); + p += 2; *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SERVERNAME_HOSTNAME ); - *p++ = MBEDTLS_BYTE_1( hostname_len ); - *p++ = MBEDTLS_BYTE_0( hostname_len ); + + MBEDTLS_PUT_UINT16_BE( hostname_len, p, 0 ); + p += 2; memcpy( p, ssl->hostname, hostname_len ); @@ -181,8 +182,8 @@ static int ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, /* * Secure renegotiation */ - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO, p, 0 ); + p += 2; *p++ = 0x00; *p++ = MBEDTLS_BYTE_0( ssl->verify_data_len + 1 ); @@ -281,14 +282,14 @@ static int ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, * SignatureAndHashAlgorithm * supported_signature_algorithms<2..2^16-2>; */ - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SIG_ALG ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SIG_ALG ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SIG_ALG, p, 0 ); + p += 2; - *p++ = MBEDTLS_BYTE_1( sig_alg_len + 2 ); - *p++ = MBEDTLS_BYTE_0( sig_alg_len + 2 ); + MBEDTLS_PUT_UINT16_BE( sig_alg_len + 2, p, 0 ); + p += 2; - *p++ = MBEDTLS_BYTE_1( sig_alg_len ); - *p++ = MBEDTLS_BYTE_0( sig_alg_len ); + MBEDTLS_PUT_UINT16_BE( sig_alg_len, p, 0 ); + p += 2; *olen = 6 + sig_alg_len; @@ -356,14 +357,14 @@ static int ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl, elliptic_curve_list[elliptic_curve_len++] = MBEDTLS_BYTE_0( info->tls_id ); } - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES, p, 0 ); + p += 2; - *p++ = MBEDTLS_BYTE_1( elliptic_curve_len + 2 ); - *p++ = MBEDTLS_BYTE_0( elliptic_curve_len + 2 ); + MBEDTLS_PUT_UINT16_BE( elliptic_curve_len + 2, p, 0 ); + p += 2; - *p++ = MBEDTLS_BYTE_1( elliptic_curve_len ); - *p++ = MBEDTLS_BYTE_0( elliptic_curve_len ); + MBEDTLS_PUT_UINT16_BE( elliptic_curve_len, p, 0 ); + p += 2; *olen = 6 + elliptic_curve_len; @@ -384,8 +385,8 @@ static int ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, ( "client hello, adding supported_point_formats extension" ) ); MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 2; @@ -421,8 +422,8 @@ static int ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ECJPAKE_KKPP, p, 0 ); + p += 2; /* * We may need to send ClientHello multiple times for Hello verification. @@ -464,8 +465,8 @@ static int ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, memcpy( p + 2, ssl->handshake->ecjpake_cache, kkpp_len ); } - *p++ = MBEDTLS_BYTE_1( kkpp_len ); - *p++ = MBEDTLS_BYTE_0( kkpp_len ); + MBEDTLS_PUT_UINT16_BE( kkpp_len, p, 0 ); + p += 2; *olen = kkpp_len + 4; @@ -504,11 +505,11 @@ static int ssl_write_cid_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, (unsigned)( ssl->own_cid_len + 5 ) ); /* Add extension ID + size */ - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_CID ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_CID ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_CID, p, 0 ); + p += 2; ext_len = (size_t) ssl->own_cid_len + 1; - *p++ = MBEDTLS_BYTE_1( ext_len ); - *p++ = MBEDTLS_BYTE_0( ext_len ); + MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); + p += 2; *p++ = (uint8_t) ssl->own_cid_len; memcpy( p, ssl->own_cid, ssl->own_cid_len ); @@ -537,8 +538,8 @@ static int ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 5 ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 1; @@ -569,8 +570,8 @@ static int ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 0x00; @@ -599,8 +600,8 @@ static int ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 0x00; @@ -631,11 +632,11 @@ static int ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, /* The addition is safe here since the ticket length is 16 bit. */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 + tlen ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SESSION_TICKET ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SESSION_TICKET ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SESSION_TICKET, p, 0 ); + p += 2; - *p++ = MBEDTLS_BYTE_1( tlen ); - *p++ = MBEDTLS_BYTE_0( tlen ); + MBEDTLS_PUT_UINT16_BE( tlen, p, 0 ); + p += 2; *olen = 4; @@ -675,8 +676,8 @@ static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 + alpnlen ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ALPN ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ALPN ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ALPN, p, 0 ); + p += 2; /* * opaque ProtocolName<1..2^8-1>; @@ -758,12 +759,11 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, ext_len + 4 ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_USE_SRTP ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_USE_SRTP ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_USE_SRTP, p, 0 ); + p += 2; - - *p++ = MBEDTLS_BYTE_1( ext_len ); - *p++ = MBEDTLS_BYTE_0( ext_len ); + MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); + p += 2; /* protection profile length: 2*(ssl->conf->dtls_srtp_profile_list_len) */ /* micro-optimization: @@ -786,8 +786,9 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, { MBEDTLS_SSL_DEBUG_MSG( 3, ( "ssl_write_use_srtp_ext, add profile: %04x", profile_value ) ); - *p++ = MBEDTLS_BYTE_1( profile_value ); - *p++ = MBEDTLS_BYTE_0( profile_value ); + MBEDTLS_PUT_UINT16_BE( profile_value, p, 0 ); + p += 2; + } else { @@ -855,10 +856,8 @@ static int ssl_generate_random( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_HAVE_TIME) t = mbedtls_time( NULL ); - *p++ = MBEDTLS_BYTE_3( t ); - *p++ = MBEDTLS_BYTE_2( t ); - *p++ = MBEDTLS_BYTE_1( t ); - *p++ = MBEDTLS_BYTE_0( t ); + MBEDTLS_PUT_UINT32_BE( t, p, 0 ); + p += 4; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, current time: %" MBEDTLS_PRINTF_LONGLONG, (long long) t ) ); @@ -1141,8 +1140,8 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); n++; - *p++ = MBEDTLS_BYTE_1( ciphersuites[i] ); - *p++ = MBEDTLS_BYTE_0( ciphersuites[i] ); + MBEDTLS_PUT_UINT16_BE( ciphersuites[i], p, 0 ); + p += 2; } MBEDTLS_SSL_DEBUG_MSG( 3, @@ -1157,8 +1156,8 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "adding EMPTY_RENEGOTIATION_INFO_SCSV" ) ); MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO, p, 0 ); + p += 2; n++; } @@ -1321,8 +1320,8 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) { /* No need to check for space here, because the extension * writing functions already took care of that. */ - *p++ = MBEDTLS_BYTE_1( ext_len ); - *p++ = MBEDTLS_BYTE_0( ext_len ); + MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); + p += 2; p += ext_len; } diff --git a/library/ssl_srv.c b/library/ssl_srv.c index a791b80764..c63af7a32a 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1970,12 +1970,11 @@ static void ssl_write_cid_ext( mbedtls_ssl_context *ssl, * opaque cid<0..2^8-1>; * } ConnectionId; */ - - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_CID ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_CID ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_CID, p, 0 ); + p += 2; ext_len = (size_t) ssl->own_cid_len + 1; - *p++ = MBEDTLS_BYTE_1( ext_len ); - *p++ = MBEDTLS_BYTE_0( ext_len ); + MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); + p += 2; *p++ = (uint8_t) ssl->own_cid_len; memcpy( p, ssl->own_cid, ssl->own_cid_len ); @@ -2016,8 +2015,8 @@ static void ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding encrypt then mac extension" ) ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 0x00; @@ -2042,8 +2041,8 @@ static void ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding extended master secret " "extension" ) ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 0x00; @@ -2067,8 +2066,8 @@ static void ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding session ticket extension" ) ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SESSION_TICKET ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SESSION_TICKET ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SESSION_TICKET, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 0x00; @@ -2091,8 +2090,8 @@ static void ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, secure renegotiation extension" ) ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_RENEGOTIATION_INFO, p, 0 ); + p += 2; #if defined(MBEDTLS_SSL_RENEGOTIATION) if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ) @@ -2132,8 +2131,8 @@ static void ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, max_fragment_length extension" ) ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 1; @@ -2162,8 +2161,8 @@ static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, supported_point_formats extension" ) ); - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS, p, 0 ); + p += 2; *p++ = 0x00; *p++ = 2; @@ -2200,8 +2199,8 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, return; } - *p++ = MBEDTLS_BYTE_1( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); - *p++ = MBEDTLS_BYTE_0( MBEDTLS_TLS_EXT_ECJPAKE_KKPP ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_ECJPAKE_KKPP, p, 0 ); + p += 2; ret = mbedtls_ecjpake_write_round_one( &ssl->handshake->ecjpake_ctx, p + 2, end - p - 2, &kkpp_len, @@ -2212,8 +2211,8 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, return; } - *p++ = MBEDTLS_BYTE_1( kkpp_len ); - *p++ = MBEDTLS_BYTE_0( kkpp_len ); + MBEDTLS_PUT_UINT16_BE( kkpp_len, p, 0 ); + p += 2; *olen = kkpp_len + 4; } @@ -2488,10 +2487,8 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_HAVE_TIME) t = mbedtls_time( NULL ); - *p++ = MBEDTLS_BYTE_3( t ); - *p++ = MBEDTLS_BYTE_2( t ); - *p++ = MBEDTLS_BYTE_1( t ); - *p++ = MBEDTLS_BYTE_0( t ); + MBEDTLS_PUT_UINT32_BE( t, p, 0 ); + p += 4; MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %" MBEDTLS_PRINTF_LONGLONG, (long long) t ) ); @@ -2572,8 +2569,8 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed", ssl->handshake->resume ? "a" : "no" ) ); - *p++ = MBEDTLS_BYTE_1( ssl->session_negotiate->ciphersuite ); - *p++ = MBEDTLS_BYTE_0( ssl->session_negotiate->ciphersuite ); + MBEDTLS_PUT_UINT16_BE( ssl->session_negotiate->ciphersuite, p, 0 ); + p += 2; *p++ = MBEDTLS_BYTE_0( ssl->session_negotiate->compression ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %s", @@ -2642,8 +2639,8 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) if( ext_len > 0 ) { - *p++ = MBEDTLS_BYTE_1( ext_len ); - *p++ = MBEDTLS_BYTE_0( ext_len ); + MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); + p += 2; p += ext_len; } @@ -2819,8 +2816,8 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) break; } - *p++ = MBEDTLS_BYTE_1( dn_size ); - *p++ = MBEDTLS_BYTE_0( dn_size ); + MBEDTLS_PUT_UINT16_BE( dn_size, p, 0 ); + p += 2; memcpy( p, crt->subject_raw.p, dn_size ); p += dn_size; diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 33f026f4d1..abf4c0f5f2 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -4664,14 +4664,8 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, { start = (uint64_t) session->start; - *p++ = MBEDTLS_BYTE_7( start ); - *p++ = MBEDTLS_BYTE_6( start ); - *p++ = MBEDTLS_BYTE_5( start ); - *p++ = MBEDTLS_BYTE_4( start ); - *p++ = MBEDTLS_BYTE_3( start ); - *p++ = MBEDTLS_BYTE_2( start ); - *p++ = MBEDTLS_BYTE_1( start ); - *p++ = MBEDTLS_BYTE_0( start ); + MBEDTLS_PUT_UINT64_BE( start, p, 0 ); + p += 8; } #endif /* MBEDTLS_HAVE_TIME */ @@ -4687,8 +4681,8 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, if( used <= buf_len ) { - *p++ = MBEDTLS_BYTE_1( session->ciphersuite ); - *p++ = MBEDTLS_BYTE_0( session->ciphersuite ); + MBEDTLS_PUT_UINT16_BE( session->ciphersuite, p, 0 ); + p += 2; *p++ = MBEDTLS_BYTE_0( session->compression ); @@ -4699,10 +4693,8 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, memcpy( p, session->master, 48 ); p += 48; - *p++ = MBEDTLS_BYTE_3( session->verify_result ); - *p++ = MBEDTLS_BYTE_2( session->verify_result ); - *p++ = MBEDTLS_BYTE_1( session->verify_result ); - *p++ = MBEDTLS_BYTE_0( session->verify_result ); + MBEDTLS_PUT_UINT32_BE( session->verify_result, p, 0 ); + p += 4; } /* @@ -4772,10 +4764,8 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session, p += session->ticket_len; } - *p++ = MBEDTLS_BYTE_3( session->ticket_lifetime ); - *p++ = MBEDTLS_BYTE_2( session->ticket_lifetime ); - *p++ = MBEDTLS_BYTE_1( session->ticket_lifetime ); - *p++ = MBEDTLS_BYTE_0( session->ticket_lifetime ); + MBEDTLS_PUT_UINT32_BE( session->ticket_lifetime, p, 0 ); + p += 4; } #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */ @@ -5713,10 +5703,8 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 4 + session_len; if( used <= buf_len ) { - *p++ = MBEDTLS_BYTE_3( session_len ); - *p++ = MBEDTLS_BYTE_2( session_len ); - *p++ = MBEDTLS_BYTE_1( session_len ); - *p++ = MBEDTLS_BYTE_0( session_len ); + MBEDTLS_PUT_UINT32_BE( session_len, p, 0 ); + p += 4; ret = ssl_session_save( ssl->session, 1, p, session_len, &session_len ); @@ -5757,33 +5745,19 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 4; if( used <= buf_len ) { - *p++ = MBEDTLS_BYTE_3( ssl->badmac_seen ); - *p++ = MBEDTLS_BYTE_2( ssl->badmac_seen ); - *p++ = MBEDTLS_BYTE_1( ssl->badmac_seen ); - *p++ = MBEDTLS_BYTE_0( ssl->badmac_seen ); + MBEDTLS_PUT_UINT32_BE( ssl->badmac_seen, p, 0 ); + p += 4; } #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) used += 16; if( used <= buf_len ) { - *p++ = MBEDTLS_BYTE_7( ssl->in_window_top ); - *p++ = MBEDTLS_BYTE_6( ssl->in_window_top ); - *p++ = MBEDTLS_BYTE_5( ssl->in_window_top ); - *p++ = MBEDTLS_BYTE_4( ssl->in_window_top ); - *p++ = MBEDTLS_BYTE_3( ssl->in_window_top ); - *p++ = MBEDTLS_BYTE_2( ssl->in_window_top ); - *p++ = MBEDTLS_BYTE_1( ssl->in_window_top ); - *p++ = MBEDTLS_BYTE_0( ssl->in_window_top ); + MBEDTLS_PUT_UINT64_BE( ssl->in_window_top, p, 0 ); + p += 8; - *p++ = MBEDTLS_BYTE_7( ssl->in_window ); - *p++ = MBEDTLS_BYTE_6( ssl->in_window ); - *p++ = MBEDTLS_BYTE_5( ssl->in_window ); - *p++ = MBEDTLS_BYTE_4( ssl->in_window ); - *p++ = MBEDTLS_BYTE_3( ssl->in_window ); - *p++ = MBEDTLS_BYTE_2( ssl->in_window ); - *p++ = MBEDTLS_BYTE_1( ssl->in_window ); - *p++ = MBEDTLS_BYTE_0( ssl->in_window ); + MBEDTLS_PUT_UINT64_BE( ssl->in_window, p, 0 ); + p += 8; } #endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ @@ -5806,8 +5780,8 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 2; if( used <= buf_len ) { - *p++ = MBEDTLS_BYTE_1( ssl->mtu ); - *p++ = MBEDTLS_BYTE_0( ssl->mtu ); + MBEDTLS_PUT_UINT16_BE( ssl->mtu, p, 0 ); + p += 2; } #endif /* MBEDTLS_SSL_PROTO_DTLS */ From e4603eece9aa216190edb5edd0dd3f51cf47df48 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 20 Aug 2021 13:05:30 +0100 Subject: [PATCH 336/966] Compress byte reading macros in if statements exchange MBEDTLS_BYTE_x in if statements with MBEDTLS_GET_UINT16_BE Signed-off-by: Joe Subbiani --- library/ssl_srv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/ssl_srv.c b/library/ssl_srv.c index c63af7a32a..1841b55790 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1848,8 +1848,7 @@ read_record_header: for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) for( i = 0; ciphersuites[i] != 0; i++ ) { - if( p[0] != MBEDTLS_BYTE_1( ciphersuites[i] ) || - p[1] != MBEDTLS_BYTE_0( ciphersuites[i] )) + if( MBEDTLS_GET_UINT16_BE(p, 0) != ciphersuites[i] ) continue; got_common_suite = 1; @@ -1865,8 +1864,7 @@ read_record_header: for( i = 0; ciphersuites[i] != 0; i++ ) for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 ) { - if( p[0] != MBEDTLS_BYTE_1( ciphersuites[i] ) || - p[1] != MBEDTLS_BYTE_0( ciphersuites[i] )) + if( MBEDTLS_GET_UINT16_BE(p, 0) != ciphersuites[i] ) continue; got_common_suite = 1; From 94180e708ff9496f7b3bc6bfe50bdaab7226ba34 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 20 Aug 2021 16:20:44 +0100 Subject: [PATCH 337/966] Minor coding style improvement Signed-off-by: Joe Subbiani --- library/ssl_cli.c | 4 +--- library/ssl_srv.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index df32cfdb67..9120aa2f75 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -788,7 +788,6 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl, profile_value ) ); MBEDTLS_PUT_UINT16_BE( profile_value, p, 0 ); p += 2; - } else { @@ -1321,8 +1320,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) /* No need to check for space here, because the extension * writing functions already took care of that. */ MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); - p += 2; - p += ext_len; + p += 2 + ext_len; } ssl->out_msglen = p - buf; diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 1841b55790..b8c4314846 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -2638,8 +2638,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) if( ext_len > 0 ) { MBEDTLS_PUT_UINT16_BE( ext_len, p, 0 ); - p += 2; - p += ext_len; + p += 2 + ext_len; } ssl->out_msglen = p - buf; From 3879c345ec95be0150b9d076b47a8f83edd250a4 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 23 Aug 2021 10:56:06 +0200 Subject: [PATCH 338/966] Fix typo in the changelog for chunked CCM. Signed-off-by: Mateusz Starzyk --- ChangeLog.d/chunked_ccm.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.d/chunked_ccm.txt b/ChangeLog.d/chunked_ccm.txt index 4e3065f906..67faecca5e 100644 --- a/ChangeLog.d/chunked_ccm.txt +++ b/ChangeLog.d/chunked_ccm.txt @@ -3,6 +3,6 @@ Changes The multi-part functions: mbedtls_ccm_starts(), mbedtls_ccm_set_lengths(), mbedtls_ccm_update_ad(), mbedtls_ccm_update(), mbedtls_ccm_finish() were introduced in mbedTLS 3.0 release, however their implementation was - postponed util now. + postponed until now. Implemented functions support chunked data input for both CCM and CCM* algorithms. From 90cc33aad60b14a7425f751c0d0f2494ac2dd782 Mon Sep 17 00:00:00 2001 From: Andrey Starodubtsev Date: Mon, 23 Aug 2021 12:14:56 +0300 Subject: [PATCH 339/966] Misprint was fixed Signed-off-by: Andrey Starodubtsev --- include/mbedtls/ssl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index f08fc89a5b..3cb896cb4c 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -602,7 +602,7 @@ typedef int mbedtls_ssl_recv_t( void *ctx, * \param ctx Context for the receive callback (typically a file descriptor) * \param buf Buffer to write the received data to * \param len Length of the receive buffer - * \param timeout Maximum nomber of millisecondes to wait for data + * \param timeout Maximum number of milliseconds to wait for data * 0 means no timeout (potentially waiting forever) * * \return The callback must return the number of bytes received, From a5cb0d24d4737fa02ff9c0df315a582558c0ecc8 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Mon, 23 Aug 2021 11:35:25 +0100 Subject: [PATCH 340/966] Tidy up grouped MBEDTLS_BYTE_x macros exchange groups of the byte reading macros with MBEDTLS_PUT_UINTxyz and then shift the pointer afterwards. Easier to read as you can see how big the data is that you are putting in, and in the case of UINT32 AND UINT64 it saves some vertical space. Signed-off-by: Joe Subbiani --- library/ctr_drbg.c | 7 ++----- library/ecjpake.c | 11 +++-------- library/ssl_tls.c | 18 ++++++++---------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/library/ctr_drbg.c b/library/ctr_drbg.c index 68b32a366b..93a7cdcd1f 100644 --- a/library/ctr_drbg.c +++ b/library/ctr_drbg.c @@ -152,11 +152,8 @@ static int block_cipher_df( unsigned char *output, * (Total is padded to a multiple of 16-bytes with zeroes) */ p = buf + MBEDTLS_CTR_DRBG_BLOCKSIZE; - *p++ = MBEDTLS_BYTE_3( data_len ); - *p++ = MBEDTLS_BYTE_2( data_len ); - *p++ = MBEDTLS_BYTE_1( data_len ); - *p++ = MBEDTLS_BYTE_0( data_len ); - p += 3; + MBEDTLS_PUT_UINT32_BE( data_len, p, 0); + p += 4 + 3; *p++ = MBEDTLS_CTR_DRBG_SEEDLEN; memcpy( p, data, data_len ); p[data_len] = 0x80; diff --git a/library/ecjpake.c b/library/ecjpake.c index a599b1ba48..738a97719c 100644 --- a/library/ecjpake.c +++ b/library/ecjpake.c @@ -180,10 +180,7 @@ static int ecjpake_write_len_point( unsigned char **p, if( ret != 0 ) return( ret ); - (*p)[0] = MBEDTLS_BYTE_3( len ); - (*p)[1] = MBEDTLS_BYTE_2( len ); - (*p)[2] = MBEDTLS_BYTE_1( len ); - (*p)[3] = MBEDTLS_BYTE_0( len ); + MBEDTLS_PUT_UINT32_BE( len, *p, 0 ); *p += 4 + len; @@ -223,10 +220,8 @@ static int ecjpake_hash( const mbedtls_md_info_t *md_info, if( end - p < 4 ) return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); - *p++ = MBEDTLS_BYTE_3( id_len ); - *p++ = MBEDTLS_BYTE_2( id_len ); - *p++ = MBEDTLS_BYTE_1( id_len ); - *p++ = MBEDTLS_BYTE_0( id_len ); + MBEDTLS_PUT_UINT32_BE( id_len, p, 0 ); + p += 4; if( end < p || (size_t)( end - p ) < id_len ) return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index abf4c0f5f2..5cd47e6ce5 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -1487,8 +1487,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch if( end - p < 2 ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - *(p++) = MBEDTLS_BYTE_1( psk_len ); - *(p++) = MBEDTLS_BYTE_0( psk_len ); + MBEDTLS_PUT_UINT16_BE( psk_len, p, 0 ); + p += 2; if( end < p || (size_t)( end - p ) < psk_len ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); @@ -1528,9 +1528,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_calc_secret", ret ); return( ret ); } - *(p++) = MBEDTLS_BYTE_1( len ); - *(p++) = MBEDTLS_BYTE_0( len ); - p += len; + MBEDTLS_PUT_UINT16_BE( len, p, 0 ); + p += 2 + len; MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K ); } @@ -1550,9 +1549,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch return( ret ); } - *(p++) = MBEDTLS_BYTE_1( zlen ); - *(p++) = MBEDTLS_BYTE_0( zlen ); - p += zlen; + MBEDTLS_PUT_UINT16_BE( zlen, p, 0 ); + p += 2 + zlen; MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, MBEDTLS_DEBUG_ECDH_Z ); @@ -1568,8 +1566,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch if( end - p < 2 ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - *(p++) = MBEDTLS_BYTE_1( psk_len ); - *(p++) = MBEDTLS_BYTE_0( psk_len ); + MBEDTLS_PUT_UINT16_BE( psk_len, p, 0 ); + p += 2; if( end < p || (size_t)( end - p ) < psk_len ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); From fc1e9ffcb21fa4e6b23f912522f821c64e12da28 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Mon, 23 Aug 2021 13:54:56 +0100 Subject: [PATCH 341/966] Use Abstract Base Classes to ensure Problem is not instantiated - Problem() is a parent abstract class that should only be used for subclassing. - With the help of ABC, implement abstract methods that force subclasses to implement quiet and verbose outputs. - The repeated logic of "if self.quiet" is consolidated in Problem. Signed-off-by: Yuto Takano --- tests/scripts/check_names.py | 60 ++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 0eba96740c..a9aa118ea4 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -42,6 +42,7 @@ The script returns 0 on success, 1 on test failure, and 2 if there is a script error. It must be run from Mbed TLS root. """ +import abc import argparse import glob import textwrap @@ -92,9 +93,11 @@ class Match(): # pylint: disable=too-few-public-methods " {0} | {1}\n".format(" " * len(gutter), underline) ) -class Problem(): # pylint: disable=too-few-public-methods +class Problem(abc.ABC): # pylint: disable=too-few-public-methods """ - A parent class representing a form of static analysis error. + An abstract parent class representing a form of static analysis error. + It extends an Abstract Base Class, which means it is not instantiable, and + it also mandates certain abstract methods to be implemented in subclasses. """ # Class variable to control the quietness of all problems quiet = False @@ -104,6 +107,28 @@ class Problem(): # pylint: disable=too-few-public-methods self.textwrapper.initial_indent = " > " self.textwrapper.subsequent_indent = " " + def __str__(self): + """ + Unified string representation method for all Problems. + """ + if self.__class__.quiet: + return self.quiet_output() + return self.verbose_output() + + @abc.abstractmethod + def quiet_output(self): + """ + The output when --quiet is enabled. + """ + pass + + @abc.abstractmethod + def verbose_output(self): + """ + The default output with explanation and code snippet if appropriate. + """ + pass + class SymbolNotInHeader(Problem): # pylint: disable=too-few-public-methods """ A problem that occurs when an exported/available symbol in the object file @@ -117,10 +142,10 @@ class SymbolNotInHeader(Problem): # pylint: disable=too-few-public-methods self.symbol_name = symbol_name Problem.__init__(self) - def __str__(self): - if self.quiet: - return "{0}".format(self.symbol_name) + def quiet_output(self): + return "{0}".format(self.symbol_name) + def verbose_output(self): return self.textwrapper.fill( "'{0}' was found as an available symbol in the output of nm, " "however it was not declared in any header files." @@ -140,13 +165,14 @@ class PatternMismatch(Problem): # pylint: disable=too-few-public-methods self.match = match Problem.__init__(self) - def __str__(self): - if self.quiet: - return ( - "{0}:{1}:{2}" - .format(self.match.filename, self.match.line_no, self.match.name) - ) + def quiet_output(self): + return ( + "{0}:{1}:{2}" + .format(self.match.filename, self.match.line_no, self.match.name) + ) + + def verbose_output(self): return self.textwrapper.fill( "{0}:{1}: '{2}' does not match the required pattern '{3}'." .format( @@ -169,13 +195,13 @@ class Typo(Problem): # pylint: disable=too-few-public-methods self.match = match Problem.__init__(self) - def __str__(self): - if self.quiet: - return ( - "{0}:{1}:{2}" - .format(self.match.filename, self.match.line_no, self.match.name) - ) + def quiet_output(self): + return ( + "{0}:{1}:{2}" + .format(self.match.filename, self.match.line_no, self.match.name) + ) + def verbose_output(self): return self.textwrapper.fill( "{0}:{1}: '{2}' looks like a typo. It was not found in any " "macros or any enums. If this is not a typo, put " From d07f4fc30fec6dcb6d79313b13ebd928559eef24 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Tue, 24 Aug 2021 11:01:23 +0200 Subject: [PATCH 342/966] Use separate expected results for MAC sign and verify key policy. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_psa_crypto.data | 54 ++++++++++----------- tests/suites/test_suite_psa_crypto.function | 16 +++--- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index e3e9a5225a..bc4edb2b7b 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -418,111 +418,111 @@ key_attributes_init: PSA key policy: MAC, SIGN_HASH -> SIGN_HASH+MESSAGE depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS:PSA_ERROR_NOT_PERMITTED PSA key policy: MAC, VERIFY_HASH -> VERIFY_HASH+MESSAGE depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED:PSA_SUCCESS PSA key policy: MAC, SIGN+VERIFY_HASH -> {SIGN,VERIFY}_{HASH,MESSAGE} depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS:PSA_SUCCESS PSA key policy: MAC, {SIGN,VERIFY}_{HASH,MESSAGE} depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS:PSA_SUCCESS PSA key policy: MAC, SIGN_MESSAGE depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS:PSA_ERROR_NOT_PERMITTED PSA key policy: MAC, VERIFY_MESSAGE depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED:PSA_SUCCESS PSA key policy: MAC, SIGN+VERIFY_MESSAGE depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS:PSA_SUCCESS PSA key policy: MAC, neither sign nor verify depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:0:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED +mac_key_policy:0:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: MAC, wrong algorithm depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_224:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_224):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_224):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: MAC, alg=0 in policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: MAC, ANY_HASH in policy is not meaningful depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_ANY_HASH):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_HMAC(PSA_ALG_ANY_HASH):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: HMAC, sign-verify, tag length > min-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 30):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 30):PSA_SUCCESS:PSA_SUCCESS PSA key policy: HMAC, sign-verify, tag length = min-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_SUCCESS:PSA_SUCCESS PSA key policy: HMAC, sign-verify, tag length < min-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 10):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 10):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: CMAC, sign-verify, tag length > min-length policy depends_on:PSA_WANT_ALG_CMAC:PSA_WANT_KEY_TYPE_AES -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_CMAC, 10):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_CMAC, 16):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_CMAC, 10):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_CMAC, 16):PSA_SUCCESS:PSA_SUCCESS PSA key policy: CMAC, sign-verify, tag length = min-length policy depends_on:PSA_WANT_ALG_CMAC:PSA_WANT_KEY_TYPE_AES -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_CMAC, 10):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_CMAC, 10):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_CMAC, 10):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_CMAC, 10):PSA_SUCCESS:PSA_SUCCESS PSA key policy: CMAC, sign-verify, tag length < min-length policy depends_on:PSA_WANT_ALG_CMAC:PSA_WANT_KEY_TYPE_AES -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_CMAC, 10):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_CMAC, 8):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_CMAC, 10):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_CMAC, 8):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: HMAC, sign-verify, default tag length > min-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 31):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 31):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS:PSA_SUCCESS PSA key policy: HMAC, sign-verify, default tag length = min-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 32):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 32):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_SUCCESS:PSA_SUCCESS PSA key policy: HMAC, sign-verify, default tag length < min-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 33):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 33):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: HMAC, sign-verify, min-length policy, unmatched base alg depends_on:PSA_WANT_ALG_CMAC:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_CMAC, 20):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_CMAC, 20):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: HMAC, sign-verify, min-length policy, unmatched base alg (different hash base) depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_224:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_224), 20):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_224), 20):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: HMAC, sign-verify, min-length policy, unmatched base alg (different algorithm) depends_on:PSA_WANT_ALG_CMAC:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 10):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_CMAC:PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 10):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_CMAC:PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: HMAC, sign-verify, min-length policy used as algorithm depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_ERROR_INVALID_ARGUMENT +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_ERROR_INVALID_ARGUMENT:PSA_ERROR_INVALID_ARGUMENT PSA key policy: HMAC, sign-verify, tag length > exact-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 10):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 10):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: HMAC, sign-verify, tag length = exact-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_SUCCESS +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_SUCCESS:PSA_SUCCESS PSA key policy: HMAC, sign-verify, tag length < exact-length policy depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 10):PSA_ERROR_NOT_PERMITTED +mac_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 10):PSA_ERROR_NOT_PERMITTED:PSA_ERROR_NOT_PERMITTED PSA key policy: cipher, encrypt | decrypt depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 3fe512e8e7..cde28a8e75 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -792,7 +792,8 @@ void mac_key_policy( int policy_usage_arg, int key_type_arg, data_t *key_data, int exercise_alg_arg, - int expected_status_arg ) + int expected_status_sign_arg, + int expected_status_verify_arg ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; @@ -802,7 +803,8 @@ void mac_key_policy( int policy_usage_arg, psa_algorithm_t exercise_alg = exercise_alg_arg; psa_key_usage_t policy_usage = policy_usage_arg; psa_status_t status; - psa_status_t expected_status = expected_status_arg; + psa_status_t expected_status_sign = expected_status_sign_arg; + psa_status_t expected_status_verify = expected_status_verify_arg; unsigned char mac[PSA_MAC_MAX_SIZE]; PSA_ASSERT( psa_crypto_init( ) ); @@ -818,19 +820,13 @@ void mac_key_policy( int policy_usage_arg, mbedtls_test_update_key_usage_flags( policy_usage ) ); status = psa_mac_sign_setup( &operation, key, exercise_alg ); - if( ( mbedtls_test_update_key_usage_flags(policy_usage) & PSA_KEY_USAGE_SIGN_MESSAGE ) == 0 ) - TEST_EQUAL( status, PSA_ERROR_NOT_PERMITTED ); - else - TEST_EQUAL( status, expected_status ); + TEST_EQUAL( status, expected_status_sign ); psa_mac_abort( &operation ); memset( mac, 0, sizeof( mac ) ); status = psa_mac_verify_setup( &operation, key, exercise_alg ); - if( ( mbedtls_test_update_key_usage_flags(policy_usage) & PSA_KEY_USAGE_VERIFY_MESSAGE ) == 0 ) - TEST_EQUAL( status, PSA_ERROR_NOT_PERMITTED ); - else - TEST_EQUAL( status, expected_status ); + TEST_EQUAL( status, expected_status_verify ); exit: psa_mac_abort( &operation ); From cadebe5343c40d2e17b4acb24b5024290f63d98d Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 24 Aug 2021 10:36:45 +0800 Subject: [PATCH 343/966] fix several format and comment issues Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 2 +- library/ssl_tls.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 70dc501c0b..d328d23cdb 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -2582,7 +2582,7 @@ int mbedtls_ssl_session_save( const mbedtls_ssl_session *session, * the server supports. * * \warning The ciphersuites array \p ciphersuites is not copied. - * It must remain valid for the lifetime the SSL + * It must remain valid for the lifetime of the SSL * configuration \p conf. * * \param conf The SSL configuration to modify. diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 4933980cd9..834a23983f 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3549,7 +3549,7 @@ void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, } #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -void mbedtls_ssl_conf_tls13_key_exchange_modes( mbedtls_ssl_config* conf, +void mbedtls_ssl_conf_tls13_key_exchange_modes( mbedtls_ssl_config *conf, const int kex_modes ) { conf->tls13_kex_modes = kex_modes; From 69e0ec46b7db6c90539e360f2275a41821fbdd8b Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 24 Aug 2021 10:44:15 +0800 Subject: [PATCH 344/966] Replace SHA512_C with SHA384_C Signed-off-by: Jerry Yu --- library/ssl_ciphersuites.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ssl_ciphersuites.c b/library/ssl_ciphersuites.c index 9a416c811d..b10a9634ef 100644 --- a/library/ssl_ciphersuites.c +++ b/library/ssl_ciphersuites.c @@ -295,14 +295,14 @@ static const mbedtls_ssl_ciphersuite_t ciphersuite_definitions[] = #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_GCM_C) -#if defined(MBEDTLS_SHA512_C) +#if defined(MBEDTLS_SHA384_C) { MBEDTLS_TLS1_3_AES_256_GCM_SHA384, "TLS1-3-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_NONE, /* Key exchange not part of ciphersuite in TLS 1.3 */ MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_4, 0 }, -#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_SHA384_C */ #if defined(MBEDTLS_SHA256_C) { MBEDTLS_TLS1_3_AES_128_GCM_SHA256, "TLS1-3-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, From 31c01d303eddf649ba076fb0e6ee5d1405b16ee8 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 24 Aug 2021 10:49:06 +0800 Subject: [PATCH 345/966] Rename available values for tls13_kex_modes Rename `psk_pure` to `psk` and `ephemeral_pure` to `ephemeral` Signed-off-by: Jerry Yu --- programs/ssl/ssl_client2.c | 6 +++--- programs/ssl/ssl_server2.c | 6 +++--- tests/ssl-opt.sh | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 223b7bff2f..f583f2267c 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -339,7 +339,7 @@ int main( void ) #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #define USAGE_TLS13_KEY_EXCHANGE_MODES \ " tls13_kex_modes=%%s default: all\n" \ - " options: psk_pure, psk_ephemeral, ephemeral_pure, ephemeral_all, psk_all, all\n" + " options: psk, psk_ephemeral, ephemeral, ephemeral_all, psk_all, all\n" #else #define USAGE_TLS13_KEY_EXCHANGE_MODES "" #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ @@ -1091,11 +1091,11 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) else if( strcmp( p, "tls13_kex_modes" ) == 0 ) { - if( strcmp( q, "psk_pure" ) == 0 ) + if( strcmp( q, "psk" ) == 0 ) opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; else if( strcmp(q, "psk_ephemeral" ) == 0 ) opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; - else if( strcmp(q, "ephemeral_pure" ) == 0 ) + else if( strcmp(q, "ephemeral" ) == 0 ) opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; else if( strcmp(q, "ephemeral_all" ) == 0 ) opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL; diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 87558f54cb..a339bbf53c 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -436,7 +436,7 @@ int main( void ) #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #define USAGE_TLS13_KEY_EXCHANGE_MODES \ " tls13_kex_modes=%%s default: all\n" \ - " options: psk_pure, psk_ephemeral, ephemeral_pure, ephemeral_all, psk_all, all\n" + " options: psk, psk_ephemeral, ephemeral, ephemeral_all, psk_all, all\n" #else #define USAGE_TLS13_KEY_EXCHANGE_MODES "" #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ @@ -1734,11 +1734,11 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) else if( strcmp( p, "tls13_kex_modes" ) == 0 ) { - if( strcmp( q, "psk_pure" ) == 0 ) + if( strcmp( q, "psk" ) == 0 ) opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; else if( strcmp(q, "psk_ephemeral" ) == 0 ) opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; - else if( strcmp(q, "ephemeral_pure" ) == 0 ) + else if( strcmp(q, "ephemeral" ) == 0 ) opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; else if( strcmp(q, "ephemeral_all" ) == 0 ) opt.tls13_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL; diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 56c4a5fba7..6066bc702a 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1458,8 +1458,8 @@ run_test "SHA-256 allowed by default in client certificate" \ # ssl_client2/ssl_server2 example programs works. requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS 1.3, key exchange mode parameter passing: PSK only" \ - "$P_SRV tls13_kex_modes=psk_pure" \ - "$P_CLI tls13_kex_modes=psk_pure" \ + "$P_SRV tls13_kex_modes=psk" \ + "$P_CLI tls13_kex_modes=psk" \ 0 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS 1.3, key exchange mode parameter passing: PSK-ephemeral only" \ @@ -1468,8 +1468,8 @@ run_test "TLS 1.3, key exchange mode parameter passing: PSK-ephemeral only" \ 0 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS 1.3, key exchange mode parameter passing: Pure-ephemeral only" \ - "$P_SRV tls13_kex_modes=ephemeral_pure" \ - "$P_CLI tls13_kex_modes=ephemeral_pure" \ + "$P_SRV tls13_kex_modes=ephemeral" \ + "$P_CLI tls13_kex_modes=ephemeral" \ 0 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS 1.3, key exchange mode parameter passing: All ephemeral" \ From d85a52c508b49c337b9c5bb294c2636daa4d7aa7 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 24 Aug 2021 10:55:07 +0800 Subject: [PATCH 346/966] Add mask for kex_modes Signed-off-by: Jerry Yu --- library/ssl_tls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 834a23983f..8a65b70adb 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3552,7 +3552,7 @@ void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, void mbedtls_ssl_conf_tls13_key_exchange_modes( mbedtls_ssl_config *conf, const int kex_modes ) { - conf->tls13_kex_modes = kex_modes; + conf->tls13_kex_modes = kex_modes & MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL; } #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From d9343f2f0ffc48353e44560cdf23ee6e917b921a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 23 Aug 2021 18:59:49 +0100 Subject: [PATCH 347/966] Refactor is_encrypt into aead setup arguments Avoid touching the operation until later. Signed-off-by: Paul Elliott --- library/psa_crypto.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 1566a45342..13116dcad7 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3403,6 +3403,7 @@ static psa_algorithm_t psa_aead_get_base_algorithm( psa_algorithm_t alg ) /* Set the key for a multipart authenticated operation. */ static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, + int is_encrypt, mbedtls_svc_key_id_t key, psa_algorithm_t alg ) { @@ -3430,7 +3431,7 @@ static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, goto exit; } - if( operation->is_encrypt ) + if( is_encrypt ) key_usage = PSA_KEY_USAGE_ENCRYPT; else key_usage = PSA_KEY_USAGE_DECRYPT; @@ -3445,7 +3446,7 @@ static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, .core = slot->attr }; - if( operation->is_encrypt ) + if( is_encrypt ) status = psa_driver_wrapper_aead_encrypt_setup( operation, &attributes, slot->key.data, @@ -3472,6 +3473,7 @@ exit: { status = unlock_status; operation->alg = psa_aead_get_base_algorithm( alg ); + operation->is_encrypt = is_encrypt; } else psa_aead_abort( operation ); @@ -3484,9 +3486,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg ) { - operation->is_encrypt = 1; - - return( psa_aead_setup( operation, key, alg ) ); + return( psa_aead_setup( operation, 1, key, alg ) ); } /* Set the key for a multipart authenticated decryption operation. */ @@ -3494,9 +3494,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg ) { - operation->is_encrypt = 0; - - return( psa_aead_setup( operation, key, alg ) ); + return( psa_aead_setup( operation, 0, key, alg ) ); } /* Generate a random nonce / IV for multipart AEAD operation */ From f127763ec9d234ec50adb01c9697649fdcb2395f Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 24 Aug 2021 18:11:37 +0100 Subject: [PATCH 348/966] Align generate nonce variables with psa convention Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 45 +++++++++++---------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 58e43870b8..26c6c768e0 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3671,8 +3671,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, /* BEGIN_CASE */ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, int alg_arg, - int nonce_len, - int expected_generated_len_arg, + int nonce_length, + int expected_nonce_length_arg, data_t *additional_data, data_t *input_data, int expected_status_arg ) @@ -3686,13 +3686,13 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; - size_t nonce_generated_len = 0; - size_t expected_generated_len = expected_generated_len_arg; - unsigned char *output_data = NULL; - unsigned char *final_data = NULL; + size_t actual_nonce_length = 0; + size_t expected_nonce_length = expected_nonce_length_arg; + unsigned char *output = NULL; + unsigned char *ciphertext = NULL; size_t output_size = 0; - size_t finish_output_size = 0; - size_t output_length = 0; + size_t ciphertext_size = 0; + size_t ciphertext_length = 0; size_t tag_length = 0; uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; @@ -3709,13 +3709,13 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); - ASSERT_ALLOC( output_data, output_size ); + ASSERT_ALLOC( output, output_size ); - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + ciphertext_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + TEST_ASSERT( ciphertext_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - ASSERT_ALLOC( final_data, finish_output_size ); + ASSERT_ALLOC( ciphertext, ciphertext_size ); operation = psa_aead_operation_init( ); @@ -3727,20 +3727,20 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, if( status == PSA_ERROR_NOT_SUPPORTED ) { MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_len ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_length ); } PSA_ASSERT( status ); status = psa_aead_generate_nonce( &operation, nonce_buffer, - nonce_len, - &nonce_generated_len ); + nonce_length, + &actual_nonce_length ); TEST_EQUAL( status, expected_status ); - TEST_EQUAL( nonce_generated_len, expected_generated_len ); + TEST_EQUAL( actual_nonce_length, expected_nonce_length ); - TEST_ASSERT( nonce_generated_len < PSA_AEAD_NONCE_MAX_SIZE ); + TEST_ASSERT( actual_nonce_length < PSA_AEAD_NONCE_MAX_SIZE ); if( expected_status == PSA_SUCCESS ) { @@ -3751,17 +3751,18 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, additional_data->len ) ); PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len, - output_data, output_size, &output_length ) ); + output, output_size, + &ciphertext_length ) ); - PSA_ASSERT( psa_aead_finish( &operation, final_data, finish_output_size, - &output_length, tag_buffer, + PSA_ASSERT( psa_aead_finish( &operation, ciphertext, ciphertext_size, + &ciphertext_length, tag_buffer, PSA_AEAD_TAG_MAX_SIZE, &tag_length ) ); } exit: psa_destroy_key( key ); - mbedtls_free( output_data ); - mbedtls_free( final_data ); + mbedtls_free( output ); + mbedtls_free( ciphertext ); psa_aead_abort( &operation ); PSA_DONE( ); } From 6f0e72038d34bc7b26f42170f4bd8f38dfec7cf6 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 25 Aug 2021 12:57:18 +0100 Subject: [PATCH 349/966] Align set nonce variables with psa convention Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 39 +++++++++++---------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 26c6c768e0..4ac4210602 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3771,7 +3771,7 @@ exit: /* BEGIN_CASE */ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, int alg_arg, - int nonce_len, + int nonce_length, int allow_null_nonce_buffer, data_t *additional_data, data_t *input_data, @@ -3786,11 +3786,11 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; - unsigned char *output_data = NULL; - unsigned char *final_data = NULL; + unsigned char *output = NULL; + unsigned char *ciphertext = NULL; size_t output_size = 0; - size_t finish_output_size = 0; - size_t output_length = 0; + size_t ciphertext_size = 0; + size_t ciphertext_length = 0; size_t tag_length = 0; uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; int index = 0; @@ -3808,13 +3808,13 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); - ASSERT_ALLOC( output_data, output_size ); + ASSERT_ALLOC( output, output_size ); - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + ciphertext_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + TEST_ASSERT( ciphertext_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - ASSERT_ALLOC( final_data, finish_output_size ); + ASSERT_ALLOC( ciphertext, ciphertext_size ); operation = psa_aead_operation_init( ); @@ -3826,12 +3826,12 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, if( status == PSA_ERROR_NOT_SUPPORTED ) { MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_len ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_length ); } PSA_ASSERT( status ); - if( nonce_len == 0 ) + if( nonce_length == 0 ) { if( !allow_null_nonce_buffer ) { @@ -3841,15 +3841,15 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, } else { - ASSERT_ALLOC( nonce_buffer, nonce_len ); + ASSERT_ALLOC( nonce_buffer, nonce_length ); - for( index = 0; index < nonce_len - 1; ++index) + for( index = 0; index < nonce_length - 1; ++index) { nonce_buffer[index] = 'a' + index; } } - status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_len ); + status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_length ); TEST_EQUAL( status, expected_status ); @@ -3861,17 +3861,18 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, additional_data->len ) ); PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len, - output_data, output_size, &output_length ) ); + output, output_size, + &ciphertext_length ) ); - PSA_ASSERT( psa_aead_finish( &operation, final_data, finish_output_size, - &output_length, tag_buffer, + PSA_ASSERT( psa_aead_finish( &operation, ciphertext, ciphertext_size, + &ciphertext_length, tag_buffer, PSA_AEAD_TAG_MAX_SIZE, &tag_length ) ); } exit: psa_destroy_key( key ); - mbedtls_free( output_data ); - mbedtls_free( final_data ); + mbedtls_free( output ); + mbedtls_free( ciphertext ); mbedtls_free( nonce_buffer ); psa_aead_abort( &operation ); PSA_DONE( ); From daf5c8954c121b73f2cb1764e99738eac686ad61 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 25 Aug 2021 16:24:58 +0100 Subject: [PATCH 350/966] Remove extraneous state checks Signed-off-by: Paul Elliott --- library/psa_crypto.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 13116dcad7..0bdbc5bd74 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3514,8 +3514,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, goto exit; } - if( operation->nonce_set || operation->ad_started || - operation->body_started || !operation->is_encrypt ) + if( operation->nonce_set || !operation->is_encrypt ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3561,8 +3560,7 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, goto exit; } - if( operation->nonce_set || operation->ad_started || - operation->body_started ) + if( operation->nonce_set ) { status = PSA_ERROR_BAD_STATE; goto exit; From b8db2c572615c3d6a8563643f591efa87800dbff Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 25 Aug 2021 16:33:06 +0100 Subject: [PATCH 351/966] Remove extra blank lines Signed-off-by: Paul Elliott --- library/psa_crypto.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 0bdbc5bd74..79b2618b51 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3438,7 +3438,6 @@ static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, status = psa_get_and_lock_key_slot_with_policy( key, &slot, key_usage, alg ); - if( status != PSA_SUCCESS ) goto exit; @@ -3458,15 +3457,12 @@ static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, slot->key.data, slot->key.bytes, alg ); - - if( status != PSA_SUCCESS ) goto exit; operation->key_type = psa_get_key_type( &attributes ); exit: - unlock_status = psa_unlock_key_slot( slot ); if( status == PSA_SUCCESS ) @@ -3522,7 +3518,6 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, required_nonce_size = PSA_AEAD_NONCE_LENGTH( operation->key_type, operation->alg ); - if( nonce_size < required_nonce_size ) { status = PSA_ERROR_BUFFER_TOO_SMALL; @@ -3530,14 +3525,12 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, } status = psa_generate_random( nonce, required_nonce_size ); - if( status != PSA_SUCCESS ) goto exit; status = psa_aead_set_nonce( operation, nonce, required_nonce_size ); exit: - if( status == PSA_SUCCESS ) *nonce_length = required_nonce_size; else @@ -3576,7 +3569,6 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, nonce_length ); exit: - if( status == PSA_SUCCESS ) operation->nonce_set = 1; else @@ -3609,7 +3601,6 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, plaintext_length ); exit: - if( status == PSA_SUCCESS ) { operation->ad_remaining = ad_length; @@ -3655,7 +3646,6 @@ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, input_length ); exit: - if( status == PSA_SUCCESS ) operation->ad_started = 1; else @@ -3714,7 +3704,6 @@ psa_status_t psa_aead_update( psa_aead_operation_t *operation, output_length ); exit: - if( status == PSA_SUCCESS ) operation->body_started = 1; else @@ -3750,7 +3739,6 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, *tag_length = tag_size; status = psa_aead_final_checks( operation ); - if( status != PSA_SUCCESS ) goto exit; @@ -3766,7 +3754,6 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, tag, tag_size, tag_length ); exit: - /* In case the operation fails and the user fails to check for failure or * the zero tag size, make sure the tag is set to something impossible. * Even if the operation succeeds, make sure we set the rest of the @@ -3796,7 +3783,6 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, *plaintext_length = 0; status = psa_aead_final_checks( operation ); - if( status != PSA_SUCCESS ) goto exit; @@ -3812,7 +3798,6 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, tag, tag_length ); exit: - psa_aead_abort( operation ); return( status ); From 3242f6c8efd6f4af7b06725d7a2c720c78a03bb2 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 25 Aug 2021 16:33:47 +0100 Subject: [PATCH 352/966] Fix formatting issue Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 79b2618b51..c2b318ccaa 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3517,7 +3517,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, } required_nonce_size = PSA_AEAD_NONCE_LENGTH( operation->key_type, - operation->alg ); + operation->alg ); if( nonce_size < required_nonce_size ) { status = PSA_ERROR_BUFFER_TOO_SMALL; From efda3408ce87fc659e273ed86bf66a75390ffeb1 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 25 Aug 2021 17:16:52 +0100 Subject: [PATCH 353/966] Fix formatting issues Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 92c5ccf9ea..337748a23b 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -469,7 +469,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( operation->is_encrypt ? MBEDTLS_CHACHAPOLY_ENCRYPT : MBEDTLS_CHACHAPOLY_DECRYPT ) ); - } + } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { @@ -482,6 +482,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( return( status ); } + /* Declare the lengths of the message and additional data for AEAD. */ psa_status_t mbedtls_psa_aead_set_lengths( mbedtls_psa_aead_operation_t *operation, From 2e450093e1a9e217741664dc9b0e7a5b1e62a0d9 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 25 Aug 2021 17:18:22 +0100 Subject: [PATCH 354/966] Remove variables declared as unused They are now always being used. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 337748a23b..aa266ea87a 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -473,9 +473,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ { - ( void ) operation; ( void ) nonce; - ( void ) nonce_length; return ( PSA_ERROR_NOT_SUPPORTED ); } From 5e69aa5709bb6f6bf1f089ec8648e800c5c8a82b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 25 Aug 2021 17:24:37 +0100 Subject: [PATCH 355/966] Remove NULL check for set nonce Also remove tests which would pass NULL to this function. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 2 +- tests/suites/test_suite_psa_crypto.data | 23 +++++++-------------- tests/suites/test_suite_psa_crypto.function | 8 ++----- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index aa266ea87a..033dc82079 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -443,7 +443,7 @@ psa_status_t mbedtls_psa_aead_set_nonce( psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; if( mbedtls_aead_check_nonce_length( operation, nonce_length ) - != PSA_SUCCESS || nonce == NULL ) + != PSA_SUCCESS ) { return( PSA_ERROR_INVALID_ARGUMENT ); } diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index f2355d60b8..371fee0247 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2598,41 +2598,33 @@ PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:12:"":"":PSA_SUCCESS -PSA Multipart Set Nonce, AES - GCM, IV = 0 (NULL) -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:1:"":"":PSA_ERROR_INVALID_ARGUMENT - PSA Multipart Set Nonce, AES - GCM, IV = 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:0:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"":"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce, AES - GCM, IV = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:0:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Set Nonce, AES - GCM, IV = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):20:0:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 12 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:0:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 8 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:0:"":"":PSA_ERROR_INVALID_ARGUMENT - -PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 (NULL) -depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:1:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:"":"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"":"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:0:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:"":"":PSA_ERROR_INVALID_ARGUMENT PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 10 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES @@ -2662,7 +2654,6 @@ PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_SUCCESS - PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 4ac4210602..5fb7086a11 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3772,7 +3772,6 @@ exit: void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, int alg_arg, int nonce_length, - int allow_null_nonce_buffer, data_t *additional_data, data_t *input_data, int expected_status_arg ) @@ -3833,11 +3832,8 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, if( nonce_length == 0 ) { - if( !allow_null_nonce_buffer ) - { - /* Arbitrary size buffer, to test zero length valid buffer. */ - ASSERT_ALLOC( nonce_buffer, 4 ); - } + /* Arbitrary size buffer, to test zero length valid buffer. */ + ASSERT_ALLOC( nonce_buffer, 4 ); } else { From 1ebcd55aface9312859044d43f3b3ae6decc59fa Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 30 Aug 2021 17:09:03 +0200 Subject: [PATCH 356/966] Extend mac_key_policy test. Add checks for psa_mac_compute and psa_mac_verify. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_psa_crypto.function | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index cde28a8e75..8df2ceafef 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -822,6 +822,23 @@ void mac_key_policy( int policy_usage_arg, status = psa_mac_sign_setup( &operation, key, exercise_alg ); TEST_EQUAL( status, expected_status_sign ); + /* Calculate the MAC, one-shot case. */ + uint8_t input[128] = {0}; + size_t mac_len; + TEST_EQUAL( psa_mac_compute( key, exercise_alg, + input, 128, + mac, PSA_MAC_MAX_SIZE, &mac_len ), + expected_status_sign ); + + /* Verify correct MAC, one-shot case. */ + status = psa_mac_verify( key, exercise_alg, input, 128, + mac, mac_len ); + + if( expected_status_sign != PSA_SUCCESS && expected_status_verify == PSA_SUCCESS ) + TEST_EQUAL( status, PSA_ERROR_INVALID_SIGNATURE ); + else + TEST_EQUAL( status, expected_status_verify ); + psa_mac_abort( &operation ); memset( mac, 0, sizeof( mac ) ); From e28d49b3b666d10677fd555090eaf75081267943 Mon Sep 17 00:00:00 2001 From: Kenneth Soerensen Date: Thu, 3 Jan 2019 12:39:29 +0100 Subject: [PATCH 357/966] Remove compiler warning if only MBEDTLS_PK_PARSE_C is defined Warning reported with IAR compiler: "mbedtls\library\pkparse.c",1167 Warning[Pe550]: variable "ret" was set but never used Signed-off-by: Kenneth Soerensen --- library/pkparse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/pkparse.c b/library/pkparse.c index fe6aaca338..b2d3bb0747 100644 --- a/library/pkparse.c +++ b/library/pkparse.c @@ -1370,8 +1370,8 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, } #endif /* MBEDTLS_PKCS12_C || MBEDTLS_PKCS5_C */ - if( ( ret = pk_parse_key_pkcs8_unencrypted_der( - pk, key, keylen, f_rng, p_rng ) ) == 0 ) + ret = pk_parse_key_pkcs8_unencrypted_der( pk, key, keylen, f_rng, p_rng ); + if( ret == 0 ) { return( 0 ); } From a73b57774451017a0499e24b22c99ae850093471 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 19 Jul 2021 14:36:03 +0200 Subject: [PATCH 358/966] Make the fields of mbedtls_ecp_curve_info public The whole point of this structure is to provide information, both for the library's own sake and to applications. Signed-off-by: Gilles Peskine --- include/mbedtls/ecp.h | 12 ++++++++---- programs/pkey/gen_key.c | 12 ++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/mbedtls/ecp.h b/include/mbedtls/ecp.h index 384d0608a7..b2a2e32564 100644 --- a/include/mbedtls/ecp.h +++ b/include/mbedtls/ecp.h @@ -147,13 +147,17 @@ typedef enum /** * Curve information, for use by other modules. + * + * The fields of this structure are part of the public API and can be + * accessed directly by applications. Future versions of the library may + * add extra fields or reorder existing fields. */ typedef struct mbedtls_ecp_curve_info { - mbedtls_ecp_group_id MBEDTLS_PRIVATE(grp_id); /*!< An internal identifier. */ - uint16_t MBEDTLS_PRIVATE(tls_id); /*!< The TLS NamedCurve identifier. */ - uint16_t MBEDTLS_PRIVATE(bit_size); /*!< The curve size in bits. */ - const char *MBEDTLS_PRIVATE(name); /*!< A human-friendly name. */ + mbedtls_ecp_group_id grp_id; /*!< An internal identifier. */ + uint16_t tls_id; /*!< The TLS NamedCurve identifier. */ + uint16_t bit_size; /*!< The curve size in bits. */ + const char *name; /*!< A human-friendly name. */ } mbedtls_ecp_curve_info; /** diff --git a/programs/pkey/gen_key.c b/programs/pkey/gen_key.c index 4043dfa6e0..7535eee3f3 100644 --- a/programs/pkey/gen_key.c +++ b/programs/pkey/gen_key.c @@ -86,7 +86,7 @@ int dev_random_entropy_poll( void *data, unsigned char *output, #endif #if defined(MBEDTLS_ECP_C) -#define DFL_EC_CURVE mbedtls_ecp_curve_list()->MBEDTLS_PRIVATE(grp_id) +#define DFL_EC_CURVE mbedtls_ecp_curve_list()->grp_id #else #define DFL_EC_CURVE 0 #endif @@ -219,9 +219,9 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_ECP_C) mbedtls_printf( " available ec_curve values:\n" ); curve_info = mbedtls_ecp_curve_list(); - mbedtls_printf( " %s (default)\n", curve_info->MBEDTLS_PRIVATE(name) ); - while( ( ++curve_info )->MBEDTLS_PRIVATE(name) != NULL ) - mbedtls_printf( " %s\n", curve_info->MBEDTLS_PRIVATE(name) ); + mbedtls_printf( " %s (default)\n", curve_info->name ); + while( ( ++curve_info )->name != NULL ) + mbedtls_printf( " %s\n", curve_info->name ); #endif /* MBEDTLS_ECP_C */ goto exit; } @@ -270,7 +270,7 @@ int main( int argc, char *argv[] ) { if( ( curve_info = mbedtls_ecp_curve_info_from_name( q ) ) == NULL ) goto usage; - opt.ec_curve = curve_info->MBEDTLS_PRIVATE(grp_id); + opt.ec_curve = curve_info->grp_id; } #endif else if( strcmp( p, "filename" ) == 0 ) @@ -391,7 +391,7 @@ int main( int argc, char *argv[] ) { mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( key ); mbedtls_printf( "curve: %s\n", - mbedtls_ecp_curve_info_from_grp_id( ecp->MBEDTLS_PRIVATE(grp).id )->MBEDTLS_PRIVATE(name) ); + mbedtls_ecp_curve_info_from_grp_id( ecp->MBEDTLS_PRIVATE(grp).id )->name ); mbedtls_mpi_write_file( "X_Q: ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), 16, NULL ); mbedtls_mpi_write_file( "Y_Q: ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Y), 16, NULL ); mbedtls_mpi_write_file( "D: ", &ecp->MBEDTLS_PRIVATE(d) , 16, NULL ); From 0be02bd823c07737775a2251e7426270f2c4f902 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 19 Jul 2021 16:32:54 +0200 Subject: [PATCH 359/966] Add accessor functions for cipher_info fields Add functions to read the type, mode, name and key_bitlen fields from mbedtls_cipher_info_t. These are the fields that applications are most likely to care about. TLS code also uses iv_size and block_size, which it might make sense to expose, but most applications shouldn't need those, so I'm not exposing them for now. Call the new functions in unit tests, so they're at least smoke-tested. Signed-off-by: Gilles Peskine --- include/mbedtls/cipher.h | 76 +++++++++++++++++++++++++ tests/suites/test_suite_cipher.function | 42 +++++++++++++- 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h index 9c9a2e88cd..7921f4d85f 100644 --- a/include/mbedtls/cipher.h +++ b/include/mbedtls/cipher.h @@ -414,6 +414,82 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_ciph int key_bitlen, const mbedtls_cipher_mode_t mode ); +/** + * \brief Retrieve the identifier for a cipher info structure. + * + * \param[in] info The cipher info structure to query. + * This may be \c NULL. + * + * \return The full cipher identifier (\c MBEDTLS_CIPHER_xxx). + * \return #MBEDTLS_CIPHER_NONE if \p info is \c NULL. + */ +static inline mbedtls_cipher_type_t mbedtls_cipher_info_get_type( + const mbedtls_cipher_info_t *info ) +{ + if( info == NULL ) + return( MBEDTLS_CIPHER_NONE ); + else + return( info->MBEDTLS_PRIVATE(type) ); +} + +/** + * \brief Retrieve the operation mode for a cipher info structure. + * + * \param[in] info The cipher info structure to query. + * This may be \c NULL. + * + * \return The cipher mode (\c MBEDTLS_MODE_xxx). + * \return #MBEDTLS_MODE_NONE if \p info is \c NULL. + */ +static inline mbedtls_cipher_mode_t mbedtls_cipher_info_get_mode( + const mbedtls_cipher_info_t *info ) +{ + if( info == NULL ) + return( MBEDTLS_MODE_NONE ); + else + return( info->MBEDTLS_PRIVATE(mode) ); +} + +/** + * \brief Retrieve the key size for a cipher info structure. + * + * \param[in] info The cipher info structure to query. + * This may be \c NULL. + * + * \return The key length in bits. + * For variable-sized ciphers, this is the default length. + * For DES, this includes the parity bits. + * \return \c 0 if \p info is \c NULL. + */ +static inline size_t mbedtls_cipher_info_get_key_bitlen( + const mbedtls_cipher_info_t *info ) +{ + if( info == NULL ) + return( 0 ); + else + return( info->MBEDTLS_PRIVATE(key_bitlen) ); +} + +/** + * \brief Retrieve the human-readable name for a + * cipher info structure. + * + * \param[in] info The cipher info structure to query. + * This may be \c NULL. + * + * \return The cipher name, which is a human readable string, + * with static storage duration. + * \return \c NULL if \c info is \p NULL. + */ +static inline const char *mbedtls_cipher_info_get_name( + const mbedtls_cipher_info_t *info ) +{ + if( info == NULL ) + return( NULL ); + else + return( info->MBEDTLS_PRIVATE(name) ); +} + /** * \brief This function initializes a \p cipher_context as NONE. * diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index 674349f764..94ea88f791 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -13,6 +13,38 @@ #define MBEDTLS_CIPHER_AUTH_CRYPT #endif +/* Check the internal consistency of a cipher info structure, and + * check it against mbedtls_cipher_info_from_xxx(). */ +static int check_cipher_info( mbedtls_cipher_type_t type, + const mbedtls_cipher_info_t *info ) +{ + size_t key_bitlen; + + TEST_ASSERT( info != NULL ); + TEST_EQUAL( type, mbedtls_cipher_info_get_type( info ) ); + TEST_EQUAL( type, info->type ); + TEST_ASSERT( mbedtls_cipher_info_from_type( type ) == info ); + + TEST_EQUAL( info->mode, mbedtls_cipher_info_get_mode( info ) ); + + /* Insist that get_name() return the string from the structure and + * not a copy. A copy would have an unknown storage duration. */ + TEST_ASSERT( mbedtls_cipher_info_get_name( info ) == info->name ); + TEST_ASSERT( mbedtls_cipher_info_from_string( info->name ) == info ); + + key_bitlen = mbedtls_cipher_info_get_key_bitlen( info ); + TEST_ASSERT( key_bitlen % 8 == 0 ); + /* All current and plausible supported ciphers use a 64-bit, 128-bit + * or 256-bit key, except XTS which uses a double AES key. */ + TEST_ASSERT( key_bitlen >= 64 ); + TEST_ASSERT( key_bitlen <= 512 ); + + return( 1 ); + +exit: + return( 0 ); +} + #if defined(MBEDTLS_CIPHER_AUTH_CRYPT) /* Helper for resetting key/direction * @@ -81,7 +113,13 @@ void mbedtls_cipher_list( ) const int *cipher_type; for( cipher_type = mbedtls_cipher_list(); *cipher_type != 0; cipher_type++ ) - TEST_ASSERT( mbedtls_cipher_info_from_type( *cipher_type ) != NULL ); + { + const mbedtls_cipher_info_t *info = + mbedtls_cipher_info_from_type( *cipher_type ); + mbedtls_test_set_step( *cipher_type ); + if( ! check_cipher_info( *cipher_type, info ) ) + goto exit; + } } /* END_CASE */ @@ -309,6 +347,8 @@ void enc_dec_buf( int cipher_id, char * cipher_string, int key_len, cipher_info = mbedtls_cipher_info_from_type( cipher_id ); TEST_ASSERT( NULL != cipher_info ); TEST_ASSERT( mbedtls_cipher_info_from_string( cipher_string ) == cipher_info ); + TEST_ASSERT( strcmp( mbedtls_cipher_info_get_name( cipher_info ), + cipher_string ) == 0 ); /* Initialise enc and dec contexts */ TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx_dec, cipher_info ) ); From 80932fa9448cb6c9016041f660f0d2444b1e27af Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 19 Jul 2021 17:34:02 +0200 Subject: [PATCH 360/966] Don't access cipher_info private fields in sample programs Use the new accessor functions. Signed-off-by: Gilles Peskine --- programs/aes/crypt_and_hash.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/programs/aes/crypt_and_hash.c b/programs/aes/crypt_and_hash.c index a8026a3353..ba9827f45e 100644 --- a/programs/aes/crypt_and_hash.c +++ b/programs/aes/crypt_and_hash.c @@ -124,7 +124,7 @@ int main( int argc, char *argv[] ) while( *list ) { cipher_info = mbedtls_cipher_info_from_type( *list ); - mbedtls_printf( " %s\n", cipher_info->MBEDTLS_PRIVATE(name) ); + mbedtls_printf( " %s\n", mbedtls_cipher_info_get_name( cipher_info ) ); list++; } @@ -309,7 +309,9 @@ int main( int argc, char *argv[] ) } - if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->MBEDTLS_PRIVATE(key_bitlen), + if( mbedtls_cipher_setkey( &cipher_ctx, + digest, + mbedtls_cipher_info_get_key_bitlen( cipher_info ), MBEDTLS_ENCRYPT ) != 0 ) { mbedtls_fprintf( stderr, "mbedtls_cipher_setkey() returned error\n"); @@ -408,7 +410,7 @@ int main( int argc, char *argv[] ) /* * Check the file size. */ - if( cipher_info->MBEDTLS_PRIVATE(mode) != MBEDTLS_MODE_GCM && + if( mbedtls_cipher_info_get_mode( cipher_info ) != MBEDTLS_MODE_GCM && ( ( filesize - mbedtls_md_get_size( md_info ) ) % mbedtls_cipher_get_block_size( &cipher_ctx ) ) != 0 ) { @@ -448,7 +450,9 @@ int main( int argc, char *argv[] ) mbedtls_md_finish( &md_ctx, digest ); } - if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->MBEDTLS_PRIVATE(key_bitlen), + if( mbedtls_cipher_setkey( &cipher_ctx, + digest, + mbedtls_cipher_info_get_key_bitlen( cipher_info ), MBEDTLS_DECRYPT ) != 0 ) { mbedtls_fprintf( stderr, "mbedtls_cipher_setkey() returned error\n" ); From e720dbe17762655b86e46b5968ba4e029c78c378 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 19 Jul 2021 17:37:46 +0200 Subject: [PATCH 361/966] Use cipher_info accessor functions in TLS code Signed-off-by: Gilles Peskine --- library/ssl_ticket.c | 6 +++--- library/ssl_tls.c | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c index bce9a1cd71..db2bb52b34 100644 --- a/library/ssl_ticket.c +++ b/library/ssl_ticket.c @@ -141,13 +141,13 @@ int mbedtls_ssl_ticket_setup( mbedtls_ssl_ticket_context *ctx, if( cipher_info == NULL ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - if( cipher_info->mode != MBEDTLS_MODE_GCM && - cipher_info->mode != MBEDTLS_MODE_CCM ) + if( mbedtls_cipher_info_get_mode( cipher_info ) != MBEDTLS_MODE_GCM && + mbedtls_cipher_info_get_mode( cipher_info ) != MBEDTLS_MODE_CCM ) { return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); } - if( cipher_info->key_bitlen > 8 * MAX_KEY_BYTES ) + if( mbedtls_cipher_info_get_key_bitlen( cipher_info ) > 8 * MAX_KEY_BYTES ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); #if defined(MBEDTLS_USE_PSA_CRYPTO) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 07b51003ab..1e81384aa7 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -789,14 +789,14 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, * Determine the appropriate key, IV and MAC length. */ - keylen = cipher_info->key_bitlen / 8; + keylen = mbedtls_cipher_info_get_key_bitlen( cipher_info ) / 8; #if defined(MBEDTLS_GCM_C) || \ defined(MBEDTLS_CCM_C) || \ defined(MBEDTLS_CHACHAPOLY_C) - if( cipher_info->mode == MBEDTLS_MODE_GCM || - cipher_info->mode == MBEDTLS_MODE_CCM || - cipher_info->mode == MBEDTLS_MODE_CHACHAPOLY ) + if( mbedtls_cipher_info_get_mode( cipher_info ) == MBEDTLS_MODE_GCM || + mbedtls_cipher_info_get_mode( cipher_info ) == MBEDTLS_MODE_CCM || + mbedtls_cipher_info_get_mode( cipher_info ) == MBEDTLS_MODE_CHACHAPOLY ) { size_t explicit_ivlen; @@ -814,7 +814,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, * sequence number). */ transform->ivlen = 12; - if( cipher_info->mode == MBEDTLS_MODE_CHACHAPOLY ) + if( mbedtls_cipher_info_get_mode( cipher_info ) == MBEDTLS_MODE_CHACHAPOLY ) transform->fixed_ivlen = 12; else transform->fixed_ivlen = 4; @@ -826,8 +826,8 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, else #endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C || MBEDTLS_CHACHAPOLY_C */ #if defined(MBEDTLS_SSL_SOME_SUITES_USE_MAC) - if( cipher_info->mode == MBEDTLS_MODE_STREAM || - cipher_info->mode == MBEDTLS_MODE_CBC ) + if( mbedtls_cipher_info_get_mode( cipher_info ) == MBEDTLS_MODE_STREAM || + mbedtls_cipher_info_get_mode( cipher_info ) == MBEDTLS_MODE_CBC ) { /* Initialize HMAC contexts */ if( ( ret = mbedtls_md_setup( &transform->md_ctx_enc, md_info, 1 ) ) != 0 || @@ -845,7 +845,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, transform->ivlen = cipher_info->iv_size; /* Minimum length */ - if( cipher_info->mode == MBEDTLS_MODE_STREAM ) + if( mbedtls_cipher_info_get_mode( cipher_info ) == MBEDTLS_MODE_STREAM ) transform->minlen = transform->maclen; else { @@ -1060,7 +1060,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, } if( ( ret = mbedtls_cipher_setkey( &transform->cipher_ctx_enc, key1, - cipher_info->key_bitlen, + mbedtls_cipher_info_get_key_bitlen( cipher_info ), MBEDTLS_ENCRYPT ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setkey", ret ); @@ -1068,7 +1068,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, } if( ( ret = mbedtls_cipher_setkey( &transform->cipher_ctx_dec, key2, - cipher_info->key_bitlen, + mbedtls_cipher_info_get_key_bitlen( cipher_info ), MBEDTLS_DECRYPT ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setkey", ret ); @@ -1076,7 +1076,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, } #if defined(MBEDTLS_CIPHER_MODE_CBC) - if( cipher_info->mode == MBEDTLS_MODE_CBC ) + if( mbedtls_cipher_info_get_mode( cipher_info ) == MBEDTLS_MODE_CBC ) { if( ( ret = mbedtls_cipher_set_padding_mode( &transform->cipher_ctx_enc, MBEDTLS_PADDING_NONE ) ) != 0 ) From ce9e3a92fe3db6f20b267005e9f12b3e6ffbd389 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 19 Jul 2021 17:38:09 +0200 Subject: [PATCH 362/966] Remove redundant null check mbedtls_cipher_info_get_xxx has well-defined behavior on NULL, so no need to check first. Signed-off-by: Gilles Peskine --- library/ssl_ticket.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c index db2bb52b34..e998111d93 100644 --- a/library/ssl_ticket.c +++ b/library/ssl_ticket.c @@ -138,8 +138,6 @@ int mbedtls_ssl_ticket_setup( mbedtls_ssl_ticket_context *ctx, ctx->ticket_lifetime = lifetime; cipher_info = mbedtls_cipher_info_from_type( cipher); - if( cipher_info == NULL ) - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); if( mbedtls_cipher_info_get_mode( cipher_info ) != MBEDTLS_MODE_GCM && mbedtls_cipher_info_get_mode( cipher_info ) != MBEDTLS_MODE_CCM ) From b11d61e095dd656afec02716f350db1e2063a8b9 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 4 Aug 2021 20:38:59 +0200 Subject: [PATCH 363/966] mbedtls_net_context: make fd public on Unix/POSIX platforms On platforms with BSD-like sockets, it is useful for applications to have access to the underlying file descriptor so that they can use functions like select() and poll(). Do not promise that the field will exist on other platforms such as Windows (where the type and name of the field are technically wrong because Windows socket handles are actually not file descriptors). Signed-off-by: Gilles Peskine --- include/mbedtls/net_sockets.h | 8 +++++++- programs/ssl/mini_client.c | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/net_sockets.h b/include/mbedtls/net_sockets.h index c8214a2335..0c754b122c 100644 --- a/include/mbedtls/net_sockets.h +++ b/include/mbedtls/net_sockets.h @@ -94,7 +94,13 @@ extern "C" { */ typedef struct mbedtls_net_context { - int MBEDTLS_PRIVATE(fd); /**< The underlying file descriptor */ + /** The underlying file descriptor. + * + * This field is only guaranteed to be present on POSIX/Unix-like platforms. + * On other platforms, it may have a different type, have a different + * meaning, or be absent altogether. + */ + int fd; } mbedtls_net_context; diff --git a/programs/ssl/mini_client.c b/programs/ssl/mini_client.c index 1e0bef6b1c..97bfe68061 100644 --- a/programs/ssl/mini_client.c +++ b/programs/ssl/mini_client.c @@ -246,13 +246,13 @@ int main( void ) addr.sin_addr.s_addr = *((char *) &ret) == ret ? ADDR_LE : ADDR_BE; ret = 0; - if( ( server_fd.MBEDTLS_PRIVATE(fd) = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 ) + if( ( server_fd.fd = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 ) { ret = socket_failed; goto exit; } - if( connect( server_fd.MBEDTLS_PRIVATE(fd), + if( connect( server_fd.fd, (const struct sockaddr *) &addr, sizeof( addr ) ) < 0 ) { ret = connect_failed; From b89d9c05990355b9a7522d62380a41c237195a3b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 4 Aug 2021 20:55:33 +0200 Subject: [PATCH 364/966] Make fields of ASN.1 data structures public The structures mbedtls_asn1_buf, mbedtls_asn1_bitstring, mbedtls_asn1_sequence and mbedtls_asn1_named_data are designed to allow access to data after parsing. Make their fields public. Document that chaining fields are essentially read-only. Signed-off-by: Gilles Peskine --- include/mbedtls/asn1.h | 46 +++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/include/mbedtls/asn1.h b/include/mbedtls/asn1.h index f45fc17511..34a39d9eb9 100644 --- a/include/mbedtls/asn1.h +++ b/include/mbedtls/asn1.h @@ -152,9 +152,9 @@ extern "C" { */ typedef struct mbedtls_asn1_buf { - int MBEDTLS_PRIVATE(tag); /**< ASN1 type, e.g. MBEDTLS_ASN1_UTF8_STRING. */ - size_t MBEDTLS_PRIVATE(len); /**< ASN1 length, in octets. */ - unsigned char *MBEDTLS_PRIVATE(p); /**< ASN1 data, e.g. in ASCII. */ + int tag; /**< ASN1 type, e.g. MBEDTLS_ASN1_UTF8_STRING. */ + size_t len; /**< ASN1 length, in octets. */ + unsigned char *p; /**< ASN1 data, e.g. in ASCII. */ } mbedtls_asn1_buf; @@ -163,9 +163,9 @@ mbedtls_asn1_buf; */ typedef struct mbedtls_asn1_bitstring { - size_t MBEDTLS_PRIVATE(len); /**< ASN1 length, in octets. */ - unsigned char MBEDTLS_PRIVATE(unused_bits); /**< Number of unused bits at the end of the string */ - unsigned char *MBEDTLS_PRIVATE(p); /**< Raw ASN1 data for the bit string */ + size_t len; /**< ASN1 length, in octets. */ + unsigned char unused_bits; /**< Number of unused bits at the end of the string */ + unsigned char *p; /**< Raw ASN1 data for the bit string */ } mbedtls_asn1_bitstring; @@ -174,8 +174,16 @@ mbedtls_asn1_bitstring; */ typedef struct mbedtls_asn1_sequence { - mbedtls_asn1_buf MBEDTLS_PRIVATE(buf); /**< Buffer containing the given ASN.1 item. */ - struct mbedtls_asn1_sequence *MBEDTLS_PRIVATE(next); /**< The next entry in the sequence. */ + mbedtls_asn1_buf buf; /**< Buffer containing the given ASN.1 item. */ + + /** The next entry in the sequence. + * + * The details memory management for sequences are not documented and + * may change in future versions. Set this field to \p NULL when + * initializing a structure, and do not modify it except via Mbed TLS + * library functions. + */ + struct mbedtls_asn1_sequence *next; } mbedtls_asn1_sequence; @@ -184,10 +192,24 @@ mbedtls_asn1_sequence; */ typedef struct mbedtls_asn1_named_data { - mbedtls_asn1_buf MBEDTLS_PRIVATE(oid); /**< The object identifier. */ - mbedtls_asn1_buf MBEDTLS_PRIVATE(val); /**< The named value. */ - struct mbedtls_asn1_named_data *MBEDTLS_PRIVATE(next); /**< The next entry in the sequence. */ - unsigned char MBEDTLS_PRIVATE(next_merged); /**< Merge next item into the current one? */ + mbedtls_asn1_buf oid; /**< The object identifier. */ + mbedtls_asn1_buf val; /**< The named value. */ + + /** The next entry in the sequence. + * + * The details memory management for named data sequences are not documented + * and may change in future versions. Set this field to \p NULL when + * initializing a structure, and do not modify it except via Mbed TLS + * library functions. + */ + struct mbedtls_asn1_named_data *next; + + /** Merge next item into the current one? + * + * This field exists for the sake of Mbed TLS's X.509 certificate parsing + * code and may change in future versions of the library. + */ + unsigned char MBEDTLS_PRIVATE(next_merged); } mbedtls_asn1_named_data; From 842edf474c7c4844dd28aab059b931b0793d276d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 4 Aug 2021 21:56:10 +0200 Subject: [PATCH 365/966] Make many fields of X.509 structures public The structures mbedtls_x509_time, mbedtls_x509_crl_entry, mbedtls_x509_crl, mbedtls_x509_crt, mbedtls_x509_san_other_name, mbedtls_x509_subject_alternative_name, mbedtls_x509_csr are designed to expose the result of parsing X.509 data. Document many of their fields as being publicly readable. Signed-off-by: Gilles Peskine --- include/mbedtls/x509.h | 4 +-- include/mbedtls/x509_crl.h | 43 ++++++++++++++---------- include/mbedtls/x509_crt.h | 69 ++++++++++++++++++++++---------------- include/mbedtls/x509_csr.h | 18 ++++++---- programs/x509/cert_write.c | 8 ++--- 5 files changed, 83 insertions(+), 59 deletions(-) diff --git a/include/mbedtls/x509.h b/include/mbedtls/x509.h index df187cb098..9a4be95a3e 100644 --- a/include/mbedtls/x509.h +++ b/include/mbedtls/x509.h @@ -246,8 +246,8 @@ typedef mbedtls_asn1_sequence mbedtls_x509_sequence; /** Container for date and time (precision in seconds). */ typedef struct mbedtls_x509_time { - int MBEDTLS_PRIVATE(year), MBEDTLS_PRIVATE(mon), MBEDTLS_PRIVATE(day); /**< Date. */ - int MBEDTLS_PRIVATE(hour), MBEDTLS_PRIVATE(min), MBEDTLS_PRIVATE(sec); /**< Time. */ + int year, mon, day; /**< Date. */ + int hour, min, sec; /**< Time. */ } mbedtls_x509_time; diff --git a/include/mbedtls/x509_crl.h b/include/mbedtls/x509_crl.h index 9331827bb2..f65e9847ba 100644 --- a/include/mbedtls/x509_crl.h +++ b/include/mbedtls/x509_crl.h @@ -43,16 +43,25 @@ extern "C" { /** * Certificate revocation list entry. * Contains the CA-specific serial numbers and revocation dates. + * + * Some fields of this structure are publicly readable. Do not modify + * them except via Mbed TLS library functions: the effect of modifying + * those fields or the data that those fields points to is unspecified. */ typedef struct mbedtls_x509_crl_entry { - mbedtls_x509_buf MBEDTLS_PRIVATE(raw); - - mbedtls_x509_buf MBEDTLS_PRIVATE(serial); - - mbedtls_x509_time MBEDTLS_PRIVATE(revocation_date); - - mbedtls_x509_buf MBEDTLS_PRIVATE(entry_ext); + /** Direct access to the whole entry inside the containing buffer. */ + mbedtls_x509_buf raw; + /** The serial number of the revoked certificate. */ + mbedtls_x509_buf serial; + /** The revocation date of this entry. */ + mbedtls_x509_time revocation_date; + /** Direct access to the list of CRL entry extensions + * (an ASN.1 constructed sequence). + * + * If there are no extensions, `entry_ext.len == 0` and + * `entry_ext.p == NULL`. */ + mbedtls_x509_buf entry_ext; struct mbedtls_x509_crl_entry *MBEDTLS_PRIVATE(next); } @@ -64,22 +73,22 @@ mbedtls_x509_crl_entry; */ typedef struct mbedtls_x509_crl { - mbedtls_x509_buf MBEDTLS_PRIVATE(raw); /**< The raw certificate data (DER). */ - mbedtls_x509_buf MBEDTLS_PRIVATE(tbs); /**< The raw certificate body (DER). The part that is To Be Signed. */ + mbedtls_x509_buf raw; /**< The raw certificate data (DER). */ + mbedtls_x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */ - int MBEDTLS_PRIVATE(version); /**< CRL version (1=v1, 2=v2) */ - mbedtls_x509_buf MBEDTLS_PRIVATE(sig_oid); /**< CRL signature type identifier */ + int version; /**< CRL version (1=v1, 2=v2) */ + mbedtls_x509_buf sig_oid; /**< CRL signature type identifier */ - mbedtls_x509_buf MBEDTLS_PRIVATE(issuer_raw); /**< The raw issuer data (DER). */ + mbedtls_x509_buf issuer_raw; /**< The raw issuer data (DER). */ - mbedtls_x509_name MBEDTLS_PRIVATE(issuer); /**< The parsed issuer data (named information object). */ + mbedtls_x509_name issuer; /**< The parsed issuer data (named information object). */ - mbedtls_x509_time MBEDTLS_PRIVATE(this_update); - mbedtls_x509_time MBEDTLS_PRIVATE(next_update); + mbedtls_x509_time this_update; + mbedtls_x509_time next_update; - mbedtls_x509_crl_entry MBEDTLS_PRIVATE(entry); /**< The CRL entries containing the certificate revocation times for this CA. */ + mbedtls_x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(crl_ext); + mbedtls_x509_buf crl_ext; mbedtls_x509_buf MBEDTLS_PRIVATE(sig_oid2); mbedtls_x509_buf MBEDTLS_PRIVATE(sig); diff --git a/include/mbedtls/x509_crt.h b/include/mbedtls/x509_crt.h index 49211a948f..6731100f20 100644 --- a/include/mbedtls/x509_crt.h +++ b/include/mbedtls/x509_crt.h @@ -45,36 +45,40 @@ extern "C" { /** * Container for an X.509 certificate. The certificate may be chained. + * + * Some fields of this structure are publicly readable. Do not modify + * them except via Mbed TLS library functions: the effect of modifying + * those fields or the data that those fields points to is unspecified. */ typedef struct mbedtls_x509_crt { int MBEDTLS_PRIVATE(own_buffer); /**< Indicates if \c raw is owned * by the structure or not. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(raw); /**< The raw certificate data (DER). */ - mbedtls_x509_buf MBEDTLS_PRIVATE(tbs); /**< The raw certificate body (DER). The part that is To Be Signed. */ + mbedtls_x509_buf raw; /**< The raw certificate data (DER). */ + mbedtls_x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */ - int MBEDTLS_PRIVATE(version); /**< The X.509 version. (1=v1, 2=v2, 3=v3) */ - mbedtls_x509_buf MBEDTLS_PRIVATE(serial); /**< Unique id for certificate issued by a specific CA. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(sig_oid); /**< Signature algorithm, e.g. sha1RSA */ + int version; /**< The X.509 version. (1=v1, 2=v2, 3=v3) */ + mbedtls_x509_buf serial; /**< Unique id for certificate issued by a specific CA. */ + mbedtls_x509_buf sig_oid; /**< Signature algorithm, e.g. sha1RSA */ - mbedtls_x509_buf MBEDTLS_PRIVATE(issuer_raw); /**< The raw issuer data (DER). Used for quick comparison. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(subject_raw); /**< The raw subject data (DER). Used for quick comparison. */ + mbedtls_x509_buf issuer_raw; /**< The raw issuer data (DER). Used for quick comparison. */ + mbedtls_x509_buf subject_raw; /**< The raw subject data (DER). Used for quick comparison. */ - mbedtls_x509_name MBEDTLS_PRIVATE(issuer); /**< The parsed issuer data (named information object). */ - mbedtls_x509_name MBEDTLS_PRIVATE(subject); /**< The parsed subject data (named information object). */ + mbedtls_x509_name issuer; /**< The parsed issuer data (named information object). */ + mbedtls_x509_name subject; /**< The parsed subject data (named information object). */ - mbedtls_x509_time MBEDTLS_PRIVATE(valid_from); /**< Start time of certificate validity. */ - mbedtls_x509_time MBEDTLS_PRIVATE(valid_to); /**< End time of certificate validity. */ + mbedtls_x509_time valid_from; /**< Start time of certificate validity. */ + mbedtls_x509_time valid_to; /**< End time of certificate validity. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(pk_raw); - mbedtls_pk_context MBEDTLS_PRIVATE(pk); /**< Container for the public key context. */ + mbedtls_x509_buf pk_raw; + mbedtls_pk_context pk; /**< Container for the public key context. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(issuer_id); /**< Optional X.509 v2/v3 issuer unique identifier. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(subject_id); /**< Optional X.509 v2/v3 subject unique identifier. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(v3_ext); /**< Optional X.509 v3 extensions. */ - mbedtls_x509_sequence MBEDTLS_PRIVATE(subject_alt_names); /**< Optional list of raw entries of Subject Alternative Names extension (currently only dNSName and OtherName are listed). */ + mbedtls_x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique identifier. */ + mbedtls_x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique identifier. */ + mbedtls_x509_buf v3_ext; /**< Optional X.509 v3 extensions. */ + mbedtls_x509_sequence subject_alt_names; /**< Optional list of raw entries of Subject Alternative Names extension (currently only dNSName and OtherName are listed). */ - mbedtls_x509_sequence MBEDTLS_PRIVATE(certificate_policies); /**< Optional list of certificate policies (Only anyPolicy is printed and enforced, however the rest of the policies are still listed). */ + mbedtls_x509_sequence certificate_policies; /**< Optional list of certificate policies (Only anyPolicy is printed and enforced, however the rest of the policies are still listed). */ int MBEDTLS_PRIVATE(ext_types); /**< Bit string containing detected and parsed extensions */ int MBEDTLS_PRIVATE(ca_istrue); /**< Optional Basic Constraint extension value: 1 if this certificate belongs to a CA, 0 otherwise. */ @@ -82,7 +86,7 @@ typedef struct mbedtls_x509_crt unsigned int MBEDTLS_PRIVATE(key_usage); /**< Optional key usage extension value: See the values in x509.h */ - mbedtls_x509_sequence MBEDTLS_PRIVATE(ext_key_usage); /**< Optional list of extended key usage OIDs. */ + mbedtls_x509_sequence ext_key_usage; /**< Optional list of extended key usage OIDs. */ unsigned char MBEDTLS_PRIVATE(ns_cert_type); /**< Optional Netscape certificate type extension value: See the values in x509.h */ @@ -100,6 +104,9 @@ mbedtls_x509_crt; * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } + * + * Future versions of the library may add new fields to this structure or + * to its embedded union and structure. */ typedef struct mbedtls_x509_san_other_name { @@ -108,7 +115,7 @@ typedef struct mbedtls_x509_san_other_name * To check the value of the type id, you should use * \p MBEDTLS_OID_CMP with a known OID mbedtls_x509_buf. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(type_id); /**< The type id. */ + mbedtls_x509_buf type_id; /**< The type id. */ union { /** @@ -119,26 +126,30 @@ typedef struct mbedtls_x509_san_other_name */ struct { - mbedtls_x509_buf MBEDTLS_PRIVATE(oid); /**< The object identifier. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(val); /**< The named value. */ + mbedtls_x509_buf oid; /**< The object identifier. */ + mbedtls_x509_buf val; /**< The named value. */ } - MBEDTLS_PRIVATE(hardware_module_name); + hardware_module_name; } - MBEDTLS_PRIVATE(value); + value; } mbedtls_x509_san_other_name; /** - * A structure for holding the parsed Subject Alternative Name, according to type + * A structure for holding the parsed Subject Alternative Name, + * according to type. + * + * Future versions of the library may add new fields to this structure or + * to its embedded union and structure. */ typedef struct mbedtls_x509_subject_alternative_name { - int MBEDTLS_PRIVATE(type); /**< The SAN type, value of MBEDTLS_X509_SAN_XXX. */ + int type; /**< The SAN type, value of MBEDTLS_X509_SAN_XXX. */ union { - mbedtls_x509_san_other_name MBEDTLS_PRIVATE(other_name); /**< The otherName supported type. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(unstructured_name); /**< The buffer for the un constructed types. Only dnsName currently supported */ + mbedtls_x509_san_other_name other_name; /**< The otherName supported type. */ + mbedtls_x509_buf unstructured_name; /**< The buffer for the un constructed types. Only dnsName currently supported */ } - MBEDTLS_PRIVATE(san); /**< A union of the supported SAN types */ + san; /**< A union of the supported SAN types */ } mbedtls_x509_subject_alternative_name; diff --git a/include/mbedtls/x509_csr.h b/include/mbedtls/x509_csr.h index 674f9ce793..5d1ce0e418 100644 --- a/include/mbedtls/x509_csr.h +++ b/include/mbedtls/x509_csr.h @@ -42,20 +42,24 @@ extern "C" { /** * Certificate Signing Request (CSR) structure. + * + * Some fields of this structure are publicly readable. Do not modify + * them except via Mbed TLS library functions: the effect of modifying + * those fields or the data that those fields points to is unspecified. */ typedef struct mbedtls_x509_csr { - mbedtls_x509_buf MBEDTLS_PRIVATE(raw); /**< The raw CSR data (DER). */ - mbedtls_x509_buf MBEDTLS_PRIVATE(cri); /**< The raw CertificateRequestInfo body (DER). */ + mbedtls_x509_buf raw; /**< The raw CSR data (DER). */ + mbedtls_x509_buf cri; /**< The raw CertificateRequestInfo body (DER). */ - int MBEDTLS_PRIVATE(version); /**< CSR version (1=v1). */ + int version; /**< CSR version (1=v1). */ - mbedtls_x509_buf MBEDTLS_PRIVATE(subject_raw); /**< The raw subject data (DER). */ - mbedtls_x509_name MBEDTLS_PRIVATE(subject); /**< The parsed subject data (named information object). */ + mbedtls_x509_buf subject_raw; /**< The raw subject data (DER). */ + mbedtls_x509_name subject; /**< The parsed subject data (named information object). */ - mbedtls_pk_context MBEDTLS_PRIVATE(pk); /**< Container for the public key context. */ + mbedtls_pk_context pk; /**< Container for the public key context. */ - mbedtls_x509_buf MBEDTLS_PRIVATE(sig_oid); + mbedtls_x509_buf sig_oid; mbedtls_x509_buf MBEDTLS_PRIVATE(sig); mbedtls_md_type_t MBEDTLS_PRIVATE(sig_md); /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */ mbedtls_pk_type_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */ diff --git a/programs/x509/cert_write.c b/programs/x509/cert_write.c index 9a20d63419..763f8684f6 100644 --- a/programs/x509/cert_write.c +++ b/programs/x509/cert_write.c @@ -514,7 +514,7 @@ int main( int argc, char *argv[] ) } ret = mbedtls_x509_dn_gets( issuer_name, sizeof(issuer_name), - &issuer_crt.MBEDTLS_PRIVATE(subject) ); + &issuer_crt.subject ); if( ret < 0 ) { mbedtls_strerror( ret, buf, 1024 ); @@ -548,7 +548,7 @@ int main( int argc, char *argv[] ) } ret = mbedtls_x509_dn_gets( subject_name, sizeof(subject_name), - &csr.MBEDTLS_PRIVATE(subject) ); + &csr.subject ); if( ret < 0 ) { mbedtls_strerror( ret, buf, 1024 ); @@ -558,7 +558,7 @@ int main( int argc, char *argv[] ) } opt.subject_name = subject_name; - subject_key = &csr.MBEDTLS_PRIVATE(pk); + subject_key = &csr.pk; mbedtls_printf( " ok\n" ); } @@ -602,7 +602,7 @@ int main( int argc, char *argv[] ) // if( strlen( opt.issuer_crt ) ) { - if( mbedtls_pk_check_pair( &issuer_crt.MBEDTLS_PRIVATE(pk), issuer_key, + if( mbedtls_pk_check_pair( &issuer_crt.pk, issuer_key, mbedtls_ctr_drbg_random, &ctr_drbg ) != 0 ) { mbedtls_printf( " failed\n ! issuer_key does not match " From 44ffc79d298c172e9bf2000acec9edc0ba0e95f6 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 31 Aug 2021 22:59:35 +0200 Subject: [PATCH 366/966] Copyediting in comments Signed-off-by: Gilles Peskine --- include/mbedtls/asn1.h | 10 +++++----- include/mbedtls/x509_csr.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/mbedtls/asn1.h b/include/mbedtls/asn1.h index 34a39d9eb9..4746c1cb4d 100644 --- a/include/mbedtls/asn1.h +++ b/include/mbedtls/asn1.h @@ -178,9 +178,9 @@ typedef struct mbedtls_asn1_sequence /** The next entry in the sequence. * - * The details memory management for sequences are not documented and + * The details of memory management for sequences are not documented and * may change in future versions. Set this field to \p NULL when - * initializing a structure, and do not modify it except via Mbed TLS + * initializing a structure, and do not modify it except via Mbed TLS * library functions. */ struct mbedtls_asn1_sequence *next; @@ -197,9 +197,9 @@ typedef struct mbedtls_asn1_named_data /** The next entry in the sequence. * - * The details memory management for named data sequences are not documented - * and may change in future versions. Set this field to \p NULL when - * initializing a structure, and do not modify it except via Mbed TLS + * The details of memory management for named data sequences are not + * documented and may change in future versions. Set this field to \p NULL + * when initializing a structure, and do not modify it except via Mbed TLS * library functions. */ struct mbedtls_asn1_named_data *next; diff --git a/include/mbedtls/x509_csr.h b/include/mbedtls/x509_csr.h index 5d1ce0e418..f80a1a1307 100644 --- a/include/mbedtls/x509_csr.h +++ b/include/mbedtls/x509_csr.h @@ -45,7 +45,7 @@ extern "C" { * * Some fields of this structure are publicly readable. Do not modify * them except via Mbed TLS library functions: the effect of modifying - * those fields or the data that those fields points to is unspecified. + * those fields or the data that those fields point to is unspecified. */ typedef struct mbedtls_x509_csr { From 2e9d65f928be9287e5e2c5a443beaa845982b8bb Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 31 Aug 2021 23:05:19 +0200 Subject: [PATCH 367/966] Note that custom info structures are not supported This was already documented for mbedtls_md_info_t. Also document it for mbedtls_pk_info_t (where it's fairly obvious since the structure is not defined in a public header) and for mbedtls_cipher_info_t (where it's not obvious since the structure is defined in a public header). Signed-off-by: Gilles Peskine --- include/mbedtls/cipher.h | 7 +++++++ include/mbedtls/pk.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h index 7921f4d85f..b4630f63cd 100644 --- a/include/mbedtls/cipher.h +++ b/include/mbedtls/cipher.h @@ -258,6 +258,13 @@ typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t; /** * Cipher information. Allows calling cipher functions * in a generic way. + * + * \note The library does not support custom cipher info structures, + * only built-in structures returned by the functions + * mbedtls_cipher_info_from_string(), + * mbedtls_cipher_info_from_type(), + * mbedtls_cipher_info_from_values(), + * mbedtls_cipher_info_from_psa(). */ typedef struct mbedtls_cipher_info_t { diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h index ded52225f2..5f9f29ff6d 100644 --- a/include/mbedtls/pk.h +++ b/include/mbedtls/pk.h @@ -186,6 +186,10 @@ typedef struct mbedtls_pk_debug_item /** * \brief Public key information and operations + * + * \note The library does not support custom pk info structures, + * only built-in structures returned by + * mbedtls_cipher_info_from_type(). */ typedef struct mbedtls_pk_info_t mbedtls_pk_info_t; From ca939959e4d33174176c81900a4a8fb343f357b7 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 31 Aug 2021 23:18:07 +0200 Subject: [PATCH 368/966] Allow read-only access to lists of certificates, CRL, CRL entries Signed-off-by: Gilles Peskine --- include/mbedtls/x509_crl.h | 10 ++++++++-- include/mbedtls/x509_crt.h | 5 ++++- programs/ssl/dtls_server.c | 2 +- programs/ssl/ssl_fork_server.c | 2 +- programs/ssl/ssl_server.c | 2 +- programs/x509/cert_app.c | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/mbedtls/x509_crl.h b/include/mbedtls/x509_crl.h index f65e9847ba..52bd43cd3c 100644 --- a/include/mbedtls/x509_crl.h +++ b/include/mbedtls/x509_crl.h @@ -63,7 +63,10 @@ typedef struct mbedtls_x509_crl_entry * `entry_ext.p == NULL`. */ mbedtls_x509_buf entry_ext; - struct mbedtls_x509_crl_entry *MBEDTLS_PRIVATE(next); + /** Next element in the linked list of entries. + * \p NULL indicates the end of the list. + * Do not modify this field directly. */ + struct mbedtls_x509_crl_entry *next; } mbedtls_x509_crl_entry; @@ -96,7 +99,10 @@ typedef struct mbedtls_x509_crl mbedtls_pk_type_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */ void *MBEDTLS_PRIVATE(sig_opts); /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */ - struct mbedtls_x509_crl *MBEDTLS_PRIVATE(next); + /** Next element in the linked list of CRL. + * \p NULL indicates the end of the list. + * Do not modify this field directly. */ + struct mbedtls_x509_crl *next; } mbedtls_x509_crl; diff --git a/include/mbedtls/x509_crt.h b/include/mbedtls/x509_crt.h index 6731100f20..3c11a99899 100644 --- a/include/mbedtls/x509_crt.h +++ b/include/mbedtls/x509_crt.h @@ -95,7 +95,10 @@ typedef struct mbedtls_x509_crt mbedtls_pk_type_t MBEDTLS_PRIVATE(sig_pk); /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */ void *MBEDTLS_PRIVATE(sig_opts); /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */ - struct mbedtls_x509_crt *MBEDTLS_PRIVATE(next); /**< Next certificate in the CA-chain. */ + /** Next certificate in the linked list that constitutes the CA chain. + * \p NULL indicates the end of the list. + * Do not modify this field directly. */ + struct mbedtls_x509_crt *next; } mbedtls_x509_crt; diff --git a/programs/ssl/dtls_server.c b/programs/ssl/dtls_server.c index f2570490f5..5d1cccbe64 100644 --- a/programs/ssl/dtls_server.c +++ b/programs/ssl/dtls_server.c @@ -226,7 +226,7 @@ int main( void ) mbedtls_ssl_cache_set ); #endif - mbedtls_ssl_conf_ca_chain( &conf, srvcert.MBEDTLS_PRIVATE(next), NULL ); + mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) { printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); diff --git a/programs/ssl/ssl_fork_server.c b/programs/ssl/ssl_fork_server.c index 542a334606..694fc3b7ae 100644 --- a/programs/ssl/ssl_fork_server.c +++ b/programs/ssl/ssl_fork_server.c @@ -190,7 +190,7 @@ int main( void ) mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); - mbedtls_ssl_conf_ca_chain( &conf, srvcert.MBEDTLS_PRIVATE(next), NULL ); + mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) { mbedtls_printf( " failed! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); diff --git a/programs/ssl/ssl_server.c b/programs/ssl/ssl_server.c index ace657ceba..95557fb059 100644 --- a/programs/ssl/ssl_server.c +++ b/programs/ssl/ssl_server.c @@ -212,7 +212,7 @@ int main( void ) mbedtls_ssl_cache_set ); #endif - mbedtls_ssl_conf_ca_chain( &conf, srvcert.MBEDTLS_PRIVATE(next), NULL ); + mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); diff --git a/programs/x509/cert_app.c b/programs/x509/cert_app.c index aab15db2b7..3d8f37b646 100644 --- a/programs/x509/cert_app.c +++ b/programs/x509/cert_app.c @@ -331,7 +331,7 @@ int main( int argc, char *argv[] ) mbedtls_printf( "%s\n", buf ); - cur = cur->MBEDTLS_PRIVATE(next); + cur = cur->next; } /* From 6ac8f94a72cb75071c79797908c4927b37e2f85a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 1 Sep 2021 08:31:49 +0200 Subject: [PATCH 369/966] Fix cipher info key length sanity checks Most supported ciphers have a 128-bit, 192-bit or 256-bit keys. List the exceptions explicitly. This commit fixes a test failure with the null cipher and an incorrect comment that omitted several key lengths. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_cipher.function | 31 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index 94ea88f791..c809d9a280 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -33,11 +33,32 @@ static int check_cipher_info( mbedtls_cipher_type_t type, TEST_ASSERT( mbedtls_cipher_info_from_string( info->name ) == info ); key_bitlen = mbedtls_cipher_info_get_key_bitlen( info ); - TEST_ASSERT( key_bitlen % 8 == 0 ); - /* All current and plausible supported ciphers use a 64-bit, 128-bit - * or 256-bit key, except XTS which uses a double AES key. */ - TEST_ASSERT( key_bitlen >= 64 ); - TEST_ASSERT( key_bitlen <= 512 ); + if( info->type == MBEDTLS_CIPHER_NULL ) + TEST_ASSERT( key_bitlen == 0 ); + else if( info->mode == MBEDTLS_MODE_XTS ) + { + TEST_ASSERT( key_bitlen == 256 || + key_bitlen == 384 || + key_bitlen == 512 ); + } + else if( ! strncmp( info->name, "DES-EDE3-", 9 ) ) + { + TEST_ASSERT( key_bitlen == 192 ); + } + else if( ! strncmp( info->name, "DES-EDE-", 8 ) ) + { + TEST_ASSERT( key_bitlen == 128 ); + } + else if( ! strncmp( info->name, "DES-", 4 ) ) + { + TEST_ASSERT( key_bitlen == 64 ); + } + else + { + TEST_ASSERT( key_bitlen == 128 || + key_bitlen == 192 || + key_bitlen == 256 ); + } return( 1 ); From e40ae6bbed2af4b792b1704359fac3b6669052de Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 1 Sep 2021 12:47:49 +0200 Subject: [PATCH 370/966] Fix typo Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index 8aacfce55e..c78af48e4a 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -86,7 +86,7 @@ typedef struct mbedtls_ccm_context size_t MBEDTLS_PRIVATE(tag_len); /*!< Total tag length */ size_t MBEDTLS_PRIVATE(processed); /*!< Track how many bytes of input data were processed (chunked input). - Used indepenedantly for both auth data + Used independently for both auth data and plaintext/ciphertext. This variable is set to zero after auth data input is finished. */ From 7251eda6ff7106752eab172862cc74f476e2b049 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 1 Sep 2021 13:26:44 +0200 Subject: [PATCH 371/966] Replace BAD_SEQUENCE error with BAD_INPUT Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 2 -- library/ccm.c | 6 +++--- tests/suites/test_suite_ccm.function | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index c78af48e4a..6f991fefbd 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -61,8 +61,6 @@ #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /** Authenticated decryption failed. */ #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F -/** CCM functions called in the wrong sequence. */ -#define MBEDTLS_ERR_CCM_BAD_SEQUENCE -0x0011 #ifdef __cplusplus extern "C" { diff --git a/library/ccm.c b/library/ccm.c index 0a904613ed..d9d25cecd9 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -270,7 +270,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, { if( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) { - return MBEDTLS_ERR_CCM_BAD_SEQUENCE; + return MBEDTLS_ERR_CCM_BAD_INPUT; } if( !(ctx->state & CCM_STATE__AUTH_DATA_STARTED) ) @@ -444,12 +444,12 @@ int mbedtls_ccm_finish( mbedtls_ccm_context *ctx, if( ctx->add_len > 0 && !( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) ) { - return MBEDTLS_ERR_CCM_BAD_SEQUENCE; + return MBEDTLS_ERR_CCM_BAD_INPUT; } if( ctx->plaintext_len > 0 && ctx->processed != ctx->plaintext_len ) { - return MBEDTLS_ERR_CCM_BAD_SEQUENCE; + return MBEDTLS_ERR_CCM_BAD_INPUT; } /* diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 48c4fe919d..128bd86d98 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -559,7 +559,7 @@ void mbedtls_ccm_incomplete_ad( int cipher_id, int mode, TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len/2) ); ASSERT_ALLOC( output, 16 ); - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_finish( &ctx, output, 16 ) ); exit: mbedtls_free( output ); @@ -585,7 +585,7 @@ void mbedtls_ccm_full_ad_and_overflow( int cipher_id, int mode, // pass full auth data TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); // pass 1 extra byte - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_update_ad( &ctx, add->x, 1) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update_ad( &ctx, add->x, 1) ); exit: mbedtls_ccm_free( &ctx ); } @@ -644,7 +644,7 @@ void mbedtls_ccm_incomplete_update( int cipher_id, int mode, output = NULL; ASSERT_ALLOC( output, 16 ); - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_finish( &ctx, output, 16 ) ); exit: mbedtls_free( output ); @@ -699,7 +699,7 @@ void mbedtls_ccm_instant_finish( int cipher_id, int mode, TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, 16, 16, 16 ) ); ASSERT_ALLOC( output, 16 ); - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_SEQUENCE, mbedtls_ccm_finish( &ctx, output, 16 ) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_finish( &ctx, output, 16 ) ); exit: mbedtls_free( output ); From 3d7d52c2edba82ec109e533379727099b3073deb Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 1 Sep 2021 10:33:14 +0100 Subject: [PATCH 372/966] Formatting fixes Signed-off-by: Paul Elliott --- library/psa_crypto.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index c2b318ccaa..b335aa37c5 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3553,7 +3553,7 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, goto exit; } - if( operation->nonce_set ) + if( operation->nonce_set ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3612,7 +3612,8 @@ exit: return( status ); } - /* Pass additional data to an active multipart AEAD operation. */ + +/* Pass additional data to an active multipart AEAD operation. */ psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation, const uint8_t *input, size_t input_length ) From c6d11d02f5223f62a35954dc2b8c5342a246ad8f Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 1 Sep 2021 12:04:23 +0100 Subject: [PATCH 373/966] Aligh update buffer test variables with psa naming Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 29 ++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 5fb7086a11..e01c49588e 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3878,7 +3878,7 @@ exit: /* BEGIN_CASE */ void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, int alg_arg, - int buffer_size, + int output_size_arg, data_t *nonce, data_t *additional_data, data_t *input_data, @@ -3892,10 +3892,11 @@ void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; - unsigned char *output_data = NULL; - unsigned char *final_data = NULL; - size_t finish_output_size = 0; - size_t output_length = 0; + unsigned char *output = NULL; + unsigned char *ciphertext = NULL; + size_t output_size = output_size_arg; + size_t ciphertext_size = 0; + size_t ciphertext_length = 0; size_t tag_length = 0; uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; @@ -3910,13 +3911,11 @@ void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); - ASSERT_ALLOC( output_data, buffer_size ); + ASSERT_ALLOC( output, output_size ); - finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + ciphertext_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - - ASSERT_ALLOC( final_data, finish_output_size ); + ASSERT_ALLOC( ciphertext, ciphertext_size ); operation = psa_aead_operation_init( ); @@ -3939,22 +3938,22 @@ void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, additional_data->len ) ); status = psa_aead_update( &operation, input_data->x, input_data->len, - output_data, buffer_size, &output_length ); + output, output_size, &ciphertext_length ); TEST_EQUAL( status, expected_status ); if( expected_status == PSA_SUCCESS ) { /* Ensure we can still complete operation. */ - PSA_ASSERT( psa_aead_finish( &operation, final_data, finish_output_size, - &output_length, tag_buffer, + PSA_ASSERT( psa_aead_finish( &operation, ciphertext, ciphertext_size, + &ciphertext_length, tag_buffer, PSA_AEAD_TAG_MAX_SIZE, &tag_length ) ); } exit: psa_destroy_key( key ); - mbedtls_free( output_data ); - mbedtls_free( final_data ); + mbedtls_free( output ); + mbedtls_free( ciphertext ); psa_aead_abort( &operation ); PSA_DONE( ); } From 7f6284224799746a0c93a31fc46afc49249acbbd Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 1 Sep 2021 12:08:29 +0100 Subject: [PATCH 374/966] Add test for calling update when nonce not set Previously only testing calling update_ad in this state. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index e01c49588e..0c009811c7 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4224,6 +4224,19 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + /* Test for double setting nonce. */ operation = psa_aead_operation_init( ); From b0450febe6fc546b9744b8637b8671a16d809bf6 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 1 Sep 2021 15:06:26 +0100 Subject: [PATCH 375/966] Tests for sending too much data after set lengths We previously had tests for not sending enough (additional) data, but were missing tests for sending too much. I have added these to the state tests, as I don't think this is complex enough to deserve a standalone test. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 0c009811c7..a881087151 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4407,6 +4407,40 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* Test for sending too much additional data after setting lengths. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, 0, 0 ) ); + + + TEST_EQUAL( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ), + PSA_ERROR_INVALID_ARGUMENT ); + + psa_aead_abort( &operation ); + + /* Test for sending too much data after setting lengths. */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, 0, 0 ) ); + + TEST_EQUAL( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ), + PSA_ERROR_INVALID_ARGUMENT ); + + psa_aead_abort( &operation ); + /* Test sending additional data after data. */ operation = psa_aead_operation_init( ); From 88d681ca35a11644a4c492c8a6d8cfd90e0ef391 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 1 Sep 2021 11:19:33 +0200 Subject: [PATCH 376/966] Make size_t -> int downcasts explicit mbedtls_cipher_setkey takes an int argument. Cast explicitly, otherwise MSVC complains. Where possible, just stick to size_t. Signed-off-by: Gilles Peskine --- library/ssl_tls.c | 6 +++--- programs/aes/crypt_and_hash.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 1e81384aa7..754c76f80a 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -689,7 +689,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, unsigned char *mac_dec; size_t mac_key_len = 0; size_t iv_copy_len; - unsigned keylen; + size_t keylen; const mbedtls_ssl_ciphersuite_t *ciphersuite_info; const mbedtls_cipher_info_t *cipher_info; const mbedtls_md_info_t *md_info; @@ -1060,7 +1060,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, } if( ( ret = mbedtls_cipher_setkey( &transform->cipher_ctx_enc, key1, - mbedtls_cipher_info_get_key_bitlen( cipher_info ), + (int) mbedtls_cipher_info_get_key_bitlen( cipher_info ), MBEDTLS_ENCRYPT ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setkey", ret ); @@ -1068,7 +1068,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, } if( ( ret = mbedtls_cipher_setkey( &transform->cipher_ctx_dec, key2, - mbedtls_cipher_info_get_key_bitlen( cipher_info ), + (int) mbedtls_cipher_info_get_key_bitlen( cipher_info ), MBEDTLS_DECRYPT ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setkey", ret ); diff --git a/programs/aes/crypt_and_hash.c b/programs/aes/crypt_and_hash.c index ba9827f45e..5ed2ece702 100644 --- a/programs/aes/crypt_and_hash.c +++ b/programs/aes/crypt_and_hash.c @@ -311,7 +311,7 @@ int main( int argc, char *argv[] ) if( mbedtls_cipher_setkey( &cipher_ctx, digest, - mbedtls_cipher_info_get_key_bitlen( cipher_info ), + (int) mbedtls_cipher_info_get_key_bitlen( cipher_info ), MBEDTLS_ENCRYPT ) != 0 ) { mbedtls_fprintf( stderr, "mbedtls_cipher_setkey() returned error\n"); @@ -452,7 +452,7 @@ int main( int argc, char *argv[] ) if( mbedtls_cipher_setkey( &cipher_ctx, digest, - mbedtls_cipher_info_get_key_bitlen( cipher_info ), + (int) mbedtls_cipher_info_get_key_bitlen( cipher_info ), MBEDTLS_DECRYPT ) != 0 ) { mbedtls_fprintf( stderr, "mbedtls_cipher_setkey() returned error\n" ); From ab46aa0436eb60b4ff15af69758d41fcfe8f7254 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 17 Aug 2021 10:48:26 +0800 Subject: [PATCH 377/966] Upgrade gnutls-next to 3.7.2 v3.7.2 introduces DISABLE_TLS13_COMPAT_MODE. That can be used to verify if TLS13 COMPATIBLE is not available. Change-Id: Id68748e92504835b5a63b2565a618f728e7222f6 Signed-off-by: Jerry Yu --- tests/compat-in-docker.sh | 4 ++-- tests/docker/bionic/Dockerfile | 18 +++++++++--------- tests/ssl-opt-in-docker.sh | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/compat-in-docker.sh b/tests/compat-in-docker.sh index aef0a07289..3a1cd2144c 100755 --- a/tests/compat-in-docker.sh +++ b/tests/compat-in-docker.sh @@ -42,13 +42,13 @@ esac case "${GNUTLS_CLI:-default}" in "legacy") export GNUTLS_CLI="/usr/local/gnutls-3.3.8/bin/gnutls-cli";; - "next") export GNUTLS_CLI="/usr/local/gnutls-3.6.5/bin/gnutls-cli";; + "next") export GNUTLS_CLI="/usr/local/gnutls-3.7.2/bin/gnutls-cli";; *) ;; esac case "${GNUTLS_SERV:-default}" in "legacy") export GNUTLS_SERV="/usr/local/gnutls-3.3.8/bin/gnutls-serv";; - "next") export GNUTLS_SERV="/usr/local/gnutls-3.6.5/bin/gnutls-serv";; + "next") export GNUTLS_SERV="/usr/local/gnutls-3.7.2/bin/gnutls-serv";; *) ;; esac diff --git a/tests/docker/bionic/Dockerfile b/tests/docker/bionic/Dockerfile index 1d24aa3268..41789c677c 100644 --- a/tests/docker/bionic/Dockerfile +++ b/tests/docker/bionic/Dockerfile @@ -137,29 +137,29 @@ RUN cd /tmp \ ENV GNUTLS_CLI=/usr/local/gnutls-3.4.10/bin/gnutls-cli ENV GNUTLS_SERV=/usr/local/gnutls-3.4.10/bin/gnutls-serv -# Build libnettle 3.4 (needed by gnutls next) +# Build libnettle 3.7.3 (needed by gnutls next) RUN cd /tmp \ - && wget https://ftp.gnu.org/gnu/nettle/nettle-3.4.1.tar.gz -qO- | tar xz \ - && cd nettle-3.4.1 \ + && wget https://ftp.gnu.org/gnu/nettle/nettle-3.7.3.tar.gz -qO- | tar xz \ + && cd nettle-3.7.3 \ && ./configure --disable-documentation \ && make ${MAKEFLAGS_PARALLEL} \ && make install \ && /sbin/ldconfig \ && rm -rf /tmp/nettle* -# Build gnutls next (3.6.5) +# Build gnutls next (3.7.2) RUN cd /tmp \ - && wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.5.tar.xz -qO- | tar xJ \ - && cd gnutls-3.6.5 \ - && ./configure --prefix=/usr/local/gnutls-3.6.5 --exec_prefix=/usr/local/gnutls-3.6.5 \ + && wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/gnutls-3.7.2.tar.xz -qO- | tar xJ \ + && cd gnutls-3.7.2 \ + && ./configure --prefix=/usr/local/gnutls-3.7.2 --exec_prefix=/usr/local/gnutls-3.7.2 \ --with-included-libtasn1 --with-included-unistring --without-p11-kit \ --disable-shared --disable-guile --disable-doc \ && make ${MAKEFLAGS_PARALLEL} \ && make install \ && rm -rf /tmp/gnutls* -ENV GNUTLS_NEXT_CLI=/usr/local/gnutls-3.6.5/bin/gnutls-cli -ENV GNUTLS_NEXT_SERV=/usr/local/gnutls-3.6.5/bin/gnutls-serv +ENV GNUTLS_NEXT_CLI=/usr/local/gnutls-3.7.2/bin/gnutls-cli +ENV GNUTLS_NEXT_SERV=/usr/local/gnutls-3.7.2/bin/gnutls-serv RUN pip3 install --no-cache-dir \ mbed-host-tests \ diff --git a/tests/ssl-opt-in-docker.sh b/tests/ssl-opt-in-docker.sh index 401a69c569..e7bb01d8ca 100755 --- a/tests/ssl-opt-in-docker.sh +++ b/tests/ssl-opt-in-docker.sh @@ -42,13 +42,13 @@ esac case "${GNUTLS_CLI:-default}" in "legacy") export GNUTLS_CLI="/usr/local/gnutls-3.3.8/bin/gnutls-cli";; - "next") export GNUTLS_CLI="/usr/local/gnutls-3.6.5/bin/gnutls-cli";; + "next") export GNUTLS_CLI="/usr/local/gnutls-3.7.2/bin/gnutls-cli";; *) ;; esac case "${GNUTLS_SERV:-default}" in "legacy") export GNUTLS_SERV="/usr/local/gnutls-3.3.8/bin/gnutls-serv";; - "next") export GNUTLS_SERV="/usr/local/gnutls-3.6.5/bin/gnutls-serv";; + "next") export GNUTLS_SERV="/usr/local/gnutls-3.7.2/bin/gnutls-serv";; *) ;; esac From b12d81d1a30656305e3dd8dc39b9489bc3988002 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 17 Aug 2021 10:56:08 +0800 Subject: [PATCH 378/966] Add feature tests for gnutls-next Test NO_TICKETS and DISABLE_TLS13_COMPAT_MODE Change-Id: Idf21b36bd64c7eefe4e0e6fb875b2e06ebb0aa07 Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index ad925f0f0c..bf5d9dbd97 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -405,6 +405,44 @@ requires_gnutls_tls1_3() { fi } +# check %NO_TICKETS option +requires_gnutls_next_no_ticket() { + requires_gnutls_next + if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then + GNUTLS_NO_TICKETS_AVAILABLE="NO" + fi + if [ -z "${GNUTLS_NO_TICKETS_AVAILABLE:-}" ]; then + if $GNUTLS_NEXT_CLI --priority-list 2>&1 | grep NO_TICKETS >/dev/null + then + GNUTLS_NO_TICKETS_AVAILABLE="YES" + else + GNUTLS_NO_TICKETS_AVAILABLE="NO" + fi + fi + if [ "$GNUTLS_NO_TICKETS_AVAILABLE" = "NO" ]; then + SKIP_NEXT="YES" + fi +} + +# check %%DISABLE_TLS13_COMPAT_MODE option +requires_gnutls_next_disable_tls13_compat() { + requires_gnutls_next + if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then + GNUTLS_DISABLE_TLS13_COMPAT_MODE_AVAILABLE="NO" + fi + if [ -z "${GNUTLS_DISABLE_TLS13_COMPAT_MODE_AVAILABLE:-}" ]; then + if $GNUTLS_NEXT_CLI --priority-list 2>&1 | grep DISABLE_TLS13_COMPAT_MODE >/dev/null + then + GNUTLS_DISABLE_TLS13_COMPAT_MODE_AVAILABLE="YES" + else + GNUTLS_DISABLE_TLS13_COMPAT_MODE_AVAILABLE="NO" + fi + fi + if [ "$GNUTLS_DISABLE_TLS13_COMPAT_MODE_AVAILABLE" = "NO" ]; then + SKIP_NEXT="YES" + fi +} + # skip next test if IPv6 isn't available on this host requires_ipv6() { if [ -z "${HAS_IPV6:-}" ]; then @@ -8589,11 +8627,13 @@ run_test "TLS1.3: Test openssl tls1_3 feature" \ -c "TLS 1.3" \ -s "TLS 1.3" -# gnutls feature tests: check if tls1.3 exists. +# gnutls feature tests: check if tls1.3,NO_TICKETS and DISABLE_TLS13_COMPAT_MODE exist. requires_gnutls_tls1_3 +requires_gnutls_next_no_ticket +requires_gnutls_next_disable_tls13_compat run_test "TLS1.3: Test gnutls tls1_3 feature" \ - "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3" \ - "$G_NEXT_CLI localhost --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3 -V" \ + "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE" \ + "$G_NEXT_CLI localhost --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE -V" \ 0 \ -s "Version: TLS1.3" \ -c "Version: TLS1.3" From 64f0b5f454092950fb4ddc5eff5b415a2bad71d7 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 2 Sep 2021 11:50:38 +0200 Subject: [PATCH 379/966] Return BAD_INPUT error for CCM context's erroneous state Signed-off-by: Mateusz Starzyk --- library/ccm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index d9d25cecd9..ca95b8eeb7 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -263,7 +263,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, if( ctx->state & CCM_STATE__ERROR ) { - return ret; + return MBEDTLS_ERR_CCM_BAD_INPUT; } if( ctx->add_len > 0 && add_len > 0 ) @@ -339,7 +339,7 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, if( ctx->state & CCM_STATE__ERROR ) { - return MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + return MBEDTLS_ERR_CCM_BAD_INPUT; } if( ctx->processed + input_len > ctx->plaintext_len ) From 75261df2e3c9d9e892291e23b7af375a91386e71 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 2 Sep 2021 17:40:08 +0800 Subject: [PATCH 380/966] fix comment issues Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index bf5d9dbd97..3e199e2881 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -405,7 +405,7 @@ requires_gnutls_tls1_3() { fi } -# check %NO_TICKETS option +# Check %NO_TICKETS option requires_gnutls_next_no_ticket() { requires_gnutls_next if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then @@ -424,7 +424,7 @@ requires_gnutls_next_no_ticket() { fi } -# check %%DISABLE_TLS13_COMPAT_MODE option +# Check %DISABLE_TLS13_COMPAT_MODE option requires_gnutls_next_disable_tls13_compat() { requires_gnutls_next if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then @@ -8627,7 +8627,7 @@ run_test "TLS1.3: Test openssl tls1_3 feature" \ -c "TLS 1.3" \ -s "TLS 1.3" -# gnutls feature tests: check if tls1.3,NO_TICKETS and DISABLE_TLS13_COMPAT_MODE exist. +# gnutls feature tests: check if TLS 1.3 is supported as well as the NO_TICKETS and DISABLE_TLS13_COMPAT_MODE options. requires_gnutls_tls1_3 requires_gnutls_next_no_ticket requires_gnutls_next_disable_tls13_compat From df2507301b12e9247cad8dbb94e5bee144ed8ec0 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 2 Sep 2021 12:36:02 +0200 Subject: [PATCH 381/966] Use AES-128 for multipart CCM corner cases tests Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 112 +++++++++++++++---------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index 91aa98bd43..c8f6351633 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -1550,110 +1550,110 @@ CCM* decrypt, skip update NIST DVPT AES-256 #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"867b0d87cf6e0f718200a97b4f6d5ad5" -CCM encrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM encrypt, overflow ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM encrypt, incomplete ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM encrypt, incomplete ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM encrypt, full ad and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM encrypt, full ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM encrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM encrypt, overflow update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM encrypt, incomplete update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM encrypt, incomplete update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM encrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM encrypt, full update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM decrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM decrypt, overflow ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM decrypt, incomplete ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM decrypt, incomplete ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM decrypt, full ad and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM decrypt, full ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM decrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM decrypt, overflow update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16)) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM decrypt, incomplete update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM decrypt, incomplete update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16)) depends_on:MBEDTLS_AES_C -mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM decrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM decrypt, full update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM* encrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* encrypt, overflow ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM* encrypt, incomplete ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* encrypt, incomplete ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM* encrypt, full ad and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* encrypt, full ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM* encrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* encrypt, overflow update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM* encrypt, incomplete update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* encrypt, incomplete update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM* encrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* encrypt, full update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM* decrypt, overflow ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* decrypt, overflow ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM* decrypt, incomplete ad NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* decrypt, incomplete ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_incomplete_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM* decrypt, full ad and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* decrypt, full ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" -CCM* decrypt, overflow update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* decrypt, overflow update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM* decrypt, incomplete update NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* decrypt, incomplete update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM* decrypt, full update and overflow NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) +CCM* decrypt, full update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"3726c1aaf85ee8099a7ebd3268700e07d4b3f292c65bba34":"13501aebda19a9bf1b5ffaa42a":"ead4c45ff9db54f9902a6de181" +mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" -CCM encrypt, instant finish NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) -mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a" +CCM encrypt, instant finish NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98" -CCM decrypt, instant finish NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) -mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a" +CCM decrypt, instant finish NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98" -CCM* encrypt, instant finish NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) -mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a" +CCM* encrypt, instant finish NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98" -CCM* decrypt, instant finish NIST VADT AES-192 #14 (P=24, N=13, A=13, T=16) -mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"b5f43f3ae38a6165f0f990abe9ee50cd9ad7e847a0a51731":"13501aebda19a9bf1b5ffaa42a" +CCM* decrypt, instant finish NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98" From 8394484f0ade7173c00bc08b3e2c42021893b140 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Tue, 20 Jul 2021 18:26:03 +0100 Subject: [PATCH 382/966] Add draft python tool to translate MBed ciphersuites Created 2 functions - translate_gnu() - translate_ossl() Each function takes a parameter `m_cipher` (expected in the MBedTLS naming standard), and through a series of edge cases/replaces, modifies the ciphersuite name to match the GNU and OpenSSL naming conventions respectively. This will serve as to maintain a single list that can be translated, rather than maintaining 3 lists for OpenSSL and GNU also. This commit serves as a checkpoint, and the program will be cleaned up in the future. The program currently runs a series of tests to check every given ciphersuite name combination in compat.sh to ensure they are translated correctly. Some OpenSSL names appear to have typos and as such have been corrected in this program until I have recieved more information. The errors were commented out to keep note of. Signed-off-by: Joe Subbiani --- translate_ciphers.py | 485 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 485 insertions(+) create mode 100644 translate_ciphers.py diff --git a/translate_ciphers.py b/translate_ciphers.py new file mode 100644 index 0000000000..cf0be7257d --- /dev/null +++ b/translate_ciphers.py @@ -0,0 +1,485 @@ + +def translate_gnu(m_cipher): + + m_cipher = "+" + m_cipher[4:] + m_cipher = m_cipher.replace("-WITH-", ":+") + m_cipher = m_cipher.replace("-EDE", "") + if m_cipher.split("-")[-1] == "SHA": + m_cipher = m_cipher+"1" + + + if m_cipher.split("-")[-1] == "8" or m_cipher.split("-")[-1] == "CCM": + m_cipher = m_cipher+":+AEAD" + else: + index=m_cipher.rindex("-") + m_cipher = m_cipher[:index]+":+"+m_cipher[index+1:] + m_cipher = m_cipher.replace("GCM:+SHA256", "GCM:+AEAD") + m_cipher = m_cipher.replace("GCM:+SHA384", "GCM:+AEAD") + + return m_cipher + +def translate_ossl(m_cipher): + m_cipher = m_cipher[4:] + m_cipher = m_cipher.replace("-WITH", "") + m_cipher = m_cipher.replace("AES-", "AES") + m_cipher = m_cipher.replace("CAMELLIA-", "CAMELLIA") + m_cipher = m_cipher.replace("ARIA-", "ARIA") + + m_cipher = m_cipher.replace("-EDE", "") + + m_cipher = m_cipher.replace("3DES-CBC", "DES-CBC3") + try: + index = m_cipher.rindex("CBC") + if m_cipher[index-4:index-1] != "DES": + m_cipher = m_cipher.replace("CBC-", "") + except: + pass + + if m_cipher[:4] == "RSA-": + m_cipher = m_cipher[4:] + + m_cipher = m_cipher.replace("ECDHE-RSA-ARIA", "ECDHE-ARIA") + + try: + index = m_cipher.rindex("POLY1305") + m_cipher=m_cipher[:index+8] + except Exception as e: + pass#print(e) + + return m_cipher + +def test_all_common(): + m_ciphers = [ + "TLS-ECDHE-ECDSA-WITH-NULL-SHA", + "TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", + "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", + "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", + + "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", + "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", + "TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", + "TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", + + "TLS-DHE-RSA-WITH-AES-128-CBC-SHA", + "TLS-DHE-RSA-WITH-AES-256-CBC-SHA", + "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", + "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", + "TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", + "TLS-RSA-WITH-AES-256-CBC-SHA", + "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", + "TLS-RSA-WITH-AES-128-CBC-SHA", + "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", + "TLS-RSA-WITH-3DES-EDE-CBC-SHA", + "TLS-RSA-WITH-NULL-MD5", + "TLS-RSA-WITH-NULL-SHA", + + "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", + "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", + "TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", + "TLS-ECDHE-RSA-WITH-NULL-SHA", + + "TLS-RSA-WITH-AES-128-CBC-SHA256", + "TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", + "TLS-RSA-WITH-AES-256-CBC-SHA256", + "TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", + "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", + "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", + "TLS-RSA-WITH-AES-128-GCM-SHA256", + "TLS-RSA-WITH-AES-256-GCM-SHA384", + "TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", + "TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", + "TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", + "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", + + "TLS-PSK-WITH-3DES-EDE-CBC-SHA", + "TLS-PSK-WITH-AES-128-CBC-SHA", + "TLS-PSK-WITH-AES-256-CBC-SHA", + ] + g_ciphers = [ + "+ECDHE-ECDSA:+NULL:+SHA1", + "+ECDHE-ECDSA:+3DES-CBC:+SHA1", + "+ECDHE-ECDSA:+AES-128-CBC:+SHA1", + "+ECDHE-ECDSA:+AES-256-CBC:+SHA1", + + "+ECDHE-ECDSA:+AES-128-CBC:+SHA256", + "+ECDHE-ECDSA:+AES-256-CBC:+SHA384", + "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", + "+ECDHE-ECDSA:+AES-256-GCM:+AEAD", + + "+DHE-RSA:+AES-128-CBC:+SHA1", + "+DHE-RSA:+AES-256-CBC:+SHA1", + "+DHE-RSA:+CAMELLIA-128-CBC:+SHA1", + "+DHE-RSA:+CAMELLIA-256-CBC:+SHA1", + "+DHE-RSA:+3DES-CBC:+SHA1", + "+RSA:+AES-256-CBC:+SHA1", + "+RSA:+CAMELLIA-256-CBC:+SHA1", + "+RSA:+AES-128-CBC:+SHA1", + "+RSA:+CAMELLIA-128-CBC:+SHA1", + "+RSA:+3DES-CBC:+SHA1", + "+RSA:+NULL:+MD5", + "+RSA:+NULL:+SHA1", + + "+ECDHE-RSA:+AES-128-CBC:+SHA1", + "+ECDHE-RSA:+AES-256-CBC:+SHA1", + "+ECDHE-RSA:+3DES-CBC:+SHA1", + "+ECDHE-RSA:+NULL:+SHA1", + + "+RSA:+AES-128-CBC:+SHA256", + "+DHE-RSA:+AES-128-CBC:+SHA256", + "+RSA:+AES-256-CBC:+SHA256", + "+DHE-RSA:+AES-256-CBC:+SHA256", + "+ECDHE-RSA:+AES-128-CBC:+SHA256", + "+ECDHE-RSA:+AES-256-CBC:+SHA384", + "+RSA:+AES-128-GCM:+AEAD", + "+RSA:+AES-256-GCM:+AEAD", + "+DHE-RSA:+AES-128-GCM:+AEAD", + "+DHE-RSA:+AES-256-GCM:+AEAD", + "+ECDHE-RSA:+AES-128-GCM:+AEAD", + "+ECDHE-RSA:+AES-256-GCM:+AEAD", + + "+PSK:+3DES-CBC:+SHA1", + "+PSK:+AES-128-CBC:+SHA1", + "+PSK:+AES-256-CBC:+SHA1", + ] + o_ciphers = [ + "ECDHE-ECDSA-NULL-SHA", + "ECDHE-ECDSA-DES-CBC3-SHA", + "ECDHE-ECDSA-AES128-SHA", + "ECDHE-ECDSA-AES256-SHA", + + "ECDHE-ECDSA-AES128-SHA256", + "ECDHE-ECDSA-AES256-SHA384", + "ECDHE-ECDSA-AES128-GCM-SHA256", + "ECDHE-ECDSA-AES256-GCM-SHA384", + + "DHE-RSA-AES128-SHA", + "DHE-RSA-AES256-SHA", + "DHE-RSA-CAMELLIA128-SHA", + "DHE-RSA-CAMELLIA256-SHA", + #"EDH-RSA-DES-CBC3-SHA", + "DHE-RSA-DES-CBC3-SHA", + "AES256-SHA", + "CAMELLIA256-SHA", + "AES128-SHA", + "CAMELLIA128-SHA", + "DES-CBC3-SHA", + "NULL-MD5", + "NULL-SHA", + + "ECDHE-RSA-AES128-SHA", + "ECDHE-RSA-AES256-SHA", + "ECDHE-RSA-DES-CBC3-SHA", + "ECDHE-RSA-NULL-SHA", + + #"NULL-SHA256", + "AES128-SHA256", + "DHE-RSA-AES128-SHA256", + "AES256-SHA256", + "DHE-RSA-AES256-SHA256", + "ECDHE-RSA-AES128-SHA256", + "ECDHE-RSA-AES256-SHA384", + "AES128-GCM-SHA256", + "AES256-GCM-SHA384", + "DHE-RSA-AES128-GCM-SHA256", + "DHE-RSA-AES256-GCM-SHA384", + "ECDHE-RSA-AES128-GCM-SHA256", + "ECDHE-RSA-AES256-GCM-SHA384", + + #"PSK-3DES-EDE-CBC-SHA", + #"PSK-AES128-CBC-SHA", + #"PSK-AES256-CBC-SHA", + + "PSK-DES-CBC3-SHA", + "PSK-AES128-SHA", + "PSK-AES256-SHA", + ] + + for i in range(len(m_ciphers)): + + g = translate_gnu(m_ciphers[i]) + if g!=g_ciphers[i]: + print("GNU", i) + print("new".ljust(10), g) + print("original".ljust(10), g_ciphers[i]) + # break + + + o = translate_ossl(m_ciphers[i]) + if o!=o_ciphers[i]: + print("OpenSSL", i) + print("new".ljust(10), o) + print("original".ljust(10), o_ciphers[i]) + # break + +def test_mbed_ossl_common(): + m_ciphers = [ + "TLS-ECDH-ECDSA-WITH-NULL-SHA", + "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", + "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", + "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", + + "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", + "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", + "TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", + "TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", + "TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", + "TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", + "TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", + + "TLS-RSA-WITH-DES-CBC-SHA", + "TLS-DHE-RSA-WITH-DES-CBC-SHA", + + "TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", + "TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", + "TLS-RSA-WITH-ARIA-256-GCM-SHA384", + "TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", + "TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", + "TLS-RSA-WITH-ARIA-128-GCM-SHA256", + "TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + + "TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", + "TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", + "TLS-PSK-WITH-ARIA-256-GCM-SHA384", + "TLS-PSK-WITH-ARIA-128-GCM-SHA256", + "TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", + "TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + "TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + ] + o_ciphers = [ + "ECDH-ECDSA-NULL-SHA", + "ECDH-ECDSA-DES-CBC3-SHA", + "ECDH-ECDSA-AES128-SHA", + "ECDH-ECDSA-AES256-SHA", + + "ECDH-ECDSA-AES128-SHA256", + "ECDH-ECDSA-AES256-SHA384", + "ECDH-ECDSA-AES128-GCM-SHA256", + "ECDH-ECDSA-AES256-GCM-SHA384", + "ECDHE-ECDSA-ARIA256-GCM-SHA384", + "ECDHE-ECDSA-ARIA128-GCM-SHA256", + "ECDHE-ECDSA-CHACHA20-POLY1305", + + "DES-CBC-SHA", + #"EDH-RSA-DES-CBC-SHA", + "DHE-RSA-DES-CBC-SHA", + + "ECDHE-ARIA256-GCM-SHA384", + "DHE-RSA-ARIA256-GCM-SHA384", + "ARIA256-GCM-SHA384", + "ECDHE-ARIA128-GCM-SHA256", + "DHE-RSA-ARIA128-GCM-SHA256", + "ARIA128-GCM-SHA256", + "DHE-RSA-CHACHA20-POLY1305", + "ECDHE-RSA-CHACHA20-POLY1305", + + "DHE-PSK-ARIA256-GCM-SHA384", + "DHE-PSK-ARIA128-GCM-SHA256", + "PSK-ARIA256-GCM-SHA384", + "PSK-ARIA128-GCM-SHA256", + "PSK-CHACHA20-POLY1305", + "ECDHE-PSK-CHACHA20-POLY1305", + "DHE-PSK-CHACHA20-POLY1305", + ] + + for i in range(len(m_ciphers)): + + o = translate_ossl(m_ciphers[i]) + if o!=o_ciphers[i]: + print("OpenSSL", i) + print("new".ljust(10), o) + print("original".ljust(10), o_ciphers[i]) + # break + +def test_mbed_gnu_common(): + m_ciphers = [ + "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-ECDHE-ECDSA-WITH-AES-128-CCM", + "TLS-ECDHE-ECDSA-WITH-AES-256-CCM", + "TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", + "TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", + + "TLS-RSA-WITH-NULL-SHA256", + + "TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", + "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", + "TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-RSA-WITH-AES-128-CCM", + "TLS-RSA-WITH-AES-256-CCM", + "TLS-DHE-RSA-WITH-AES-128-CCM", + "TLS-DHE-RSA-WITH-AES-256-CCM", + "TLS-RSA-WITH-AES-128-CCM-8", + "TLS-RSA-WITH-AES-256-CCM-8", + "TLS-DHE-RSA-WITH-AES-128-CCM-8", + "TLS-DHE-RSA-WITH-AES-256-CCM-8", + + "TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", + "TLS-DHE-PSK-WITH-AES-128-CBC-SHA", + "TLS-DHE-PSK-WITH-AES-256-CBC-SHA", + + "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", + "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", + "TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", + "TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", + "TLS-RSA-PSK-WITH-AES-256-CBC-SHA", + "TLS-RSA-PSK-WITH-AES-128-CBC-SHA", + + "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", + "TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", + "TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-ECDHE-PSK-WITH-NULL-SHA384", + "TLS-ECDHE-PSK-WITH-NULL-SHA256", + "TLS-PSK-WITH-AES-128-CBC-SHA256", + "TLS-PSK-WITH-AES-256-CBC-SHA384", + "TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", + "TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", + "TLS-PSK-WITH-NULL-SHA256", + "TLS-PSK-WITH-NULL-SHA384", + "TLS-DHE-PSK-WITH-NULL-SHA256", + "TLS-DHE-PSK-WITH-NULL-SHA384", + "TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", + "TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", + "TLS-RSA-PSK-WITH-NULL-SHA256", + "TLS-RSA-PSK-WITH-NULL-SHA384", + "TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-PSK-WITH-AES-128-GCM-SHA256", + "TLS-PSK-WITH-AES-256-GCM-SHA384", + "TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", + "TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", + "TLS-PSK-WITH-AES-128-CCM", + "TLS-PSK-WITH-AES-256-CCM", + "TLS-DHE-PSK-WITH-AES-128-CCM", + "TLS-DHE-PSK-WITH-AES-256-CCM", + "TLS-PSK-WITH-AES-128-CCM-8", + "TLS-PSK-WITH-AES-256-CCM-8", + "TLS-DHE-PSK-WITH-AES-128-CCM-8", + "TLS-DHE-PSK-WITH-AES-256-CCM-8", + "TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", + "TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", + ] + g_ciphers = [ + "+ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256", + "+ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384", + "+ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD", + "+ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD", + "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", + "+ECDHE-ECDSA:+AES-256-CCM:+AEAD", + "+ECDHE-ECDSA:+AES-128-CCM-8:+AEAD", + "+ECDHE-ECDSA:+AES-256-CCM-8:+AEAD", + + "+RSA:+NULL:+SHA256", + + "+ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256", + "+ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384", + "+RSA:+CAMELLIA-128-CBC:+SHA256", + "+RSA:+CAMELLIA-256-CBC:+SHA256", + "+DHE-RSA:+CAMELLIA-128-CBC:+SHA256", + "+DHE-RSA:+CAMELLIA-256-CBC:+SHA256", + "+ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD", + "+ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD", + "+DHE-RSA:+CAMELLIA-128-GCM:+AEAD", + "+DHE-RSA:+CAMELLIA-256-GCM:+AEAD", + "+RSA:+CAMELLIA-128-GCM:+AEAD", + "+RSA:+CAMELLIA-256-GCM:+AEAD", + "+RSA:+AES-128-CCM:+AEAD", + "+RSA:+AES-256-CCM:+AEAD", + "+DHE-RSA:+AES-128-CCM:+AEAD", + "+DHE-RSA:+AES-256-CCM:+AEAD", + "+RSA:+AES-128-CCM-8:+AEAD", + "+RSA:+AES-256-CCM-8:+AEAD", + "+DHE-RSA:+AES-128-CCM-8:+AEAD", + "+DHE-RSA:+AES-256-CCM-8:+AEAD", + + "+DHE-PSK:+3DES-CBC:+SHA1", + "+DHE-PSK:+AES-128-CBC:+SHA1", + "+DHE-PSK:+AES-256-CBC:+SHA1", + + "+ECDHE-PSK:+AES-256-CBC:+SHA1", + "+ECDHE-PSK:+AES-128-CBC:+SHA1", + "+ECDHE-PSK:+3DES-CBC:+SHA1", + "+RSA-PSK:+3DES-CBC:+SHA1", + "+RSA-PSK:+AES-256-CBC:+SHA1", + "+RSA-PSK:+AES-128-CBC:+SHA1", + + "+ECDHE-PSK:+AES-256-CBC:+SHA384", + "+ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384", + "+ECDHE-PSK:+AES-128-CBC:+SHA256", + "+ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256", + "+ECDHE-PSK:+NULL:+SHA384", + "+ECDHE-PSK:+NULL:+SHA256", + "+PSK:+AES-128-CBC:+SHA256", + "+PSK:+AES-256-CBC:+SHA384", + "+DHE-PSK:+AES-128-CBC:+SHA256", + "+DHE-PSK:+AES-256-CBC:+SHA384", + "+PSK:+NULL:+SHA256", + "+PSK:+NULL:+SHA384", + "+DHE-PSK:+NULL:+SHA256", + "+DHE-PSK:+NULL:+SHA384", + "+RSA-PSK:+AES-256-CBC:+SHA384", + "+RSA-PSK:+AES-128-CBC:+SHA256", + "+RSA-PSK:+NULL:+SHA256", + "+RSA-PSK:+NULL:+SHA384", + "+DHE-PSK:+CAMELLIA-128-CBC:+SHA256", + "+DHE-PSK:+CAMELLIA-256-CBC:+SHA384", + "+PSK:+CAMELLIA-128-CBC:+SHA256", + "+PSK:+CAMELLIA-256-CBC:+SHA384", + "+RSA-PSK:+CAMELLIA-256-CBC:+SHA384", + "+RSA-PSK:+CAMELLIA-128-CBC:+SHA256", + "+PSK:+AES-128-GCM:+AEAD", + "+PSK:+AES-256-GCM:+AEAD", + "+DHE-PSK:+AES-128-GCM:+AEAD", + "+DHE-PSK:+AES-256-GCM:+AEAD", + "+PSK:+AES-128-CCM:+AEAD", + "+PSK:+AES-256-CCM:+AEAD", + "+DHE-PSK:+AES-128-CCM:+AEAD", + "+DHE-PSK:+AES-256-CCM:+AEAD", + "+PSK:+AES-128-CCM-8:+AEAD", + "+PSK:+AES-256-CCM-8:+AEAD", + "+DHE-PSK:+AES-128-CCM-8:+AEAD", + "+DHE-PSK:+AES-256-CCM-8:+AEAD", + "+RSA-PSK:+CAMELLIA-128-GCM:+AEAD", + "+RSA-PSK:+CAMELLIA-256-GCM:+AEAD", + "+PSK:+CAMELLIA-128-GCM:+AEAD", + "+PSK:+CAMELLIA-256-GCM:+AEAD", + "+DHE-PSK:+CAMELLIA-128-GCM:+AEAD", + "+DHE-PSK:+CAMELLIA-256-GCM:+AEAD", + "+RSA-PSK:+AES-256-GCM:+AEAD", + "+RSA-PSK:+AES-128-GCM:+AEAD", + ] + + for i in range(len(m_ciphers)): + + g = translate_gnu(m_ciphers[i]) + if g!=g_ciphers[i]: + print("GNU", i) + print("new".ljust(10), g) + print("original".ljust(10), g_ciphers[i]) + # break + +test_all_common() +test_mbed_ossl_common() +test_mbed_gnu_common() \ No newline at end of file From 3ad58329da67e6eed6148da2c6ceade44a84c5bb Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 21 Jul 2021 16:48:54 +0100 Subject: [PATCH 383/966] Reformat translation functions and test in seperate file Moved the test over to a seperate file, where I can start experimenting with how the script will be called. Commented and improved the translation functions. They should be more readable, however I added comments anyway to quickly identify every step involved with te translation from MBedTLS to GNU or OpenSSL Signed-off-by: Joe Subbiani --- test_translate.py | 427 +++++++++++++++++++++++++++++++++++++ translate_ciphers.py | 495 ++++--------------------------------------- 2 files changed, 465 insertions(+), 457 deletions(-) create mode 100644 test_translate.py diff --git a/test_translate.py b/test_translate.py new file mode 100644 index 0000000000..9de283059c --- /dev/null +++ b/test_translate.py @@ -0,0 +1,427 @@ +from translate_ciphers import * + +def assert_equal(translate, original): + try: + assert(translate == original) + except AssertionError: + print("%s\n%s\n" %(translate, original)) + +def test_all_common(): + m_ciphers = [ + "TLS-ECDHE-ECDSA-WITH-NULL-SHA", + "TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", + "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", + "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", + + "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", + "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", + "TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", + "TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", + + "TLS-DHE-RSA-WITH-AES-128-CBC-SHA", + "TLS-DHE-RSA-WITH-AES-256-CBC-SHA", + "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", + "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", + "TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", + "TLS-RSA-WITH-AES-256-CBC-SHA", + "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", + "TLS-RSA-WITH-AES-128-CBC-SHA", + "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", + "TLS-RSA-WITH-3DES-EDE-CBC-SHA", + "TLS-RSA-WITH-NULL-MD5", + "TLS-RSA-WITH-NULL-SHA", + + "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", + "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", + "TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", + "TLS-ECDHE-RSA-WITH-NULL-SHA", + + "TLS-RSA-WITH-AES-128-CBC-SHA256", + "TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", + "TLS-RSA-WITH-AES-256-CBC-SHA256", + "TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", + "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", + "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", + "TLS-RSA-WITH-AES-128-GCM-SHA256", + "TLS-RSA-WITH-AES-256-GCM-SHA384", + "TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", + "TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", + "TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", + "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", + + "TLS-PSK-WITH-3DES-EDE-CBC-SHA", + "TLS-PSK-WITH-AES-128-CBC-SHA", + "TLS-PSK-WITH-AES-256-CBC-SHA", + ] + g_ciphers = [ + "+ECDHE-ECDSA:+NULL:+SHA1", + "+ECDHE-ECDSA:+3DES-CBC:+SHA1", + "+ECDHE-ECDSA:+AES-128-CBC:+SHA1", + "+ECDHE-ECDSA:+AES-256-CBC:+SHA1", + + "+ECDHE-ECDSA:+AES-128-CBC:+SHA256", + "+ECDHE-ECDSA:+AES-256-CBC:+SHA384", + "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", + "+ECDHE-ECDSA:+AES-256-GCM:+AEAD", + + "+DHE-RSA:+AES-128-CBC:+SHA1", + "+DHE-RSA:+AES-256-CBC:+SHA1", + "+DHE-RSA:+CAMELLIA-128-CBC:+SHA1", + "+DHE-RSA:+CAMELLIA-256-CBC:+SHA1", + "+DHE-RSA:+3DES-CBC:+SHA1", + "+RSA:+AES-256-CBC:+SHA1", + "+RSA:+CAMELLIA-256-CBC:+SHA1", + "+RSA:+AES-128-CBC:+SHA1", + "+RSA:+CAMELLIA-128-CBC:+SHA1", + "+RSA:+3DES-CBC:+SHA1", + "+RSA:+NULL:+MD5", + "+RSA:+NULL:+SHA1", + + "+ECDHE-RSA:+AES-128-CBC:+SHA1", + "+ECDHE-RSA:+AES-256-CBC:+SHA1", + "+ECDHE-RSA:+3DES-CBC:+SHA1", + "+ECDHE-RSA:+NULL:+SHA1", + + "+RSA:+AES-128-CBC:+SHA256", + "+DHE-RSA:+AES-128-CBC:+SHA256", + "+RSA:+AES-256-CBC:+SHA256", + "+DHE-RSA:+AES-256-CBC:+SHA256", + "+ECDHE-RSA:+AES-128-CBC:+SHA256", + "+ECDHE-RSA:+AES-256-CBC:+SHA384", + "+RSA:+AES-128-GCM:+AEAD", + "+RSA:+AES-256-GCM:+AEAD", + "+DHE-RSA:+AES-128-GCM:+AEAD", + "+DHE-RSA:+AES-256-GCM:+AEAD", + "+ECDHE-RSA:+AES-128-GCM:+AEAD", + "+ECDHE-RSA:+AES-256-GCM:+AEAD", + + "+PSK:+3DES-CBC:+SHA1", + "+PSK:+AES-128-CBC:+SHA1", + "+PSK:+AES-256-CBC:+SHA1", + ] + o_ciphers = [ + "ECDHE-ECDSA-NULL-SHA", + "ECDHE-ECDSA-DES-CBC3-SHA", + "ECDHE-ECDSA-AES128-SHA", + "ECDHE-ECDSA-AES256-SHA", + + "ECDHE-ECDSA-AES128-SHA256", + "ECDHE-ECDSA-AES256-SHA384", + "ECDHE-ECDSA-AES128-GCM-SHA256", + "ECDHE-ECDSA-AES256-GCM-SHA384", + + "DHE-RSA-AES128-SHA", + "DHE-RSA-AES256-SHA", + "DHE-RSA-CAMELLIA128-SHA", + "DHE-RSA-CAMELLIA256-SHA", + "EDH-RSA-DES-CBC3-SHA", + "AES256-SHA", + "CAMELLIA256-SHA", + "AES128-SHA", + "CAMELLIA128-SHA", + "DES-CBC3-SHA", + "NULL-MD5", + "NULL-SHA", + + "ECDHE-RSA-AES128-SHA", + "ECDHE-RSA-AES256-SHA", + "ECDHE-RSA-DES-CBC3-SHA", + "ECDHE-RSA-NULL-SHA", + + #"NULL-SHA256", + "AES128-SHA256", + "DHE-RSA-AES128-SHA256", + "AES256-SHA256", + "DHE-RSA-AES256-SHA256", + "ECDHE-RSA-AES128-SHA256", + "ECDHE-RSA-AES256-SHA384", + "AES128-GCM-SHA256", + "AES256-GCM-SHA384", + "DHE-RSA-AES128-GCM-SHA256", + "DHE-RSA-AES256-GCM-SHA384", + "ECDHE-RSA-AES128-GCM-SHA256", + "ECDHE-RSA-AES256-GCM-SHA384", + + "PSK-3DES-EDE-CBC-SHA", + "PSK-AES128-CBC-SHA", + "PSK-AES256-CBC-SHA", + + #"PSK-DES-CBC3-SHA", + #"PSK-AES128-SHA", + #"PSK-AES256-SHA", + ] + + for i in range(len(m_ciphers)): + + g = translate_gnu(m_ciphers[i]) + assert_equal(g, g_ciphers[i]) + + o = translate_ossl(m_ciphers[i]) + assert_equal(o, o_ciphers[i]) + +def test_mbed_ossl_common(): + m_ciphers = [ + "TLS-ECDH-ECDSA-WITH-NULL-SHA", + "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", + "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", + "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", + + "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", + "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", + "TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", + "TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", + "TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", + "TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", + "TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", + + "TLS-RSA-WITH-DES-CBC-SHA", + "TLS-DHE-RSA-WITH-DES-CBC-SHA", + + "TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", + "TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", + "TLS-RSA-WITH-ARIA-256-GCM-SHA384", + "TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", + "TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", + "TLS-RSA-WITH-ARIA-128-GCM-SHA256", + "TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + + "TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", + "TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", + "TLS-PSK-WITH-ARIA-256-GCM-SHA384", + "TLS-PSK-WITH-ARIA-128-GCM-SHA256", + "TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", + "TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + "TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + ] + o_ciphers = [ + "ECDH-ECDSA-NULL-SHA", + "ECDH-ECDSA-DES-CBC3-SHA", + "ECDH-ECDSA-AES128-SHA", + "ECDH-ECDSA-AES256-SHA", + + "ECDH-ECDSA-AES128-SHA256", + "ECDH-ECDSA-AES256-SHA384", + "ECDH-ECDSA-AES128-GCM-SHA256", + "ECDH-ECDSA-AES256-GCM-SHA384", + "ECDHE-ECDSA-ARIA256-GCM-SHA384", + "ECDHE-ECDSA-ARIA128-GCM-SHA256", + "ECDHE-ECDSA-CHACHA20-POLY1305", + + "DES-CBC-SHA", + "EDH-RSA-DES-CBC-SHA", + #"DHE-RSA-DES-CBC-SHA", + + "ECDHE-ARIA256-GCM-SHA384", + "DHE-RSA-ARIA256-GCM-SHA384", + "ARIA256-GCM-SHA384", + "ECDHE-ARIA128-GCM-SHA256", + "DHE-RSA-ARIA128-GCM-SHA256", + "ARIA128-GCM-SHA256", + "DHE-RSA-CHACHA20-POLY1305", + "ECDHE-RSA-CHACHA20-POLY1305", + + "DHE-PSK-ARIA256-GCM-SHA384", + "DHE-PSK-ARIA128-GCM-SHA256", + "PSK-ARIA256-GCM-SHA384", + "PSK-ARIA128-GCM-SHA256", + "PSK-CHACHA20-POLY1305", + "ECDHE-PSK-CHACHA20-POLY1305", + "DHE-PSK-CHACHA20-POLY1305", + ] + + for i in range(len(m_ciphers)): + + o = translate_ossl(m_ciphers[i]) + assert_equal(o, o_ciphers[i]) + + +def test_mbed_gnu_common(): + m_ciphers = [ + "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-ECDHE-ECDSA-WITH-AES-128-CCM", + "TLS-ECDHE-ECDSA-WITH-AES-256-CCM", + "TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", + "TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", + + "TLS-RSA-WITH-NULL-SHA256", + + "TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", + "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", + "TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-RSA-WITH-AES-128-CCM", + "TLS-RSA-WITH-AES-256-CCM", + "TLS-DHE-RSA-WITH-AES-128-CCM", + "TLS-DHE-RSA-WITH-AES-256-CCM", + "TLS-RSA-WITH-AES-128-CCM-8", + "TLS-RSA-WITH-AES-256-CCM-8", + "TLS-DHE-RSA-WITH-AES-128-CCM-8", + "TLS-DHE-RSA-WITH-AES-256-CCM-8", + + "TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", + "TLS-DHE-PSK-WITH-AES-128-CBC-SHA", + "TLS-DHE-PSK-WITH-AES-256-CBC-SHA", + + "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", + "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", + "TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", + "TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", + "TLS-RSA-PSK-WITH-AES-256-CBC-SHA", + "TLS-RSA-PSK-WITH-AES-128-CBC-SHA", + + "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", + "TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", + "TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-ECDHE-PSK-WITH-NULL-SHA384", + "TLS-ECDHE-PSK-WITH-NULL-SHA256", + "TLS-PSK-WITH-AES-128-CBC-SHA256", + "TLS-PSK-WITH-AES-256-CBC-SHA384", + "TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", + "TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", + "TLS-PSK-WITH-NULL-SHA256", + "TLS-PSK-WITH-NULL-SHA384", + "TLS-DHE-PSK-WITH-NULL-SHA256", + "TLS-DHE-PSK-WITH-NULL-SHA384", + "TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", + "TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", + "TLS-RSA-PSK-WITH-NULL-SHA256", + "TLS-RSA-PSK-WITH-NULL-SHA384", + "TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "TLS-PSK-WITH-AES-128-GCM-SHA256", + "TLS-PSK-WITH-AES-256-GCM-SHA384", + "TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", + "TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", + "TLS-PSK-WITH-AES-128-CCM", + "TLS-PSK-WITH-AES-256-CCM", + "TLS-DHE-PSK-WITH-AES-128-CCM", + "TLS-DHE-PSK-WITH-AES-256-CCM", + "TLS-PSK-WITH-AES-128-CCM-8", + "TLS-PSK-WITH-AES-256-CCM-8", + "TLS-DHE-PSK-WITH-AES-128-CCM-8", + "TLS-DHE-PSK-WITH-AES-256-CCM-8", + "TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", + "TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", + ] + g_ciphers = [ + "+ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256", + "+ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384", + "+ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD", + "+ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD", + "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", + "+ECDHE-ECDSA:+AES-256-CCM:+AEAD", + "+ECDHE-ECDSA:+AES-128-CCM-8:+AEAD", + "+ECDHE-ECDSA:+AES-256-CCM-8:+AEAD", + + "+RSA:+NULL:+SHA256", + + "+ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256", + "+ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384", + "+RSA:+CAMELLIA-128-CBC:+SHA256", + "+RSA:+CAMELLIA-256-CBC:+SHA256", + "+DHE-RSA:+CAMELLIA-128-CBC:+SHA256", + "+DHE-RSA:+CAMELLIA-256-CBC:+SHA256", + "+ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD", + "+ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD", + "+DHE-RSA:+CAMELLIA-128-GCM:+AEAD", + "+DHE-RSA:+CAMELLIA-256-GCM:+AEAD", + "+RSA:+CAMELLIA-128-GCM:+AEAD", + "+RSA:+CAMELLIA-256-GCM:+AEAD", + "+RSA:+AES-128-CCM:+AEAD", + "+RSA:+AES-256-CCM:+AEAD", + "+DHE-RSA:+AES-128-CCM:+AEAD", + "+DHE-RSA:+AES-256-CCM:+AEAD", + "+RSA:+AES-128-CCM-8:+AEAD", + "+RSA:+AES-256-CCM-8:+AEAD", + "+DHE-RSA:+AES-128-CCM-8:+AEAD", + "+DHE-RSA:+AES-256-CCM-8:+AEAD", + + "+DHE-PSK:+3DES-CBC:+SHA1", + "+DHE-PSK:+AES-128-CBC:+SHA1", + "+DHE-PSK:+AES-256-CBC:+SHA1", + + "+ECDHE-PSK:+AES-256-CBC:+SHA1", + "+ECDHE-PSK:+AES-128-CBC:+SHA1", + "+ECDHE-PSK:+3DES-CBC:+SHA1", + "+RSA-PSK:+3DES-CBC:+SHA1", + "+RSA-PSK:+AES-256-CBC:+SHA1", + "+RSA-PSK:+AES-128-CBC:+SHA1", + + "+ECDHE-PSK:+AES-256-CBC:+SHA384", + "+ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384", + "+ECDHE-PSK:+AES-128-CBC:+SHA256", + "+ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256", + "+ECDHE-PSK:+NULL:+SHA384", + "+ECDHE-PSK:+NULL:+SHA256", + "+PSK:+AES-128-CBC:+SHA256", + "+PSK:+AES-256-CBC:+SHA384", + "+DHE-PSK:+AES-128-CBC:+SHA256", + "+DHE-PSK:+AES-256-CBC:+SHA384", + "+PSK:+NULL:+SHA256", + "+PSK:+NULL:+SHA384", + "+DHE-PSK:+NULL:+SHA256", + "+DHE-PSK:+NULL:+SHA384", + "+RSA-PSK:+AES-256-CBC:+SHA384", + "+RSA-PSK:+AES-128-CBC:+SHA256", + "+RSA-PSK:+NULL:+SHA256", + "+RSA-PSK:+NULL:+SHA384", + "+DHE-PSK:+CAMELLIA-128-CBC:+SHA256", + "+DHE-PSK:+CAMELLIA-256-CBC:+SHA384", + "+PSK:+CAMELLIA-128-CBC:+SHA256", + "+PSK:+CAMELLIA-256-CBC:+SHA384", + "+RSA-PSK:+CAMELLIA-256-CBC:+SHA384", + "+RSA-PSK:+CAMELLIA-128-CBC:+SHA256", + "+PSK:+AES-128-GCM:+AEAD", + "+PSK:+AES-256-GCM:+AEAD", + "+DHE-PSK:+AES-128-GCM:+AEAD", + "+DHE-PSK:+AES-256-GCM:+AEAD", + "+PSK:+AES-128-CCM:+AEAD", + "+PSK:+AES-256-CCM:+AEAD", + "+DHE-PSK:+AES-128-CCM:+AEAD", + "+DHE-PSK:+AES-256-CCM:+AEAD", + "+PSK:+AES-128-CCM-8:+AEAD", + "+PSK:+AES-256-CCM-8:+AEAD", + "+DHE-PSK:+AES-128-CCM-8:+AEAD", + "+DHE-PSK:+AES-256-CCM-8:+AEAD", + "+RSA-PSK:+CAMELLIA-128-GCM:+AEAD", + "+RSA-PSK:+CAMELLIA-256-GCM:+AEAD", + "+PSK:+CAMELLIA-128-GCM:+AEAD", + "+PSK:+CAMELLIA-256-GCM:+AEAD", + "+DHE-PSK:+CAMELLIA-128-GCM:+AEAD", + "+DHE-PSK:+CAMELLIA-256-GCM:+AEAD", + "+RSA-PSK:+AES-256-GCM:+AEAD", + "+RSA-PSK:+AES-128-GCM:+AEAD", + ] + + for i in range(len(m_ciphers)): + + g = translate_gnu(m_ciphers[i]) + assert_equal(g, g_ciphers[i]) + + +test_all_common() +test_mbed_ossl_common() +test_mbed_gnu_common() diff --git a/translate_ciphers.py b/translate_ciphers.py index cf0be7257d..e17d41c75b 100644 --- a/translate_ciphers.py +++ b/translate_ciphers.py @@ -1,485 +1,66 @@ +import re def translate_gnu(m_cipher): - + # Remove "TLS-" + # Replace "-WITH-" with ":+" + # Remove "EDE" m_cipher = "+" + m_cipher[4:] m_cipher = m_cipher.replace("-WITH-", ":+") m_cipher = m_cipher.replace("-EDE", "") - if m_cipher.split("-")[-1] == "SHA": + + # SHA == SHA1, if the last 3 chars are SHA append 1 + if m_cipher[-3:] == "SHA": m_cipher = m_cipher+"1" - - - if m_cipher.split("-")[-1] == "8" or m_cipher.split("-")[-1] == "CCM": + + # CCM or CCM-8 should be followed by ":+AEAD" + if "CCM" in m_cipher: m_cipher = m_cipher+":+AEAD" + + # Replace the last "-" with ":+" + # Replace "GCM:+SHAxyz" with "GCM:+AEAD" else: index=m_cipher.rindex("-") m_cipher = m_cipher[:index]+":+"+m_cipher[index+1:] - m_cipher = m_cipher.replace("GCM:+SHA256", "GCM:+AEAD") - m_cipher = m_cipher.replace("GCM:+SHA384", "GCM:+AEAD") + m_cipher = re.sub(r"GCM\:\+SHA\d\d\d", "GCM:+AEAD", m_cipher) return m_cipher - + def translate_ossl(m_cipher): + # Remove "TLS-" + # Remove "WITH" m_cipher = m_cipher[4:] m_cipher = m_cipher.replace("-WITH", "") + + # Remove the "-" from "ABC-xyz" m_cipher = m_cipher.replace("AES-", "AES") m_cipher = m_cipher.replace("CAMELLIA-", "CAMELLIA") m_cipher = m_cipher.replace("ARIA-", "ARIA") - - m_cipher = m_cipher.replace("-EDE", "") - - m_cipher = m_cipher.replace("3DES-CBC", "DES-CBC3") - try: - index = m_cipher.rindex("CBC") - if m_cipher[index-4:index-1] != "DES": - m_cipher = m_cipher.replace("CBC-", "") - except: - pass + # Remove "RSA" if it is at the beginning if m_cipher[:4] == "RSA-": m_cipher = m_cipher[4:] + # For all circumstances outside of PSK + if "PSK" not in m_cipher: + m_cipher = m_cipher.replace("-EDE", "") + m_cipher = m_cipher.replace("3DES-CBC", "DES-CBC3") + + # Remove "CBC" if it is not prefixed by DES + if "CBC" in m_cipher: + index = m_cipher.rindex("CBC") + if m_cipher[index-4:index-1] != "DES": + m_cipher = m_cipher.replace("CBC-", "") + + # ECDHE-RSA-ARIA does not exist in OpenSSL m_cipher = m_cipher.replace("ECDHE-RSA-ARIA", "ECDHE-ARIA") - try: + # POLY1305 should not be followed by anything + if "POLY1305" in m_cipher: index = m_cipher.rindex("POLY1305") m_cipher=m_cipher[:index+8] - except Exception as e: - pass#print(e) + + # If DES is being used, Replace DHE with EDH + if "DES" in m_cipher and "DHE" in m_cipher and "ECDHE" not in m_cipher: + m_cipher = m_cipher.replace("DHE", "EDH") return m_cipher - -def test_all_common(): - m_ciphers = [ - "TLS-ECDHE-ECDSA-WITH-NULL-SHA", - "TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", - "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", - "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", - - "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", - "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", - "TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", - "TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", - - "TLS-DHE-RSA-WITH-AES-128-CBC-SHA", - "TLS-DHE-RSA-WITH-AES-256-CBC-SHA", - "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", - "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", - "TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", - "TLS-RSA-WITH-AES-256-CBC-SHA", - "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", - "TLS-RSA-WITH-AES-128-CBC-SHA", - "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", - "TLS-RSA-WITH-3DES-EDE-CBC-SHA", - "TLS-RSA-WITH-NULL-MD5", - "TLS-RSA-WITH-NULL-SHA", - - "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", - "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", - "TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", - "TLS-ECDHE-RSA-WITH-NULL-SHA", - - "TLS-RSA-WITH-AES-128-CBC-SHA256", - "TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", - "TLS-RSA-WITH-AES-256-CBC-SHA256", - "TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", - "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", - "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", - "TLS-RSA-WITH-AES-128-GCM-SHA256", - "TLS-RSA-WITH-AES-256-GCM-SHA384", - "TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", - "TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", - "TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", - "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", - - "TLS-PSK-WITH-3DES-EDE-CBC-SHA", - "TLS-PSK-WITH-AES-128-CBC-SHA", - "TLS-PSK-WITH-AES-256-CBC-SHA", - ] - g_ciphers = [ - "+ECDHE-ECDSA:+NULL:+SHA1", - "+ECDHE-ECDSA:+3DES-CBC:+SHA1", - "+ECDHE-ECDSA:+AES-128-CBC:+SHA1", - "+ECDHE-ECDSA:+AES-256-CBC:+SHA1", - - "+ECDHE-ECDSA:+AES-128-CBC:+SHA256", - "+ECDHE-ECDSA:+AES-256-CBC:+SHA384", - "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", - "+ECDHE-ECDSA:+AES-256-GCM:+AEAD", - - "+DHE-RSA:+AES-128-CBC:+SHA1", - "+DHE-RSA:+AES-256-CBC:+SHA1", - "+DHE-RSA:+CAMELLIA-128-CBC:+SHA1", - "+DHE-RSA:+CAMELLIA-256-CBC:+SHA1", - "+DHE-RSA:+3DES-CBC:+SHA1", - "+RSA:+AES-256-CBC:+SHA1", - "+RSA:+CAMELLIA-256-CBC:+SHA1", - "+RSA:+AES-128-CBC:+SHA1", - "+RSA:+CAMELLIA-128-CBC:+SHA1", - "+RSA:+3DES-CBC:+SHA1", - "+RSA:+NULL:+MD5", - "+RSA:+NULL:+SHA1", - - "+ECDHE-RSA:+AES-128-CBC:+SHA1", - "+ECDHE-RSA:+AES-256-CBC:+SHA1", - "+ECDHE-RSA:+3DES-CBC:+SHA1", - "+ECDHE-RSA:+NULL:+SHA1", - - "+RSA:+AES-128-CBC:+SHA256", - "+DHE-RSA:+AES-128-CBC:+SHA256", - "+RSA:+AES-256-CBC:+SHA256", - "+DHE-RSA:+AES-256-CBC:+SHA256", - "+ECDHE-RSA:+AES-128-CBC:+SHA256", - "+ECDHE-RSA:+AES-256-CBC:+SHA384", - "+RSA:+AES-128-GCM:+AEAD", - "+RSA:+AES-256-GCM:+AEAD", - "+DHE-RSA:+AES-128-GCM:+AEAD", - "+DHE-RSA:+AES-256-GCM:+AEAD", - "+ECDHE-RSA:+AES-128-GCM:+AEAD", - "+ECDHE-RSA:+AES-256-GCM:+AEAD", - - "+PSK:+3DES-CBC:+SHA1", - "+PSK:+AES-128-CBC:+SHA1", - "+PSK:+AES-256-CBC:+SHA1", - ] - o_ciphers = [ - "ECDHE-ECDSA-NULL-SHA", - "ECDHE-ECDSA-DES-CBC3-SHA", - "ECDHE-ECDSA-AES128-SHA", - "ECDHE-ECDSA-AES256-SHA", - - "ECDHE-ECDSA-AES128-SHA256", - "ECDHE-ECDSA-AES256-SHA384", - "ECDHE-ECDSA-AES128-GCM-SHA256", - "ECDHE-ECDSA-AES256-GCM-SHA384", - - "DHE-RSA-AES128-SHA", - "DHE-RSA-AES256-SHA", - "DHE-RSA-CAMELLIA128-SHA", - "DHE-RSA-CAMELLIA256-SHA", - #"EDH-RSA-DES-CBC3-SHA", - "DHE-RSA-DES-CBC3-SHA", - "AES256-SHA", - "CAMELLIA256-SHA", - "AES128-SHA", - "CAMELLIA128-SHA", - "DES-CBC3-SHA", - "NULL-MD5", - "NULL-SHA", - - "ECDHE-RSA-AES128-SHA", - "ECDHE-RSA-AES256-SHA", - "ECDHE-RSA-DES-CBC3-SHA", - "ECDHE-RSA-NULL-SHA", - - #"NULL-SHA256", - "AES128-SHA256", - "DHE-RSA-AES128-SHA256", - "AES256-SHA256", - "DHE-RSA-AES256-SHA256", - "ECDHE-RSA-AES128-SHA256", - "ECDHE-RSA-AES256-SHA384", - "AES128-GCM-SHA256", - "AES256-GCM-SHA384", - "DHE-RSA-AES128-GCM-SHA256", - "DHE-RSA-AES256-GCM-SHA384", - "ECDHE-RSA-AES128-GCM-SHA256", - "ECDHE-RSA-AES256-GCM-SHA384", - - #"PSK-3DES-EDE-CBC-SHA", - #"PSK-AES128-CBC-SHA", - #"PSK-AES256-CBC-SHA", - - "PSK-DES-CBC3-SHA", - "PSK-AES128-SHA", - "PSK-AES256-SHA", - ] - - for i in range(len(m_ciphers)): - - g = translate_gnu(m_ciphers[i]) - if g!=g_ciphers[i]: - print("GNU", i) - print("new".ljust(10), g) - print("original".ljust(10), g_ciphers[i]) - # break - - - o = translate_ossl(m_ciphers[i]) - if o!=o_ciphers[i]: - print("OpenSSL", i) - print("new".ljust(10), o) - print("original".ljust(10), o_ciphers[i]) - # break - -def test_mbed_ossl_common(): - m_ciphers = [ - "TLS-ECDH-ECDSA-WITH-NULL-SHA", - "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", - "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", - "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", - - "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", - "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", - "TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", - "TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", - "TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", - "TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", - "TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", - - "TLS-RSA-WITH-DES-CBC-SHA", - "TLS-DHE-RSA-WITH-DES-CBC-SHA", - - "TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", - "TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", - "TLS-RSA-WITH-ARIA-256-GCM-SHA384", - "TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", - "TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", - "TLS-RSA-WITH-ARIA-128-GCM-SHA256", - "TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", - "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", - - "TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", - "TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", - "TLS-PSK-WITH-ARIA-256-GCM-SHA384", - "TLS-PSK-WITH-ARIA-128-GCM-SHA256", - "TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", - "TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", - "TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", - ] - o_ciphers = [ - "ECDH-ECDSA-NULL-SHA", - "ECDH-ECDSA-DES-CBC3-SHA", - "ECDH-ECDSA-AES128-SHA", - "ECDH-ECDSA-AES256-SHA", - - "ECDH-ECDSA-AES128-SHA256", - "ECDH-ECDSA-AES256-SHA384", - "ECDH-ECDSA-AES128-GCM-SHA256", - "ECDH-ECDSA-AES256-GCM-SHA384", - "ECDHE-ECDSA-ARIA256-GCM-SHA384", - "ECDHE-ECDSA-ARIA128-GCM-SHA256", - "ECDHE-ECDSA-CHACHA20-POLY1305", - - "DES-CBC-SHA", - #"EDH-RSA-DES-CBC-SHA", - "DHE-RSA-DES-CBC-SHA", - - "ECDHE-ARIA256-GCM-SHA384", - "DHE-RSA-ARIA256-GCM-SHA384", - "ARIA256-GCM-SHA384", - "ECDHE-ARIA128-GCM-SHA256", - "DHE-RSA-ARIA128-GCM-SHA256", - "ARIA128-GCM-SHA256", - "DHE-RSA-CHACHA20-POLY1305", - "ECDHE-RSA-CHACHA20-POLY1305", - - "DHE-PSK-ARIA256-GCM-SHA384", - "DHE-PSK-ARIA128-GCM-SHA256", - "PSK-ARIA256-GCM-SHA384", - "PSK-ARIA128-GCM-SHA256", - "PSK-CHACHA20-POLY1305", - "ECDHE-PSK-CHACHA20-POLY1305", - "DHE-PSK-CHACHA20-POLY1305", - ] - - for i in range(len(m_ciphers)): - - o = translate_ossl(m_ciphers[i]) - if o!=o_ciphers[i]: - print("OpenSSL", i) - print("new".ljust(10), o) - print("original".ljust(10), o_ciphers[i]) - # break - -def test_mbed_gnu_common(): - m_ciphers = [ - "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-ECDHE-ECDSA-WITH-AES-128-CCM", - "TLS-ECDHE-ECDSA-WITH-AES-256-CCM", - "TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", - "TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", - - "TLS-RSA-WITH-NULL-SHA256", - - "TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", - "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", - "TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-RSA-WITH-AES-128-CCM", - "TLS-RSA-WITH-AES-256-CCM", - "TLS-DHE-RSA-WITH-AES-128-CCM", - "TLS-DHE-RSA-WITH-AES-256-CCM", - "TLS-RSA-WITH-AES-128-CCM-8", - "TLS-RSA-WITH-AES-256-CCM-8", - "TLS-DHE-RSA-WITH-AES-128-CCM-8", - "TLS-DHE-RSA-WITH-AES-256-CCM-8", - - "TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", - "TLS-DHE-PSK-WITH-AES-128-CBC-SHA", - "TLS-DHE-PSK-WITH-AES-256-CBC-SHA", - - "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", - "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", - "TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", - "TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", - "TLS-RSA-PSK-WITH-AES-256-CBC-SHA", - "TLS-RSA-PSK-WITH-AES-128-CBC-SHA", - - "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", - "TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", - "TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-ECDHE-PSK-WITH-NULL-SHA384", - "TLS-ECDHE-PSK-WITH-NULL-SHA256", - "TLS-PSK-WITH-AES-128-CBC-SHA256", - "TLS-PSK-WITH-AES-256-CBC-SHA384", - "TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", - "TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", - "TLS-PSK-WITH-NULL-SHA256", - "TLS-PSK-WITH-NULL-SHA384", - "TLS-DHE-PSK-WITH-NULL-SHA256", - "TLS-DHE-PSK-WITH-NULL-SHA384", - "TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", - "TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", - "TLS-RSA-PSK-WITH-NULL-SHA256", - "TLS-RSA-PSK-WITH-NULL-SHA384", - "TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-PSK-WITH-AES-128-GCM-SHA256", - "TLS-PSK-WITH-AES-256-GCM-SHA384", - "TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", - "TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", - "TLS-PSK-WITH-AES-128-CCM", - "TLS-PSK-WITH-AES-256-CCM", - "TLS-DHE-PSK-WITH-AES-128-CCM", - "TLS-DHE-PSK-WITH-AES-256-CCM", - "TLS-PSK-WITH-AES-128-CCM-8", - "TLS-PSK-WITH-AES-256-CCM-8", - "TLS-DHE-PSK-WITH-AES-128-CCM-8", - "TLS-DHE-PSK-WITH-AES-256-CCM-8", - "TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", - "TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", - ] - g_ciphers = [ - "+ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256", - "+ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384", - "+ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD", - "+ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD", - "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", - "+ECDHE-ECDSA:+AES-256-CCM:+AEAD", - "+ECDHE-ECDSA:+AES-128-CCM-8:+AEAD", - "+ECDHE-ECDSA:+AES-256-CCM-8:+AEAD", - - "+RSA:+NULL:+SHA256", - - "+ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256", - "+ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384", - "+RSA:+CAMELLIA-128-CBC:+SHA256", - "+RSA:+CAMELLIA-256-CBC:+SHA256", - "+DHE-RSA:+CAMELLIA-128-CBC:+SHA256", - "+DHE-RSA:+CAMELLIA-256-CBC:+SHA256", - "+ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD", - "+ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD", - "+DHE-RSA:+CAMELLIA-128-GCM:+AEAD", - "+DHE-RSA:+CAMELLIA-256-GCM:+AEAD", - "+RSA:+CAMELLIA-128-GCM:+AEAD", - "+RSA:+CAMELLIA-256-GCM:+AEAD", - "+RSA:+AES-128-CCM:+AEAD", - "+RSA:+AES-256-CCM:+AEAD", - "+DHE-RSA:+AES-128-CCM:+AEAD", - "+DHE-RSA:+AES-256-CCM:+AEAD", - "+RSA:+AES-128-CCM-8:+AEAD", - "+RSA:+AES-256-CCM-8:+AEAD", - "+DHE-RSA:+AES-128-CCM-8:+AEAD", - "+DHE-RSA:+AES-256-CCM-8:+AEAD", - - "+DHE-PSK:+3DES-CBC:+SHA1", - "+DHE-PSK:+AES-128-CBC:+SHA1", - "+DHE-PSK:+AES-256-CBC:+SHA1", - - "+ECDHE-PSK:+AES-256-CBC:+SHA1", - "+ECDHE-PSK:+AES-128-CBC:+SHA1", - "+ECDHE-PSK:+3DES-CBC:+SHA1", - "+RSA-PSK:+3DES-CBC:+SHA1", - "+RSA-PSK:+AES-256-CBC:+SHA1", - "+RSA-PSK:+AES-128-CBC:+SHA1", - - "+ECDHE-PSK:+AES-256-CBC:+SHA384", - "+ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384", - "+ECDHE-PSK:+AES-128-CBC:+SHA256", - "+ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256", - "+ECDHE-PSK:+NULL:+SHA384", - "+ECDHE-PSK:+NULL:+SHA256", - "+PSK:+AES-128-CBC:+SHA256", - "+PSK:+AES-256-CBC:+SHA384", - "+DHE-PSK:+AES-128-CBC:+SHA256", - "+DHE-PSK:+AES-256-CBC:+SHA384", - "+PSK:+NULL:+SHA256", - "+PSK:+NULL:+SHA384", - "+DHE-PSK:+NULL:+SHA256", - "+DHE-PSK:+NULL:+SHA384", - "+RSA-PSK:+AES-256-CBC:+SHA384", - "+RSA-PSK:+AES-128-CBC:+SHA256", - "+RSA-PSK:+NULL:+SHA256", - "+RSA-PSK:+NULL:+SHA384", - "+DHE-PSK:+CAMELLIA-128-CBC:+SHA256", - "+DHE-PSK:+CAMELLIA-256-CBC:+SHA384", - "+PSK:+CAMELLIA-128-CBC:+SHA256", - "+PSK:+CAMELLIA-256-CBC:+SHA384", - "+RSA-PSK:+CAMELLIA-256-CBC:+SHA384", - "+RSA-PSK:+CAMELLIA-128-CBC:+SHA256", - "+PSK:+AES-128-GCM:+AEAD", - "+PSK:+AES-256-GCM:+AEAD", - "+DHE-PSK:+AES-128-GCM:+AEAD", - "+DHE-PSK:+AES-256-GCM:+AEAD", - "+PSK:+AES-128-CCM:+AEAD", - "+PSK:+AES-256-CCM:+AEAD", - "+DHE-PSK:+AES-128-CCM:+AEAD", - "+DHE-PSK:+AES-256-CCM:+AEAD", - "+PSK:+AES-128-CCM-8:+AEAD", - "+PSK:+AES-256-CCM-8:+AEAD", - "+DHE-PSK:+AES-128-CCM-8:+AEAD", - "+DHE-PSK:+AES-256-CCM-8:+AEAD", - "+RSA-PSK:+CAMELLIA-128-GCM:+AEAD", - "+RSA-PSK:+CAMELLIA-256-GCM:+AEAD", - "+PSK:+CAMELLIA-128-GCM:+AEAD", - "+PSK:+CAMELLIA-256-GCM:+AEAD", - "+DHE-PSK:+CAMELLIA-128-GCM:+AEAD", - "+DHE-PSK:+CAMELLIA-256-GCM:+AEAD", - "+RSA-PSK:+AES-256-GCM:+AEAD", - "+RSA-PSK:+AES-128-GCM:+AEAD", - ] - - for i in range(len(m_ciphers)): - - g = translate_gnu(m_ciphers[i]) - if g!=g_ciphers[i]: - print("GNU", i) - print("new".ljust(10), g) - print("original".ljust(10), g_ciphers[i]) - # break - -test_all_common() -test_mbed_ossl_common() -test_mbed_gnu_common() \ No newline at end of file From 97cd599545087b5fc7a4d551be6301ac6e1d881e Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 22 Jul 2021 16:08:29 +0100 Subject: [PATCH 384/966] Implement bash script for testing Added formatting functions to translate_ciphersuite.py to take a string of multiple ciphersuite names, in the current compat.sh and output the translated ciphersuite names in the same format Created test_translate.sh which uses samples from compat.sh to compare against the translated versions to ensure the translations are produced in the correct format Signed-off-by: Joe Subbiani --- test_translate.py | 0 test_translate.sh | 113 +++++++++++++++++++++++++++++++++++++++++++ translate_ciphers.py | 32 ++++++++++++ 3 files changed, 145 insertions(+) mode change 100644 => 100755 test_translate.py create mode 100755 test_translate.sh mode change 100644 => 100755 translate_ciphers.py diff --git a/test_translate.py b/test_translate.py old mode 100644 new mode 100755 diff --git a/test_translate.sh b/test_translate.sh new file mode 100755 index 0000000000..43b7ff4e39 --- /dev/null +++ b/test_translate.sh @@ -0,0 +1,113 @@ +#!/bin/sh + +# Ciphers that will use translate_ciphers.py +M_CIPHERS="" +O_CIPHERS="" +G_CIPHERS="" + +# Ciphers taken directly from compat.sh +Mt_CIPHERS="" +Ot_CIPHERS="" +Gt_CIPHERS="" + +# Initial list to be split into 3 +CIPHERS="TLS-ECDHE-ECDSA-WITH-NULL-SHA \ + TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ + TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ + TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ + " + +M_CIPHERS="$M_CIPHERS \ + $CIPHERS" + +G=`python3 translate_ciphers.py g "$CIPHERS"` +G_CIPHERS="$G_CIPHERS \ + $G" + +O=`python3 translate_ciphers.py o "$CIPHERS"` +O_CIPHERS="$O_CIPHERS \ + $O" + +Mt_CIPHERS="$Mt_CIPHERS \ + TLS-ECDHE-ECDSA-WITH-NULL-SHA \ + TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ + TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ + TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ + " +Gt_CIPHERS="$Gt_CIPHERS \ + +ECDHE-ECDSA:+NULL:+SHA1 \ + +ECDHE-ECDSA:+3DES-CBC:+SHA1 \ + +ECDHE-ECDSA:+AES-128-CBC:+SHA1 \ + +ECDHE-ECDSA:+AES-256-CBC:+SHA1 \ + " +Ot_CIPHERS="$Ot_CIPHERS \ + ECDHE-ECDSA-NULL-SHA \ + ECDHE-ECDSA-DES-CBC3-SHA \ + ECDHE-ECDSA-AES128-SHA \ + ECDHE-ECDSA-AES256-SHA \ + " + + +# Initial list to be split into 3 +CIPHERS="TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ + TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ + TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ + " + +M_CIPHERS="$M_CIPHERS \ + $CIPHERS" + +G=`python3 translate_ciphers.py g "$CIPHERS"` +G_CIPHERS="$G_CIPHERS \ + $G" + +O=`python3 translate_ciphers.py o "$CIPHERS"` +O_CIPHERS="$O_CIPHERS \ + $O" + +Mt_CIPHERS="$Mt_CIPHERS \ + TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ + TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ + TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ + " +Gt_CIPHERS="$Gt_CIPHERS \ + +ECDHE-ECDSA:+AES-128-CBC:+SHA256 \ + +ECDHE-ECDSA:+AES-256-CBC:+SHA384 \ + +ECDHE-ECDSA:+AES-128-GCM:+AEAD \ + +ECDHE-ECDSA:+AES-256-GCM:+AEAD \ + " +Ot_CIPHERS="$Ot_CIPHERS \ + ECDHE-ECDSA-AES128-SHA256 \ + ECDHE-ECDSA-AES256-SHA384 \ + ECDHE-ECDSA-AES128-GCM-SHA256 \ + ECDHE-ECDSA-AES256-GCM-SHA384 \ + " + +# Normalise spacing +M_CIPHERS=$( echo "$M_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') +G_CIPHERS=$( echo "$G_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') +O_CIPHERS=$( echo "$O_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') + +Mt_CIPHERS=$( echo "$Mt_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') +Gt_CIPHERS=$( echo "$Gt_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') +Ot_CIPHERS=$( echo "$Ot_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') + +# Compare the compat.sh names with the translated names +# Upon fail, print them to view the differences +if [ "$Mt_CIPHERS" != "$M_CIPHERS" ] +then + echo "MBED Translated: $M_CIPHERS" + echo "MBED Original: $Mt_CIPHERS" +fi +if [ "$Gt_CIPHERS" != "$G_CIPHERS" ] +then + echo "GNU Translated: $G_CIPHERS" + echo "GNU Original: $Gt_CIPHERS" +fi +if [ "$Ot_CIPHERS" != "$O_CIPHERS" ] +then + echo "OpenSSL Translated: $O_CIPHERS" + echo "OpenSSL Original: $Ot_CIPHERS" +fi \ No newline at end of file diff --git a/translate_ciphers.py b/translate_ciphers.py old mode 100644 new mode 100755 index e17d41c75b..b9a2d53747 --- a/translate_ciphers.py +++ b/translate_ciphers.py @@ -1,4 +1,5 @@ import re +import sys def translate_gnu(m_cipher): # Remove "TLS-" @@ -64,3 +65,34 @@ def translate_ossl(m_cipher): m_cipher = m_cipher.replace("DHE", "EDH") return m_cipher + +def format_g(m_ciphers): + #ciphers = (re.findall(r"TLS-.+\s*\\", m_ciphers)) + m_ciphers = m_ciphers.split() + g_ciphers = [] + for i in m_ciphers: + g_ciphers.append(translate_gnu(i)) + return " ".join(g_ciphers) + +def format_o(m_ciphers): + m_ciphers = m_ciphers.split() + o_ciphers = [] + for i in m_ciphers: + o_ciphers.append(translate_ossl(i)) + return " ".join(o_ciphers) + +def main(): + # print command line arguments + if len(sys.argv) <= 2: + exit(1) + if sys.argv[1] == "g": + print(format_g(sys.argv[2])) + exit(0) + elif sys.argv[1] == "o": + print(format_o(sys.argv[2])) + exit(0) + else: + exit(1) + +if __name__ == "__main__": + main() \ No newline at end of file From 29239b00a672564e39221905d5063c5f5f9815b6 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 22 Jul 2021 17:33:59 +0100 Subject: [PATCH 385/966] Move translate scripts to test directory To be used by compat.sh, the files were moved to the same directory. The files were also renamed to be distinguishable aside from their file extensions Signed-off-by: Joe Subbiani --- test_translate.sh => tests/test_translate_format.sh | 0 test_translate.py => tests/test_translate_names.py | 0 translate_ciphers.py => tests/translate_ciphers.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename test_translate.sh => tests/test_translate_format.sh (100%) rename test_translate.py => tests/test_translate_names.py (100%) rename translate_ciphers.py => tests/translate_ciphers.py (100%) diff --git a/test_translate.sh b/tests/test_translate_format.sh similarity index 100% rename from test_translate.sh rename to tests/test_translate_format.sh diff --git a/test_translate.py b/tests/test_translate_names.py similarity index 100% rename from test_translate.py rename to tests/test_translate_names.py diff --git a/translate_ciphers.py b/tests/translate_ciphers.py similarity index 100% rename from translate_ciphers.py rename to tests/translate_ciphers.py From a16ccac1d9a8a8c16d2f74e0d16f83463e0faab5 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 22 Jul 2021 18:52:17 +0100 Subject: [PATCH 386/966] Format files and add license comment Changes to pass tests/scripts/check_files.py -Add missing new line at end of each file -Remove any trailing whitespaces -Added file shebang comments Added license info and purpose of file descriptions. The 2 test_translate... files may not be stay later down the line, but incase they do become permanent, it is good to add the appropriate comments now. Signed-off-by: Joe Subbiani --- tests/test_translate_format.sh | 33 ++++++++++++++++++++++++++++++-- tests/test_translate_names.py | 27 ++++++++++++++++++++++++-- tests/translate_ciphers.py | 35 ++++++++++++++++++++++++++++++++-- 3 files changed, 89 insertions(+), 6 deletions(-) diff --git a/tests/test_translate_format.sh b/tests/test_translate_format.sh index 43b7ff4e39..55d8a8a8e8 100755 --- a/tests/test_translate_format.sh +++ b/tests/test_translate_format.sh @@ -1,5 +1,34 @@ #!/bin/sh +# test_translate_format.sh +# +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Purpose +# +# Test translate_ciphers.py formatting by comparing the translated +# ciphersuite names to the true names. As in compat.sh, the spaces between +# the ciphersuite names are normalised. +# +# On fail, the translated cipher suite names do not match the correct ones. +# In this case the difference will be printed in stdout. +# +# This files main purpose is to ensure translate_ciphers.py can take strings +# in the expected format and return them in the format compat.sh will expect. + # Ciphers that will use translate_ciphers.py M_CIPHERS="" O_CIPHERS="" @@ -19,7 +48,7 @@ CIPHERS="TLS-ECDHE-ECDSA-WITH-NULL-SHA \ M_CIPHERS="$M_CIPHERS \ $CIPHERS" - + G=`python3 translate_ciphers.py g "$CIPHERS"` G_CIPHERS="$G_CIPHERS \ $G" @@ -110,4 +139,4 @@ if [ "$Ot_CIPHERS" != "$O_CIPHERS" ] then echo "OpenSSL Translated: $O_CIPHERS" echo "OpenSSL Original: $Ot_CIPHERS" -fi \ No newline at end of file +fi diff --git a/tests/test_translate_names.py b/tests/test_translate_names.py index 9de283059c..d018c10916 100755 --- a/tests/test_translate_names.py +++ b/tests/test_translate_names.py @@ -1,3 +1,28 @@ +#!/usr/bin/env python3 + +# test_translate_names.py +# +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Purpose +# +# Test translate_ciphers.py by running every MBedTLS ciphersuite name +# combination through the translate functions and comparing them to their +# correct GNU or OpenSSL counterpart. + from translate_ciphers import * def assert_equal(translate, original): @@ -235,7 +260,6 @@ def test_mbed_ossl_common(): o = translate_ossl(m_ciphers[i]) assert_equal(o, o_ciphers[i]) - def test_mbed_gnu_common(): m_ciphers = [ "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", @@ -420,7 +444,6 @@ def test_mbed_gnu_common(): g = translate_gnu(m_ciphers[i]) assert_equal(g, g_ciphers[i]) - test_all_common() test_mbed_ossl_common() diff --git a/tests/translate_ciphers.py b/tests/translate_ciphers.py index b9a2d53747..07affb290d 100755 --- a/tests/translate_ciphers.py +++ b/tests/translate_ciphers.py @@ -1,3 +1,34 @@ +#!/usr/bin/env python3 + +# translate_ciphers.py +# +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Purpose +# +# Translate ciphersuite names in MBedTLS format to OpenSSL and GNU +# standards. +# +# Format and analyse strings past in via input arguments to match +# the expected strings utilised in compat.sh. +# +# sys.argv[1] should be "g" or "o" for GNU or OpenSSL. +# sys.argv[2] should be a string containing one or more +# ciphersuite names. + import re import sys @@ -91,8 +122,8 @@ def main(): elif sys.argv[1] == "o": print(format_o(sys.argv[2])) exit(0) - else: + else: exit(1) if __name__ == "__main__": - main() \ No newline at end of file + main() From 15d7124661e79a87f389be39fc21524fa0f30cc3 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Mon, 26 Jul 2021 12:20:00 +0100 Subject: [PATCH 387/966] Replace lists with calls to translate_ciphersuite.py Replace the OpenSSL $O_CIPHERS and GNU $G_CIPHERS declarations with calls to translate_ciphersuite.py Declared a new variable for each sublist $CIPHERS which is appended to MBedTLS $M_CIPHERS and translated+appended to the OpenSSL and GNU lists. Fixes #4674 Signed-off-by: Joe Subbiani --- tests/compat.sh | 391 ++++++++++----------------------- tests/test_translate_format.sh | 18 +- 2 files changed, 120 insertions(+), 289 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index c2bef26121..04b4dd521c 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -246,51 +246,38 @@ add_common_ciphersuites() "ECDSA") if [ `minor_ver "$MODE"` -gt 0 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDHE-ECDSA-WITH-NULL-SHA \ + CIPHERS="TLS-ECDHE-ECDSA-WITH-NULL-SHA \ TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ " - G_CIPHERS="$G_CIPHERS \ - +ECDHE-ECDSA:+NULL:+SHA1 \ - +ECDHE-ECDSA:+3DES-CBC:+SHA1 \ - +ECDHE-ECDSA:+AES-128-CBC:+SHA1 \ - +ECDHE-ECDSA:+AES-256-CBC:+SHA1 \ - " - O_CIPHERS="$O_CIPHERS \ - ECDHE-ECDSA-NULL-SHA \ - ECDHE-ECDSA-DES-CBC3-SHA \ - ECDHE-ECDSA-AES128-SHA \ - ECDHE-ECDSA-AES256-SHA \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" fi if [ `minor_ver "$MODE"` -ge 3 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ + CIPHERS="TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ " - G_CIPHERS="$G_CIPHERS \ - +ECDHE-ECDSA:+AES-128-CBC:+SHA256 \ - +ECDHE-ECDSA:+AES-256-CBC:+SHA384 \ - +ECDHE-ECDSA:+AES-128-GCM:+AEAD \ - +ECDHE-ECDSA:+AES-256-GCM:+AEAD \ - " - O_CIPHERS="$O_CIPHERS \ - ECDHE-ECDSA-AES128-SHA256 \ - ECDHE-ECDSA-AES256-SHA384 \ - ECDHE-ECDSA-AES128-GCM-SHA256 \ - ECDHE-ECDSA-AES256-GCM-SHA384 \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" fi ;; "RSA") - M_CIPHERS="$M_CIPHERS \ - TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ + CIPHERS="TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ TLS-DHE-RSA-WITH-AES-256-CBC-SHA \ TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA \ TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA \ @@ -303,59 +290,32 @@ add_common_ciphersuites() TLS-RSA-WITH-NULL-MD5 \ TLS-RSA-WITH-NULL-SHA \ " - G_CIPHERS="$G_CIPHERS \ - +DHE-RSA:+AES-128-CBC:+SHA1 \ - +DHE-RSA:+AES-256-CBC:+SHA1 \ - +DHE-RSA:+CAMELLIA-128-CBC:+SHA1 \ - +DHE-RSA:+CAMELLIA-256-CBC:+SHA1 \ - +DHE-RSA:+3DES-CBC:+SHA1 \ - +RSA:+AES-256-CBC:+SHA1 \ - +RSA:+CAMELLIA-256-CBC:+SHA1 \ - +RSA:+AES-128-CBC:+SHA1 \ - +RSA:+CAMELLIA-128-CBC:+SHA1 \ - +RSA:+3DES-CBC:+SHA1 \ - +RSA:+NULL:+MD5 \ - +RSA:+NULL:+SHA1 \ - " - O_CIPHERS="$O_CIPHERS \ - DHE-RSA-AES128-SHA \ - DHE-RSA-AES256-SHA \ - DHE-RSA-CAMELLIA128-SHA \ - DHE-RSA-CAMELLIA256-SHA \ - EDH-RSA-DES-CBC3-SHA \ - AES256-SHA \ - CAMELLIA256-SHA \ - AES128-SHA \ - CAMELLIA128-SHA \ - DES-CBC3-SHA \ - NULL-MD5 \ - NULL-SHA \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" + if [ `minor_ver "$MODE"` -gt 0 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA \ + CIPHERS="TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA \ TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA \ TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA \ TLS-ECDHE-RSA-WITH-NULL-SHA \ " - G_CIPHERS="$G_CIPHERS \ - +ECDHE-RSA:+AES-128-CBC:+SHA1 \ - +ECDHE-RSA:+AES-256-CBC:+SHA1 \ - +ECDHE-RSA:+3DES-CBC:+SHA1 \ - +ECDHE-RSA:+NULL:+SHA1 \ - " - O_CIPHERS="$O_CIPHERS \ - ECDHE-RSA-AES256-SHA \ - ECDHE-RSA-AES128-SHA \ - ECDHE-RSA-DES-CBC3-SHA \ - ECDHE-RSA-NULL-SHA \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" fi if [ `minor_ver "$MODE"` -ge 3 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-RSA-WITH-AES-128-CBC-SHA256 \ + CIPHERS="TLS-RSA-WITH-AES-128-CBC-SHA256 \ TLS-DHE-RSA-WITH-AES-128-CBC-SHA256 \ TLS-RSA-WITH-AES-256-CBC-SHA256 \ TLS-DHE-RSA-WITH-AES-256-CBC-SHA256 \ @@ -368,54 +328,28 @@ add_common_ciphersuites() TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384 \ " - G_CIPHERS="$G_CIPHERS \ - +RSA:+AES-128-CBC:+SHA256 \ - +DHE-RSA:+AES-128-CBC:+SHA256 \ - +RSA:+AES-256-CBC:+SHA256 \ - +DHE-RSA:+AES-256-CBC:+SHA256 \ - +ECDHE-RSA:+AES-128-CBC:+SHA256 \ - +ECDHE-RSA:+AES-256-CBC:+SHA384 \ - +RSA:+AES-128-GCM:+AEAD \ - +RSA:+AES-256-GCM:+AEAD \ - +DHE-RSA:+AES-128-GCM:+AEAD \ - +DHE-RSA:+AES-256-GCM:+AEAD \ - +ECDHE-RSA:+AES-128-GCM:+AEAD \ - +ECDHE-RSA:+AES-256-GCM:+AEAD \ - " - O_CIPHERS="$O_CIPHERS \ - NULL-SHA256 \ - AES128-SHA256 \ - DHE-RSA-AES128-SHA256 \ - AES256-SHA256 \ - DHE-RSA-AES256-SHA256 \ - ECDHE-RSA-AES128-SHA256 \ - ECDHE-RSA-AES256-SHA384 \ - AES128-GCM-SHA256 \ - DHE-RSA-AES128-GCM-SHA256 \ - AES256-GCM-SHA384 \ - DHE-RSA-AES256-GCM-SHA384 \ - ECDHE-RSA-AES128-GCM-SHA256 \ - ECDHE-RSA-AES256-GCM-SHA384 \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS NULL-SHA256 $O" fi ;; "PSK") - M_CIPHERS="$M_CIPHERS \ - TLS-PSK-WITH-3DES-EDE-CBC-SHA \ + CIPHERS="TLS-PSK-WITH-3DES-EDE-CBC-SH \ TLS-PSK-WITH-AES-128-CBC-SHA \ TLS-PSK-WITH-AES-256-CBC-SHA \ " - G_CIPHERS="$G_CIPHERS \ - +PSK:+3DES-CBC:+SHA1 \ - +PSK:+AES-128-CBC:+SHA1 \ - +PSK:+AES-256-CBC:+SHA1 \ - " - O_CIPHERS="$O_CIPHERS \ - PSK-3DES-EDE-CBC-SHA \ - PSK-AES128-CBC-SHA \ - PSK-AES256-CBC-SHA \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" ;; esac } @@ -437,23 +371,19 @@ add_openssl_ciphersuites() "ECDSA") if [ `minor_ver "$MODE"` -gt 0 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDH-ECDSA-WITH-NULL-SHA \ + CIPHERS="TLS-ECDH-ECDSA-WITH-NULL-SHA \ TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA \ TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA \ TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA \ " - O_CIPHERS="$O_CIPHERS \ - ECDH-ECDSA-NULL-SHA \ - ECDH-ECDSA-DES-CBC3-SHA \ - ECDH-ECDSA-AES128-SHA \ - ECDH-ECDSA-AES256-SHA \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" fi if [ `minor_ver "$MODE"` -ge 3 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256 \ + CIPHERS="TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256 \ TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384 \ TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384 \ @@ -461,31 +391,25 @@ add_openssl_ciphersuites() TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256 \ TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256 \ " - O_CIPHERS="$O_CIPHERS \ - ECDH-ECDSA-AES128-SHA256 \ - ECDH-ECDSA-AES256-SHA384 \ - ECDH-ECDSA-AES128-GCM-SHA256 \ - ECDH-ECDSA-AES256-GCM-SHA384 \ - ECDHE-ECDSA-ARIA256-GCM-SHA384 \ - ECDHE-ECDSA-ARIA128-GCM-SHA256 \ - ECDHE-ECDSA-CHACHA20-POLY1305 \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" fi ;; "RSA") - M_CIPHERS="$M_CIPHERS \ - TLS-RSA-WITH-DES-CBC-SHA \ + CIPHERS="TLS-RSA-WITH-DES-CBC-SHA \ TLS-DHE-RSA-WITH-DES-CBC-SHA \ " - O_CIPHERS="$O_CIPHERS \ - DES-CBC-SHA \ - EDH-RSA-DES-CBC-SHA \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" + if [ `minor_ver "$MODE"` -ge 3 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384 \ + CIPHERS="TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384 \ TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384 \ TLS-RSA-WITH-ARIA-256-GCM-SHA384 \ TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256 \ @@ -494,24 +418,17 @@ add_openssl_ciphersuites() TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256 \ TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256 \ " - O_CIPHERS="$O_CIPHERS \ - ECDHE-ARIA256-GCM-SHA384 \ - DHE-RSA-ARIA256-GCM-SHA384 \ - ARIA256-GCM-SHA384 \ - ECDHE-ARIA128-GCM-SHA256 \ - DHE-RSA-ARIA128-GCM-SHA256 \ - ARIA128-GCM-SHA256 \ - DHE-RSA-CHACHA20-POLY1305 \ - ECDHE-RSA-CHACHA20-POLY1305 \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" fi ;; "PSK") if [ `minor_ver "$MODE"` -ge 3 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384 \ + CIPHERS="TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384 \ TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256 \ TLS-PSK-WITH-ARIA-256-GCM-SHA384 \ TLS-PSK-WITH-ARIA-128-GCM-SHA256 \ @@ -519,15 +436,10 @@ add_openssl_ciphersuites() TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256 \ TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256 \ " - O_CIPHERS="$O_CIPHERS \ - DHE-PSK-ARIA256-GCM-SHA384 \ - DHE-PSK-ARIA128-GCM-SHA256 \ - PSK-ARIA256-GCM-SHA384 \ - PSK-ARIA128-GCM-SHA256 \ - DHE-PSK-CHACHA20-POLY1305 \ - ECDHE-PSK-CHACHA20-POLY1305 \ - PSK-CHACHA20-POLY1305 \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" fi ;; esac @@ -543,43 +455,34 @@ add_gnutls_ciphersuites() "ECDSA") if [ `minor_ver "$MODE"` -ge 3 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256 \ - TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384 \ - TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256 \ - TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384 \ - TLS-ECDHE-ECDSA-WITH-AES-128-CCM \ - TLS-ECDHE-ECDSA-WITH-AES-256-CCM \ - TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \ - TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8 \ - " - G_CIPHERS="$G_CIPHERS \ - +ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256 \ - +ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384 \ - +ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD \ - +ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD \ - +ECDHE-ECDSA:+AES-128-CCM:+AEAD \ - +ECDHE-ECDSA:+AES-256-CCM:+AEAD \ - +ECDHE-ECDSA:+AES-128-CCM-8:+AEAD \ - +ECDHE-ECDSA:+AES-256-CCM-8:+AEAD \ + CIPHERS="TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256 \ + TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384 \ + TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256 \ + TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384 \ + TLS-ECDHE-ECDSA-WITH-AES-128-CCM \ + TLS-ECDHE-ECDSA-WITH-AES-256-CCM \ + TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \ + TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8 \ " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" fi ;; "RSA") if [ `minor_ver "$MODE"` -gt 0 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-RSA-WITH-NULL-SHA256 \ - " - G_CIPHERS="$G_CIPHERS \ - +RSA:+NULL:+SHA256 \ - " + CIPHERS="TLS-RSA-WITH-NULL-SHA256" + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" fi if [ `minor_ver "$MODE"` -ge 3 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ + CIPHERS="TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384 \ TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256 \ @@ -600,65 +503,41 @@ add_gnutls_ciphersuites() TLS-DHE-RSA-WITH-AES-128-CCM-8 \ TLS-DHE-RSA-WITH-AES-256-CCM-8 \ " - G_CIPHERS="$G_CIPHERS \ - +ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256 \ - +ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384 \ - +RSA:+CAMELLIA-128-CBC:+SHA256 \ - +RSA:+CAMELLIA-256-CBC:+SHA256 \ - +DHE-RSA:+CAMELLIA-128-CBC:+SHA256 \ - +DHE-RSA:+CAMELLIA-256-CBC:+SHA256 \ - +ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD \ - +ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD \ - +DHE-RSA:+CAMELLIA-128-GCM:+AEAD \ - +DHE-RSA:+CAMELLIA-256-GCM:+AEAD \ - +RSA:+CAMELLIA-128-GCM:+AEAD \ - +RSA:+CAMELLIA-256-GCM:+AEAD \ - +RSA:+AES-128-CCM:+AEAD \ - +RSA:+AES-256-CCM:+AEAD \ - +RSA:+AES-128-CCM-8:+AEAD \ - +RSA:+AES-256-CCM-8:+AEAD \ - +DHE-RSA:+AES-128-CCM:+AEAD \ - +DHE-RSA:+AES-256-CCM:+AEAD \ - +DHE-RSA:+AES-128-CCM-8:+AEAD \ - +DHE-RSA:+AES-256-CCM-8:+AEAD \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" fi ;; "PSK") - M_CIPHERS="$M_CIPHERS \ - TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA \ + CIPHERS="TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA \ TLS-DHE-PSK-WITH-AES-128-CBC-SHA \ TLS-DHE-PSK-WITH-AES-256-CBC-SHA \ " - G_CIPHERS="$G_CIPHERS \ - +DHE-PSK:+3DES-CBC:+SHA1 \ - +DHE-PSK:+AES-128-CBC:+SHA1 \ - +DHE-PSK:+AES-256-CBC:+SHA1 \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + if [ `minor_ver "$MODE"` -gt 0 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA \ + CIPHERS="TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA \ TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA \ TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA \ TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA \ TLS-RSA-PSK-WITH-AES-256-CBC-SHA \ TLS-RSA-PSK-WITH-AES-128-CBC-SHA \ " - G_CIPHERS="$G_CIPHERS \ - +ECDHE-PSK:+3DES-CBC:+SHA1 \ - +ECDHE-PSK:+AES-128-CBC:+SHA1 \ - +ECDHE-PSK:+AES-256-CBC:+SHA1 \ - +RSA-PSK:+3DES-CBC:+SHA1 \ - +RSA-PSK:+AES-256-CBC:+SHA1 \ - +RSA-PSK:+AES-128-CBC:+SHA1 \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + fi if [ `minor_ver "$MODE"` -ge 3 ] then - M_CIPHERS="$M_CIPHERS \ - TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \ + CIPHERS="TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \ TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384 \ TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \ TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256 \ @@ -703,52 +582,10 @@ add_gnutls_ciphersuites() TLS-RSA-PSK-WITH-AES-256-GCM-SHA384 \ TLS-RSA-PSK-WITH-AES-128-GCM-SHA256 \ " - G_CIPHERS="$G_CIPHERS \ - +ECDHE-PSK:+AES-256-CBC:+SHA384 \ - +ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384 \ - +ECDHE-PSK:+AES-128-CBC:+SHA256 \ - +ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256 \ - +PSK:+AES-128-CBC:+SHA256 \ - +PSK:+AES-256-CBC:+SHA384 \ - +DHE-PSK:+AES-128-CBC:+SHA256 \ - +DHE-PSK:+AES-256-CBC:+SHA384 \ - +RSA-PSK:+AES-256-CBC:+SHA384 \ - +RSA-PSK:+AES-128-CBC:+SHA256 \ - +DHE-PSK:+CAMELLIA-128-CBC:+SHA256 \ - +DHE-PSK:+CAMELLIA-256-CBC:+SHA384 \ - +PSK:+CAMELLIA-128-CBC:+SHA256 \ - +PSK:+CAMELLIA-256-CBC:+SHA384 \ - +RSA-PSK:+CAMELLIA-256-CBC:+SHA384 \ - +RSA-PSK:+CAMELLIA-128-CBC:+SHA256 \ - +PSK:+AES-128-GCM:+AEAD \ - +PSK:+AES-256-GCM:+AEAD \ - +DHE-PSK:+AES-128-GCM:+AEAD \ - +DHE-PSK:+AES-256-GCM:+AEAD \ - +PSK:+AES-128-CCM:+AEAD \ - +PSK:+AES-256-CCM:+AEAD \ - +DHE-PSK:+AES-128-CCM:+AEAD \ - +DHE-PSK:+AES-256-CCM:+AEAD \ - +PSK:+AES-128-CCM-8:+AEAD \ - +PSK:+AES-256-CCM-8:+AEAD \ - +DHE-PSK:+AES-128-CCM-8:+AEAD \ - +DHE-PSK:+AES-256-CCM-8:+AEAD \ - +RSA-PSK:+CAMELLIA-128-GCM:+AEAD \ - +RSA-PSK:+CAMELLIA-256-GCM:+AEAD \ - +PSK:+CAMELLIA-128-GCM:+AEAD \ - +PSK:+CAMELLIA-256-GCM:+AEAD \ - +DHE-PSK:+CAMELLIA-128-GCM:+AEAD \ - +DHE-PSK:+CAMELLIA-256-GCM:+AEAD \ - +RSA-PSK:+AES-256-GCM:+AEAD \ - +RSA-PSK:+AES-128-GCM:+AEAD \ - +ECDHE-PSK:+NULL:+SHA384 \ - +ECDHE-PSK:+NULL:+SHA256 \ - +PSK:+NULL:+SHA256 \ - +PSK:+NULL:+SHA384 \ - +DHE-PSK:+NULL:+SHA256 \ - +DHE-PSK:+NULL:+SHA384 \ - +RSA-PSK:+NULL:+SHA256 \ - +RSA-PSK:+NULL:+SHA384 \ - " + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" fi ;; esac diff --git a/tests/test_translate_format.sh b/tests/test_translate_format.sh index 55d8a8a8e8..241db47398 100755 --- a/tests/test_translate_format.sh +++ b/tests/test_translate_format.sh @@ -46,16 +46,13 @@ CIPHERS="TLS-ECDHE-ECDSA-WITH-NULL-SHA \ TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ " -M_CIPHERS="$M_CIPHERS \ - $CIPHERS" +M_CIPHERS="$M_CIPHERS $CIPHERS" G=`python3 translate_ciphers.py g "$CIPHERS"` -G_CIPHERS="$G_CIPHERS \ - $G" +G_CIPHERS="$G_CIPHERS $G" O=`python3 translate_ciphers.py o "$CIPHERS"` -O_CIPHERS="$O_CIPHERS \ - $O" +O_CIPHERS="$O_CIPHERS $O" Mt_CIPHERS="$Mt_CIPHERS \ TLS-ECDHE-ECDSA-WITH-NULL-SHA \ @@ -84,16 +81,13 @@ CIPHERS="TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ " -M_CIPHERS="$M_CIPHERS \ - $CIPHERS" +M_CIPHERS="$M_CIPHERS $CIPHERS" G=`python3 translate_ciphers.py g "$CIPHERS"` -G_CIPHERS="$G_CIPHERS \ - $G" +G_CIPHERS="$G_CIPHERS $G" O=`python3 translate_ciphers.py o "$CIPHERS"` -O_CIPHERS="$O_CIPHERS \ - $O" +O_CIPHERS="$O_CIPHERS $O" Mt_CIPHERS="$Mt_CIPHERS \ TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ From d16d273a40a87838fa53d994905b5c86f67cd9e5 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Mon, 26 Jul 2021 13:33:35 +0100 Subject: [PATCH 388/966] Compact 2 format functions to 1 In translate_ciphers.py there were 2 format functions that were virtually identical and a check was made beforehand to decide which one to call. Now the check is made inside a single function to reduce duplicate code Signed-off-by: Joe Subbiani --- tests/translate_ciphers.py | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/tests/translate_ciphers.py b/tests/translate_ciphers.py index 07affb290d..d6b604dd3d 100755 --- a/tests/translate_ciphers.py +++ b/tests/translate_ciphers.py @@ -97,33 +97,23 @@ def translate_ossl(m_cipher): return m_cipher -def format_g(m_ciphers): - #ciphers = (re.findall(r"TLS-.+\s*\\", m_ciphers)) - m_ciphers = m_ciphers.split() - g_ciphers = [] - for i in m_ciphers: - g_ciphers.append(translate_gnu(i)) - return " ".join(g_ciphers) - -def format_o(m_ciphers): - m_ciphers = m_ciphers.split() - o_ciphers = [] - for i in m_ciphers: - o_ciphers.append(translate_ossl(i)) - return " ".join(o_ciphers) +def format(mode, ciphers): + ciphers = ciphers.split() + t_ciphers = [] + if mode == "g": + for i in ciphers: + t_ciphers.append(translate_gnu(i)) + if mode == "o": + for i in ciphers: + t_ciphers.append(translate_ossl(i)) + return " ".join(t_ciphers) def main(): # print command line arguments if len(sys.argv) <= 2: exit(1) - if sys.argv[1] == "g": - print(format_g(sys.argv[2])) - exit(0) - elif sys.argv[1] == "o": - print(format_o(sys.argv[2])) - exit(0) else: - exit(1) + print(format(sys.argv[1], sys.argv[2])) if __name__ == "__main__": main() From 34d62620fb1d915c99e16e3f780a3c1f69647a5f Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Tue, 27 Jul 2021 14:55:56 +0100 Subject: [PATCH 389/966] Reduce calls to translate_ciphers.py in compat.sh After every edge case to append which ciphers were being used a call to translate_ciphers.py was being made. Now a call to translate_ciphers are made at the end of every function where ciphersuite names are being added. This occurs 3 times. 1 for MBedTLS, GNUTLS and OpenSSL. 1 for MBedTLS and OpenSSL and another 1 for MBedTLS and GNUTLS. Signed-off-by: Joe Subbiani --- tests/compat.sh | 166 +++++++++++++++++------------------------------- 1 file changed, 57 insertions(+), 109 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index 04b4dd521c..8e0988e998 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -241,43 +241,33 @@ reset_ciphersuites() # three times: in each peer's list (with the name that this peer uses). add_common_ciphersuites() { + CIPHERS="" case $TYPE in "ECDSA") if [ `minor_ver "$MODE"` -gt 0 ] then - CIPHERS="TLS-ECDHE-ECDSA-WITH-NULL-SHA \ + CIPHERS="$CIPHERS \ + TLS-ECDHE-ECDSA-WITH-NULL-SHA \ TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" fi if [ `minor_ver "$MODE"` -ge 3 ] then - CIPHERS="TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ + CIPHERS="$CIPHERS \ + TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" fi ;; "RSA") - CIPHERS="TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ + CIPHERS="$CIPHERS \ + TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ TLS-DHE-RSA-WITH-AES-256-CBC-SHA \ TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA \ TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA \ @@ -290,32 +280,19 @@ add_common_ciphersuites() TLS-RSA-WITH-NULL-MD5 \ TLS-RSA-WITH-NULL-SHA \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" - if [ `minor_ver "$MODE"` -gt 0 ] then - CIPHERS="TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA \ + CIPHERS="$CIPHERS \ + TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA \ TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA \ TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA \ TLS-ECDHE-RSA-WITH-NULL-SHA \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" fi if [ `minor_ver "$MODE"` -ge 3 ] then - CIPHERS="TLS-RSA-WITH-AES-128-CBC-SHA256 \ + CIPHERS="$CIPHERS \ + TLS-RSA-WITH-AES-128-CBC-SHA256 \ TLS-DHE-RSA-WITH-AES-128-CBC-SHA256 \ TLS-RSA-WITH-AES-256-CBC-SHA256 \ TLS-DHE-RSA-WITH-AES-256-CBC-SHA256 \ @@ -328,30 +305,26 @@ add_common_ciphersuites() TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384 \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS NULL-SHA256 $O" + O_CIPHERS="$O_CIPHERS NULL-SHA256" fi ;; "PSK") - CIPHERS="TLS-PSK-WITH-3DES-EDE-CBC-SH \ + CIPHERS="$CIPHERS \ + TLS-PSK-WITH-3DES-EDE-CBC-SHA \ TLS-PSK-WITH-AES-128-CBC-SHA \ TLS-PSK-WITH-AES-256-CBC-SHA \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" ;; esac + + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" } # Ciphersuites usable only with Mbed TLS and OpenSSL @@ -366,24 +339,23 @@ add_common_ciphersuites() # GnuTLS in 3.5.0 and the CI only has 3.4.x so far. add_openssl_ciphersuites() { + CIPHERS="" case $TYPE in "ECDSA") if [ `minor_ver "$MODE"` -gt 0 ] then - CIPHERS="TLS-ECDH-ECDSA-WITH-NULL-SHA \ + CIPHERS="$CIPHERS \ + TLS-ECDH-ECDSA-WITH-NULL-SHA \ TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA \ TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA \ TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" fi if [ `minor_ver "$MODE"` -ge 3 ] then - CIPHERS="TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256 \ + CIPHERS="$CIPHERS \ + TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256 \ TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384 \ TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384 \ @@ -391,25 +363,18 @@ add_openssl_ciphersuites() TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256 \ TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256 \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" fi ;; "RSA") - CIPHERS="TLS-RSA-WITH-DES-CBC-SHA \ + CIPHERS="$CIPHERS \ + TLS-RSA-WITH-DES-CBC-SHA \ TLS-DHE-RSA-WITH-DES-CBC-SHA \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" - if [ `minor_ver "$MODE"` -ge 3 ] then - CIPHERS="TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384 \ + CIPHERS="$CIPHERS \ + TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384 \ TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384 \ TLS-RSA-WITH-ARIA-256-GCM-SHA384 \ TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256 \ @@ -418,17 +383,14 @@ add_openssl_ciphersuites() TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256 \ TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256 \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" fi ;; "PSK") if [ `minor_ver "$MODE"` -ge 3 ] then - CIPHERS="TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384 \ + CIPHERS="$CIPHERS \ + TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384 \ TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256 \ TLS-PSK-WITH-ARIA-256-GCM-SHA384 \ TLS-PSK-WITH-ARIA-128-GCM-SHA256 \ @@ -436,13 +398,14 @@ add_openssl_ciphersuites() TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256 \ TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256 \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - O=`python3 translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" fi ;; esac + + M_CIPHERS="$M_CIPHERS $CIPHERS" + + O=`python3 translate_ciphers.py o "$CIPHERS"` + O_CIPHERS="$O_CIPHERS $O" } # Ciphersuites usable only with Mbed TLS and GnuTLS @@ -450,12 +413,14 @@ add_openssl_ciphersuites() # with its Mbed TLS name. add_gnutls_ciphersuites() { + CIPHERS="" case $TYPE in "ECDSA") if [ `minor_ver "$MODE"` -ge 3 ] then - CIPHERS="TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256 \ + CIPHERS="$CIPHERS \ + TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256 \ TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384 \ TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256 \ TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384 \ @@ -464,25 +429,18 @@ add_gnutls_ciphersuites() TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \ TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8 \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" fi ;; "RSA") if [ `minor_ver "$MODE"` -gt 0 ] then - CIPHERS="TLS-RSA-WITH-NULL-SHA256" - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" + CIPHERS="$CIPHERS TLS-RSA-WITH-NULL-SHA256" fi if [ `minor_ver "$MODE"` -ge 3 ] then - CIPHERS="TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ + CIPHERS="$CIPHERS \ + TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384 \ TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256 \ @@ -503,41 +461,30 @@ add_gnutls_ciphersuites() TLS-DHE-RSA-WITH-AES-128-CCM-8 \ TLS-DHE-RSA-WITH-AES-256-CCM-8 \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" fi ;; "PSK") - CIPHERS="TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA \ - TLS-DHE-PSK-WITH-AES-128-CBC-SHA \ - TLS-DHE-PSK-WITH-AES-256-CBC-SHA \ + CIPHERS="$CIPHERS \ + TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA \ + TLS-DHE-PSK-WITH-AES-128-CBC-SHA \ + TLS-DHE-PSK-WITH-AES-256-CBC-SHA \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" - if [ `minor_ver "$MODE"` -gt 0 ] then - CIPHERS="TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA \ + CIPHERS="$CIPHERS \ + TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA \ TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA \ TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA \ TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA \ TLS-RSA-PSK-WITH-AES-256-CBC-SHA \ TLS-RSA-PSK-WITH-AES-128-CBC-SHA \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" - fi if [ `minor_ver "$MODE"` -ge 3 ] then - CIPHERS="TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \ + CIPHERS="$CIPHERS \ + TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \ TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384 \ TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \ TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256 \ @@ -582,13 +529,14 @@ add_gnutls_ciphersuites() TLS-RSA-PSK-WITH-AES-256-GCM-SHA384 \ TLS-RSA-PSK-WITH-AES-128-GCM-SHA256 \ " - M_CIPHERS="$M_CIPHERS $CIPHERS" - - G=`python3 translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" fi ;; esac + + M_CIPHERS="$M_CIPHERS $CIPHERS" + + G=`python3 translate_ciphers.py g "$CIPHERS"` + G_CIPHERS="$G_CIPHERS $G" } # Ciphersuites usable only with Mbed TLS (not currently supported by another From 0fadf8ef7dd25f7aee9df0db09bf6d52a7b3b20b Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Tue, 27 Jul 2021 15:22:26 +0100 Subject: [PATCH 390/966] Improve coding style and consistancy - Replace uses of mbed and gnu with mbedtls and gnutls respectivley. - Uses sys.exit() rather than exit() - Rename format() as it is an inbuilt python function - Add error information if incorrect arguments are passsed to translate_ciphers.py Signed-off-by: Joe Subbiani --- ...at.sh => test_translate_ciphers_format.sh} | 8 ++-- ...mes.py => test_translate_ciphers_names.py} | 19 +++----- tests/translate_ciphers.py | 48 ++++++++++++------- 3 files changed, 41 insertions(+), 34 deletions(-) rename tests/{test_translate_format.sh => test_translate_ciphers_format.sh} (96%) rename tests/{test_translate_names.py => test_translate_ciphers_names.py} (97%) diff --git a/tests/test_translate_format.sh b/tests/test_translate_ciphers_format.sh similarity index 96% rename from tests/test_translate_format.sh rename to tests/test_translate_ciphers_format.sh index 241db47398..9b3b4bb823 100755 --- a/tests/test_translate_format.sh +++ b/tests/test_translate_ciphers_format.sh @@ -121,13 +121,13 @@ Ot_CIPHERS=$( echo "$Ot_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/ # Upon fail, print them to view the differences if [ "$Mt_CIPHERS" != "$M_CIPHERS" ] then - echo "MBED Translated: $M_CIPHERS" - echo "MBED Original: $Mt_CIPHERS" + echo "MBEDTLS Translated: $M_CIPHERS" + echo "MBEDTLS Original: $Mt_CIPHERS" fi if [ "$Gt_CIPHERS" != "$G_CIPHERS" ] then - echo "GNU Translated: $G_CIPHERS" - echo "GNU Original: $Gt_CIPHERS" + echo "GNUTLS Translated: $G_CIPHERS" + echo "GNUTLS Original: $Gt_CIPHERS" fi if [ "$Ot_CIPHERS" != "$O_CIPHERS" ] then diff --git a/tests/test_translate_names.py b/tests/test_translate_ciphers_names.py similarity index 97% rename from tests/test_translate_names.py rename to tests/test_translate_ciphers_names.py index d018c10916..70b2a8fc7d 100755 --- a/tests/test_translate_names.py +++ b/tests/test_translate_ciphers_names.py @@ -21,7 +21,7 @@ # # Test translate_ciphers.py by running every MBedTLS ciphersuite name # combination through the translate functions and comparing them to their -# correct GNU or OpenSSL counterpart. +# correct GNUTLS or OpenSSL counterpart. from translate_ciphers import * @@ -170,21 +170,17 @@ def test_all_common(): "PSK-3DES-EDE-CBC-SHA", "PSK-AES128-CBC-SHA", "PSK-AES256-CBC-SHA", - - #"PSK-DES-CBC3-SHA", - #"PSK-AES128-SHA", - #"PSK-AES256-SHA", ] for i in range(len(m_ciphers)): - g = translate_gnu(m_ciphers[i]) + g = translate_gnutls(m_ciphers[i]) assert_equal(g, g_ciphers[i]) o = translate_ossl(m_ciphers[i]) assert_equal(o, o_ciphers[i]) -def test_mbed_ossl_common(): +def test_mbedtls_ossl_common(): m_ciphers = [ "TLS-ECDH-ECDSA-WITH-NULL-SHA", "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", @@ -235,7 +231,6 @@ def test_mbed_ossl_common(): "DES-CBC-SHA", "EDH-RSA-DES-CBC-SHA", - #"DHE-RSA-DES-CBC-SHA", "ECDHE-ARIA256-GCM-SHA384", "DHE-RSA-ARIA256-GCM-SHA384", @@ -260,7 +255,7 @@ def test_mbed_ossl_common(): o = translate_ossl(m_ciphers[i]) assert_equal(o, o_ciphers[i]) -def test_mbed_gnu_common(): +def test_mbedtls_gnutls_common(): m_ciphers = [ "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", @@ -442,9 +437,9 @@ def test_mbed_gnu_common(): for i in range(len(m_ciphers)): - g = translate_gnu(m_ciphers[i]) + g = translate_gnutls(m_ciphers[i]) assert_equal(g, g_ciphers[i]) test_all_common() -test_mbed_ossl_common() -test_mbed_gnu_common() +test_mbedtls_ossl_common() +test_mbedtls_gnutls_common() diff --git a/tests/translate_ciphers.py b/tests/translate_ciphers.py index d6b604dd3d..0f76cf5083 100755 --- a/tests/translate_ciphers.py +++ b/tests/translate_ciphers.py @@ -19,20 +19,20 @@ # # Purpose # -# Translate ciphersuite names in MBedTLS format to OpenSSL and GNU +# Translate ciphersuite names in MBedTLS format to OpenSSL and GNUTLS # standards. # # Format and analyse strings past in via input arguments to match # the expected strings utilised in compat.sh. # -# sys.argv[1] should be "g" or "o" for GNU or OpenSSL. +# sys.argv[1] should be "g" or "o" for GNUTLS or OpenSSL. # sys.argv[2] should be a string containing one or more # ciphersuite names. import re import sys -def translate_gnu(m_cipher): +def translate_gnutls(m_cipher): # Remove "TLS-" # Replace "-WITH-" with ":+" # Remove "EDE" @@ -97,23 +97,35 @@ def translate_ossl(m_cipher): return m_cipher -def format(mode, ciphers): - ciphers = ciphers.split() - t_ciphers = [] - if mode == "g": - for i in ciphers: - t_ciphers.append(translate_gnu(i)) - if mode == "o": - for i in ciphers: - t_ciphers.append(translate_ossl(i)) - return " ".join(t_ciphers) +def format_ciphersuite_names(mode, ciphers): + #ciphers = ciphers.split() + #t_ciphers = [] + #if mode == "g": + # for i in ciphers: + # t_ciphers.append(translate_gnutls(i)) + #elif mode == "o": + # for i in ciphers: + # t_ciphers.append(translate_ossl(i)) + #else: + # print("Incorrect use of argument 1, should be either \"g\" or \"o\"") + # exit(1) + #return " ".join(t_ciphers) + try: + t = {"g": translate_gnutls, "o": translate_ossl}[mode] + return " ".join(t(c) for c in ciphers.split()) + except Exception as E: + if E != mode: print(E) + else: print("Incorrect use of argument 1, should be either \"g\" or \"o\"") + sys.exit(1) def main(): - # print command line arguments - if len(sys.argv) <= 2: - exit(1) - else: - print(format(sys.argv[1], sys.argv[2])) + if len(sys.argv) != 3: + print("""Incorrect number of arguments. +The first argument with either an \"o\" for OpenSSL or \"g\" for GNUTLS. +The second argument should a single space seperated string of MBedTLS ciphersuite names""") + sys.exit(1) + print(format_ciphersuite_names(sys.argv[1], sys.argv[2])) + sys.exit(0) if __name__ == "__main__": main() From 6452f1ee35cc19d964390021c8ca71df14143360 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Tue, 27 Jul 2021 15:28:07 +0100 Subject: [PATCH 391/966] Modify file name comments to match the file rename Signed-off-by: Joe Subbiani --- tests/test_translate_ciphers_format.sh | 2 +- tests/test_translate_ciphers_names.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_translate_ciphers_format.sh b/tests/test_translate_ciphers_format.sh index 9b3b4bb823..97a6c23c70 100755 --- a/tests/test_translate_ciphers_format.sh +++ b/tests/test_translate_ciphers_format.sh @@ -1,6 +1,6 @@ #!/bin/sh -# test_translate_format.sh +# test_translate_ciphers_format.sh # # Copyright The Mbed TLS Contributors # SPDX-License-Identifier: Apache-2.0 diff --git a/tests/test_translate_ciphers_names.py b/tests/test_translate_ciphers_names.py index 70b2a8fc7d..f6cfa6db5a 100755 --- a/tests/test_translate_ciphers_names.py +++ b/tests/test_translate_ciphers_names.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# test_translate_names.py +# test_translate_ciphers_names.py # # Copyright The Mbed TLS Contributors # SPDX-License-Identifier: Apache-2.0 From a032963d65f025205cc72406e8b813021e8e18d6 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Tue, 27 Jul 2021 15:40:12 +0100 Subject: [PATCH 392/966] Modify comment descriptions of add_xxx_ciphersuites() Modify the comments to include the use of the translate function and retire the explanation of maintaining 2 seperate lists Signed-off-by: Joe Subbiani --- tests/compat.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index 8e0988e998..ffad4ec4f8 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -328,8 +328,10 @@ add_common_ciphersuites() } # Ciphersuites usable only with Mbed TLS and OpenSSL -# Each ciphersuite should appear two times, once with its OpenSSL name, once -# with its Mbed TLS name. +# Each ciphersuite is compiled case by case in the MBedTLS standard, and +# is appended to the list of MBedTLS ciphersuites $M_CIPHERS. The same list +# is translated to the OpenSSL naming standard and appended to the list of +# OpenSSL ciphersuites $O_CIPHERS # # NOTE: for some reason RSA-PSK doesn't work with OpenSSL, # so RSA-PSK ciphersuites need to go in other sections, see @@ -409,8 +411,10 @@ add_openssl_ciphersuites() } # Ciphersuites usable only with Mbed TLS and GnuTLS -# Each ciphersuite should appear two times, once with its GnuTLS name, once -# with its Mbed TLS name. +# Each ciphersuite is compiled case by case in the MBedTLS standard, and +# is appended to the list of MBedTLS ciphersuites $M_CIPHERS. The same list +# is translated to the GnuTLS naming standard and appended to the list of +# GnuTLS ciphersuites $G_CIPHERS add_gnutls_ciphersuites() { CIPHERS="" From 43592bd1f9c708a38b95a3bbf62ffb825304d7e9 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Tue, 27 Jul 2021 16:32:21 +0100 Subject: [PATCH 393/966] Remove trailing whitespaces Signed-off-by: Joe Subbiani --- tests/compat.sh | 6 +++--- tests/translate_ciphers.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index ffad4ec4f8..391a1e045d 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -330,7 +330,7 @@ add_common_ciphersuites() # Ciphersuites usable only with Mbed TLS and OpenSSL # Each ciphersuite is compiled case by case in the MBedTLS standard, and # is appended to the list of MBedTLS ciphersuites $M_CIPHERS. The same list -# is translated to the OpenSSL naming standard and appended to the list of +# is translated to the OpenSSL naming standard and appended to the list of # OpenSSL ciphersuites $O_CIPHERS # # NOTE: for some reason RSA-PSK doesn't work with OpenSSL, @@ -413,7 +413,7 @@ add_openssl_ciphersuites() # Ciphersuites usable only with Mbed TLS and GnuTLS # Each ciphersuite is compiled case by case in the MBedTLS standard, and # is appended to the list of MBedTLS ciphersuites $M_CIPHERS. The same list -# is translated to the GnuTLS naming standard and appended to the list of +# is translated to the GnuTLS naming standard and appended to the list of # GnuTLS ciphersuites $G_CIPHERS add_gnutls_ciphersuites() { @@ -536,7 +536,7 @@ add_gnutls_ciphersuites() fi ;; esac - + M_CIPHERS="$M_CIPHERS $CIPHERS" G=`python3 translate_ciphers.py g "$CIPHERS"` diff --git a/tests/translate_ciphers.py b/tests/translate_ciphers.py index 0f76cf5083..5f9a5e384b 100755 --- a/tests/translate_ciphers.py +++ b/tests/translate_ciphers.py @@ -120,7 +120,7 @@ def format_ciphersuite_names(mode, ciphers): def main(): if len(sys.argv) != 3: - print("""Incorrect number of arguments. + print("""Incorrect number of arguments. The first argument with either an \"o\" for OpenSSL or \"g\" for GNUTLS. The second argument should a single space seperated string of MBedTLS ciphersuite names""") sys.exit(1) From 4a703cef899ab5a644a6b19993fdedc02f315dc8 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 28 Jul 2021 09:59:25 +0100 Subject: [PATCH 394/966] Remove commented out old code When making a modified function I commented out the previous code in case I needed to use some of it, and forgot to remove it. This has now been resolved Signed-off-by: Joe Subbiani --- tests/translate_ciphers.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/translate_ciphers.py b/tests/translate_ciphers.py index 5f9a5e384b..2f1543c045 100755 --- a/tests/translate_ciphers.py +++ b/tests/translate_ciphers.py @@ -98,18 +98,6 @@ def translate_ossl(m_cipher): return m_cipher def format_ciphersuite_names(mode, ciphers): - #ciphers = ciphers.split() - #t_ciphers = [] - #if mode == "g": - # for i in ciphers: - # t_ciphers.append(translate_gnutls(i)) - #elif mode == "o": - # for i in ciphers: - # t_ciphers.append(translate_ossl(i)) - #else: - # print("Incorrect use of argument 1, should be either \"g\" or \"o\"") - # exit(1) - #return " ".join(t_ciphers) try: t = {"g": translate_gnutls, "o": translate_ossl}[mode] return " ".join(t(c) for c in ciphers.split()) From f3fcc29eb159152dc05fbe40bd5d47f0ccbac042 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 28 Jul 2021 15:51:02 +0100 Subject: [PATCH 395/966] Move translate scripts to appropriate folder "tests/scripts/*.py is executable programs used only for testing" Signed-off-by: Joe Subbiani --- tests/compat.sh | 8 ++++---- tests/{ => scripts}/test_translate_ciphers_format.sh | 0 tests/{ => scripts}/test_translate_ciphers_names.py | 0 tests/{ => scripts}/translate_ciphers.py | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename tests/{ => scripts}/test_translate_ciphers_format.sh (100%) rename tests/{ => scripts}/test_translate_ciphers_names.py (100%) rename tests/{ => scripts}/translate_ciphers.py (100%) diff --git a/tests/compat.sh b/tests/compat.sh index 391a1e045d..e814e9db16 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -320,10 +320,10 @@ add_common_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - G=`python3 translate_ciphers.py g "$CIPHERS"` + G=`python3 scripts/translate_ciphers.py g "$CIPHERS"` G_CIPHERS="$G_CIPHERS $G" - O=`python3 translate_ciphers.py o "$CIPHERS"` + O=`python3 scripts/translate_ciphers.py o "$CIPHERS"` O_CIPHERS="$O_CIPHERS $O" } @@ -406,7 +406,7 @@ add_openssl_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - O=`python3 translate_ciphers.py o "$CIPHERS"` + O=`python3 scripts/translate_ciphers.py o "$CIPHERS"` O_CIPHERS="$O_CIPHERS $O" } @@ -539,7 +539,7 @@ add_gnutls_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - G=`python3 translate_ciphers.py g "$CIPHERS"` + G=`python3 scripts/translate_ciphers.py g "$CIPHERS"` G_CIPHERS="$G_CIPHERS $G" } diff --git a/tests/test_translate_ciphers_format.sh b/tests/scripts/test_translate_ciphers_format.sh similarity index 100% rename from tests/test_translate_ciphers_format.sh rename to tests/scripts/test_translate_ciphers_format.sh diff --git a/tests/test_translate_ciphers_names.py b/tests/scripts/test_translate_ciphers_names.py similarity index 100% rename from tests/test_translate_ciphers_names.py rename to tests/scripts/test_translate_ciphers_names.py diff --git a/tests/translate_ciphers.py b/tests/scripts/translate_ciphers.py similarity index 100% rename from tests/translate_ciphers.py rename to tests/scripts/translate_ciphers.py From f849a93d94e1f9d0122352598c0f6f47be532a85 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 28 Jul 2021 16:50:30 +0100 Subject: [PATCH 396/966] Improve python coding style As per check-python-files.sh, added string documentation for files and functions. Modified for loops to use enumerate rather than range(len( although as the same iteration index is used for multiple lists it does not seem quite appropriate Signed-off-by: Joe Subbiani --- tests/scripts/test_translate_ciphers_names.py | 49 +++++++++++++------ tests/scripts/translate_ciphers.py | 43 +++++++++------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/tests/scripts/test_translate_ciphers_names.py b/tests/scripts/test_translate_ciphers_names.py index f6cfa6db5a..c40d376974 100755 --- a/tests/scripts/test_translate_ciphers_names.py +++ b/tests/scripts/test_translate_ciphers_names.py @@ -17,21 +17,32 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Purpose -# -# Test translate_ciphers.py by running every MBedTLS ciphersuite name -# combination through the translate functions and comparing them to their -# correct GNUTLS or OpenSSL counterpart. -from translate_ciphers import * +""" +Test translate_ciphers.py by running every MBedTLS ciphersuite name +combination through the translate functions and comparing them to their +correct GNUTLS or OpenSSL counterpart. +""" + +from translate_ciphers import translate_gnutls, translate_ossl def assert_equal(translate, original): + """ + Compare the translated ciphersuite name against the original + On fail, print the mismatch on the screen to directly compare the + differences + """ try: - assert(translate == original) + assert translate == original except AssertionError: print("%s\n%s\n" %(translate, original)) def test_all_common(): + """ + Translate the MBedTLS ciphersuite names to the common OpenSSL and + GnuTLS ciphersite names, and compare them with the true, expected + corresponding OpenSSL and GnuTLS ciphersuite names + """ m_ciphers = [ "TLS-ECDHE-ECDSA-WITH-NULL-SHA", "TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", @@ -172,15 +183,20 @@ def test_all_common(): "PSK-AES256-CBC-SHA", ] - for i in range(len(m_ciphers)): + for i, m_cipher in enumerate(m_ciphers): - g = translate_gnutls(m_ciphers[i]) + g = translate_gnutls(m_cipher) assert_equal(g, g_ciphers[i]) - o = translate_ossl(m_ciphers[i]) + o = translate_ossl(m_cipher) assert_equal(o, o_ciphers[i]) def test_mbedtls_ossl_common(): + """ + Translate the MBedTLS ciphersuite names to the common OpenSSL + ciphersite names, and compare them with the true, expected + corresponding OpenSSL ciphersuite name + """ m_ciphers = [ "TLS-ECDH-ECDSA-WITH-NULL-SHA", "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", @@ -250,12 +266,17 @@ def test_mbedtls_ossl_common(): "DHE-PSK-CHACHA20-POLY1305", ] - for i in range(len(m_ciphers)): + for i, m_cipher in enumerate(m_ciphers): - o = translate_ossl(m_ciphers[i]) + o = translate_ossl(m_cipher) assert_equal(o, o_ciphers[i]) def test_mbedtls_gnutls_common(): + """ + Translate the MBedTLS ciphersuite names to the common GnuTLS + ciphersite names, and compare them with the true, expected + corresponding GnuTLS ciphersuite names + """ m_ciphers = [ "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", @@ -435,9 +456,9 @@ def test_mbedtls_gnutls_common(): "+RSA-PSK:+AES-128-GCM:+AEAD", ] - for i in range(len(m_ciphers)): + for i, m_ciphers in enumerate(m_ciphers): - g = translate_gnutls(m_ciphers[i]) + g = translate_gnutls(m_ciphers) assert_equal(g, g_ciphers[i]) test_all_common() diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index 2f1543c045..66c878ac39 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -16,23 +16,27 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# -# Purpose -# -# Translate ciphersuite names in MBedTLS format to OpenSSL and GNUTLS -# standards. -# -# Format and analyse strings past in via input arguments to match -# the expected strings utilised in compat.sh. -# -# sys.argv[1] should be "g" or "o" for GNUTLS or OpenSSL. -# sys.argv[2] should be a string containing one or more -# ciphersuite names. + +""" +Translate ciphersuite names in MBedTLS format to OpenSSL and GNUTLS +standards. + +Format and analyse strings past in via input arguments to match +the expected strings utilised in compat.sh. + +sys.argv[1] should be "g" or "o" for GNUTLS or OpenSSL. +sys.argv[2] should be a string containing one or more ciphersuite names. +""" import re import sys def translate_gnutls(m_cipher): + """ + Translate m_cipher from MBedTLS ciphersuite naming convention + and return the GnuTLS naming convention + """ + # Remove "TLS-" # Replace "-WITH-" with ":+" # Remove "EDE" @@ -51,13 +55,18 @@ def translate_gnutls(m_cipher): # Replace the last "-" with ":+" # Replace "GCM:+SHAxyz" with "GCM:+AEAD" else: - index=m_cipher.rindex("-") + index = m_cipher.rindex("-") m_cipher = m_cipher[:index]+":+"+m_cipher[index+1:] m_cipher = re.sub(r"GCM\:\+SHA\d\d\d", "GCM:+AEAD", m_cipher) return m_cipher def translate_ossl(m_cipher): + """ + Translate m_cipher from MBedTLS ciphersuite naming convention + and return the OpenSSL naming convention + """ + # Remove "TLS-" # Remove "WITH" m_cipher = m_cipher[4:] @@ -89,7 +98,7 @@ def translate_ossl(m_cipher): # POLY1305 should not be followed by anything if "POLY1305" in m_cipher: index = m_cipher.rindex("POLY1305") - m_cipher=m_cipher[:index+8] + m_cipher = m_cipher[:index+8] # If DES is being used, Replace DHE with EDH if "DES" in m_cipher and "DHE" in m_cipher and "ECDHE" not in m_cipher: @@ -101,9 +110,9 @@ def format_ciphersuite_names(mode, ciphers): try: t = {"g": translate_gnutls, "o": translate_ossl}[mode] return " ".join(t(c) for c in ciphers.split()) - except Exception as E: - if E != mode: print(E) - else: print("Incorrect use of argument 1, should be either \"g\" or \"o\"") + except (KeyError) as e: + print(e) + print("Incorrect use of argument 1, should be either \"g\" or \"o\"") sys.exit(1) def main(): From a56e10db4ccc2ce71a2b27b3ebd019a6f6503665 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 29 Jul 2021 10:01:26 +0100 Subject: [PATCH 397/966] Run test_translate_ciphers_format.sh from root Signed-off-by: Joe Subbiani --- tests/scripts/test_translate_ciphers_format.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/scripts/test_translate_ciphers_format.sh b/tests/scripts/test_translate_ciphers_format.sh index 97a6c23c70..6f1bdd08be 100755 --- a/tests/scripts/test_translate_ciphers_format.sh +++ b/tests/scripts/test_translate_ciphers_format.sh @@ -29,6 +29,11 @@ # This files main purpose is to ensure translate_ciphers.py can take strings # in the expected format and return them in the format compat.sh will expect. +if cd $( dirname $0 ); then :; else + echo "cd $( dirname $0 ) failed" >&2 + exit 1 +fi + # Ciphers that will use translate_ciphers.py M_CIPHERS="" O_CIPHERS="" From 3eac5b9c6ded3797c595d447ebd14ee74452c776 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 29 Jul 2021 10:07:05 +0100 Subject: [PATCH 398/966] Use zip rather than enumerate After improving coding style, pylint suggeted using enumerate but zip is more appropriate to avoid indexing Signed-off-by: Joe Subbiani --- tests/scripts/test_translate_ciphers_names.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/scripts/test_translate_ciphers_names.py b/tests/scripts/test_translate_ciphers_names.py index c40d376974..84bcc9931d 100755 --- a/tests/scripts/test_translate_ciphers_names.py +++ b/tests/scripts/test_translate_ciphers_names.py @@ -183,13 +183,13 @@ def test_all_common(): "PSK-AES256-CBC-SHA", ] - for i, m_cipher in enumerate(m_ciphers): + for m, g_exp, o_exp in zip(m_ciphers, g_ciphers, o_ciphers): - g = translate_gnutls(m_cipher) - assert_equal(g, g_ciphers[i]) + g = translate_gnutls(m) + assert_equal(g, g_exp) - o = translate_ossl(m_cipher) - assert_equal(o, o_ciphers[i]) + o = translate_ossl(m) + assert_equal(o, o_exp) def test_mbedtls_ossl_common(): """ @@ -266,10 +266,10 @@ def test_mbedtls_ossl_common(): "DHE-PSK-CHACHA20-POLY1305", ] - for i, m_cipher in enumerate(m_ciphers): + for m, o_exp in zip(m_ciphers, o_ciphers): - o = translate_ossl(m_cipher) - assert_equal(o, o_ciphers[i]) + o = translate_ossl(m) + assert_equal(o, o_exp) def test_mbedtls_gnutls_common(): """ @@ -456,10 +456,10 @@ def test_mbedtls_gnutls_common(): "+RSA-PSK:+AES-128-GCM:+AEAD", ] - for i, m_ciphers in enumerate(m_ciphers): + for m, g_exp in zip(m_ciphers, g_ciphers): - g = translate_gnutls(m_ciphers) - assert_equal(g, g_ciphers[i]) + g = translate_gnutls(m) + assert_equal(g, g_exp) test_all_common() test_mbedtls_ossl_common() From beb3f41f2f528277d86840ec7bdbefce8d7194cd Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 16 Aug 2021 15:00:55 +0800 Subject: [PATCH 399/966] Add handshake_set_state helper function Signed-off-by: Jerry Yu --- library/ssl_misc.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index b4f841a373..36754a3237 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1323,4 +1323,14 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf } #endif /* MBEDTLS_SSL_PROTO_TLS1_2 && MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL*/ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context* ssl, + int state ) +{ + ssl->state = state; +} + +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #endif /* ssl_misc.h */ From a13c7e739cf3200d4784e1fbbf1b0412d9aee467 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 17 Aug 2021 10:44:40 +0800 Subject: [PATCH 400/966] add dummy client hello process Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 3 +++ library/ssl_tls13_client.c | 51 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 2909dc8e5b..54be3a5b9f 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -573,6 +573,9 @@ typedef enum MBEDTLS_SSL_HANDSHAKE_OVER, MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET, MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT, +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + MBEDTLS_SSL_ENCRYPTED_EXTENSIONS, +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ } mbedtls_ssl_states; diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 368b5572db..d619d80ed9 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -26,11 +26,58 @@ #if defined(MBEDTLS_SSL_CLI_C) #include "ssl_misc.h" +#include + +static int ssl_client_hello_process( mbedtls_ssl_context* ssl ); int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) { - ((void) ssl); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + int ret = 0; + + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Handshake completed but ssl->handshake is NULL.\n" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); + + switch( ssl->state ) + { + case MBEDTLS_SSL_HELLO_REQUEST: + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_HELLO ); + break; + + case MBEDTLS_SSL_CLIENT_HELLO: + ret = ssl_client_hello_process( ssl ); + break; + + case MBEDTLS_SSL_SERVER_HELLO: + // Stop here : we haven't finished whole flow + ret=MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); + break; + + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + return( ret ); +} + +static int ssl_client_hello_process( mbedtls_ssl_context* ssl ) +{ + int ret = 0; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); + + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_HELLO ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write client hello" ) ); + /* client_hello_process haven't finished */ + ret=MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + return ret; } #endif /* MBEDTLS_SSL_CLI_C */ From 65dd2ccfe696d6cfaecfc376038db1d71dc1c28e Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 18 Aug 2021 16:38:40 +0800 Subject: [PATCH 401/966] Add dummy stages for `client_hello_process` Signed-off-by: Jerry Yu --- library/CMakeLists.txt | 1 + library/Makefile | 1 + library/ssl_misc.h | 37 ++++++++++++++++++++ library/ssl_tls13_client.c | 54 ++++++++++++++++++++++++++++++ library/ssl_tls13_generic.c | 67 +++++++++++++++++++++++++++++++++++++ 5 files changed, 160 insertions(+) create mode 100644 library/ssl_tls13_generic.c diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 5adc128c96..a5d692cbe4 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -106,6 +106,7 @@ set(src_tls ssl_tls13_keys.c ssl_tls13_server.c ssl_tls13_client.c + ssl_tls13_generic.c ) if(CMAKE_COMPILER_IS_GNUCC) diff --git a/library/Makefile b/library/Makefile index 8c58fb8501..13cd7db0c6 100644 --- a/library/Makefile +++ b/library/Makefile @@ -169,6 +169,7 @@ OBJS_TLS= \ ssl_tls13_keys.o \ ssl_tls13_client.o \ ssl_tls13_server.o \ + ssl_tls13_generic.o \ # This line is intentionally left blank .SILENT: diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 36754a3237..4c3f6c0d5e 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -26,6 +26,7 @@ #include "mbedtls/ssl.h" #include "mbedtls/cipher.h" +#include "mbedtls/debug.h" #if defined(MBEDTLS_USE_PSA_CRYPTO) #include "psa/crypto.h" @@ -102,6 +103,30 @@ #define MBEDTLS_SSL_RENEGOTIATION_DONE 2 /* Done or aborted */ #define MBEDTLS_SSL_RENEGOTIATION_PENDING 3 /* Requested (server only) */ +#define MBEDTLS_SSL_PROC_STRIP_PARENS( ... ) __VA_ARGS__ + +#define MBEDTLS_SSL_PROC_CHK( fn, args ) \ + do { \ + ret = fn(MBEDTLS_SSL_PROC_STRIP_PARENS args); \ + if( ret != 0 ) \ + { \ + if( ret > 0 ) \ + ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR; \ + MBEDTLS_SSL_DEBUG_RET( 1, #fn, ret ); \ + goto cleanup; \ + } \ + } while( 0 ) + +#define MBEDTLS_SSL_PROC_CHK_NEG( fn, args ) \ + do { \ + ret = fn(MBEDTLS_SSL_PROC_STRIP_PARENS args); \ + if( ret < 0 ) \ + { \ + MBEDTLS_SSL_DEBUG_RET( 1, #fn, ret ); \ + goto cleanup; \ + } \ + } while( 0 ) + /* * DTLS retransmission states, see RFC 6347 4.2.4 * @@ -1331,6 +1356,18 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context* ssl, ssl->state = state; } +int mbedtls_ssl_start_handshake_msg( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char **buf, + size_t *buflen ); +int mbedtls_ssl_finish_handshake_msg( mbedtls_ssl_context *ssl, + size_t buf_len, + size_t msg_len ); +void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, + unsigned hs_type, + size_t total_hs_len ); + + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* ssl_misc.h */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index d619d80ed9..46c071b6bb 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -28,6 +28,7 @@ #include "ssl_misc.h" #include +/* Main entry point; orchestrates the other functions */ static int ssl_client_hello_process( mbedtls_ssl_context* ssl ); int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) @@ -66,20 +67,73 @@ int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) return( ret ); } + +static int ssl_client_hello_prepare( mbedtls_ssl_context* ssl ); +static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, + unsigned char* buf, size_t buflen, + size_t* len_without_binders, + size_t* len_with_binders ); +static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ); + static int ssl_client_hello_process( mbedtls_ssl_context* ssl ) { int ret = 0; + unsigned char *buf; + size_t buf_len, msg_len; + size_t len_without_binders = 0; MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); + MBEDTLS_SSL_PROC_CHK( ssl_client_hello_prepare, ( ssl ) ); + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_start_handshake_msg, ( ssl, + MBEDTLS_SSL_HS_CLIENT_HELLO, &buf, &buf_len ) ); + + MBEDTLS_SSL_PROC_CHK( ssl_client_hello_write_partial, ( ssl, buf, buf_len, + &len_without_binders, + &msg_len ) ); + + mbedtls_ssl_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, + msg_len ); + ssl->handshake->update_checksum( ssl, buf, len_without_binders ); + + MBEDTLS_SSL_PROC_CHK( ssl_client_hello_postprocess, ( ssl ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_finish_handshake_msg, ( ssl, buf_len, msg_len ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_HELLO ); +cleanup: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write client hello" ) ); /* client_hello_process haven't finished */ ret=MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; return ret; } +static int ssl_client_hello_prepare( mbedtls_ssl_context* ssl ) +{ + ((void) ssl); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + +static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, + unsigned char* buf, size_t buflen, + size_t* len_without_binders, + size_t* len_with_binders ) +{ + ((void) ssl); + ((void) buf); + ((void) buflen); + ((void) len_without_binders); + ((void) len_with_binders); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + +static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ) +{ + ((void) ssl); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + #endif /* MBEDTLS_SSL_CLI_C */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c new file mode 100644 index 0000000000..51c8fe3bd5 --- /dev/null +++ b/library/ssl_tls13_generic.c @@ -0,0 +1,67 @@ +/* + * TLS 1.3 functionality shared between client and server + * + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "common.h" + +#if defined(MBEDTLS_SSL_TLS_C) + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +#include "ssl_misc.h" + +int mbedtls_ssl_start_handshake_msg( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char **buf, + size_t *buflen ) +{ + ((void) ssl); + ((void) hs_type); + ((void) buf); + ((void) buflen); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + +int mbedtls_ssl_finish_handshake_msg( mbedtls_ssl_context *ssl, + size_t buf_len, + size_t msg_len ) +{ + ((void) ssl); + ((void) buf_len); + ((void) msg_len); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + +void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, + unsigned hs_type, + size_t total_hs_len ) +{ + unsigned char hs_hdr[4]; + + /* Build HS header for checksum update. */ + hs_hdr[0] = hs_type; + hs_hdr[1] = (unsigned char)( total_hs_len >> 16 ); + hs_hdr[2] = (unsigned char)( total_hs_len >> 8 ); + hs_hdr[3] = (unsigned char)( total_hs_len >> 0 ); + + ssl->handshake->update_checksum( ssl, hs_hdr, sizeof( hs_hdr ) ); +} + +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + +#endif /* MBEDTLS_SSL_TLS_C */ From c8a392c47e1c71b67b90c47f509f47fc57cefdc9 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 18 Aug 2021 16:46:28 +0800 Subject: [PATCH 402/966] Implement stages except write_partial Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 34 ++++++++++++++++++++++++++-------- library/ssl_tls13_generic.c | 24 ++++++++++++++++-------- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 46c071b6bb..b06147c0c9 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -99,7 +99,6 @@ static int ssl_client_hello_process( mbedtls_ssl_context* ssl ) MBEDTLS_SSL_PROC_CHK( ssl_client_hello_postprocess, ( ssl ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_finish_handshake_msg, ( ssl, buf_len, msg_len ) ); - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_HELLO ); cleanup: @@ -111,8 +110,31 @@ cleanup: static int ssl_client_hello_prepare( mbedtls_ssl_context* ssl ) { - ((void) ssl); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + int ret; + size_t rand_bytes_len; + + if( ssl->conf->f_rng == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided" ) ); + return( MBEDTLS_ERR_SSL_NO_RNG ); + } + + rand_bytes_len = 32; + + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->handshake->randbytes, rand_bytes_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); + return( ret ); + } + + return( 0 ); +} + +static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ) +{ + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_HELLO ); + + return( 0 ); } static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, @@ -128,11 +150,7 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); } -static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ) -{ - ((void) ssl); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); -} + #endif /* MBEDTLS_SSL_CLI_C */ diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 51c8fe3bd5..5aa5d8a014 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -23,6 +23,8 @@ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +#include "mbedtls/error.h" + #include "ssl_misc.h" int mbedtls_ssl_start_handshake_msg( mbedtls_ssl_context *ssl, @@ -30,21 +32,27 @@ int mbedtls_ssl_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned char **buf, size_t *buflen ) { - ((void) ssl); - ((void) hs_type); - ((void) buf); - ((void) buflen); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + *buf = ssl->out_msg + 4; + *buflen = MBEDTLS_SSL_OUT_CONTENT_LEN - 4; + + ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->out_msg[0] = hs_type; + + return( 0 ); } int mbedtls_ssl_finish_handshake_msg( mbedtls_ssl_context *ssl, size_t buf_len, size_t msg_len ) { - ((void) ssl); + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; ((void) buf_len); - ((void) msg_len); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + + ssl->out_msglen = msg_len + 4; + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext, ( ssl, 0 ) ); + +cleanup: + return( ret ); } void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, From 93bcd61a414c9e320b149a9d1e66009cd94dfd87 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 18 Aug 2021 12:47:24 +0800 Subject: [PATCH 403/966] Add field into handshake params Add `extensions_present` field. It represents which are present. Signed-off-by: Jerry Yu --- library/ssl_misc.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 4c3f6c0d5e..5f15b8da77 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -103,6 +103,21 @@ #define MBEDTLS_SSL_RENEGOTIATION_DONE 2 /* Done or aborted */ #define MBEDTLS_SSL_RENEGOTIATION_PENDING 3 /* Requested (server only) */ +/* List of extensions used in extensions_present of mbedtls_ssl_handshake_params */ +#define MBEDTLS_SSL_EXT_NONE 0 +#define MBEDTLS_SSL_EXT_PRE_SHARED_KEY ( 1 << 0 ) +#define MBEDTLS_SSL_EXT_KEY_SHARE ( 1 << 1 ) +#define MBEDTLS_SSL_EXT_SIGNATURE_ALGORITHM ( 1 << 2 ) +#define MBEDTLS_SSL_EXT_SUPPORTED_GROUPS ( 1 << 3 ) +#define MBEDTLS_SSL_EXT_MAX_FRAGMENT_LENGTH ( 1 << 4 ) +#define MBEDTLS_SSL_EXT_ALPN ( 1 << 5 ) +#define MBEDTLS_SSL_EXT_SUPPORTED_VERSION ( 1 << 6 ) +#define MBEDTLS_SSL_EXT_PSK_KEY_EXCHANGE_MODES ( 1 << 7 ) +#define MBEDTLS_SSL_EXT_EARLY_DATA ( 1 << 8 ) +#define MBEDTLS_SSL_EXT_SERVERNAME ( 1 << 9 ) +#define MBEDTLS_SSL_EXT_COOKIE ( 1 << 10 ) +#define MBEDTLS_SSL_EXT_CID ( 1 << 11 ) + #define MBEDTLS_SSL_PROC_STRIP_PARENS( ... ) __VA_ARGS__ #define MBEDTLS_SSL_PROC_CHK( fn, args ) \ @@ -631,6 +646,9 @@ struct mbedtls_ssl_handshake_params int max_major_ver; /*!< max. major version client*/ int max_minor_ver; /*!< max. minor version client*/ int cli_exts; /*!< client extension presence*/ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + int extensions_present; /*!< extension presence; Each bitfield represents an extension and defined as \c MBEDTLS_SSL_EXT_XXX */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) int new_session_ticket; /*!< use NewSessionTicket? */ From 7984d9931e549d040a75b964dd8a24dfd96f0b3d Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 18 Aug 2021 10:31:29 +0800 Subject: [PATCH 404/966] Add tls1.3 extension IANA values Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 54be3a5b9f..f988c0d8f1 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -474,6 +474,8 @@ #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4 #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10 +#define MBEDTLS_TLS_EXT_SUPPORTED_GROUPS 10 /* Renamed in TLS 1.3 */ + #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11 #define MBEDTLS_TLS_EXT_SIG_ALG 13 @@ -487,6 +489,15 @@ #define MBEDTLS_TLS_EXT_SESSION_TICKET 35 +/* TLS 1.3 */ +#define MBEDTLS_TLS_EXT_PRE_SHARED_KEY 41 +#define MBEDTLS_TLS_EXT_EARLY_DATA 42 +#define MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS 43 +#define MBEDTLS_TLS_EXT_COOKIE 44 +#define MBEDTLS_TLS_EXT_PSK_KEY_EXCHANGE_MODES 45 + +#define MBEDTLS_TLS_EXT_KEY_SHARES 51 + /* The value of the CID extension is still TBD as of * draft-ietf-tls-dtls-connection-id-05 * (https://tools.ietf.org/html/draft-ietf-tls-dtls-connection-id-05). From bc20bdd3a9f271ac0605716714111090436d18d9 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 24 Aug 2021 15:59:48 +0800 Subject: [PATCH 405/966] Implement write_partial with dummy exts Signed-off-by: Jerry Yu --- library/ssl_misc.h | 3 + library/ssl_tls13_client.c | 293 +++++++++++++++++++++++++++++++++++- library/ssl_tls13_generic.c | 34 +++++ 3 files changed, 327 insertions(+), 3 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 5f15b8da77..dfb5634974 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1385,6 +1385,9 @@ void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, size_t total_hs_len ); +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) +int mbedtls_ssl_write_signature_algorithms_ext(mbedtls_ssl_context* ssl, unsigned char* buf, unsigned char* end, size_t* olen); +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index b06147c0c9..fbc8fd5fb4 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -25,6 +25,8 @@ #if defined(MBEDTLS_SSL_CLI_C) +#include + #include "ssl_misc.h" #include @@ -137,20 +139,305 @@ static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ) return( 0 ); } +/* Write extensions */ + +static void ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, + unsigned char* buf, + unsigned char* end, + size_t* olen ); + +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + +static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl, + unsigned char* buf, + unsigned char* end, + size_t* olen ); + +static int ssl_write_key_shares_ext( mbedtls_ssl_context *ssl, + unsigned char* buf, + unsigned char* end, + size_t* olen ); + +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, unsigned char* buf, size_t buflen, size_t* len_without_binders, size_t* len_with_binders ) +{ + /* Extensions */ + + /* extension_start + * Used during extension writing where the + * buffer pointer to the beginning of the + * extension list must be kept to write + * the total extension list size in the end. + */ + + int ret; + unsigned char* extension_start; + size_t cur_ext_len; /* Size of the current extension */ + size_t total_ext_len; /* Size of list of extensions */ + + /* Length information */ + size_t rand_bytes_len; + size_t version_len; + + /* Buffer management */ + unsigned char* start = buf; + unsigned char* end = buf + buflen; + + /* Ciphersuite-related variables */ + const int* ciphersuites; + const mbedtls_ssl_ciphersuite_t* ciphersuite_info; + size_t i; /* used to iterate through ciphersuite list */ + /* ciphersuite_start points to the start of the ciphersuite list, i.e. to the length field*/ + unsigned char* ciphersuite_start; + size_t ciphersuite_count; + + /* Keeping track of the included extensions */ + ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; + + rand_bytes_len = 32; + + /* NOTE: + * Even for DTLS 1.3, we are writing a TLS handshake header here. + * The actual DTLS 1.3 handshake header is inserted in + * the record writing routine mbedtls_ssl_write_record(). + * + * For cTLS the length, and the version field + * are elided. The random bytes are shorter. + */ + version_len = 2; + + if( ssl->conf->max_major_ver == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "configured max major version is invalid, " + "consider using mbedtls_ssl_config_defaults()" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + ssl->major_ver = ssl->conf->min_major_ver; + ssl->minor_ver = ssl->conf->min_minor_ver; + + /* For TLS 1.3 we use the legacy version number {0x03, 0x03} + * instead of the true version number. + * + * For DTLS 1.3 we use the legacy version number + * {254,253}. + * + * In cTLS the version number is elided. + */ + *buf++ = 0x03; + *buf++ = 0x03; + buflen -= version_len; + + /* Write random bytes */ + memcpy( buf, ssl->handshake->randbytes, rand_bytes_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf, rand_bytes_len ); + + buf += rand_bytes_len; + buflen -= rand_bytes_len; + + /* Versions of TLS before TLS 1.3 supported a + * "session resumption" feature which has been merged with pre-shared + * keys in this version. A client which has a + * cached session ID set by a pre-TLS 1.3 server SHOULD set this + * field to that value. In compatibility mode, + * this field MUST be non-empty, so a client not offering a + * pre-TLS 1.3 session MUST generate a new 32-byte value. This value + * need not be random but SHOULD be unpredictable to avoid + * implementations fixating on a specific value ( also known as + * ossification ). Otherwise, it MUST be set as a zero-length vector + * ( i.e., a zero-valued single byte length field ). + */ + if( buflen < 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small to hold ClientHello" ) ); + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + } + + *buf++ = 0; /* session id length set to zero */ + buflen -= 1; + + /* + * Ciphersuite list + * + * This is a list of the symmetric cipher options supported by + * the client, specifically the record protection algorithm + * ( including secret key length ) and a hash to be used with + * HKDF, in descending order of client preference. + */ + ciphersuites = ssl->conf->ciphersuite_list; + + if( buflen < 2 /* for ciphersuite list length */ ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small to hold ClientHello" ) ); + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + } + + /* Skip writing ciphersuite length for now */ + ciphersuite_count = 0; + ciphersuite_start = buf; + buf += 2; + buflen -= 2; + + for ( i = 0; ciphersuites[i] != 0; i++ ) + { + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuites[i] ); + + if( ciphersuite_info == NULL ) + continue; + + if( ciphersuite_info->min_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 || + ciphersuite_info->max_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 ) + continue; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x, %s", + (unsigned int) ciphersuites[i], ciphersuite_info->name ) ); + + ciphersuite_count++; + + if( buflen < 2 /* for ciphersuite list length */ ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small to hold ClientHello" ) ); + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + } + + *buf++ = (unsigned char)( ciphersuites[i] >> 8 ); + *buf++ = (unsigned char)( ciphersuites[i] ); + + buflen -= 2; + + } + + /* write ciphersuite length now */ + *ciphersuite_start++ = (unsigned char)( ciphersuite_count*2 >> 8 ); + *ciphersuite_start++ = (unsigned char)( ciphersuite_count*2 ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", ciphersuite_count ) ); + + /* For every TLS 1.3 ClientHello, this vector MUST contain exactly + * one byte set to zero, which corresponds to the 'null' compression + * method in prior versions of TLS. + * + * For cTLS this field is elided. + */ + if( buflen < 2 /* for ciphersuite list length */ ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small to hold ClientHello" ) ); + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + } + + *buf++ = 1; + *buf++ = MBEDTLS_SSL_COMPRESS_NULL; + + buflen -= 2; + + /* First write extensions, then the total length */ + extension_start = buf; + total_ext_len = 0; + buf += 2; + + /* Supported Versions Extension is mandatory with TLS 1.3. + * + * For cTLS we only need to provide it if there is more than one version + * and currently there is only one. + */ + ssl_write_supported_versions_ext( ssl, buf, end, &cur_ext_len ); + total_ext_len += cur_ext_len; + buf += cur_ext_len; + +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + /* The supported_groups and the key_share extensions are + * REQUIRED for ECDHE ciphersuites. + */ + ret = ssl_write_supported_groups_ext( ssl, buf, end, &cur_ext_len ); + if( ret != 0 ) + return( ret ); + + total_ext_len += cur_ext_len; + buf += cur_ext_len; + + /* The supported_signature_algorithms extension is REQUIRED for + * certificate authenticated ciphersuites. */ + ret = mbedtls_ssl_write_signature_algorithms_ext( ssl, buf, end, &cur_ext_len ); + if( ret != 0 ) + return( ret ); + + total_ext_len += cur_ext_len; + buf += cur_ext_len; + + /* We need to send the key shares under three conditions: + * 1 ) A certificate-based ciphersuite is being offered. In this case + * supported_groups and supported_signature extensions have been successfully added. + * 2 ) A PSK-based ciphersuite with ECDHE is offered. In this case the + * psk_key_exchange_modes has been added as the last extension. + * 3 ) Or, in case all ciphers are supported ( which includes #1 and #2 from above ) + */ + + ret = ssl_write_key_shares_ext( ssl, buf, end, &cur_ext_len ); + if( ret != 0 ) + return( ret ); + + total_ext_len += cur_ext_len; + buf += cur_ext_len; +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + + /* Add more extensions here */ + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, total extension length: %" MBEDTLS_PRINTF_SIZET , + total_ext_len ) ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extension_start, total_ext_len ); + + /* Write extension length */ + *extension_start++ = (unsigned char)( ( total_ext_len >> 8 ) & 0xFF ); + *extension_start++ = (unsigned char)( ( total_ext_len ) & 0xFF ); + + *len_without_binders = buf - start; + *len_with_binders = ( extension_start + total_ext_len ) - start; + return( 0 ); +} + +static void ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, + unsigned char* buf, + unsigned char* end, + size_t* olen ) { ((void) ssl); ((void) buf); - ((void) buflen); - ((void) len_without_binders); - ((void) len_with_binders); + ((void) end); + ((void) olen); +} + +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + +static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl, + unsigned char* buf, + unsigned char* end, + size_t* olen ) +{ + ((void) ssl); + ((void) buf); + ((void) end); + ((void) olen); return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); } +static int ssl_write_key_shares_ext( mbedtls_ssl_context *ssl, + unsigned char* buf, + unsigned char* end, + size_t* olen ) +{ + ((void) ssl); + ((void) buf); + ((void) end); + ((void) olen); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #endif /* MBEDTLS_SSL_CLI_C */ diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 5aa5d8a014..7ec7423ea0 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -70,6 +70,40 @@ void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, ssl->handshake->update_checksum( ssl, hs_hdr, sizeof( hs_hdr ) ); } +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + +/* + * mbedtls_ssl_write_signature_algorithms_ext( ) + * + * enum { + * .... + * ecdsa_secp256r1_sha256( 0x0403 ), + * ecdsa_secp384r1_sha384( 0x0503 ), + * ecdsa_secp521r1_sha512( 0x0603 ), + * .... + * } SignatureScheme; + * + * struct { + * SignatureScheme supported_signature_algorithms<2..2^16-2>; + * } SignatureSchemeList; + * + * Only if we handle at least one key exchange that needs signatures. + */ + +int mbedtls_ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, + unsigned char* buf, + unsigned char* end, + size_t* olen ) +{ + ((void) ssl); + ((void) buf); + ((void) end); + ((void) olen); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_TLS_C */ From ef6b36b484ea00bae37c5833d14b15127d76ea98 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 24 Aug 2021 16:29:02 +0800 Subject: [PATCH 406/966] add supported versions extension Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 42 ++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index fbc8fd5fb4..0b10b12f41 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -400,15 +400,49 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, return( 0 ); } +/* + * ssl_write_supported_versions_ext(): + * + * struct { + * ProtocolVersion versions<2..254>; + * } SupportedVersions; + */ static void ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, unsigned char* buf, unsigned char* end, size_t* olen ) { - ((void) ssl); - ((void) buf); - ((void) end); - ((void) olen); + unsigned char *p = buf; + + *olen = 0; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported version extension" ) ); + + if( end < p || (size_t)( end - p ) < 7 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); + return; + } + + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS >> 8 ) & 0xFF ); + *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS ) & 0xFF ); + + /* total length */ + *p++ = 0x00; + *p++ = 3; + + /* length of next field */ + *p++ = 0x2; + + /* This implementation only supports a single TLS version, and only + * advertises a single value. + */ + mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, + ssl->conf->transport, p ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); + + *olen = 7; } #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) From 32cd5b19dc15ece9669e6e40a1730301082297ff Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 24 Aug 2021 18:07:13 +0800 Subject: [PATCH 407/966] fix unused variable warning Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 0b10b12f41..f6e145b294 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -173,8 +173,9 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, * extension list must be kept to write * the total extension list size in the end. */ - +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) int ret; +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ unsigned char* extension_start; size_t cur_ext_len; /* Size of the current extension */ size_t total_ext_len; /* Size of list of extensions */ From b3317e1a01d2754e7ca1a9fbfb1566a8b5798d83 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 14:30:22 +0800 Subject: [PATCH 408/966] Add extension types in rfc8446 Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index f988c0d8f1..b7b22c20d4 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -472,31 +472,37 @@ #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4 +#define MBEDTLS_TLS_EXT_STATUS_REQUEST 5 /* RFC 8446 TLS 1.3 */ #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10 -#define MBEDTLS_TLS_EXT_SUPPORTED_GROUPS 10 /* Renamed in TLS 1.3 */ - +#define MBEDTLS_TLS_EXT_SUPPORTED_GROUPS 10 /* RFC 8446 TLS 1.3 */ #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11 -#define MBEDTLS_TLS_EXT_SIG_ALG 13 - +#define MBEDTLS_TLS_EXT_SIG_ALG 13 /* RFC 8446 TLS 1.3 */ #define MBEDTLS_TLS_EXT_USE_SRTP 14 - +#define MBEDTLS_TLS_EXT_HEARTBEAT 15 /* RFC 8446 TLS 1.3 */ #define MBEDTLS_TLS_EXT_ALPN 16 +#define MBEDTLS_TLS_EXT_SCT 18 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_SERV_CERT_TYPE 19 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_CLI_CERT_TYPE 20 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_PADDING 21 /* RFC 8446 TLS 1.3 */ #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */ #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */ #define MBEDTLS_TLS_EXT_SESSION_TICKET 35 -/* TLS 1.3 */ -#define MBEDTLS_TLS_EXT_PRE_SHARED_KEY 41 -#define MBEDTLS_TLS_EXT_EARLY_DATA 42 -#define MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS 43 -#define MBEDTLS_TLS_EXT_COOKIE 44 -#define MBEDTLS_TLS_EXT_PSK_KEY_EXCHANGE_MODES 45 +#define MBEDTLS_TLS_EXT_PRE_SHARED_KEY 41 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_EARLY_DATA 42 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS 43 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_COOKIE 44 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_PSK_KEY_EXCHANGE_MODES 45 /* RFC 8446 TLS 1.3 */ -#define MBEDTLS_TLS_EXT_KEY_SHARES 51 +#define MBEDTLS_TLS_EXT_CERT_AUTH 47 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_OID_FILTERS 48 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_POST_HANDSHAKE_AUTH 49 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_SIG_ALG_CERT 50 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_KEY_SHARE 51 /* RFC 8446 TLS 1.3 */ /* The value of the CID extension is still TBD as of * draft-ietf-tls-dtls-connection-id-05 From 8e7ca0432ef291e1e0502e352cf830cfbabdd875 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 15:31:37 +0800 Subject: [PATCH 409/966] fix extensions_present issues fix comments for the mask values. follow same order as IANA values. Signed-off-by: Jerry Yu --- library/ssl_misc.h | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index dfb5634974..bda2a7a1a6 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -103,20 +103,34 @@ #define MBEDTLS_SSL_RENEGOTIATION_DONE 2 /* Done or aborted */ #define MBEDTLS_SSL_RENEGOTIATION_PENDING 3 /* Requested (server only) */ -/* List of extensions used in extensions_present of mbedtls_ssl_handshake_params */ -#define MBEDTLS_SSL_EXT_NONE 0 -#define MBEDTLS_SSL_EXT_PRE_SHARED_KEY ( 1 << 0 ) -#define MBEDTLS_SSL_EXT_KEY_SHARE ( 1 << 1 ) -#define MBEDTLS_SSL_EXT_SIGNATURE_ALGORITHM ( 1 << 2 ) -#define MBEDTLS_SSL_EXT_SUPPORTED_GROUPS ( 1 << 3 ) -#define MBEDTLS_SSL_EXT_MAX_FRAGMENT_LENGTH ( 1 << 4 ) -#define MBEDTLS_SSL_EXT_ALPN ( 1 << 5 ) -#define MBEDTLS_SSL_EXT_SUPPORTED_VERSION ( 1 << 6 ) -#define MBEDTLS_SSL_EXT_PSK_KEY_EXCHANGE_MODES ( 1 << 7 ) -#define MBEDTLS_SSL_EXT_EARLY_DATA ( 1 << 8 ) -#define MBEDTLS_SSL_EXT_SERVERNAME ( 1 << 9 ) -#define MBEDTLS_SSL_EXT_COOKIE ( 1 << 10 ) -#define MBEDTLS_SSL_EXT_CID ( 1 << 11 ) +/* + * Mask of TLS 1.3 handshake extensions used in extensions_present + * of mbedtls_ssl_handshake_params. + */ +#define MBEDTLS_SSL_EXT_NONE 0 + +#define MBEDTLS_SSL_EXT_SERVERNAME ( 1 << 0 ) +#define MBEDTLS_SSL_EXT_MAX_FRAGMENT_LENGTH ( 1 << 1 ) +#define MBEDTLS_SSL_EXT_STATUS_REQUEST ( 1 << 2 ) +#define MBEDTLS_SSL_EXT_SUPPORTED_GROUPS ( 1 << 3 ) +#define MBEDTLS_SSL_EXT_SIG_ALG ( 1 << 4 ) +#define MBEDTLS_SSL_EXT_USE_SRTP ( 1 << 5 ) +#define MBEDTLS_SSL_EXT_HEARTBEAT ( 1 << 6 ) +#define MBEDTLS_SSL_EXT_ALPN ( 1 << 7 ) +#define MBEDTLS_SSL_EXT_SCT ( 1 << 8 ) +#define MBEDTLS_SSL_EXT_SERV_CERT_TYPE ( 1 << 9 ) +#define MBEDTLS_SSL_EXT_CLI_CERT_TYPE ( 1 << 10 ) +#define MBEDTLS_SSL_EXT_PADDING ( 1 << 11 ) +#define MBEDTLS_SSL_EXT_PRE_SHARED_KEY ( 1 << 12 ) +#define MBEDTLS_SSL_EXT_EARLY_DATA ( 1 << 13 ) +#define MBEDTLS_SSL_EXT_SUPPORTED_VERSIONS ( 1 << 14 ) +#define MBEDTLS_SSL_EXT_COOKIE ( 1 << 15 ) +#define MBEDTLS_SSL_EXT_PSK_KEY_EXCHANGE_MODES ( 1 << 16 ) +#define MBEDTLS_SSL_EXT_CERT_AUTH ( 1 << 17 ) +#define MBEDTLS_SSL_EXT_OID_FILTERS ( 1 << 18 ) +#define MBEDTLS_SSL_EXT_POST_HANDSHAKE_AUTH ( 1 << 19 ) +#define MBEDTLS_SSL_EXT_SIG_ALG_CERT ( 1 << 20 ) +#define MBEDTLS_SSL_EXT_KEY_SHARE ( 1 << 21 ) #define MBEDTLS_SSL_PROC_STRIP_PARENS( ... ) __VA_ARGS__ @@ -647,7 +661,9 @@ struct mbedtls_ssl_handshake_params int max_minor_ver; /*!< max. minor version client*/ int cli_exts; /*!< client extension presence*/ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - int extensions_present; /*!< extension presence; Each bitfield represents an extension and defined as \c MBEDTLS_SSL_EXT_XXX */ + int extensions_present; /*!< extension presence; Each bitfield + represents an extension and defined + as \c MBEDTLS_SSL_EXT_XXX */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) From c7ddeec22988235608aa7a4f3647b14d74546a53 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 16:23:47 +0800 Subject: [PATCH 410/966] Remove `len_without_binders` Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index f6e145b294..2cada0deca 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -73,8 +73,7 @@ int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) static int ssl_client_hello_prepare( mbedtls_ssl_context* ssl ); static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, unsigned char* buf, size_t buflen, - size_t* len_without_binders, - size_t* len_with_binders ); + size_t *len_with_binders ); static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ); static int ssl_client_hello_process( mbedtls_ssl_context* ssl ) @@ -82,7 +81,6 @@ static int ssl_client_hello_process( mbedtls_ssl_context* ssl ) int ret = 0; unsigned char *buf; size_t buf_len, msg_len; - size_t len_without_binders = 0; MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); @@ -91,13 +89,11 @@ static int ssl_client_hello_process( mbedtls_ssl_context* ssl ) MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_start_handshake_msg, ( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_client_hello_write_partial, ( ssl, buf, buf_len, - &len_without_binders, - &msg_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_client_hello_write_partial, ( ssl, buf, buf_len, &msg_len ) ); mbedtls_ssl_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, msg_len ); - ssl->handshake->update_checksum( ssl, buf, len_without_binders ); + ssl->handshake->update_checksum( ssl, buf, 0 ); MBEDTLS_SSL_PROC_CHK( ssl_client_hello_postprocess, ( ssl ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_finish_handshake_msg, ( ssl, buf_len, msg_len ) ); @@ -162,8 +158,7 @@ static int ssl_write_key_shares_ext( mbedtls_ssl_context *ssl, static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, unsigned char* buf, size_t buflen, - size_t* len_without_binders, - size_t* len_with_binders ) + size_t *len_with_binders ) { /* Extensions */ @@ -396,7 +391,6 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, *extension_start++ = (unsigned char)( ( total_ext_len >> 8 ) & 0xFF ); *extension_start++ = (unsigned char)( ( total_ext_len ) & 0xFF ); - *len_without_binders = buf - start; *len_with_binders = ( extension_start + total_ext_len ) - start; return( 0 ); } From 708202b7d08812f3859b854cd8e534e4154655b0 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 16:28:36 +0800 Subject: [PATCH 411/966] Move random function check move to `ssl_conf_check` Signed-off-by: Jerry Yu --- library/ssl_tls.c | 6 ++++++ library/ssl_tls13_client.c | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 07b51003ab..1c8c7bd734 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3182,6 +3182,12 @@ static int ssl_conf_check(const mbedtls_ssl_context *ssl) if( ret != 0 ) return( ret ); + if( ssl->conf->f_rng == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided" ) ); + return( MBEDTLS_ERR_SSL_NO_RNG ); + } + /* Space for further checks */ return( 0 ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 2cada0deca..036c5e5537 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -111,12 +111,6 @@ static int ssl_client_hello_prepare( mbedtls_ssl_context* ssl ) int ret; size_t rand_bytes_len; - if( ssl->conf->f_rng == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided" ) ); - return( MBEDTLS_ERR_SSL_NO_RNG ); - } - rand_bytes_len = 32; if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->handshake->randbytes, rand_bytes_len ) ) != 0 ) From 6f13f64aa668155a91e39e99f361687927a4b6f6 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 17:18:15 +0800 Subject: [PATCH 412/966] fix various format issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 4 +- library/ssl_tls13_client.c | 94 ++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 51 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index bda2a7a1a6..9cf1e4ff39 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1402,7 +1402,9 @@ void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, size_t total_hs_len ); #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) -int mbedtls_ssl_write_signature_algorithms_ext(mbedtls_ssl_context* ssl, unsigned char* buf, unsigned char* end, size_t* olen); +int mbedtls_ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, unsigned char *end, + size_t *olen); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 036c5e5537..62b6ce18f8 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -30,8 +30,10 @@ #include "ssl_misc.h" #include +#define CLIENT_HELLO_RAND_BYTES_LEN 32 +#define CLIENT_HELLO_VERSION_LEN 2 /* Main entry point; orchestrates the other functions */ -static int ssl_client_hello_process( mbedtls_ssl_context* ssl ); +static int ssl_client_hello_process( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) { @@ -70,13 +72,13 @@ int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) } -static int ssl_client_hello_prepare( mbedtls_ssl_context* ssl ); -static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, - unsigned char* buf, size_t buflen, +static int ssl_client_hello_prepare( mbedtls_ssl_context *ssl ); +static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t buflen, size_t *len_with_binders ); -static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ); +static int ssl_client_hello_postprocess( mbedtls_ssl_context *ssl ); -static int ssl_client_hello_process( mbedtls_ssl_context* ssl ) +static int ssl_client_hello_process( mbedtls_ssl_context *ssl ) { int ret = 0; unsigned char *buf; @@ -106,14 +108,13 @@ cleanup: return ret; } -static int ssl_client_hello_prepare( mbedtls_ssl_context* ssl ) +static int ssl_client_hello_prepare( mbedtls_ssl_context *ssl ) { int ret; - size_t rand_bytes_len; - rand_bytes_len = 32; - - if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->handshake->randbytes, rand_bytes_len ) ) != 0 ) + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, + ssl->handshake->randbytes, + CLIENT_HELLO_RAND_BYTES_LEN ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); return( ret ); @@ -131,27 +132,27 @@ static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ) /* Write extensions */ -static void ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, - unsigned char* buf, - unsigned char* end, - size_t* olen ); +static int ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ); #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl, - unsigned char* buf, - unsigned char* end, - size_t* olen ); + unsigned char *buf, + unsigned char *end, + size_t *olen ); static int ssl_write_key_shares_ext( mbedtls_ssl_context *ssl, - unsigned char* buf, - unsigned char* end, - size_t* olen ); + unsigned char *buf, + unsigned char *end, + size_t *olen ); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ -static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, - unsigned char* buf, size_t buflen, +static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, + unsigned char *buf, size_t buflen, size_t *len_with_binders ) { /* Extensions */ @@ -169,10 +170,6 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, size_t cur_ext_len; /* Size of the current extension */ size_t total_ext_len; /* Size of list of extensions */ - /* Length information */ - size_t rand_bytes_len; - size_t version_len; - /* Buffer management */ unsigned char* start = buf; unsigned char* end = buf + buflen; @@ -188,8 +185,6 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, /* Keeping track of the included extensions */ ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; - rand_bytes_len = 32; - /* NOTE: * Even for DTLS 1.3, we are writing a TLS handshake header here. * The actual DTLS 1.3 handshake header is inserted in @@ -198,7 +193,6 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, * For cTLS the length, and the version field * are elided. The random bytes are shorter. */ - version_len = 2; if( ssl->conf->max_major_ver == 0 ) { @@ -218,16 +212,18 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, * * In cTLS the version number is elided. */ + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_VERSION_LEN); *buf++ = 0x03; *buf++ = 0x03; - buflen -= version_len; + buflen -= CLIENT_HELLO_VERSION_LEN; /* Write random bytes */ - memcpy( buf, ssl->handshake->randbytes, rand_bytes_len ); - MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf, rand_bytes_len ); + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RAND_BYTES_LEN); + memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf, CLIENT_HELLO_RAND_BYTES_LEN ); - buf += rand_bytes_len; - buflen -= rand_bytes_len; + buf += CLIENT_HELLO_RAND_BYTES_LEN; + buflen -= CLIENT_HELLO_RAND_BYTES_LEN; /* Versions of TLS before TLS 1.3 supported a * "session resumption" feature which has been merged with pre-shared @@ -396,10 +392,10 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context* ssl, * ProtocolVersion versions<2..254>; * } SupportedVersions; */ -static void ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, - unsigned char* buf, - unsigned char* end, - size_t* olen ) +static int ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { unsigned char *p = buf; @@ -407,11 +403,7 @@ static void ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported version extension" ) ); - if( end < p || (size_t)( end - p ) < 7 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small" ) ); - return; - } + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS >> 8 ) & 0xFF ); *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS ) & 0xFF ); @@ -432,14 +424,16 @@ static void ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); *olen = 7; + + return( 0 ); } #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl, - unsigned char* buf, - unsigned char* end, - size_t* olen ) + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); @@ -449,9 +443,9 @@ static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl, } static int ssl_write_key_shares_ext( mbedtls_ssl_context *ssl, - unsigned char* buf, - unsigned char* end, - size_t* olen ) + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); From e885b7698062920884a4e6b85b08129d2ab8c334 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 17:32:34 +0800 Subject: [PATCH 413/966] fix too long lines Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 62b6ce18f8..d293629857 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -59,7 +59,7 @@ int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) case MBEDTLS_SSL_SERVER_HELLO: // Stop here : we haven't finished whole flow - ret=MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); break; @@ -88,17 +88,20 @@ static int ssl_client_hello_process( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_PROC_CHK( ssl_client_hello_prepare, ( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_start_handshake_msg, ( ssl, - MBEDTLS_SSL_HS_CLIENT_HELLO, &buf, &buf_len ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_start_handshake_msg, + ( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, + &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_client_hello_write_partial, ( ssl, buf, buf_len, &msg_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_client_hello_write_partial, + ( ssl, buf, buf_len, &msg_len ) ); mbedtls_ssl_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, msg_len ); ssl->handshake->update_checksum( ssl, buf, 0 ); MBEDTLS_SSL_PROC_CHK( ssl_client_hello_postprocess, ( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_finish_handshake_msg, ( ssl, buf_len, msg_len ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_finish_handshake_msg, + ( ssl, buf_len, msg_len ) ); cleanup: @@ -112,8 +115,8 @@ static int ssl_client_hello_prepare( mbedtls_ssl_context *ssl ) { int ret; - if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, - ssl->handshake->randbytes, + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, + ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); @@ -177,8 +180,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, /* Ciphersuite-related variables */ const int* ciphersuites; const mbedtls_ssl_ciphersuite_t* ciphersuite_info; - size_t i; /* used to iterate through ciphersuite list */ - /* ciphersuite_start points to the start of the ciphersuite list, i.e. to the length field*/ + /* ciphersuite_start points to the start of + the ciphersuite list, i.e. to the length field*/ unsigned char* ciphersuite_start; size_t ciphersuite_count; @@ -220,7 +223,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, /* Write random bytes */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RAND_BYTES_LEN); memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ); - MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf, CLIENT_HELLO_RAND_BYTES_LEN ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", + buf, CLIENT_HELLO_RAND_BYTES_LEN ); buf += CLIENT_HELLO_RAND_BYTES_LEN; buflen -= CLIENT_HELLO_RAND_BYTES_LEN; @@ -268,7 +272,7 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, buf += 2; buflen -= 2; - for ( i = 0; ciphersuites[i] != 0; i++ ) + for ( size_t i = 0; ciphersuites[i] != 0; i++ ) { ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuites[i] ); @@ -280,7 +284,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, continue; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x, %s", - (unsigned int) ciphersuites[i], ciphersuite_info->name ) ); + (unsigned int) ciphersuites[i], + ciphersuite_info->name ) ); ciphersuite_count++; @@ -301,7 +306,9 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, *ciphersuite_start++ = (unsigned char)( ciphersuite_count*2 >> 8 ); *ciphersuite_start++ = (unsigned char)( ciphersuite_count*2 ); - MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", ciphersuite_count ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, + ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", + ciphersuite_count ) ); /* For every TLS 1.3 ClientHello, this vector MUST contain exactly * one byte set to zero, which corresponds to the 'null' compression @@ -421,7 +428,8 @@ static int ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, ssl->conf->transport, p ); - MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", + ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); *olen = 7; From 2ac64193ad5cafa401e69d40b1ff7bc93a584cda Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 18:38:58 +0800 Subject: [PATCH 414/966] Apply MBEDTLS_PUT_xyz Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 24 ++++++++++++------------ library/ssl_tls13_generic.c | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index d293629857..cd929ce7ed 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -216,8 +216,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, * In cTLS the version number is elided. */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_VERSION_LEN); - *buf++ = 0x03; - *buf++ = 0x03; + MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0); + buf += 2; buflen -= CLIENT_HELLO_VERSION_LEN; /* Write random bytes */ @@ -295,16 +295,16 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); } - *buf++ = (unsigned char)( ciphersuites[i] >> 8 ); - *buf++ = (unsigned char)( ciphersuites[i] ); + MBEDTLS_PUT_UINT16_BE( ciphersuites[i], buf, 0); + buf += 2; buflen -= 2; } /* write ciphersuite length now */ - *ciphersuite_start++ = (unsigned char)( ciphersuite_count*2 >> 8 ); - *ciphersuite_start++ = (unsigned char)( ciphersuite_count*2 ); + MBEDTLS_PUT_UINT16_BE( ciphersuite_count*2, ciphersuite_start, 0); + ciphersuite_start += 2; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", @@ -385,8 +385,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extension_start, total_ext_len ); /* Write extension length */ - *extension_start++ = (unsigned char)( ( total_ext_len >> 8 ) & 0xFF ); - *extension_start++ = (unsigned char)( ( total_ext_len ) & 0xFF ); + MBEDTLS_PUT_UINT16_BE( total_ext_len, extension_start, 0); + extension_start += 2; *len_with_binders = ( extension_start + total_ext_len ) - start; return( 0 ); @@ -412,12 +412,12 @@ static int ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS >> 8 ) & 0xFF ); - *p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS ) & 0xFF ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0); /* total length */ - *p++ = 0x00; - *p++ = 3; + MBEDTLS_PUT_UINT16_BE( 3, p, 2); + + p+=4; /* length of next field */ *p++ = 0x2; diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 7ec7423ea0..4a0493a940 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -62,10 +62,10 @@ void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned char hs_hdr[4]; /* Build HS header for checksum update. */ - hs_hdr[0] = hs_type; - hs_hdr[1] = (unsigned char)( total_hs_len >> 16 ); - hs_hdr[2] = (unsigned char)( total_hs_len >> 8 ); - hs_hdr[3] = (unsigned char)( total_hs_len >> 0 ); + hs_hdr[0] = MBEDTLS_BYTE_0( hs_type ); + hs_hdr[1] = MBEDTLS_BYTE_2( total_hs_len ); + hs_hdr[2] = MBEDTLS_BYTE_1( total_hs_len ); + hs_hdr[3] = MBEDTLS_BYTE_0( total_hs_len ); ssl->handshake->update_checksum( ssl, hs_hdr, sizeof( hs_hdr ) ); } From 55b90386004e882922bbb045144e047865ba2fd2 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 18:42:05 +0800 Subject: [PATCH 415/966] fix coding style issue Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index cd929ce7ed..8996e8adcb 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -107,7 +107,7 @@ cleanup: MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write client hello" ) ); /* client_hello_process haven't finished */ - ret=MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; return ret; } From f443681f561e604740f6626f8fb411c52e2bf696 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 22:59:56 +0800 Subject: [PATCH 416/966] fix function name conversion issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 12 ++++---- library/ssl_tls.c | 2 +- library/ssl_tls13_client.c | 55 +++++++++++++++++++------------------ library/ssl_tls13_generic.c | 10 +++---- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 9cf1e4ff39..016dfe162e 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -949,7 +949,7 @@ int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step_tls1_3( mbedtls_ssl_context *ssl ); #endif @@ -1385,24 +1385,24 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context* ssl, - int state ) + mbedtls_ssl_states state ) { ssl->state = state; } -int mbedtls_ssl_start_handshake_msg( mbedtls_ssl_context *ssl, +int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, size_t *buflen ); -int mbedtls_ssl_finish_handshake_msg( mbedtls_ssl_context *ssl, +int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, size_t buf_len, size_t msg_len ); -void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, +void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, size_t total_hs_len ); #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) -int mbedtls_ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, +int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 1c8c7bd734..831cc52ac0 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5181,7 +5181,7 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) { #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) if( mbedtls_ssl_conf_is_tls13_only( ssl->conf ) ) - ret = mbedtls_ssl_handshake_client_step_tls1_3( ssl ); + ret = mbedtls_ssl_tls13_handshake_client_step( ssl ); #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_PROTO_TLS1_2) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 8996e8adcb..ceb692ea56 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -33,9 +33,9 @@ #define CLIENT_HELLO_RAND_BYTES_LEN 32 #define CLIENT_HELLO_VERSION_LEN 2 /* Main entry point; orchestrates the other functions */ -static int ssl_client_hello_process( mbedtls_ssl_context *ssl ); +static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) { int ret = 0; @@ -54,7 +54,7 @@ int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) break; case MBEDTLS_SSL_CLIENT_HELLO: - ret = ssl_client_hello_process( ssl ); + ret = ssl_tls13_write_client_hello( ssl ); break; case MBEDTLS_SSL_SERVER_HELLO: @@ -72,13 +72,13 @@ int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) } -static int ssl_client_hello_prepare( mbedtls_ssl_context *ssl ); -static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, +static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ); +static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *len_with_binders ); -static int ssl_client_hello_postprocess( mbedtls_ssl_context *ssl ); +static int ssl_tls13_finalize_client_hello( mbedtls_ssl_context *ssl ); -static int ssl_client_hello_process( mbedtls_ssl_context *ssl ) +static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) { int ret = 0; unsigned char *buf; @@ -86,21 +86,21 @@ static int ssl_client_hello_process( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); - MBEDTLS_SSL_PROC_CHK( ssl_client_hello_prepare, ( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_client_hello, ( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_start_handshake_msg, + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg, ( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_client_hello_write_partial, + MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_exts_client_hello, ( ssl, buf, buf_len, &msg_len ) ); - mbedtls_ssl_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, + mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, msg_len ); ssl->handshake->update_checksum( ssl, buf, 0 ); - MBEDTLS_SSL_PROC_CHK( ssl_client_hello_postprocess, ( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_finish_handshake_msg, + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_client_hello, ( ssl ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg, ( ssl, buf_len, msg_len ) ); cleanup: @@ -111,7 +111,7 @@ cleanup: return ret; } -static int ssl_client_hello_prepare( mbedtls_ssl_context *ssl ) +static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) { int ret; @@ -126,7 +126,7 @@ static int ssl_client_hello_prepare( mbedtls_ssl_context *ssl ) return( 0 ); } -static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ) +static int ssl_tls13_finalize_client_hello( mbedtls_ssl_context* ssl ) { mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_HELLO ); @@ -135,26 +135,26 @@ static int ssl_client_hello_postprocess( mbedtls_ssl_context* ssl ) /* Write extensions */ -static int ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ); #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) -static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ); -static int ssl_write_key_shares_ext( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ -static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *len_with_binders ) { @@ -337,7 +337,7 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, * For cTLS we only need to provide it if there is more than one version * and currently there is only one. */ - ssl_write_supported_versions_ext( ssl, buf, end, &cur_ext_len ); + ssl_tls13_write_supported_versions_ext( ssl, buf, end, &cur_ext_len ); total_ext_len += cur_ext_len; buf += cur_ext_len; @@ -345,7 +345,7 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, /* The supported_groups and the key_share extensions are * REQUIRED for ECDHE ciphersuites. */ - ret = ssl_write_supported_groups_ext( ssl, buf, end, &cur_ext_len ); + ret = ssl_tls13_write_supported_groups_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); @@ -354,7 +354,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, /* The supported_signature_algorithms extension is REQUIRED for * certificate authenticated ciphersuites. */ - ret = mbedtls_ssl_write_signature_algorithms_ext( ssl, buf, end, &cur_ext_len ); + ret = mbedtls_ssl_tls13_write_signature_algorithms_ext( ssl, buf, + end, &cur_ext_len ); if( ret != 0 ) return( ret ); @@ -369,7 +370,7 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, * 3 ) Or, in case all ciphers are supported ( which includes #1 and #2 from above ) */ - ret = ssl_write_key_shares_ext( ssl, buf, end, &cur_ext_len ); + ret = ssl_tls13_write_key_shares_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); @@ -393,13 +394,13 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, } /* - * ssl_write_supported_versions_ext(): + * ssl_tls13_write_supported_versions_ext(): * * struct { * ProtocolVersion versions<2..254>; * } SupportedVersions; */ -static int ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ) @@ -438,7 +439,7 @@ static int ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) -static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ) @@ -450,7 +451,7 @@ static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); } -static int ssl_write_key_shares_ext( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 4a0493a940..be44141518 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -27,7 +27,7 @@ #include "ssl_misc.h" -int mbedtls_ssl_start_handshake_msg( mbedtls_ssl_context *ssl, +int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, size_t *buflen ) @@ -41,7 +41,7 @@ int mbedtls_ssl_start_handshake_msg( mbedtls_ssl_context *ssl, return( 0 ); } -int mbedtls_ssl_finish_handshake_msg( mbedtls_ssl_context *ssl, +int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, size_t buf_len, size_t msg_len ) { @@ -55,7 +55,7 @@ cleanup: return( ret ); } -void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, +void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, size_t total_hs_len ) { @@ -73,7 +73,7 @@ void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* - * mbedtls_ssl_write_signature_algorithms_ext( ) + * mbedtls_ssl_tls13_write_signature_algorithms_ext( ) * * enum { * .... @@ -90,7 +90,7 @@ void mbedtls_ssl_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, * Only if we handle at least one key exchange that needs signatures. */ -int mbedtls_ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, +int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, unsigned char* buf, unsigned char* end, size_t* olen ) From d532fe77206296f428aba403416e394bb0a1dc7c Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 26 Aug 2021 23:11:55 +0800 Subject: [PATCH 417/966] write client hello also in hello reqeust Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index ceb692ea56..0a07e06c40 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -49,10 +49,11 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) switch( ssl->state ) { + /* + * ssl->state is initialized as HELLO_REQUEST. It is same + * with CLIENT_HELLO status + */ case MBEDTLS_SSL_HELLO_REQUEST: - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_HELLO ); - break; - case MBEDTLS_SSL_CLIENT_HELLO: ret = ssl_tls13_write_client_hello( ssl ); break; From 9e42f6efd36a661f177da276487a5242fd1006fc Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 27 Aug 2021 15:14:01 +0800 Subject: [PATCH 418/966] Revert "Move random function check" This reverts commit cc88b34f7942f57ea0fd27ee4b3e29f49c91f10e. It causes many test fail. It should be re-considered. Signed-off-by: Jerry Yu --- library/ssl_tls.c | 6 ------ library/ssl_tls13_client.c | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 831cc52ac0..c43f95ee1b 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3182,12 +3182,6 @@ static int ssl_conf_check(const mbedtls_ssl_context *ssl) if( ret != 0 ) return( ret ); - if( ssl->conf->f_rng == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided" ) ); - return( MBEDTLS_ERR_SSL_NO_RNG ); - } - /* Space for further checks */ return( 0 ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 0a07e06c40..f5a6e20cab 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -116,6 +116,12 @@ static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) { int ret; + if( ssl->conf->f_rng == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided" ) ); + return( MBEDTLS_ERR_SSL_NO_RNG ); + } + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ) ) != 0 ) From 9176c3ad8c58b68d1770dcdf46fd90bbd5072968 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 27 Aug 2021 14:58:49 +0800 Subject: [PATCH 419/966] trim spaces Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index f5a6e20cab..3611f70b0d 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -49,7 +49,7 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) switch( ssl->state ) { - /* + /* * ssl->state is initialized as HELLO_REQUEST. It is same * with CLIENT_HELLO status */ @@ -361,7 +361,7 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, /* The supported_signature_algorithms extension is REQUIRED for * certificate authenticated ciphersuites. */ - ret = mbedtls_ssl_tls13_write_signature_algorithms_ext( ssl, buf, + ret = mbedtls_ssl_tls13_write_signature_algorithms_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); From 92c6b402d7ccf127d4700b49af5a9977c908ee3f Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 27 Aug 2021 16:59:09 +0800 Subject: [PATCH 420/966] Remove prototype of static functions Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 318 +++++++++++++++++-------------------- 1 file changed, 147 insertions(+), 171 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 3611f70b0d..41b133437d 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -32,135 +32,82 @@ #define CLIENT_HELLO_RAND_BYTES_LEN 32 #define CLIENT_HELLO_VERSION_LEN 2 -/* Main entry point; orchestrates the other functions */ -static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ); - -int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) -{ - int ret = 0; - - if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "Handshake completed but ssl->handshake is NULL.\n" ) ); - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - } - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); - - switch( ssl->state ) - { - /* - * ssl->state is initialized as HELLO_REQUEST. It is same - * with CLIENT_HELLO status - */ - case MBEDTLS_SSL_HELLO_REQUEST: - case MBEDTLS_SSL_CLIENT_HELLO: - ret = ssl_tls13_write_client_hello( ssl ); - break; - - case MBEDTLS_SSL_SERVER_HELLO: - // Stop here : we haven't finished whole flow - ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); - break; - - default: - MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - } - - return( ret ); -} - - -static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ); -static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, - unsigned char *buf, size_t buflen, - size_t *len_with_binders ); -static int ssl_tls13_finalize_client_hello( mbedtls_ssl_context *ssl ); - -static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) -{ - int ret = 0; - unsigned char *buf; - size_t buf_len, msg_len; - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); - - MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_client_hello, ( ssl ) ); - - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg, - ( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, - &buf, &buf_len ) ); - - MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_exts_client_hello, - ( ssl, buf, buf_len, &msg_len ) ); - - mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, - msg_len ); - ssl->handshake->update_checksum( ssl, buf, 0 ); - - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_client_hello, ( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg, - ( ssl, buf_len, msg_len ) ); - -cleanup: - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write client hello" ) ); - /* client_hello_process haven't finished */ - ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; - return ret; -} - -static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) -{ - int ret; - - if( ssl->conf->f_rng == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided" ) ); - return( MBEDTLS_ERR_SSL_NO_RNG ); - } - - if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, - ssl->handshake->randbytes, - CLIENT_HELLO_RAND_BYTES_LEN ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); - return( ret ); - } - - return( 0 ); -} - -static int ssl_tls13_finalize_client_hello( mbedtls_ssl_context* ssl ) -{ - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_HELLO ); - - return( 0 ); -} /* Write extensions */ +/* + * ssl_tls13_write_supported_versions_ext(): + * + * struct { + * ProtocolVersion versions<2..254>; + * } SupportedVersions; + */ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, - size_t *olen ); + size_t *olen ) +{ + unsigned char *p = buf; + + *olen = 0; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported version extension" ) ); + + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); + + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0); + + /* total length */ + MBEDTLS_PUT_UINT16_BE( 3, p, 2); + p+=4; + + /* length of next field */ + *p++ = 0x2; + + /* This implementation only supports a single TLS version, and only + * advertises a single value. + */ + mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, + ssl->conf->transport, p ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", + ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); + + *olen = 7; + + return( 0 ); +} #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ); + unsigned char *buf, + unsigned char *end, + size_t *olen ) +{ + ((void) ssl); + ((void) buf); + ((void) end); + ((void) olen); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, - size_t *olen ); + size_t *olen ) +{ + ((void) ssl); + ((void) buf); + ((void) end); + ((void) olen); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ +/* Functions for ClientHello */ + static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *len_with_binders ) @@ -344,7 +291,9 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, * For cTLS we only need to provide it if there is more than one version * and currently there is only one. */ - ssl_tls13_write_supported_versions_ext( ssl, buf, end, &cur_ext_len ); + ret = ssl_tls13_write_supported_versions_ext( ssl, buf, end, &cur_ext_len ); + if( ret != 0 ) + return( ret ); total_ext_len += cur_ext_len; buf += cur_ext_len; @@ -400,77 +349,104 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, return( 0 ); } -/* - * ssl_tls13_write_supported_versions_ext(): - * - * struct { - * ProtocolVersion versions<2..254>; - * } SupportedVersions; - */ -static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +static int ssl_tls13_finalize_client_hello( mbedtls_ssl_context* ssl ) { - unsigned char *p = buf; + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_HELLO ); + return( 0 ); +} - *olen = 0; +static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) +{ + int ret; - MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported version extension" ) ); + if( ssl->conf->f_rng == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "no RNG provided" ) ); + return( MBEDTLS_ERR_SSL_NO_RNG ); + } - MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); - - MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0); - - /* total length */ - MBEDTLS_PUT_UINT16_BE( 3, p, 2); - - p+=4; - - /* length of next field */ - *p++ = 0x2; - - /* This implementation only supports a single TLS version, and only - * advertises a single value. - */ - mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, - ssl->conf->transport, p ); - - MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", - ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); - - *olen = 7; + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, + ssl->handshake->randbytes, + CLIENT_HELLO_RAND_BYTES_LEN ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); + return( ret ); + } return( 0 ); } -#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) - -static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +/* + * ClientHello Main entry point. + * orchestrates the other functions. + */ +static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) { - ((void) ssl); - ((void) buf); - ((void) end); - ((void) olen); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + int ret = 0; + unsigned char *buf; + size_t buf_len, msg_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); + + MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_client_hello, ( ssl ) ); + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg, + ( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, + &buf, &buf_len ) ); + + MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_exts_client_hello, + ( ssl, buf, buf_len, &msg_len ) ); + + mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, + msg_len ); + ssl->handshake->update_checksum( ssl, buf, 0 ); + + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_client_hello, ( ssl ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg, + ( ssl, buf_len, msg_len ) ); + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write client hello" ) ); + return ret; } -static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) { - ((void) ssl); - ((void) buf); - ((void) end); - ((void) olen); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); -} + int ret = 0; -#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Handshake completed but ssl->handshake is NULL.\n" ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); + + switch( ssl->state ) + { + /* + * ssl->state is initialized as HELLO_REQUEST. It is same + * with CLIENT_HELLO status + */ + case MBEDTLS_SSL_HELLO_REQUEST: + case MBEDTLS_SSL_CLIENT_HELLO: + ret = ssl_tls13_write_client_hello( ssl ); + break; + + case MBEDTLS_SSL_SERVER_HELLO: + // Stop here : we haven't finished whole flow + ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); + break; + + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + return( ret ); +} #endif /* MBEDTLS_SSL_CLI_C */ From 275619336a78c6879f82168e00fa6b510ee63ccc Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 27 Aug 2021 17:07:38 +0800 Subject: [PATCH 421/966] fix name conversion issue for tls13 server entry Signed-off-by: Jerry Yu --- library/ssl_misc.h | 2 +- library/ssl_tls.c | 2 +- library/ssl_tls13_server.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 016dfe162e..10b07b751a 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -950,7 +950,7 @@ int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_handshake_server_step_tls1_3( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl ); #endif int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index c43f95ee1b..360419240f 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5189,7 +5189,7 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) { #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) if( mbedtls_ssl_conf_is_tls13_only( ssl->conf ) ) - ret = mbedtls_ssl_handshake_server_step_tls1_3( ssl ); + ret = mbedtls_ssl_tls13_handshake_server_step( ssl ); #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_PROTO_TLS1_2) diff --git a/library/ssl_tls13_server.c b/library/ssl_tls13_server.c index a56727741b..0dcd7ed602 100644 --- a/library/ssl_tls13_server.c +++ b/library/ssl_tls13_server.c @@ -25,7 +25,7 @@ #include "ssl_misc.h" -int mbedtls_ssl_handshake_server_step_tls1_3( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl ) { ((void) ssl); return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); From 5cc8f0a0d849407adac6e033a80a0b8cf34eb58a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 27 Aug 2021 17:21:44 +0800 Subject: [PATCH 422/966] Add simple document for tls13 functions Signed-off-by: Jerry Yu --- library/ssl_misc.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 10b07b751a..8c38cd06e1 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -132,8 +132,15 @@ #define MBEDTLS_SSL_EXT_SIG_ALG_CERT ( 1 << 20 ) #define MBEDTLS_SSL_EXT_KEY_SHARE ( 1 << 21 ) +/* + * Helper macros for function call with returen check. + */ +/* utils for strip parens in marcro */ #define MBEDTLS_SSL_PROC_STRIP_PARENS( ... ) __VA_ARGS__ +/* + * Exit and print debug message when return none zero value + */ #define MBEDTLS_SSL_PROC_CHK( fn, args ) \ do { \ ret = fn(MBEDTLS_SSL_PROC_STRIP_PARENS args); \ @@ -146,6 +153,9 @@ } \ } while( 0 ) +/* + * Exit and print debug message when return negative value + */ #define MBEDTLS_SSL_PROC_CHK_NEG( fn, args ) \ do { \ ret = fn(MBEDTLS_SSL_PROC_STRIP_PARENS args); \ @@ -949,7 +959,18 @@ int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +/** + * \brief TLS1.3 client side state machine entry + * + * \param ssl SSL context + */ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ); + +/** + * \brief TLS1.3 server side state machine entry + * + * \param ssl SSL context + */ int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl ); #endif @@ -1390,18 +1411,30 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context* ssl, ssl->state = state; } +/* + * Write tls13 handshake message header + */ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, size_t *buflen ); +/* + * Write tls13 handshake message tail + */ int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, size_t buf_len, size_t msg_len ); +/* + * Update checksum with handshake header + */ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, size_t total_hs_len ); #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) +/* + * Write TLS1.3 Signature Algorithm extesion + */ int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen); From c4d22444d65c6483e349f3019ed38454c41176e8 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 27 Aug 2021 20:04:33 +0800 Subject: [PATCH 423/966] fix undeclared variable error Signed-off-by: Jerry Yu # Conflicts: # library/ssl_tls13_client.c --- library/ssl_tls13_client.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 41b133437d..a03aa8e461 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -112,7 +112,7 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *len_with_binders ) { - /* Extensions */ + /* Extensions */ /* extension_start * Used during extension writing where the @@ -120,9 +120,7 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, * extension list must be kept to write * the total extension list size in the end. */ -#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) int ret; -#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ unsigned char* extension_start; size_t cur_ext_len; /* Size of the current extension */ size_t total_ext_len; /* Size of list of extensions */ From 995ecd396ffbba84dcf84d3399c6fd270ec1b820 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 30 Aug 2021 17:53:49 +0800 Subject: [PATCH 424/966] fix wrong iana values and comments Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 14 +++++++------- library/ssl_misc.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index b7b22c20d4..540ff1fc52 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -472,21 +472,21 @@ #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4 -#define MBEDTLS_TLS_EXT_STATUS_REQUEST 5 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_STATUS_REQUEST 5 /* RFC 6066 TLS 1.3 */ #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10 -#define MBEDTLS_TLS_EXT_SUPPORTED_GROUPS 10 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_SUPPORTED_GROUPS 10 /* RFC 8422,7919 TLS 1.3 */ #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11 #define MBEDTLS_TLS_EXT_SIG_ALG 13 /* RFC 8446 TLS 1.3 */ #define MBEDTLS_TLS_EXT_USE_SRTP 14 -#define MBEDTLS_TLS_EXT_HEARTBEAT 15 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_HEARTBEAT 15 /* RFC 6520 TLS 1.3 */ #define MBEDTLS_TLS_EXT_ALPN 16 -#define MBEDTLS_TLS_EXT_SCT 18 /* RFC 8446 TLS 1.3 */ -#define MBEDTLS_TLS_EXT_SERV_CERT_TYPE 19 /* RFC 8446 TLS 1.3 */ -#define MBEDTLS_TLS_EXT_CLI_CERT_TYPE 20 /* RFC 8446 TLS 1.3 */ -#define MBEDTLS_TLS_EXT_PADDING 21 /* RFC 8446 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_SCT 18 /* RFC 6962 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_CLI_CERT_TYPE 19 /* RFC 7259 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_SERV_CERT_TYPE 20 /* RFC 7250 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_PADDING 21 /* RFC 7685 TLS 1.3 */ #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */ #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 8c38cd06e1..32017f3458 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -118,8 +118,8 @@ #define MBEDTLS_SSL_EXT_HEARTBEAT ( 1 << 6 ) #define MBEDTLS_SSL_EXT_ALPN ( 1 << 7 ) #define MBEDTLS_SSL_EXT_SCT ( 1 << 8 ) -#define MBEDTLS_SSL_EXT_SERV_CERT_TYPE ( 1 << 9 ) -#define MBEDTLS_SSL_EXT_CLI_CERT_TYPE ( 1 << 10 ) +#define MBEDTLS_SSL_EXT_CLI_CERT_TYPE ( 1 << 9 ) +#define MBEDTLS_SSL_EXT_SERV_CERT_TYPE ( 1 << 10 ) #define MBEDTLS_SSL_EXT_PADDING ( 1 << 11 ) #define MBEDTLS_SSL_EXT_PRE_SHARED_KEY ( 1 << 12 ) #define MBEDTLS_SSL_EXT_EARLY_DATA ( 1 << 13 ) From eecfbf001cb6dff76bb6756e259818ce40fc38d1 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 30 Aug 2021 18:32:07 +0800 Subject: [PATCH 425/966] fix format issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 23 ++++++++-------- library/ssl_tls13_client.c | 55 +++++++++++++++++++------------------ library/ssl_tls13_generic.c | 23 ++++++++-------- 3 files changed, 53 insertions(+), 48 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 32017f3458..50aee6ffd2 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1405,8 +1405,8 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context* ssl, - mbedtls_ssl_states state ) +static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl, + mbedtls_ssl_states state ) { ssl->state = state; } @@ -1415,29 +1415,30 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context* ssl, * Write tls13 handshake message header */ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, - unsigned hs_type, - unsigned char **buf, - size_t *buflen ); + unsigned hs_type, + unsigned char **buf, + size_t *buflen ); /* * Write tls13 handshake message tail */ int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, - size_t buf_len, - size_t msg_len ); + size_t buf_len, + size_t msg_len ); /* * Update checksum with handshake header */ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, - unsigned hs_type, - size_t total_hs_len ); + unsigned hs_type, + size_t total_hs_len ); #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* * Write TLS1.3 Signature Algorithm extesion */ int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, unsigned char *end, - size_t *olen); + unsigned char *buf, + unsigned char *end, + size_t *olen); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index a03aa8e461..ef9836d195 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -43,9 +43,9 @@ * } SupportedVersions; */ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) + unsigned char *buf, + unsigned char *end, + size_t *olen ) { unsigned char *p = buf; @@ -55,11 +55,11 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); - MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 ); /* total length */ MBEDTLS_PUT_UINT16_BE( 3, p, 2); - p+=4; + p += 4; /* length of next field */ *p++ = 0x2; @@ -67,11 +67,13 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, /* This implementation only supports a single TLS version, and only * advertises a single value. */ - mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, - ssl->conf->transport, p ); + mbedtls_ssl_write_version( ssl->conf->max_major_ver, + ssl->conf->max_minor_ver, + ssl->conf->transport, p ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", - ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); + ssl->conf->max_major_ver, + ssl->conf->max_minor_ver ) ); *olen = 7; @@ -81,9 +83,9 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); @@ -93,9 +95,9 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, } static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); @@ -109,8 +111,9 @@ static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, /* Functions for ClientHello */ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, - unsigned char *buf, size_t buflen, - size_t *len_with_binders ) + unsigned char *buf, + size_t buflen, + size_t *len_with_binders ) { /* Extensions */ @@ -121,20 +124,20 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, * the total extension list size in the end. */ int ret; - unsigned char* extension_start; + unsigned char *extension_start; size_t cur_ext_len; /* Size of the current extension */ size_t total_ext_len; /* Size of list of extensions */ /* Buffer management */ - unsigned char* start = buf; - unsigned char* end = buf + buflen; + unsigned char *start = buf; + unsigned char *end = buf + buflen; /* Ciphersuite-related variables */ - const int* ciphersuites; - const mbedtls_ssl_ciphersuite_t* ciphersuite_info; + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; /* ciphersuite_start points to the start of the ciphersuite list, i.e. to the length field*/ - unsigned char* ciphersuite_start; + unsigned char *ciphersuite_start; size_t ciphersuite_count; /* Keeping track of the included extensions */ @@ -167,13 +170,13 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, * * In cTLS the version number is elided. */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_VERSION_LEN); + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_VERSION_LEN ); MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0); buf += 2; buflen -= CLIENT_HELLO_VERSION_LEN; /* Write random bytes */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RAND_BYTES_LEN); + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RAND_BYTES_LEN ); memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf, CLIENT_HELLO_RAND_BYTES_LEN ); @@ -255,7 +258,7 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, } /* write ciphersuite length now */ - MBEDTLS_PUT_UINT16_BE( ciphersuite_count*2, ciphersuite_start, 0); + MBEDTLS_PUT_UINT16_BE( ciphersuite_count*2, ciphersuite_start, 0 ); ciphersuite_start += 2; MBEDTLS_SSL_DEBUG_MSG( 3, @@ -340,7 +343,7 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extension_start, total_ext_len ); /* Write extension length */ - MBEDTLS_PUT_UINT16_BE( total_ext_len, extension_start, 0); + MBEDTLS_PUT_UINT16_BE( total_ext_len, extension_start, 0 ); extension_start += 2; *len_with_binders = ( extension_start + total_ext_len ) - start; diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index be44141518..4b087baa26 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -28,9 +28,9 @@ #include "ssl_misc.h" int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, - unsigned hs_type, - unsigned char **buf, - size_t *buflen ) + unsigned hs_type, + unsigned char **buf, + size_t *buflen ) { *buf = ssl->out_msg + 4; *buflen = MBEDTLS_SSL_OUT_CONTENT_LEN - 4; @@ -42,8 +42,8 @@ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, } int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, - size_t buf_len, - size_t msg_len ) + size_t buf_len, + size_t msg_len ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; ((void) buf_len); @@ -56,8 +56,8 @@ cleanup: } void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, - unsigned hs_type, - size_t total_hs_len ) + unsigned hs_type, + size_t total_hs_len ) { unsigned char hs_hdr[4]; @@ -90,10 +90,11 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, * Only if we handle at least one key exchange that needs signatures. */ -int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, - unsigned char* buf, - unsigned char* end, - size_t* olen ) +int mbedtls_ssl_tls13_write_signature_algorithms_ext( + mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); From e41dec015846b3e0d461654f6ef06814d10bde61 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 10:57:07 +0800 Subject: [PATCH 426/966] Rename write signature algorithms function To keep similar name with other place. Signed-off-by: Jerry Yu --- library/ssl_misc.h | 8 ++++---- library/ssl_tls13_client.c | 3 +-- library/ssl_tls13_generic.c | 11 +++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 50aee6ffd2..6b0bf574b6 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1435,10 +1435,10 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, /* * Write TLS1.3 Signature Algorithm extesion */ -int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen); +int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index ef9836d195..dce83f427b 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -311,8 +311,7 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, /* The supported_signature_algorithms extension is REQUIRED for * certificate authenticated ciphersuites. */ - ret = mbedtls_ssl_tls13_write_signature_algorithms_ext( ssl, buf, - end, &cur_ext_len ); + ret = mbedtls_ssl_tls13_write_sig_alg_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 4b087baa26..1713d4c813 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -73,7 +73,7 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* - * mbedtls_ssl_tls13_write_signature_algorithms_ext( ) + * mbedtls_ssl_tls13_write_sig_alg_ext( ) * * enum { * .... @@ -90,11 +90,10 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, * Only if we handle at least one key exchange that needs signatures. */ -int mbedtls_ssl_tls13_write_signature_algorithms_ext( - mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); From 08906d006b01566791587a2a9e6e9623bbea7a93 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 11:05:27 +0800 Subject: [PATCH 427/966] fix name conversion issues Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index dce83f427b..80386c80d3 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -30,8 +30,8 @@ #include "ssl_misc.h" #include -#define CLIENT_HELLO_RAND_BYTES_LEN 32 -#define CLIENT_HELLO_VERSION_LEN 2 +#define CLIENT_HELLO_RANDOM_LEN 32 +#define CLIENT_HELLO_LEGACY_VERSION_LEN 2 /* Write extensions */ @@ -110,7 +110,7 @@ static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, /* Functions for ClientHello */ -static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *len_with_binders ) @@ -170,19 +170,19 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, * * In cTLS the version number is elided. */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_VERSION_LEN ); + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_LEGACY_VERSION_LEN ); MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0); - buf += 2; - buflen -= CLIENT_HELLO_VERSION_LEN; + buf += CLIENT_HELLO_LEGACY_VERSION_LEN; + buflen -= CLIENT_HELLO_LEGACY_VERSION_LEN; /* Write random bytes */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RAND_BYTES_LEN ); - memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ); + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RANDOM_LEN ); + memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RANDOM_LEN ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", - buf, CLIENT_HELLO_RAND_BYTES_LEN ); + buf, CLIENT_HELLO_RANDOM_LEN ); - buf += CLIENT_HELLO_RAND_BYTES_LEN; - buflen -= CLIENT_HELLO_RAND_BYTES_LEN; + buf += CLIENT_HELLO_RANDOM_LEN; + buflen -= CLIENT_HELLO_RANDOM_LEN; /* Versions of TLS before TLS 1.3 supported a * "session resumption" feature which has been merged with pre-shared @@ -367,7 +367,7 @@ static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->handshake->randbytes, - CLIENT_HELLO_RAND_BYTES_LEN ) ) != 0 ) + CLIENT_HELLO_RANDOM_LEN ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); return( ret ); @@ -394,7 +394,7 @@ static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) ( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_exts_client_hello, + MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_client_hello_body, ( ssl, buf, buf_len, &msg_len ) ); mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, From 159c5a0e12b3769b14ae7c7e7aab2fe310eafd05 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 12:51:25 +0800 Subject: [PATCH 428/966] fix comments issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 6 +++--- library/ssl_tls13_client.c | 42 +++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 6b0bf574b6..b1f5f36f55 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1412,14 +1412,14 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl, } /* - * Write tls13 handshake message header + * Write TLS 1.3 handshake message header */ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, size_t *buflen ); /* - * Write tls13 handshake message tail + * Write TLS 1.3 handshake message tail */ int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, size_t buf_len, @@ -1433,7 +1433,7 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* - * Write TLS1.3 Signature Algorithm extesion + * Write TLS 1.3 Signature Algorithm extension */ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf, diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 80386c80d3..f30d408230 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -51,17 +51,24 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, *olen = 0; - MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported version extension" ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported versions extension" ) ); + /* + * ExtensionType 2 + * ExtensionLength 2 + * VersionSLength 1 + * Version 2 + */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); + /* Write Extension Type */ MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 ); - /* total length */ + /* Write Extension Length */ MBEDTLS_PUT_UINT16_BE( 3, p, 2); p += 4; - /* length of next field */ + /* Length of the SupportedVersions field data */ *p++ = 0x2; /* This implementation only supports a single TLS version, and only @@ -108,7 +115,7 @@ static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ -/* Functions for ClientHello */ +/* Functions for writing ClientHello message */ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, unsigned char *buf, @@ -319,11 +326,13 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, buf += cur_ext_len; /* We need to send the key shares under three conditions: - * 1 ) A certificate-based ciphersuite is being offered. In this case - * supported_groups and supported_signature extensions have been successfully added. - * 2 ) A PSK-based ciphersuite with ECDHE is offered. In this case the + * 1) A certificate-based ciphersuite is being offered. In this case + * supported_groups and supported_signature extensions have been + * successfully added. + * 2) A PSK-based ciphersuite with ECDHE is offered. In this case the * psk_key_exchange_modes has been added as the last extension. - * 3 ) Or, in case all ciphers are supported ( which includes #1 and #2 from above ) + * 3) Or, in case all ciphers are supported ( which includes #1 and #2 + * from above ) */ ret = ssl_tls13_write_key_shares_ext( ssl, buf, end, &cur_ext_len ); @@ -377,8 +386,21 @@ static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) } /* - * ClientHello Main entry point. - * orchestrates the other functions. + * Write ClientHello handshake message. + * + * Structure of this message: + * + * uint16 ProtocolVersion; + * opaque Random[32]; + * uint8 CipherSuite[2]; // Cryptographic suite selector + * struct { + * ProtocolVersion legacy_version = 0x0303; // TLS v1.2 + * Random random; + * opaque legacy_session_id<0..32>; + * CipherSuite cipher_suites<2..2^16-2>; + * opaque legacy_compression_methods<1..2^8-1>; + * Extension extensions<8..2^16-1>; + * } ClientHello; */ static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) { From 67d4ed5b22d846d05144989ad2ba33cb0656cb17 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 13:12:43 +0800 Subject: [PATCH 429/966] force change state type Signed-off-by: Jerry Yu --- library/ssl_misc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index b1f5f36f55..e93e55b633 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1408,7 +1408,7 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl, mbedtls_ssl_states state ) { - ssl->state = state; + ssl->state = ( int ) state; } /* From 6a643100029d4e739f0f45d5290b81fd3d9e836d Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 14:40:36 +0800 Subject: [PATCH 430/966] Cleanup client_hello body. cleanup `ssl_tls13_write_client_hello_body`, fix comments issues. And move ciphersuites to separate function Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 186 ++++++++++++++++++------------------- 1 file changed, 89 insertions(+), 97 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index f30d408230..f9cfff5217 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -115,8 +115,79 @@ static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ -/* Functions for writing ClientHello message */ +/* Write ciphersuites + * CipherSuite cipher_suites<2..2^16-2>; + */ +static int ssl_tls13_write_client_hello_ciphersuites( + mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) +{ + /* Ciphersuite-related variables */ + const int *ciphersuites; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + /* ciphersuite_start points to the start of + the ciphersuite list, i.e. to the length field*/ + unsigned char *ciphersuite_start, *ciphersuite_iter; + size_t buf_len; + *olen = 0 ; + + /* + * Ciphersuite list + * + * This is a list of the symmetric cipher options supported by + * the client, specifically the record protection algorithm + * ( including secret key length ) and a hash to be used with + * HKDF, in descending order of client preference. + */ + ciphersuites = ssl->conf->ciphersuite_list; + + /* Check available spaces for ciphersuite */ + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); + + /* Write ciphersuites */ + ciphersuite_start = buf + 2; + ciphersuite_iter = ciphersuite_start; + + for ( size_t i = 0; ciphersuites[i] != 0; i++ ) + { + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuites[i] ); + + if( ciphersuite_info == NULL ) + continue; + + if( ciphersuite_info->min_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 || + ciphersuite_info->max_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 ) + continue; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x, %s", + (unsigned int) ciphersuites[i], + ciphersuite_info->name ) ); + + /* Check for available spaces */ + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); + + MBEDTLS_PUT_UINT16_BE( ciphersuites[i], ciphersuite_iter, 0); + ciphersuite_iter += 2; + + } + + buf_len = ciphersuite_iter - ciphersuite_start; + + /* write ciphersuite buf length */ + MBEDTLS_PUT_UINT16_BE( buf_len, buf, 0 ); + + + MBEDTLS_SSL_DEBUG_MSG( 3, + ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", + buf_len/2 ) ); + + return( 0 ); +} + +/* Functions for writing ClientHello message */ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, @@ -139,13 +210,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, unsigned char *start = buf; unsigned char *end = buf + buflen; - /* Ciphersuite-related variables */ - const int *ciphersuites; - const mbedtls_ssl_ciphersuite_t *ciphersuite_info; - /* ciphersuite_start points to the start of - the ciphersuite list, i.e. to the length field*/ - unsigned char *ciphersuite_start; - size_t ciphersuite_count; + *len_with_binders = 0; /* Keeping track of the included extensions */ ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; @@ -169,7 +234,9 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, ssl->major_ver = ssl->conf->min_major_ver; ssl->minor_ver = ssl->conf->min_minor_ver; - /* For TLS 1.3 we use the legacy version number {0x03, 0x03} + /* Write legacy_version + * ProtocolVersion legacy_version = 0x0303; // TLS v1.2 + * For TLS 1.3 we use the legacy version number {0x03, 0x03} * instead of the true version number. * * For DTLS 1.3 we use the legacy version number @@ -180,16 +247,16 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_LEGACY_VERSION_LEN ); MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0); buf += CLIENT_HELLO_LEGACY_VERSION_LEN; - buflen -= CLIENT_HELLO_LEGACY_VERSION_LEN; - /* Write random bytes */ + /* Write random bytes + Random random + */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RANDOM_LEN ); memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RANDOM_LEN ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf, CLIENT_HELLO_RANDOM_LEN ); buf += CLIENT_HELLO_RANDOM_LEN; - buflen -= CLIENT_HELLO_RANDOM_LEN; /* Versions of TLS before TLS 1.3 supported a * "session resumption" feature which has been merged with pre-shared @@ -203,74 +270,14 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * ossification ). Otherwise, it MUST be set as a zero-length vector * ( i.e., a zero-valued single byte length field ). */ - if( buflen < 1 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small to hold ClientHello" ) ); - return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); - } - + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 1 ); *buf++ = 0; /* session id length set to zero */ - buflen -= 1; - /* - * Ciphersuite list - * - * This is a list of the symmetric cipher options supported by - * the client, specifically the record protection algorithm - * ( including secret key length ) and a hash to be used with - * HKDF, in descending order of client preference. - */ - ciphersuites = ssl->conf->ciphersuite_list; - - if( buflen < 2 /* for ciphersuite list length */ ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small to hold ClientHello" ) ); - return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); - } - - /* Skip writing ciphersuite length for now */ - ciphersuite_count = 0; - ciphersuite_start = buf; - buf += 2; - buflen -= 2; - - for ( size_t i = 0; ciphersuites[i] != 0; i++ ) - { - ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuites[i] ); - - if( ciphersuite_info == NULL ) - continue; - - if( ciphersuite_info->min_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 || - ciphersuite_info->max_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 ) - continue; - - MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x, %s", - (unsigned int) ciphersuites[i], - ciphersuite_info->name ) ); - - ciphersuite_count++; - - if( buflen < 2 /* for ciphersuite list length */ ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small to hold ClientHello" ) ); - return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); - } - - MBEDTLS_PUT_UINT16_BE( ciphersuites[i], buf, 0); - - buf += 2; - buflen -= 2; - - } - - /* write ciphersuite length now */ - MBEDTLS_PUT_UINT16_BE( ciphersuite_count*2, ciphersuite_start, 0 ); - ciphersuite_start += 2; - - MBEDTLS_SSL_DEBUG_MSG( 3, - ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", - ciphersuite_count ) ); + /* Write ciphersuites */ + ret = ssl_tls13_write_client_hello_ciphersuites( ssl, buf, end, &cur_ext_len ); + if( ret != 0) + return( ret ); + buf += cur_ext_len; /* For every TLS 1.3 ClientHello, this vector MUST contain exactly * one byte set to zero, which corresponds to the 'null' compression @@ -278,20 +285,13 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * * For cTLS this field is elided. */ - if( buflen < 2 /* for ciphersuite list length */ ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small to hold ClientHello" ) ); - return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); - } - + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); *buf++ = 1; *buf++ = MBEDTLS_SSL_COMPRESS_NULL; - buflen -= 2; /* First write extensions, then the total length */ extension_start = buf; - total_ext_len = 0; buf += 2; /* Supported Versions Extension is mandatory with TLS 1.3. @@ -302,7 +302,6 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, ret = ssl_tls13_write_supported_versions_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); - total_ext_len += cur_ext_len; buf += cur_ext_len; #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) @@ -312,8 +311,6 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, ret = ssl_tls13_write_supported_groups_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); - - total_ext_len += cur_ext_len; buf += cur_ext_len; /* The supported_signature_algorithms extension is REQUIRED for @@ -321,8 +318,6 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, ret = mbedtls_ssl_tls13_write_sig_alg_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); - - total_ext_len += cur_ext_len; buf += cur_ext_len; /* We need to send the key shares under three conditions: @@ -338,13 +333,13 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, ret = ssl_tls13_write_key_shares_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); - - total_ext_len += cur_ext_len; buf += cur_ext_len; + #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ /* Add more extensions here */ + total_ext_len = buf - extension_start - 2; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, total extension length: %" MBEDTLS_PRINTF_SIZET , total_ext_len ) ); @@ -354,7 +349,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, MBEDTLS_PUT_UINT16_BE( total_ext_len, extension_start, 0 ); extension_start += 2; - *len_with_binders = ( extension_start + total_ext_len ) - start; + *len_with_binders = buf - start; return( 0 ); } @@ -390,9 +385,6 @@ static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) * * Structure of this message: * - * uint16 ProtocolVersion; - * opaque Random[32]; - * uint8 CipherSuite[2]; // Cryptographic suite selector * struct { * ProtocolVersion legacy_version = 0x0303; // TLS v1.2 * Random random; From a2cf7bd2436f3ad506272547e3674bc40a827527 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 16:12:00 +0800 Subject: [PATCH 431/966] fix comment issues Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 10 +++++----- library/ssl_misc.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 540ff1fc52..b0491bfead 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -472,19 +472,19 @@ #define MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH 1 #define MBEDTLS_TLS_EXT_TRUNCATED_HMAC 4 -#define MBEDTLS_TLS_EXT_STATUS_REQUEST 5 /* RFC 6066 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_STATUS_REQUEST 5 /* RFC 6066 TLS 1.2 and 1.3 */ #define MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES 10 -#define MBEDTLS_TLS_EXT_SUPPORTED_GROUPS 10 /* RFC 8422,7919 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_SUPPORTED_GROUPS 10 /* RFC 8422,7919 TLS 1.2 and 1.3 */ #define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS 11 #define MBEDTLS_TLS_EXT_SIG_ALG 13 /* RFC 8446 TLS 1.3 */ #define MBEDTLS_TLS_EXT_USE_SRTP 14 -#define MBEDTLS_TLS_EXT_HEARTBEAT 15 /* RFC 6520 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_HEARTBEAT 15 /* RFC 6520 TLS 1.2 and 1.3 */ #define MBEDTLS_TLS_EXT_ALPN 16 -#define MBEDTLS_TLS_EXT_SCT 18 /* RFC 6962 TLS 1.3 */ -#define MBEDTLS_TLS_EXT_CLI_CERT_TYPE 19 /* RFC 7259 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_SCT 18 /* RFC 6962 TLS 1.2 and 1.3 */ +#define MBEDTLS_TLS_EXT_CLI_CERT_TYPE 19 /* RFC 7250 TLS 1.3 */ #define MBEDTLS_TLS_EXT_SERV_CERT_TYPE 20 /* RFC 7250 TLS 1.3 */ #define MBEDTLS_TLS_EXT_PADDING 21 /* RFC 7685 TLS 1.3 */ #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index e93e55b633..6b17667bfe 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -960,14 +960,14 @@ int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) /** - * \brief TLS1.3 client side state machine entry + * \brief TLS 1.3 client side state machine entry * * \param ssl SSL context */ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ); /** - * \brief TLS1.3 server side state machine entry + * \brief TLS 1.3 server side state machine entry * * \param ssl SSL context */ From b7ab336b3a98c2d2e8c8ff0bd5d328647e01849a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 16:16:19 +0800 Subject: [PATCH 432/966] fix format issue Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index f9cfff5217..736cd208e4 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -65,7 +65,7 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 ); /* Write Extension Length */ - MBEDTLS_PUT_UINT16_BE( 3, p, 2); + MBEDTLS_PUT_UINT16_BE( 3, p, 2 ); p += 4; /* Length of the SupportedVersions field data */ @@ -169,7 +169,7 @@ static int ssl_tls13_write_client_hello_ciphersuites( /* Check for available spaces */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); - MBEDTLS_PUT_UINT16_BE( ciphersuites[i], ciphersuite_iter, 0); + MBEDTLS_PUT_UINT16_BE( ciphersuites[i], ciphersuite_iter, 0 ); ciphersuite_iter += 2; } @@ -245,7 +245,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * In cTLS the version number is elided. */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_LEGACY_VERSION_LEN ); - MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0); + MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0 ); buf += CLIENT_HELLO_LEGACY_VERSION_LEN; /* Write random bytes From f171e836eb58f79f315f0d12cde0c50847a22647 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 18:31:09 +0800 Subject: [PATCH 433/966] fix lenght mismatch error Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 736cd208e4..41d2a321ec 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -184,6 +184,8 @@ static int ssl_tls13_write_client_hello_ciphersuites( ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", buf_len/2 ) ); + *olen = ciphersuite_iter - buf; + return( 0 ); } From 1bc2c1f1a3086a0d20c0251580f1ecd7564a0e7c Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 1 Sep 2021 12:57:29 +0800 Subject: [PATCH 434/966] fix various issues fix comments, format and name conversion issues Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 6 +- library/ssl_tls13_client.c | 240 ++++++++++++++++-------------------- library/ssl_tls13_generic.c | 8 ++ 3 files changed, 120 insertions(+), 134 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index b0491bfead..f533859959 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -484,9 +484,9 @@ #define MBEDTLS_TLS_EXT_ALPN 16 #define MBEDTLS_TLS_EXT_SCT 18 /* RFC 6962 TLS 1.2 and 1.3 */ -#define MBEDTLS_TLS_EXT_CLI_CERT_TYPE 19 /* RFC 7250 TLS 1.3 */ -#define MBEDTLS_TLS_EXT_SERV_CERT_TYPE 20 /* RFC 7250 TLS 1.3 */ -#define MBEDTLS_TLS_EXT_PADDING 21 /* RFC 7685 TLS 1.3 */ +#define MBEDTLS_TLS_EXT_CLI_CERT_TYPE 19 /* RFC 7250 TLS 1.2 and 1.3 */ +#define MBEDTLS_TLS_EXT_SERV_CERT_TYPE 20 /* RFC 7250 TLS 1.2 and 1.3 */ +#define MBEDTLS_TLS_EXT_PADDING 21 /* RFC 7685 TLS 1.2 and 1.3 */ #define MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC 22 /* 0x16 */ #define MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET 0x0017 /* 23 */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 41d2a321ec..944e5b50c3 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -31,7 +31,7 @@ #include #define CLIENT_HELLO_RANDOM_LEN 32 -#define CLIENT_HELLO_LEGACY_VERSION_LEN 2 +#define CLIENT_HELLO_LEGACY_VERSION_LEN 2 /* Write extensions */ @@ -54,25 +54,31 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported versions extension" ) ); /* - * ExtensionType 2 - * ExtensionLength 2 - * VersionSLength 1 - * Version 2 + * Reserve space for extension header. + * + * extension_type 2 + * extension_data_length 2 + * version_length 1 + * versions 2 */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); - /* Write Extension Type */ + /* Write extension_type */ MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 ); - /* Write Extension Length */ + /* Write extension_data_length */ MBEDTLS_PUT_UINT16_BE( 3, p, 2 ); p += 4; - /* Length of the SupportedVersions field data */ + /* Length of versions */ *p++ = 0x2; - /* This implementation only supports a single TLS version, and only - * advertises a single value. + /* Write values of supported version. + * + * They are come from configuration values. And + * ssl_conf_check has valided the values. + * + * Currently, only one vesrion is advertised. */ mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, @@ -115,22 +121,22 @@ static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ -/* Write ciphersuites +/* + * Functions for writing ClientHello message. + */ +/* Write cipher_suites * CipherSuite cipher_suites<2..2^16-2>; */ -static int ssl_tls13_write_client_hello_ciphersuites( +static int ssl_tls13_write_client_hello_cipher_suites( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ) { - /* Ciphersuite-related variables */ - const int *ciphersuites; - const mbedtls_ssl_ciphersuite_t *ciphersuite_info; - /* ciphersuite_start points to the start of - the ciphersuite list, i.e. to the length field*/ - unsigned char *ciphersuite_start, *ciphersuite_iter; - size_t buf_len; + const int *cipher_suite_list; + unsigned char *cipher_suites_start; /* start of the cipher_suite_list */ + unsigned char *cipher_suites_iter; /* iteration of the cipher_suite_list */ + size_t cipher_suites_len; *olen = 0 ; @@ -142,164 +148,146 @@ static int ssl_tls13_write_client_hello_ciphersuites( * ( including secret key length ) and a hash to be used with * HKDF, in descending order of client preference. */ - ciphersuites = ssl->conf->ciphersuite_list; + cipher_suite_list = ssl->conf->ciphersuite_list; - /* Check available spaces for ciphersuite */ + /* Check there is space for the cipher suite list length (2 bytes). */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); - /* Write ciphersuites */ - ciphersuite_start = buf + 2; - ciphersuite_iter = ciphersuite_start; + /* Write cipher_suite_list */ + cipher_suites_start = buf + 2; + cipher_suites_iter = cipher_suites_start; - for ( size_t i = 0; ciphersuites[i] != 0; i++ ) + for ( size_t i = 0; cipher_suite_list[i] != 0; i++ ) { - ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuites[i] ); + int cipher_suite = cipher_suite_list[i]; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( cipher_suite ); if( ciphersuite_info == NULL ) continue; - if( ciphersuite_info->min_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 || ciphersuite_info->max_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 ) continue; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x, %s", - (unsigned int) ciphersuites[i], + (unsigned int) cipher_suite, ciphersuite_info->name ) ); - /* Check for available spaces */ + /* Check there is space for the cipher suite identifier (2 bytes). */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); - - MBEDTLS_PUT_UINT16_BE( ciphersuites[i], ciphersuite_iter, 0 ); - ciphersuite_iter += 2; - + MBEDTLS_PUT_UINT16_BE( cipher_suite, cipher_suites_iter, 0 ); + cipher_suites_iter += 2; } - buf_len = ciphersuite_iter - ciphersuite_start; - - /* write ciphersuite buf length */ - MBEDTLS_PUT_UINT16_BE( buf_len, buf, 0 ); - - + /* Write the cipher_suite_list length in number of bytes */ + cipher_suites_len = cipher_suites_iter - cipher_suites_start; + MBEDTLS_PUT_UINT16_BE( cipher_suites_len, buf, 0 ); MBEDTLS_SSL_DEBUG_MSG( 3, - ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", - buf_len/2 ) ); + ( "client hello, got %" MBEDTLS_PRINTF_SIZET " cipher suites", + cipher_suites_len/2 ) ); - *olen = ciphersuite_iter - buf; + /* Output the total length of cipher_suites field. */ + *olen = cipher_suites_iter - buf; return( 0 ); } -/* Functions for writing ClientHello message */ +/* + * Structure of ClientHello message: + * + * struct { + * ProtocolVersion legacy_version = 0x0303; // TLS v1.2 + * Random random; + * opaque legacy_session_id<0..32>; + * CipherSuite cipher_suites<2..2^16-2>; + * opaque legacy_compression_methods<1..2^8-1>; + * Extension extensions<8..2^16-1>; + * } ClientHello; + */ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, - size_t *len_with_binders ) + size_t *olen ) { - /* Extensions */ - /* extension_start - * Used during extension writing where the - * buffer pointer to the beginning of the - * extension list must be kept to write - * the total extension list size in the end. - */ int ret; - unsigned char *extension_start; - size_t cur_ext_len; /* Size of the current extension */ - size_t total_ext_len; /* Size of list of extensions */ + unsigned char *extension_start; /* Start of extensions buffer */ + size_t cur_ext_len; /* Size of the current extension */ + size_t total_ext_len; /* Size of list of extensions */ /* Buffer management */ unsigned char *start = buf; unsigned char *end = buf + buflen; - *len_with_binders = 0; - - /* Keeping track of the included extensions */ - ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; - - /* NOTE: - * Even for DTLS 1.3, we are writing a TLS handshake header here. - * The actual DTLS 1.3 handshake header is inserted in - * the record writing routine mbedtls_ssl_write_record(). - * - * For cTLS the length, and the version field - * are elided. The random bytes are shorter. - */ - - if( ssl->conf->max_major_ver == 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "configured max major version is invalid, " - "consider using mbedtls_ssl_config_defaults()" ) ); - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - } + *olen = 0; + /* No validation needed here. It has been done by ssl_conf_check() */ ssl->major_ver = ssl->conf->min_major_ver; ssl->minor_ver = ssl->conf->min_minor_ver; - /* Write legacy_version + /* + * Write legacy_version * ProtocolVersion legacy_version = 0x0303; // TLS v1.2 - * For TLS 1.3 we use the legacy version number {0x03, 0x03} + * + * For TLS 1.3 we use the legacy version number {0x03, 0x03} * instead of the true version number. - * - * For DTLS 1.3 we use the legacy version number - * {254,253}. - * - * In cTLS the version number is elided. */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_LEGACY_VERSION_LEN ); MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0 ); buf += CLIENT_HELLO_LEGACY_VERSION_LEN; - /* Write random bytes - Random random - */ + /* Write the random bytes ( random ).*/ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RANDOM_LEN ); memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RANDOM_LEN ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf, CLIENT_HELLO_RANDOM_LEN ); - buf += CLIENT_HELLO_RANDOM_LEN; - /* Versions of TLS before TLS 1.3 supported a - * "session resumption" feature which has been merged with pre-shared - * keys in this version. A client which has a - * cached session ID set by a pre-TLS 1.3 server SHOULD set this - * field to that value. In compatibility mode, - * this field MUST be non-empty, so a client not offering a - * pre-TLS 1.3 session MUST generate a new 32-byte value. This value - * need not be random but SHOULD be unpredictable to avoid - * implementations fixating on a specific value ( also known as - * ossification ). Otherwise, it MUST be set as a zero-length vector - * ( i.e., a zero-valued single byte length field ). + /* + * Write legacy_session_id + * + * Versions of TLS before TLS 1.3 supported a "session resumption" feature + * which has been merged with pre-shared keys in this version. A client + * which has a cached session ID set by a pre-TLS 1.3 server SHOULD set + * this field to that value. In compatibility mode, this field MUST be + * non-empty, so a client not offering a pre-TLS 1.3 session MUST generate + * a new 32-byte value. This value need not be random but SHOULD be + * unpredictable to avoid implementations fixating on a specific value + * ( also known as ossification ). Otherwise, it MUST be set as a zero-length + * vector ( i.e., a zero-valued single byte length field ). */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 1 ); *buf++ = 0; /* session id length set to zero */ - /* Write ciphersuites */ - ret = ssl_tls13_write_client_hello_ciphersuites( ssl, buf, end, &cur_ext_len ); + /* Write cipher_suites */ + ret = ssl_tls13_write_client_hello_cipher_suites( ssl, buf, end, &cur_ext_len ); if( ret != 0) return( ret ); buf += cur_ext_len; - /* For every TLS 1.3 ClientHello, this vector MUST contain exactly + /* Write legacy_compression_methods + * + * For every TLS 1.3 ClientHello, this vector MUST contain exactly * one byte set to zero, which corresponds to the 'null' compression * method in prior versions of TLS. - * - * For cTLS this field is elided. */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); *buf++ = 1; *buf++ = MBEDTLS_SSL_COMPRESS_NULL; + /* Write extensions */ + + /* Keeping track of the included extensions */ + ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; /* First write extensions, then the total length */ + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); extension_start = buf; buf += 2; - /* Supported Versions Extension is mandatory with TLS 1.3. + /* Write supported_versions extension * - * For cTLS we only need to provide it if there is more than one version - * and currently there is only one. + * Supported Versions Extension is mandatory with TLS 1.3. */ ret = ssl_tls13_write_supported_versions_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) @@ -307,22 +295,18 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, buf += cur_ext_len; #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) - /* The supported_groups and the key_share extensions are - * REQUIRED for ECDHE ciphersuites. + /* Write supported_groups extension + * + * It is REQUIRED for ECDHE cipher_suites. */ ret = ssl_tls13_write_supported_groups_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); buf += cur_ext_len; - /* The supported_signature_algorithms extension is REQUIRED for - * certificate authenticated ciphersuites. */ - ret = mbedtls_ssl_tls13_write_sig_alg_ext( ssl, buf, end, &cur_ext_len ); - if( ret != 0 ) - return( ret ); - buf += cur_ext_len; - - /* We need to send the key shares under three conditions: + /* Write key_share extension + * + * We need to send the key shares under three conditions: * 1) A certificate-based ciphersuite is being offered. In this case * supported_groups and supported_signature extensions have been * successfully added. @@ -331,27 +315,32 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * 3) Or, in case all ciphers are supported ( which includes #1 and #2 * from above ) */ - ret = ssl_tls13_write_key_shares_ext( ssl, buf, end, &cur_ext_len ); if( ret != 0 ) return( ret ); buf += cur_ext_len; + /* Write signature_algorithms extension + * + * It is REQUIRED for certificate authenticated cipher_suites. + */ + ret = mbedtls_ssl_tls13_write_sig_alg_ext( ssl, buf, end, &cur_ext_len ); + if( ret != 0 ) + return( ret ); + buf += cur_ext_len; + #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ /* Add more extensions here */ + /* Write the length of the list of extensions. */ total_ext_len = buf - extension_start - 2; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, total extension length: %" MBEDTLS_PRINTF_SIZET , total_ext_len ) ); - MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extension_start, total_ext_len ); - - /* Write extension length */ MBEDTLS_PUT_UINT16_BE( total_ext_len, extension_start, 0 ); - extension_start += 2; - *len_with_binders = buf - start; + *olen = buf - start; return( 0 ); } @@ -384,17 +373,6 @@ static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) /* * Write ClientHello handshake message. - * - * Structure of this message: - * - * struct { - * ProtocolVersion legacy_version = 0x0303; // TLS v1.2 - * Random random; - * opaque legacy_session_id<0..32>; - * CipherSuite cipher_suites<2..2^16-2>; - * opaque legacy_compression_methods<1..2^8-1>; - * Extension extensions<8..2^16-1>; - * } ClientHello; */ static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) { diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 1713d4c813..f33c2f636b 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -32,6 +32,13 @@ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned char **buf, size_t *buflen ) { + /* + * Reserve 4 bytes for hanshake header. ( Section 4,RFC 8446 ) + * ... + * HandshakeType msg_type; + * uint24 length; + * ... + */ *buf = ssl->out_msg + 4; *buflen = MBEDTLS_SSL_OUT_CONTENT_LEN - 4; @@ -48,6 +55,7 @@ int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; ((void) buf_len); + /* Add reserved 4 bytes for handshake header */ ssl->out_msglen = msg_len + 4; MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext, ( ssl, 0 ) ); From 790656a0a61961296552b75b446bc3f4c50d1b32 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 1 Sep 2021 15:51:48 +0800 Subject: [PATCH 435/966] fix name conversion issues fix name conversion issues in `ssl_tls13_write_client_hello_body` Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 944e5b50c3..d354087413 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -211,9 +211,9 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, { int ret; - unsigned char *extension_start; /* Start of extensions buffer */ - size_t cur_ext_len; /* Size of the current extension */ - size_t total_ext_len; /* Size of list of extensions */ + unsigned char *extensions_len_ptr; /* pointer of extensions length */ + size_t output_len; /* Length of buffer used by function */ + size_t extensions_len; /* Length of the list of extensions*/ /* Buffer management */ unsigned char *start = buf; @@ -260,10 +260,10 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, *buf++ = 0; /* session id length set to zero */ /* Write cipher_suites */ - ret = ssl_tls13_write_client_hello_cipher_suites( ssl, buf, end, &cur_ext_len ); + ret = ssl_tls13_write_client_hello_cipher_suites( ssl, buf, end, &output_len ); if( ret != 0) return( ret ); - buf += cur_ext_len; + buf += output_len; /* Write legacy_compression_methods * @@ -282,27 +282,27 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, /* First write extensions, then the total length */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); - extension_start = buf; + extensions_len_ptr = buf; buf += 2; /* Write supported_versions extension * * Supported Versions Extension is mandatory with TLS 1.3. */ - ret = ssl_tls13_write_supported_versions_ext( ssl, buf, end, &cur_ext_len ); + ret = ssl_tls13_write_supported_versions_ext( ssl, buf, end, &output_len ); if( ret != 0 ) return( ret ); - buf += cur_ext_len; + buf += output_len; #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* Write supported_groups extension * * It is REQUIRED for ECDHE cipher_suites. */ - ret = ssl_tls13_write_supported_groups_ext( ssl, buf, end, &cur_ext_len ); + ret = ssl_tls13_write_supported_groups_ext( ssl, buf, end, &output_len ); if( ret != 0 ) return( ret ); - buf += cur_ext_len; + buf += output_len; /* Write key_share extension * @@ -315,30 +315,30 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * 3) Or, in case all ciphers are supported ( which includes #1 and #2 * from above ) */ - ret = ssl_tls13_write_key_shares_ext( ssl, buf, end, &cur_ext_len ); + ret = ssl_tls13_write_key_shares_ext( ssl, buf, end, &output_len ); if( ret != 0 ) return( ret ); - buf += cur_ext_len; + buf += output_len; /* Write signature_algorithms extension * * It is REQUIRED for certificate authenticated cipher_suites. */ - ret = mbedtls_ssl_tls13_write_sig_alg_ext( ssl, buf, end, &cur_ext_len ); + ret = mbedtls_ssl_tls13_write_sig_alg_ext( ssl, buf, end, &output_len ); if( ret != 0 ) return( ret ); - buf += cur_ext_len; + buf += output_len; #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ /* Add more extensions here */ /* Write the length of the list of extensions. */ - total_ext_len = buf - extension_start - 2; + extensions_len = buf - extensions_len_ptr - 2; + MBEDTLS_PUT_UINT16_BE( extensions_len, extensions_len_ptr, 0 ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, total extension length: %" MBEDTLS_PRINTF_SIZET , - total_ext_len ) ); - MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extension_start, total_ext_len ); - MBEDTLS_PUT_UINT16_BE( total_ext_len, extension_start, 0 ); + extensions_len ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extensions_len_ptr, extensions_len ); *olen = buf - start; return( 0 ); From 0c63af6ed6576aebdb8dcc3ec9852ae42b53c75e Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 2 Sep 2021 12:59:12 +0800 Subject: [PATCH 436/966] fix comment issues Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 35 +++++++++++++++++------------------ library/ssl_tls13_generic.c | 4 ++-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index d354087413..373efff10f 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -54,7 +54,7 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported versions extension" ) ); /* - * Reserve space for extension header. + * Check space for extension header. * * extension_type 2 * extension_data_length 2 @@ -73,12 +73,11 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, /* Length of versions */ *p++ = 0x2; - /* Write values of supported version. + /* Write values of supported versions. * - * They are come from configuration values. And - * ssl_conf_check has valided the values. + * They are defined by the configuration. * - * Currently, only one vesrion is advertised. + * Currently, only one version is advertised. */ mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, @@ -133,9 +132,9 @@ static int ssl_tls13_write_client_hello_cipher_suites( unsigned char *end, size_t *olen ) { - const int *cipher_suite_list; - unsigned char *cipher_suites_start; /* start of the cipher_suite_list */ - unsigned char *cipher_suites_iter; /* iteration of the cipher_suite_list */ + const int *ciphersuite_list; + unsigned char *cipher_suites_start; /* Start of the cipher_suites list */ + unsigned char *cipher_suites_iter; /* Iteration over the cipher_suites list */ size_t cipher_suites_len; *olen = 0 ; @@ -148,18 +147,18 @@ static int ssl_tls13_write_client_hello_cipher_suites( * ( including secret key length ) and a hash to be used with * HKDF, in descending order of client preference. */ - cipher_suite_list = ssl->conf->ciphersuite_list; + ciphersuite_list = ssl->conf->ciphersuite_list; /* Check there is space for the cipher suite list length (2 bytes). */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); - /* Write cipher_suite_list */ + /* Write cipher_suites */ cipher_suites_start = buf + 2; cipher_suites_iter = cipher_suites_start; - for ( size_t i = 0; cipher_suite_list[i] != 0; i++ ) + for ( size_t i = 0; ciphersuite_list[i] != 0; i++ ) { - int cipher_suite = cipher_suite_list[i]; + int cipher_suite = ciphersuite_list[i]; const mbedtls_ssl_ciphersuite_t *ciphersuite_info; ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( cipher_suite ); @@ -179,7 +178,7 @@ static int ssl_tls13_write_client_hello_cipher_suites( cipher_suites_iter += 2; } - /* Write the cipher_suite_list length in number of bytes */ + /* Write the cipher_suites length in number of bytes */ cipher_suites_len = cipher_suites_iter - cipher_suites_start; MBEDTLS_PUT_UINT16_BE( cipher_suites_len, buf, 0 ); MBEDTLS_SSL_DEBUG_MSG( 3, @@ -211,7 +210,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, { int ret; - unsigned char *extensions_len_ptr; /* pointer of extensions length */ + unsigned char *extensions_len_ptr; /* Pointer of extensions length */ size_t output_len; /* Length of buffer used by function */ size_t extensions_len; /* Length of the list of extensions*/ @@ -392,8 +391,8 @@ static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) ( ssl, buf, buf_len, &msg_len ) ); mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, - msg_len ); - ssl->handshake->update_checksum( ssl, buf, 0 ); + msg_len ); + ssl->handshake->update_checksum( ssl, buf, msg_len ); MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_client_hello, ( ssl ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg, @@ -420,8 +419,8 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) switch( ssl->state ) { /* - * ssl->state is initialized as HELLO_REQUEST. It is same - * with CLIENT_HELLO status + * ssl->state is initialized as HELLO_REQUEST. It is the same + * as CLIENT_HELLO state. */ case MBEDTLS_SSL_HELLO_REQUEST: case MBEDTLS_SSL_CLIENT_HELLO: diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index f33c2f636b..fb6da346fc 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -30,7 +30,7 @@ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, - size_t *buflen ) + size_t *buf_len ) { /* * Reserve 4 bytes for hanshake header. ( Section 4,RFC 8446 ) @@ -40,7 +40,7 @@ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, * ... */ *buf = ssl->out_msg + 4; - *buflen = MBEDTLS_SSL_OUT_CONTENT_LEN - 4; + *buf_len = MBEDTLS_SSL_OUT_CONTENT_LEN - 4; ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; ssl->out_msg[0] = hs_type; From 2c0fbf3405aa1d71f8f2d966a06399454a53afce Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 2 Sep 2021 13:53:46 +0800 Subject: [PATCH 437/966] modify proc_chk macros - change the parameter - remove debug output - remove return value modify Signed-off-by: Jerry Yu --- library/ssl_misc.h | 17 ++++------------- library/ssl_tls13_client.c | 23 +++++++++++++---------- library/ssl_tls13_generic.c | 2 +- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 6b17667bfe..e16c674cb0 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -26,7 +26,6 @@ #include "mbedtls/ssl.h" #include "mbedtls/cipher.h" -#include "mbedtls/debug.h" #if defined(MBEDTLS_USE_PSA_CRYPTO) #include "psa/crypto.h" @@ -135,33 +134,25 @@ /* * Helper macros for function call with returen check. */ -/* utils for strip parens in marcro */ -#define MBEDTLS_SSL_PROC_STRIP_PARENS( ... ) __VA_ARGS__ - /* * Exit and print debug message when return none zero value */ -#define MBEDTLS_SSL_PROC_CHK( fn, args ) \ +#define MBEDTLS_SSL_PROC_CHK( f ) \ do { \ - ret = fn(MBEDTLS_SSL_PROC_STRIP_PARENS args); \ + ret = ( f ); \ if( ret != 0 ) \ { \ - if( ret > 0 ) \ - ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR; \ - MBEDTLS_SSL_DEBUG_RET( 1, #fn, ret ); \ goto cleanup; \ } \ } while( 0 ) - /* * Exit and print debug message when return negative value */ -#define MBEDTLS_SSL_PROC_CHK_NEG( fn, args ) \ +#define MBEDTLS_SSL_PROC_CHK_NEG( f ) \ do { \ - ret = fn(MBEDTLS_SSL_PROC_STRIP_PARENS args); \ + ret = ( f ); \ if( ret < 0 ) \ { \ - MBEDTLS_SSL_DEBUG_RET( 1, #fn, ret ); \ goto cleanup; \ } \ } while( 0 ) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 373efff10f..6b89273353 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -381,22 +381,25 @@ static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client hello" ) ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_client_hello, ( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_client_hello( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg, - ( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, - &buf, &buf_len ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( + ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, + &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_client_hello_body, - ( ssl, buf, buf_len, &msg_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_client_hello_body( ssl, buf, + buf_len, + &msg_len ) ); - mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, + mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, + MBEDTLS_SSL_HS_CLIENT_HELLO, msg_len ); ssl->handshake->update_checksum( ssl, buf, msg_len ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_client_hello, ( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg, - ( ssl, buf_len, msg_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_client_hello( ssl ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg( ssl, + buf_len, + msg_len ) ); cleanup: diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index fb6da346fc..3c49a379bd 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -57,7 +57,7 @@ int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, /* Add reserved 4 bytes for handshake header */ ssl->out_msglen = msg_len + 4; - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext, ( ssl, 0 ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext( ssl, 0 ) ); cleanup: return( ret ); From ef387d79a467c77b68605bcfd91a2981518e9b62 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 2 Sep 2021 13:59:41 +0800 Subject: [PATCH 438/966] change prototype of write body To keep consistence with others Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 6b89273353..262481c6a7 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -205,7 +205,7 @@ static int ssl_tls13_write_client_hello_cipher_suites( */ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, unsigned char *buf, - size_t buflen, + unsigned char *end, size_t *olen ) { @@ -216,7 +216,6 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, /* Buffer management */ unsigned char *start = buf; - unsigned char *end = buf + buflen; *olen = 0; @@ -388,7 +387,7 @@ static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) &buf, &buf_len ) ); MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_client_hello_body( ssl, buf, - buf_len, + buf + buf_len, &msg_len ) ); mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, From 3050f054f23e1f1b8e23df6d7593aa97848e6159 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 2 Sep 2021 12:38:51 +0200 Subject: [PATCH 439/966] Subtract 1 from input in CCM's incomplete data tests Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.function | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 128bd86d98..57f13e3d85 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -533,8 +533,8 @@ void mbedtls_ccm_overflow_ad( int cipher_id, int mode, TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); // use hardcoded values for msg length and tag length. They are not a part of this test - // set half of auth data length to provoke an overflow - TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len / 2, 16, 16 ) ); + // subtract 1 from configured auth data length to provoke an overflow + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len - 1, 16, 16 ) ); TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); exit: @@ -556,7 +556,7 @@ void mbedtls_ccm_incomplete_ad( int cipher_id, int mode, // use hardcoded values for msg length and tag length. They are not a part of this test TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, 0, 16 ) ); - TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len/2) ); + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len - 1) ); ASSERT_ALLOC( output, 16 ); TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_finish( &ctx, output, 16 ) ); @@ -605,8 +605,8 @@ void mbedtls_ccm_overflow_update( int cipher_id, int mode, TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); // use hardcoded value for tag length. It is a not a part of this test - // set half of msg length to provoke an overflow - TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, msg->len / 2, 16 ) ); + // subtract 1 from configured msg length to provoke an overflow + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, msg->len - 1, 16 ) ); TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); @@ -639,7 +639,7 @@ void mbedtls_ccm_incomplete_update( int cipher_id, int mode, ASSERT_ALLOC( output, msg->len ); olen = 0xdeadbeef; - TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg->x, msg->len/2, output, msg->len, &olen ) ); + TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg->x, msg->len - 1, output, msg->len, &olen ) ); mbedtls_free( output ); output = NULL; From d614c0b197a25870fb8ddfa56fdabec01590580c Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 29 Jul 2021 11:18:29 +0100 Subject: [PATCH 440/966] Include translate ciphers tests in all.sh To run test_translate_ciphers_names.py and _format.sh in the CI, include it in all.sh component_check_generate_test_code. Rename check_generate_test_code to check_test_helpers Signed-off-by: Joe Subbiani --- tests/scripts/all.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 9944a853f5..c3517b1403 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2743,12 +2743,16 @@ component_check_python_files () { tests/scripts/check-python-files.sh } -component_check_generate_test_code () { - msg "uint test: generate_test_code.py" +component_check_test_helpers () { + msg "unit test: generate_test_code.py" # unittest writes out mundane stuff like number or tests run on stderr. # Our convention is to reserve stderr for actual errors, and write # harmless info on stdout so it can be suppress with --quiet. ./tests/scripts/test_generate_test_code.py 2>&1 + + msg "test: translate_ciphers.py" + ./tests/scripts/test_translate_ciphers_format.sh + ./tests/scripts/test_translate_ciphers_names.py } ################################################################ From c3610baddf63f85e97fcff8ab766ad9b7f43cb3a Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 29 Jul 2021 11:35:59 +0100 Subject: [PATCH 441/966] Check exit status of translate_ciphers.py If a call to translate_ciphers.py from compat.sh returns an exit 1 status, the error message will be echod and the program will exit Signed-off-by: Joe Subbiani --- tests/compat.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index e814e9db16..e532604bf3 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -236,6 +236,14 @@ reset_ciphersuites() G_CIPHERS="" } +check_translation() +{ + if [ $? -eq 1 ]; then + echo $T + exit 1 + fi +} + # Ciphersuites that can be used with all peers. # Since we currently have three possible peers, each ciphersuite should appear # three times: in each peer's list (with the name that this peer uses). @@ -320,11 +328,13 @@ add_common_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - G=`python3 scripts/translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" + T=`python3 scripts/translate_ciphers.py g "$CIPHERS"` + check_translation $? $T + G_CIPHERS="$G_CIPHERS $T" - O=`python3 scripts/translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" + T=`python3 scripts/translate_ciphers.py o "$CIPHERS"` + check_translation $? $T + O_CIPHERS="$O_CIPHERS $T" } # Ciphersuites usable only with Mbed TLS and OpenSSL @@ -406,8 +416,9 @@ add_openssl_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - O=`python3 scripts/translate_ciphers.py o "$CIPHERS"` - O_CIPHERS="$O_CIPHERS $O" + T=`python3 scripts/translate_ciphers.py o "$CIPHERS"` + check_translation $? $T + O_CIPHERS="$O_CIPHERS $T" } # Ciphersuites usable only with Mbed TLS and GnuTLS @@ -539,8 +550,9 @@ add_gnutls_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - G=`python3 scripts/translate_ciphers.py g "$CIPHERS"` - G_CIPHERS="$G_CIPHERS $G" + T=`python3 scripts/translate_ciphers.py g "$CIPHERS"` + check_translation $? $T + G_CIPHERS="$G_CIPHERS $T" } # Ciphersuites usable only with Mbed TLS (not currently supported by another From 439a696903a9aaa45ed5d3909466c23c2b324b46 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 29 Jul 2021 12:51:09 +0100 Subject: [PATCH 442/966] Improve translation error checking If translate_ciphers.py is used incorrectly in compat.sh, an error check function - check_translation - is called to evaluate and inform the user of the error that has occured. Added an output that informs the users an error has taken place in translate_ciphers.py incase the error response is an empty string. Signed-off-by: Joe Subbiani --- tests/compat.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index e532604bf3..36018f2d18 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -238,8 +238,9 @@ reset_ciphersuites() check_translation() { - if [ $? -eq 1 ]; then - echo $T + if [ $1 -ne 0 ]; then + echo "translate_ciphers.py failed with exit code $1" >&2 + echo "$2" >&2 exit 1 fi } @@ -329,11 +330,11 @@ add_common_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" T=`python3 scripts/translate_ciphers.py g "$CIPHERS"` - check_translation $? $T + check_translation $? "$T" G_CIPHERS="$G_CIPHERS $T" T=`python3 scripts/translate_ciphers.py o "$CIPHERS"` - check_translation $? $T + check_translation $? "$T" O_CIPHERS="$O_CIPHERS $T" } @@ -417,7 +418,7 @@ add_openssl_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" T=`python3 scripts/translate_ciphers.py o "$CIPHERS"` - check_translation $? $T + check_translation $? "$T" O_CIPHERS="$O_CIPHERS $T" } @@ -551,7 +552,7 @@ add_gnutls_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" T=`python3 scripts/translate_ciphers.py g "$CIPHERS"` - check_translation $? $T + check_translation $? "$T" G_CIPHERS="$G_CIPHERS $T" } From 918ee797cecfeaa8a18da4b159d41eced0e5e266 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 30 Jul 2021 16:57:04 +0100 Subject: [PATCH 443/966] Improve consitancy and useability test_translate_ciphers_names.py - Combined m, o and g ciphers all into one a single list of tuples to avoid needing to rely on indexes test_translate_ciphers_format.sh - Removed redundant test - Added return errors compat.sh - Improved how translate_ciphers.py is called translate_ciphers.py - Improve regex and translation to be more intutive and efficient - change how arguments are taken and handelled to be more reliable Signed-off-by: Joe Subbiani --- tests/compat.sh | 8 +- .../scripts/test_translate_ciphers_format.sh | 96 +- tests/scripts/test_translate_ciphers_names.py | 877 +++++++++--------- tests/scripts/translate_ciphers.py | 59 +- 4 files changed, 525 insertions(+), 515 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index 36018f2d18..4e18fce2d2 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -329,11 +329,11 @@ add_common_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - T=`python3 scripts/translate_ciphers.py g "$CIPHERS"` + T=$(./scripts/translate_ciphers.py g $CIPHERS) check_translation $? "$T" G_CIPHERS="$G_CIPHERS $T" - T=`python3 scripts/translate_ciphers.py o "$CIPHERS"` + T=$(./scripts/translate_ciphers.py o $CIPHERS) check_translation $? "$T" O_CIPHERS="$O_CIPHERS $T" } @@ -417,7 +417,7 @@ add_openssl_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - T=`python3 scripts/translate_ciphers.py o "$CIPHERS"` + T=$(./scripts/translate_ciphers.py o $CIPHERS) check_translation $? "$T" O_CIPHERS="$O_CIPHERS $T" } @@ -551,7 +551,7 @@ add_gnutls_ciphersuites() M_CIPHERS="$M_CIPHERS $CIPHERS" - T=`python3 scripts/translate_ciphers.py g "$CIPHERS"` + T=$(./scripts/translate_ciphers.py g $CIPHERS) check_translation $? "$T" G_CIPHERS="$G_CIPHERS $T" } diff --git a/tests/scripts/test_translate_ciphers_format.sh b/tests/scripts/test_translate_ciphers_format.sh index 6f1bdd08be..1dc7bbc0e8 100755 --- a/tests/scripts/test_translate_ciphers_format.sh +++ b/tests/scripts/test_translate_ciphers_format.sh @@ -29,84 +29,71 @@ # This files main purpose is to ensure translate_ciphers.py can take strings # in the expected format and return them in the format compat.sh will expect. +set -eu + if cd $( dirname $0 ); then :; else echo "cd $( dirname $0 ) failed" >&2 exit 1 fi -# Ciphers that will use translate_ciphers.py -M_CIPHERS="" +fail=0 + +# Initalize ciphers translated from Mbed TLS using translate_ciphers.py +O_TRANSLATED_CIPHERS="" +G_TRANSLATED_CIPHERS="" + +# Initalize ciphers that are known to be in the correct format O_CIPHERS="" G_CIPHERS="" -# Ciphers taken directly from compat.sh -Mt_CIPHERS="" -Ot_CIPHERS="" -Gt_CIPHERS="" - -# Initial list to be split into 3 +# Mbed TLS ciphersuite names to be translated +# into GnuTLS and OpenSSL CIPHERS="TLS-ECDHE-ECDSA-WITH-NULL-SHA \ TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ " -M_CIPHERS="$M_CIPHERS $CIPHERS" +G=$(./translate_ciphers.py g $CIPHERS) || fail=1 +G_TRANSLATED_CIPHERS="$G_TRANSLATED_CIPHERS $G" -G=`python3 translate_ciphers.py g "$CIPHERS"` -G_CIPHERS="$G_CIPHERS $G" +O=$(./translate_ciphers.py o $CIPHERS) || fail=1 +O_TRANSLATED_CIPHERS="$O_TRANSLATED_CIPHERS $O" -O=`python3 translate_ciphers.py o "$CIPHERS"` -O_CIPHERS="$O_CIPHERS $O" - -Mt_CIPHERS="$Mt_CIPHERS \ - TLS-ECDHE-ECDSA-WITH-NULL-SHA \ - TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ - TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ - TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ - " -Gt_CIPHERS="$Gt_CIPHERS \ +G_CIPHERS="$G_CIPHERS \ +ECDHE-ECDSA:+NULL:+SHA1 \ +ECDHE-ECDSA:+3DES-CBC:+SHA1 \ +ECDHE-ECDSA:+AES-128-CBC:+SHA1 \ +ECDHE-ECDSA:+AES-256-CBC:+SHA1 \ " -Ot_CIPHERS="$Ot_CIPHERS \ +O_CIPHERS="$O_CIPHERS \ ECDHE-ECDSA-NULL-SHA \ ECDHE-ECDSA-DES-CBC3-SHA \ ECDHE-ECDSA-AES128-SHA \ ECDHE-ECDSA-AES256-SHA \ " - -# Initial list to be split into 3 -CIPHERS="TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ +# Mbed TLS ciphersuite names to be translated +# into GnuTLS and OpenSSL +CIPHERS="TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ " -M_CIPHERS="$M_CIPHERS $CIPHERS" +G=$(./translate_ciphers.py g $CIPHERS) || fail=1 +G_TRANSLATED_CIPHERS="$G_TRANSLATED_CIPHERS $G" -G=`python3 translate_ciphers.py g "$CIPHERS"` -G_CIPHERS="$G_CIPHERS $G" +O=$(./translate_ciphers.py o $CIPHERS) || fail=1 +O_TRANSLATED_CIPHERS="$O_TRANSLATED_CIPHERS $O" -O=`python3 translate_ciphers.py o "$CIPHERS"` -O_CIPHERS="$O_CIPHERS $O" - -Mt_CIPHERS="$Mt_CIPHERS \ - TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ - TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ - TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ - TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ - " -Gt_CIPHERS="$Gt_CIPHERS \ +G_CIPHERS="$G_CIPHERS \ +ECDHE-ECDSA:+AES-128-CBC:+SHA256 \ +ECDHE-ECDSA:+AES-256-CBC:+SHA384 \ +ECDHE-ECDSA:+AES-128-GCM:+AEAD \ +ECDHE-ECDSA:+AES-256-GCM:+AEAD \ " -Ot_CIPHERS="$Ot_CIPHERS \ +O_CIPHERS="$O_CIPHERS \ ECDHE-ECDSA-AES128-SHA256 \ ECDHE-ECDSA-AES256-SHA384 \ ECDHE-ECDSA-AES128-GCM-SHA256 \ @@ -114,28 +101,25 @@ Ot_CIPHERS="$Ot_CIPHERS \ " # Normalise spacing -M_CIPHERS=$( echo "$M_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') -G_CIPHERS=$( echo "$G_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') -O_CIPHERS=$( echo "$O_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') +G_TRANSLATED_CIPHERS=$( echo $G_TRANSLATED_CIPHERS ) +O_TRANSLATED_CIPHERS=$( echo $O_TRANSLATED_CIPHERS ) -Mt_CIPHERS=$( echo "$Mt_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') -Gt_CIPHERS=$( echo "$Gt_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') -Ot_CIPHERS=$( echo "$Ot_CIPHERS" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//') +G_CIPHERS=$( echo $G_CIPHERS ) +O_CIPHERS=$( echo $O_CIPHERS ) # Compare the compat.sh names with the translated names # Upon fail, print them to view the differences -if [ "$Mt_CIPHERS" != "$M_CIPHERS" ] +if [ "$G_TRANSLATED_CIPHERS" != "$G_CIPHERS" ] then - echo "MBEDTLS Translated: $M_CIPHERS" - echo "MBEDTLS Original: $Mt_CIPHERS" + echo "GnuTLS Translated: $G_TRANSLATED_CIPHERS" + echo "GnuTLS Original: $G_CIPHERS" + fail=1 fi -if [ "$Gt_CIPHERS" != "$G_CIPHERS" ] +if [ "$O_TRANSLATED_CIPHERS" != "$O_CIPHERS" ] then - echo "GNUTLS Translated: $G_CIPHERS" - echo "GNUTLS Original: $Gt_CIPHERS" -fi -if [ "$Ot_CIPHERS" != "$O_CIPHERS" ] -then - echo "OpenSSL Translated: $O_CIPHERS" - echo "OpenSSL Original: $Ot_CIPHERS" + echo "OpenSSL Translated: $O_TRANSLATED_CIPHERS" + echo "OpenSSL Original: $O_CIPHERS" + fail=1 fi + +exit $fail diff --git a/tests/scripts/test_translate_ciphers_names.py b/tests/scripts/test_translate_ciphers_names.py index 84bcc9931d..33ad4e3db7 100755 --- a/tests/scripts/test_translate_ciphers_names.py +++ b/tests/scripts/test_translate_ciphers_names.py @@ -19,11 +19,11 @@ # """ -Test translate_ciphers.py by running every MBedTLS ciphersuite name +Test translate_ciphers.py by running every Mbed TLS ciphersuite name combination through the translate functions and comparing them to their correct GNUTLS or OpenSSL counterpart. """ - +import sys from translate_ciphers import translate_gnutls, translate_ossl def assert_equal(translate, original): @@ -36,431 +36,474 @@ def assert_equal(translate, original): assert translate == original except AssertionError: print("%s\n%s\n" %(translate, original)) + sys.exit(1) def test_all_common(): """ - Translate the MBedTLS ciphersuite names to the common OpenSSL and - GnuTLS ciphersite names, and compare them with the true, expected + Translate the Mbed TLS ciphersuite names to the common OpenSSL and + GnuTLS ciphersuite names, and compare them with the true, expected corresponding OpenSSL and GnuTLS ciphersuite names """ - m_ciphers = [ - "TLS-ECDHE-ECDSA-WITH-NULL-SHA", - "TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", - "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", - "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", + ciphers = [ + ("TLS-ECDHE-ECDSA-WITH-NULL-SHA", + "+ECDHE-ECDSA:+NULL:+SHA1", + "ECDHE-ECDSA-NULL-SHA"), + ("TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", + "+ECDHE-ECDSA:+3DES-CBC:+SHA1", + "ECDHE-ECDSA-DES-CBC3-SHA"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", + "+ECDHE-ECDSA:+AES-128-CBC:+SHA1", + "ECDHE-ECDSA-AES128-SHA"), + ("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", + "+ECDHE-ECDSA:+AES-256-CBC:+SHA1", + "ECDHE-ECDSA-AES256-SHA"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", + "+ECDHE-ECDSA:+AES-128-CBC:+SHA256", + "ECDHE-ECDSA-AES128-SHA256"), + ("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", + "+ECDHE-ECDSA:+AES-256-CBC:+SHA384", + "ECDHE-ECDSA-AES256-SHA384"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", + "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", + "ECDHE-ECDSA-AES128-GCM-SHA256"), + ("TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", + "+ECDHE-ECDSA:+AES-256-GCM:+AEAD", + "ECDHE-ECDSA-AES256-GCM-SHA384"), + ("TLS-DHE-RSA-WITH-AES-128-CBC-SHA", + "+DHE-RSA:+AES-128-CBC:+SHA1", + "DHE-RSA-AES128-SHA"), + ("TLS-DHE-RSA-WITH-AES-256-CBC-SHA", + "+DHE-RSA:+AES-256-CBC:+SHA1", + "DHE-RSA-AES256-SHA"), + ("TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", + "+DHE-RSA:+CAMELLIA-128-CBC:+SHA1", + "DHE-RSA-CAMELLIA128-SHA"), + ("TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", + "+DHE-RSA:+CAMELLIA-256-CBC:+SHA1", + "DHE-RSA-CAMELLIA256-SHA"), + ("TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", + "+DHE-RSA:+3DES-CBC:+SHA1", + "EDH-RSA-DES-CBC3-SHA"), + ("TLS-RSA-WITH-AES-256-CBC-SHA", + "+RSA:+AES-256-CBC:+SHA1", + "AES256-SHA"), + ("TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", + "+RSA:+CAMELLIA-256-CBC:+SHA1", + "CAMELLIA256-SHA"), + ("TLS-RSA-WITH-AES-128-CBC-SHA", + "+RSA:+AES-128-CBC:+SHA1", + "AES128-SHA"), + ("TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", + "+RSA:+CAMELLIA-128-CBC:+SHA1", + "CAMELLIA128-SHA"), + ("TLS-RSA-WITH-3DES-EDE-CBC-SHA", + "+RSA:+3DES-CBC:+SHA1", + "DES-CBC3-SHA"), + ("TLS-RSA-WITH-NULL-MD5", + "+RSA:+NULL:+MD5", + "NULL-MD5"), + ("TLS-RSA-WITH-NULL-SHA", + "+RSA:+NULL:+SHA1", + "NULL-SHA"), + ("TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", + "+ECDHE-RSA:+AES-128-CBC:+SHA1", + "ECDHE-RSA-AES128-SHA"), + ("TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", + "+ECDHE-RSA:+AES-256-CBC:+SHA1", + "ECDHE-RSA-AES256-SHA"), + ("TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", + "+ECDHE-RSA:+3DES-CBC:+SHA1", + "ECDHE-RSA-DES-CBC3-SHA"), + ("TLS-ECDHE-RSA-WITH-NULL-SHA", + "+ECDHE-RSA:+NULL:+SHA1", + "ECDHE-RSA-NULL-SHA"), + ("TLS-RSA-WITH-AES-128-CBC-SHA256", + "+RSA:+AES-128-CBC:+SHA256", + "AES128-SHA256"), + ("TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", + "+DHE-RSA:+AES-128-CBC:+SHA256", + "DHE-RSA-AES128-SHA256"), + ("TLS-RSA-WITH-AES-256-CBC-SHA256", + "+RSA:+AES-256-CBC:+SHA256", + "AES256-SHA256"), + ("TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", + "+DHE-RSA:+AES-256-CBC:+SHA256", + "DHE-RSA-AES256-SHA256"), + ("TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", + "+ECDHE-RSA:+AES-128-CBC:+SHA256", + "ECDHE-RSA-AES128-SHA256"), + ("TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", + "+ECDHE-RSA:+AES-256-CBC:+SHA384", + "ECDHE-RSA-AES256-SHA384"), + ("TLS-RSA-WITH-AES-128-GCM-SHA256", + "+RSA:+AES-128-GCM:+AEAD", + "AES128-GCM-SHA256"), + ("TLS-RSA-WITH-AES-256-GCM-SHA384", + "+RSA:+AES-256-GCM:+AEAD", + "AES256-GCM-SHA384"), + ("TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", + "+DHE-RSA:+AES-128-GCM:+AEAD", + "DHE-RSA-AES128-GCM-SHA256"), + ("TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", + "+DHE-RSA:+AES-256-GCM:+AEAD", + "DHE-RSA-AES256-GCM-SHA384"), + ("TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", + "+ECDHE-RSA:+AES-128-GCM:+AEAD", + "ECDHE-RSA-AES128-GCM-SHA256"), + ("TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", + "+ECDHE-RSA:+AES-256-GCM:+AEAD", + "ECDHE-RSA-AES256-GCM-SHA384"), + ("TLS-PSK-WITH-3DES-EDE-CBC-SHA", + "+PSK:+3DES-CBC:+SHA1", + "PSK-3DES-EDE-CBC-SHA"), + ("TLS-PSK-WITH-AES-128-CBC-SHA", + "+PSK:+AES-128-CBC:+SHA1", + "PSK-AES128-CBC-SHA"), + ("TLS-PSK-WITH-AES-256-CBC-SHA", + "+PSK:+AES-256-CBC:+SHA1", + "PSK-AES256-CBC-SHA"), - "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", - "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", - "TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", - "TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", + ("TLS-ECDH-ECDSA-WITH-NULL-SHA", + None, + "ECDH-ECDSA-NULL-SHA"), + ("TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", + None, + "ECDH-ECDSA-DES-CBC3-SHA"), + ("TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", + None, + "ECDH-ECDSA-AES128-SHA"), + ("TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", + None, + "ECDH-ECDSA-AES256-SHA"), + ("TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", + None, + "ECDH-ECDSA-AES128-SHA256"), + ("TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", + None, + "ECDH-ECDSA-AES256-SHA384"), + ("TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", + None, + "ECDH-ECDSA-AES128-GCM-SHA256"), + ("TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", + None, + "ECDH-ECDSA-AES256-GCM-SHA384"), + ("TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", + None, + "ECDHE-ECDSA-ARIA256-GCM-SHA384"), + ("TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", + None, + "ECDHE-ECDSA-ARIA128-GCM-SHA256"), + ("TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", + None, + "ECDHE-ECDSA-CHACHA20-POLY1305"), + ("TLS-RSA-WITH-DES-CBC-SHA", + None, + "DES-CBC-SHA"), + ("TLS-DHE-RSA-WITH-DES-CBC-SHA", + None, + "EDH-RSA-DES-CBC-SHA"), + ("TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", + None, + "ECDHE-ARIA256-GCM-SHA384"), + ("TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", + None, + "DHE-RSA-ARIA256-GCM-SHA384"), + ("TLS-RSA-WITH-ARIA-256-GCM-SHA384", + None, + "ARIA256-GCM-SHA384"), + ("TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", + None, + "ECDHE-ARIA128-GCM-SHA256"), + ("TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", + None, + "DHE-RSA-ARIA128-GCM-SHA256"), + ("TLS-RSA-WITH-ARIA-128-GCM-SHA256", + None, + "ARIA128-GCM-SHA256"), + ("TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + None, + "DHE-RSA-CHACHA20-POLY1305"), + ("TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + None, + "ECDHE-RSA-CHACHA20-POLY1305"), + ("TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", + None, + "DHE-PSK-ARIA256-GCM-SHA384"), + ("TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", + None, + "DHE-PSK-ARIA128-GCM-SHA256"), + ("TLS-PSK-WITH-ARIA-256-GCM-SHA384", + None, + "PSK-ARIA256-GCM-SHA384"), + ("TLS-PSK-WITH-ARIA-128-GCM-SHA256", + None, + "PSK-ARIA128-GCM-SHA256"), + ("TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", + None, + "PSK-CHACHA20-POLY1305"), + ("TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + None, + "ECDHE-PSK-CHACHA20-POLY1305"), + ("TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + None, + "DHE-PSK-CHACHA20-POLY1305"), - "TLS-DHE-RSA-WITH-AES-128-CBC-SHA", - "TLS-DHE-RSA-WITH-AES-256-CBC-SHA", - "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", - "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", - "TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", - "TLS-RSA-WITH-AES-256-CBC-SHA", - "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", - "TLS-RSA-WITH-AES-128-CBC-SHA", - "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", - "TLS-RSA-WITH-3DES-EDE-CBC-SHA", - "TLS-RSA-WITH-NULL-MD5", - "TLS-RSA-WITH-NULL-SHA", - - "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", - "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", - "TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", - "TLS-ECDHE-RSA-WITH-NULL-SHA", - - "TLS-RSA-WITH-AES-128-CBC-SHA256", - "TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", - "TLS-RSA-WITH-AES-256-CBC-SHA256", - "TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", - "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", - "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", - "TLS-RSA-WITH-AES-128-GCM-SHA256", - "TLS-RSA-WITH-AES-256-GCM-SHA384", - "TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", - "TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", - "TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", - "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", - - "TLS-PSK-WITH-3DES-EDE-CBC-SHA", - "TLS-PSK-WITH-AES-128-CBC-SHA", - "TLS-PSK-WITH-AES-256-CBC-SHA", - ] - g_ciphers = [ - "+ECDHE-ECDSA:+NULL:+SHA1", - "+ECDHE-ECDSA:+3DES-CBC:+SHA1", - "+ECDHE-ECDSA:+AES-128-CBC:+SHA1", - "+ECDHE-ECDSA:+AES-256-CBC:+SHA1", - - "+ECDHE-ECDSA:+AES-128-CBC:+SHA256", - "+ECDHE-ECDSA:+AES-256-CBC:+SHA384", - "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", - "+ECDHE-ECDSA:+AES-256-GCM:+AEAD", - - "+DHE-RSA:+AES-128-CBC:+SHA1", - "+DHE-RSA:+AES-256-CBC:+SHA1", - "+DHE-RSA:+CAMELLIA-128-CBC:+SHA1", - "+DHE-RSA:+CAMELLIA-256-CBC:+SHA1", - "+DHE-RSA:+3DES-CBC:+SHA1", - "+RSA:+AES-256-CBC:+SHA1", - "+RSA:+CAMELLIA-256-CBC:+SHA1", - "+RSA:+AES-128-CBC:+SHA1", - "+RSA:+CAMELLIA-128-CBC:+SHA1", - "+RSA:+3DES-CBC:+SHA1", - "+RSA:+NULL:+MD5", - "+RSA:+NULL:+SHA1", - - "+ECDHE-RSA:+AES-128-CBC:+SHA1", - "+ECDHE-RSA:+AES-256-CBC:+SHA1", - "+ECDHE-RSA:+3DES-CBC:+SHA1", - "+ECDHE-RSA:+NULL:+SHA1", - - "+RSA:+AES-128-CBC:+SHA256", - "+DHE-RSA:+AES-128-CBC:+SHA256", - "+RSA:+AES-256-CBC:+SHA256", - "+DHE-RSA:+AES-256-CBC:+SHA256", - "+ECDHE-RSA:+AES-128-CBC:+SHA256", - "+ECDHE-RSA:+AES-256-CBC:+SHA384", - "+RSA:+AES-128-GCM:+AEAD", - "+RSA:+AES-256-GCM:+AEAD", - "+DHE-RSA:+AES-128-GCM:+AEAD", - "+DHE-RSA:+AES-256-GCM:+AEAD", - "+ECDHE-RSA:+AES-128-GCM:+AEAD", - "+ECDHE-RSA:+AES-256-GCM:+AEAD", - - "+PSK:+3DES-CBC:+SHA1", - "+PSK:+AES-128-CBC:+SHA1", - "+PSK:+AES-256-CBC:+SHA1", - ] - o_ciphers = [ - "ECDHE-ECDSA-NULL-SHA", - "ECDHE-ECDSA-DES-CBC3-SHA", - "ECDHE-ECDSA-AES128-SHA", - "ECDHE-ECDSA-AES256-SHA", - - "ECDHE-ECDSA-AES128-SHA256", - "ECDHE-ECDSA-AES256-SHA384", - "ECDHE-ECDSA-AES128-GCM-SHA256", - "ECDHE-ECDSA-AES256-GCM-SHA384", - - "DHE-RSA-AES128-SHA", - "DHE-RSA-AES256-SHA", - "DHE-RSA-CAMELLIA128-SHA", - "DHE-RSA-CAMELLIA256-SHA", - "EDH-RSA-DES-CBC3-SHA", - "AES256-SHA", - "CAMELLIA256-SHA", - "AES128-SHA", - "CAMELLIA128-SHA", - "DES-CBC3-SHA", - "NULL-MD5", - "NULL-SHA", - - "ECDHE-RSA-AES128-SHA", - "ECDHE-RSA-AES256-SHA", - "ECDHE-RSA-DES-CBC3-SHA", - "ECDHE-RSA-NULL-SHA", - - #"NULL-SHA256", - "AES128-SHA256", - "DHE-RSA-AES128-SHA256", - "AES256-SHA256", - "DHE-RSA-AES256-SHA256", - "ECDHE-RSA-AES128-SHA256", - "ECDHE-RSA-AES256-SHA384", - "AES128-GCM-SHA256", - "AES256-GCM-SHA384", - "DHE-RSA-AES128-GCM-SHA256", - "DHE-RSA-AES256-GCM-SHA384", - "ECDHE-RSA-AES128-GCM-SHA256", - "ECDHE-RSA-AES256-GCM-SHA384", - - "PSK-3DES-EDE-CBC-SHA", - "PSK-AES128-CBC-SHA", - "PSK-AES256-CBC-SHA", + ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", + "+ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", + "+ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", + "+ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", + "+ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM", + "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-AES-256-CCM", + "+ECDHE-ECDSA:+AES-256-CCM:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", + "+ECDHE-ECDSA:+AES-128-CCM-8:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", + "+ECDHE-ECDSA:+AES-256-CCM-8:+AEAD", + None), + ("TLS-RSA-WITH-NULL-SHA256", + "+RSA:+NULL:+SHA256", + None), + ("TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "+ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", + "+ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "+RSA:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", + "+RSA:+CAMELLIA-256-CBC:+SHA256", + None), + ("TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "+DHE-RSA:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", + "+DHE-RSA:+CAMELLIA-256-CBC:+SHA256", + None), + ("TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "+ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "+ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "+DHE-RSA:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "+DHE-RSA:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "+RSA:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "+RSA:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-RSA-WITH-AES-128-CCM", + "+RSA:+AES-128-CCM:+AEAD", + None), + ("TLS-RSA-WITH-AES-256-CCM", + "+RSA:+AES-256-CCM:+AEAD", + None), + ("TLS-DHE-RSA-WITH-AES-128-CCM", + "+DHE-RSA:+AES-128-CCM:+AEAD", + None), + ("TLS-DHE-RSA-WITH-AES-256-CCM", + "+DHE-RSA:+AES-256-CCM:+AEAD", + None), + ("TLS-RSA-WITH-AES-128-CCM-8", + "+RSA:+AES-128-CCM-8:+AEAD", + None), + ("TLS-RSA-WITH-AES-256-CCM-8", + "+RSA:+AES-256-CCM-8:+AEAD", + None), + ("TLS-DHE-RSA-WITH-AES-128-CCM-8", + "+DHE-RSA:+AES-128-CCM-8:+AEAD", + None), + ("TLS-DHE-RSA-WITH-AES-256-CCM-8", + "+DHE-RSA:+AES-256-CCM-8:+AEAD", + None), + ("TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", + "+DHE-PSK:+3DES-CBC:+SHA1", + None), + ("TLS-DHE-PSK-WITH-AES-128-CBC-SHA", + "+DHE-PSK:+AES-128-CBC:+SHA1", + None), + ("TLS-DHE-PSK-WITH-AES-256-CBC-SHA", + "+DHE-PSK:+AES-256-CBC:+SHA1", + None), + ("TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", + "+ECDHE-PSK:+AES-256-CBC:+SHA1", + None), + ("TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", + "+ECDHE-PSK:+AES-128-CBC:+SHA1", + None), + ("TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", + "+ECDHE-PSK:+3DES-CBC:+SHA1", + None), + ("TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", + "+RSA-PSK:+3DES-CBC:+SHA1", + None), + ("TLS-RSA-PSK-WITH-AES-256-CBC-SHA", + "+RSA-PSK:+AES-256-CBC:+SHA1", + None), + ("TLS-RSA-PSK-WITH-AES-128-CBC-SHA", + "+RSA-PSK:+AES-128-CBC:+SHA1", + None), + ("TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", + "+ECDHE-PSK:+AES-256-CBC:+SHA384", + None), + ("TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "+ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", + "+ECDHE-PSK:+AES-128-CBC:+SHA256", + None), + ("TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "+ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-ECDHE-PSK-WITH-NULL-SHA384", + "+ECDHE-PSK:+NULL:+SHA384", + None), + ("TLS-ECDHE-PSK-WITH-NULL-SHA256", + "+ECDHE-PSK:+NULL:+SHA256", + None), + ("TLS-PSK-WITH-AES-128-CBC-SHA256", + "+PSK:+AES-128-CBC:+SHA256", + None), + ("TLS-PSK-WITH-AES-256-CBC-SHA384", + "+PSK:+AES-256-CBC:+SHA384", + None), + ("TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", + "+DHE-PSK:+AES-128-CBC:+SHA256", + None), + ("TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", + "+DHE-PSK:+AES-256-CBC:+SHA384", + None), + ("TLS-PSK-WITH-NULL-SHA256", + "+PSK:+NULL:+SHA256", + None), + ("TLS-PSK-WITH-NULL-SHA384", + "+PSK:+NULL:+SHA384", + None), + ("TLS-DHE-PSK-WITH-NULL-SHA256", + "+DHE-PSK:+NULL:+SHA256", + None), + ("TLS-DHE-PSK-WITH-NULL-SHA384", + "+DHE-PSK:+NULL:+SHA384", + None), + ("TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", + "+RSA-PSK:+AES-256-CBC:+SHA384", + None), + ("TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", + "+RSA-PSK:+AES-128-CBC:+SHA256", + None), + ("TLS-RSA-PSK-WITH-NULL-SHA256", + "+RSA-PSK:+NULL:+SHA256", + None), + ("TLS-RSA-PSK-WITH-NULL-SHA384", + "+RSA-PSK:+NULL:+SHA384", + None), + ("TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "+DHE-PSK:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "+DHE-PSK:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "+PSK:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "+PSK:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "+RSA-PSK:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "+RSA-PSK:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-PSK-WITH-AES-128-GCM-SHA256", + "+PSK:+AES-128-GCM:+AEAD", + None), + ("TLS-PSK-WITH-AES-256-GCM-SHA384", + "+PSK:+AES-256-GCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", + "+DHE-PSK:+AES-128-GCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", + "+DHE-PSK:+AES-256-GCM:+AEAD", + None), + ("TLS-PSK-WITH-AES-128-CCM", + "+PSK:+AES-128-CCM:+AEAD", + None), + ("TLS-PSK-WITH-AES-256-CCM", + "+PSK:+AES-256-CCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-128-CCM", + "+DHE-PSK:+AES-128-CCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-256-CCM", + "+DHE-PSK:+AES-256-CCM:+AEAD", + None), + ("TLS-PSK-WITH-AES-128-CCM-8", + "+PSK:+AES-128-CCM-8:+AEAD", + None), + ("TLS-PSK-WITH-AES-256-CCM-8", + "+PSK:+AES-256-CCM-8:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-128-CCM-8", + "+DHE-PSK:+AES-128-CCM-8:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-256-CCM-8", + "+DHE-PSK:+AES-256-CCM-8:+AEAD", + None), + ("TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "+RSA-PSK:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "+RSA-PSK:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "+PSK:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "+PSK:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "+DHE-PSK:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "+DHE-PSK:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", + "+RSA-PSK:+AES-256-GCM:+AEAD", + None), + ("TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", + "+RSA-PSK:+AES-128-GCM:+AEAD", + None), ] - for m, g_exp, o_exp in zip(m_ciphers, g_ciphers, o_ciphers): + for m, g_exp, o_exp in ciphers: - g = translate_gnutls(m) - assert_equal(g, g_exp) + if g_exp != None: + g = translate_gnutls(m) + assert_equal(g, g_exp) - o = translate_ossl(m) - assert_equal(o, o_exp) - -def test_mbedtls_ossl_common(): - """ - Translate the MBedTLS ciphersuite names to the common OpenSSL - ciphersite names, and compare them with the true, expected - corresponding OpenSSL ciphersuite name - """ - m_ciphers = [ - "TLS-ECDH-ECDSA-WITH-NULL-SHA", - "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", - "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", - "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", - - "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", - "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", - "TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", - "TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", - "TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", - "TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", - "TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", - - "TLS-RSA-WITH-DES-CBC-SHA", - "TLS-DHE-RSA-WITH-DES-CBC-SHA", - - "TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", - "TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", - "TLS-RSA-WITH-ARIA-256-GCM-SHA384", - "TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", - "TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", - "TLS-RSA-WITH-ARIA-128-GCM-SHA256", - "TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", - "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", - - "TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", - "TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", - "TLS-PSK-WITH-ARIA-256-GCM-SHA384", - "TLS-PSK-WITH-ARIA-128-GCM-SHA256", - "TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", - "TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", - "TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", - ] - o_ciphers = [ - "ECDH-ECDSA-NULL-SHA", - "ECDH-ECDSA-DES-CBC3-SHA", - "ECDH-ECDSA-AES128-SHA", - "ECDH-ECDSA-AES256-SHA", - - "ECDH-ECDSA-AES128-SHA256", - "ECDH-ECDSA-AES256-SHA384", - "ECDH-ECDSA-AES128-GCM-SHA256", - "ECDH-ECDSA-AES256-GCM-SHA384", - "ECDHE-ECDSA-ARIA256-GCM-SHA384", - "ECDHE-ECDSA-ARIA128-GCM-SHA256", - "ECDHE-ECDSA-CHACHA20-POLY1305", - - "DES-CBC-SHA", - "EDH-RSA-DES-CBC-SHA", - - "ECDHE-ARIA256-GCM-SHA384", - "DHE-RSA-ARIA256-GCM-SHA384", - "ARIA256-GCM-SHA384", - "ECDHE-ARIA128-GCM-SHA256", - "DHE-RSA-ARIA128-GCM-SHA256", - "ARIA128-GCM-SHA256", - "DHE-RSA-CHACHA20-POLY1305", - "ECDHE-RSA-CHACHA20-POLY1305", - - "DHE-PSK-ARIA256-GCM-SHA384", - "DHE-PSK-ARIA128-GCM-SHA256", - "PSK-ARIA256-GCM-SHA384", - "PSK-ARIA128-GCM-SHA256", - "PSK-CHACHA20-POLY1305", - "ECDHE-PSK-CHACHA20-POLY1305", - "DHE-PSK-CHACHA20-POLY1305", - ] - - for m, o_exp in zip(m_ciphers, o_ciphers): - - o = translate_ossl(m) - assert_equal(o, o_exp) - -def test_mbedtls_gnutls_common(): - """ - Translate the MBedTLS ciphersuite names to the common GnuTLS - ciphersite names, and compare them with the true, expected - corresponding GnuTLS ciphersuite names - """ - m_ciphers = [ - "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-ECDHE-ECDSA-WITH-AES-128-CCM", - "TLS-ECDHE-ECDSA-WITH-AES-256-CCM", - "TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", - "TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", - - "TLS-RSA-WITH-NULL-SHA256", - - "TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", - "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", - "TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-RSA-WITH-AES-128-CCM", - "TLS-RSA-WITH-AES-256-CCM", - "TLS-DHE-RSA-WITH-AES-128-CCM", - "TLS-DHE-RSA-WITH-AES-256-CCM", - "TLS-RSA-WITH-AES-128-CCM-8", - "TLS-RSA-WITH-AES-256-CCM-8", - "TLS-DHE-RSA-WITH-AES-128-CCM-8", - "TLS-DHE-RSA-WITH-AES-256-CCM-8", - - "TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", - "TLS-DHE-PSK-WITH-AES-128-CBC-SHA", - "TLS-DHE-PSK-WITH-AES-256-CBC-SHA", - - "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", - "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", - "TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", - "TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", - "TLS-RSA-PSK-WITH-AES-256-CBC-SHA", - "TLS-RSA-PSK-WITH-AES-128-CBC-SHA", - - "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", - "TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", - "TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-ECDHE-PSK-WITH-NULL-SHA384", - "TLS-ECDHE-PSK-WITH-NULL-SHA256", - "TLS-PSK-WITH-AES-128-CBC-SHA256", - "TLS-PSK-WITH-AES-256-CBC-SHA384", - "TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", - "TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", - "TLS-PSK-WITH-NULL-SHA256", - "TLS-PSK-WITH-NULL-SHA384", - "TLS-DHE-PSK-WITH-NULL-SHA256", - "TLS-DHE-PSK-WITH-NULL-SHA384", - "TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", - "TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", - "TLS-RSA-PSK-WITH-NULL-SHA256", - "TLS-RSA-PSK-WITH-NULL-SHA384", - "TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "TLS-PSK-WITH-AES-128-GCM-SHA256", - "TLS-PSK-WITH-AES-256-GCM-SHA384", - "TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", - "TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", - "TLS-PSK-WITH-AES-128-CCM", - "TLS-PSK-WITH-AES-256-CCM", - "TLS-DHE-PSK-WITH-AES-128-CCM", - "TLS-DHE-PSK-WITH-AES-256-CCM", - "TLS-PSK-WITH-AES-128-CCM-8", - "TLS-PSK-WITH-AES-256-CCM-8", - "TLS-DHE-PSK-WITH-AES-128-CCM-8", - "TLS-DHE-PSK-WITH-AES-256-CCM-8", - "TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", - "TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", - ] - g_ciphers = [ - "+ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256", - "+ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384", - "+ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD", - "+ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD", - "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", - "+ECDHE-ECDSA:+AES-256-CCM:+AEAD", - "+ECDHE-ECDSA:+AES-128-CCM-8:+AEAD", - "+ECDHE-ECDSA:+AES-256-CCM-8:+AEAD", - - "+RSA:+NULL:+SHA256", - - "+ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256", - "+ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384", - "+RSA:+CAMELLIA-128-CBC:+SHA256", - "+RSA:+CAMELLIA-256-CBC:+SHA256", - "+DHE-RSA:+CAMELLIA-128-CBC:+SHA256", - "+DHE-RSA:+CAMELLIA-256-CBC:+SHA256", - "+ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD", - "+ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD", - "+DHE-RSA:+CAMELLIA-128-GCM:+AEAD", - "+DHE-RSA:+CAMELLIA-256-GCM:+AEAD", - "+RSA:+CAMELLIA-128-GCM:+AEAD", - "+RSA:+CAMELLIA-256-GCM:+AEAD", - "+RSA:+AES-128-CCM:+AEAD", - "+RSA:+AES-256-CCM:+AEAD", - "+DHE-RSA:+AES-128-CCM:+AEAD", - "+DHE-RSA:+AES-256-CCM:+AEAD", - "+RSA:+AES-128-CCM-8:+AEAD", - "+RSA:+AES-256-CCM-8:+AEAD", - "+DHE-RSA:+AES-128-CCM-8:+AEAD", - "+DHE-RSA:+AES-256-CCM-8:+AEAD", - - "+DHE-PSK:+3DES-CBC:+SHA1", - "+DHE-PSK:+AES-128-CBC:+SHA1", - "+DHE-PSK:+AES-256-CBC:+SHA1", - - "+ECDHE-PSK:+AES-256-CBC:+SHA1", - "+ECDHE-PSK:+AES-128-CBC:+SHA1", - "+ECDHE-PSK:+3DES-CBC:+SHA1", - "+RSA-PSK:+3DES-CBC:+SHA1", - "+RSA-PSK:+AES-256-CBC:+SHA1", - "+RSA-PSK:+AES-128-CBC:+SHA1", - - "+ECDHE-PSK:+AES-256-CBC:+SHA384", - "+ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384", - "+ECDHE-PSK:+AES-128-CBC:+SHA256", - "+ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256", - "+ECDHE-PSK:+NULL:+SHA384", - "+ECDHE-PSK:+NULL:+SHA256", - "+PSK:+AES-128-CBC:+SHA256", - "+PSK:+AES-256-CBC:+SHA384", - "+DHE-PSK:+AES-128-CBC:+SHA256", - "+DHE-PSK:+AES-256-CBC:+SHA384", - "+PSK:+NULL:+SHA256", - "+PSK:+NULL:+SHA384", - "+DHE-PSK:+NULL:+SHA256", - "+DHE-PSK:+NULL:+SHA384", - "+RSA-PSK:+AES-256-CBC:+SHA384", - "+RSA-PSK:+AES-128-CBC:+SHA256", - "+RSA-PSK:+NULL:+SHA256", - "+RSA-PSK:+NULL:+SHA384", - "+DHE-PSK:+CAMELLIA-128-CBC:+SHA256", - "+DHE-PSK:+CAMELLIA-256-CBC:+SHA384", - "+PSK:+CAMELLIA-128-CBC:+SHA256", - "+PSK:+CAMELLIA-256-CBC:+SHA384", - "+RSA-PSK:+CAMELLIA-256-CBC:+SHA384", - "+RSA-PSK:+CAMELLIA-128-CBC:+SHA256", - "+PSK:+AES-128-GCM:+AEAD", - "+PSK:+AES-256-GCM:+AEAD", - "+DHE-PSK:+AES-128-GCM:+AEAD", - "+DHE-PSK:+AES-256-GCM:+AEAD", - "+PSK:+AES-128-CCM:+AEAD", - "+PSK:+AES-256-CCM:+AEAD", - "+DHE-PSK:+AES-128-CCM:+AEAD", - "+DHE-PSK:+AES-256-CCM:+AEAD", - "+PSK:+AES-128-CCM-8:+AEAD", - "+PSK:+AES-256-CCM-8:+AEAD", - "+DHE-PSK:+AES-128-CCM-8:+AEAD", - "+DHE-PSK:+AES-256-CCM-8:+AEAD", - "+RSA-PSK:+CAMELLIA-128-GCM:+AEAD", - "+RSA-PSK:+CAMELLIA-256-GCM:+AEAD", - "+PSK:+CAMELLIA-128-GCM:+AEAD", - "+PSK:+CAMELLIA-256-GCM:+AEAD", - "+DHE-PSK:+CAMELLIA-128-GCM:+AEAD", - "+DHE-PSK:+CAMELLIA-256-GCM:+AEAD", - "+RSA-PSK:+AES-256-GCM:+AEAD", - "+RSA-PSK:+AES-128-GCM:+AEAD", - ] - - for m, g_exp in zip(m_ciphers, g_ciphers): - - g = translate_gnutls(m) - assert_equal(g, g_exp) + if o_exp != None: + o = translate_ossl(m) + assert_equal(o, o_exp) test_all_common() -test_mbedtls_ossl_common() -test_mbedtls_gnutls_common() diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index 66c878ac39..39339c3d23 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -21,15 +21,13 @@ Translate ciphersuite names in MBedTLS format to OpenSSL and GNUTLS standards. -Format and analyse strings past in via input arguments to match -the expected strings utilised in compat.sh. - sys.argv[1] should be "g" or "o" for GNUTLS or OpenSSL. sys.argv[2] should be a string containing one or more ciphersuite names. """ import re import sys +import argparse def translate_gnutls(m_cipher): """ @@ -37,27 +35,25 @@ def translate_gnutls(m_cipher): and return the GnuTLS naming convention """ - # Remove "TLS-" - # Replace "-WITH-" with ":+" - # Remove "EDE" - m_cipher = "+" + m_cipher[4:] + m_cipher = re.sub(r'\ATLS-', '+', m_cipher) m_cipher = m_cipher.replace("-WITH-", ":+") m_cipher = m_cipher.replace("-EDE", "") - # SHA == SHA1, if the last 3 chars are SHA append 1 + # SHA in Mbed TLS == SHA1 GnuTLS, + # if the last 3 chars are SHA append 1 if m_cipher[-3:] == "SHA": m_cipher = m_cipher+"1" # CCM or CCM-8 should be followed by ":+AEAD" - if "CCM" in m_cipher: + # Replace "GCM:+SHAxyz" with "GCM:+AEAD" + if "CCM" in m_cipher or "GCM" in m_cipher: + m_cipher = re.sub(r"GCM-SHA\d\d\d", "GCM", m_cipher) m_cipher = m_cipher+":+AEAD" # Replace the last "-" with ":+" - # Replace "GCM:+SHAxyz" with "GCM:+AEAD" else: index = m_cipher.rindex("-") - m_cipher = m_cipher[:index]+":+"+m_cipher[index+1:] - m_cipher = re.sub(r"GCM\:\+SHA\d\d\d", "GCM:+AEAD", m_cipher) + m_cipher = m_cipher[:index] + ":+" + m_cipher[index+1:] return m_cipher @@ -67,9 +63,7 @@ def translate_ossl(m_cipher): and return the OpenSSL naming convention """ - # Remove "TLS-" - # Remove "WITH" - m_cipher = m_cipher[4:] + m_cipher = re.sub(r'^TLS-', '', m_cipher) m_cipher = m_cipher.replace("-WITH", "") # Remove the "-" from "ABC-xyz" @@ -78,8 +72,7 @@ def translate_ossl(m_cipher): m_cipher = m_cipher.replace("ARIA-", "ARIA") # Remove "RSA" if it is at the beginning - if m_cipher[:4] == "RSA-": - m_cipher = m_cipher[4:] + m_cipher = re.sub(r'^RSA-', r'', m_cipher) # For all circumstances outside of PSK if "PSK" not in m_cipher: @@ -87,10 +80,7 @@ def translate_ossl(m_cipher): m_cipher = m_cipher.replace("3DES-CBC", "DES-CBC3") # Remove "CBC" if it is not prefixed by DES - if "CBC" in m_cipher: - index = m_cipher.rindex("CBC") - if m_cipher[index-4:index-1] != "DES": - m_cipher = m_cipher.replace("CBC-", "") + m_cipher = re.sub(r'(? Date: Fri, 30 Jul 2021 17:47:52 +0100 Subject: [PATCH 444/966] Improve python coding style Signed-off-by: Joe Subbiani --- tests/scripts/test_translate_ciphers_names.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/scripts/test_translate_ciphers_names.py b/tests/scripts/test_translate_ciphers_names.py index 33ad4e3db7..59ebef1d46 100755 --- a/tests/scripts/test_translate_ciphers_names.py +++ b/tests/scripts/test_translate_ciphers_names.py @@ -23,7 +23,6 @@ Test translate_ciphers.py by running every Mbed TLS ciphersuite name combination through the translate functions and comparing them to their correct GNUTLS or OpenSSL counterpart. """ -import sys from translate_ciphers import translate_gnutls, translate_ossl def assert_equal(translate, original): @@ -36,7 +35,7 @@ def assert_equal(translate, original): assert translate == original except AssertionError: print("%s\n%s\n" %(translate, original)) - sys.exit(1) + raise AssertionError def test_all_common(): """ @@ -498,11 +497,11 @@ def test_all_common(): for m, g_exp, o_exp in ciphers: - if g_exp != None: + if g_exp is not None: g = translate_gnutls(m) assert_equal(g, g_exp) - if o_exp != None: + if o_exp is not None: o = translate_ossl(m) assert_equal(o, o_exp) From f2de374fc1f16ffa0c9c0ee6612d2ada23e699fb Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Sat, 31 Jul 2021 11:37:25 +0100 Subject: [PATCH 445/966] Remove unused import Signed-off-by: Joe Subbiani --- tests/scripts/translate_ciphers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index 39339c3d23..eec340735b 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -26,7 +26,6 @@ sys.argv[2] should be a string containing one or more ciphersuite names. """ import re -import sys import argparse def translate_gnutls(m_cipher): From a25ffab4227326e314771235953e347b5257ff85 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 6 Aug 2021 09:41:27 +0100 Subject: [PATCH 446/966] Integrate tests as unit tests into one file Rather than having the tests seperated into different files, they were integrated into translate_ciphers.py and can be run from root using: `python -m unittest tests/scripts/translate_ciphers.py` test_translate_ciphers_format.sh was originally made as a testing ground before having the translation tool being implmented into compat.sh. Translating it to python code makes it redundant and therefore it will be removed. Signed-off-by: Joe Subbiani --- tests/scripts/all.sh | 5 +- .../scripts/test_translate_ciphers_format.sh | 125 ---- tests/scripts/test_translate_ciphers_names.py | 508 ----------------- tests/scripts/translate_ciphers.py | 533 +++++++++++++++++- 4 files changed, 533 insertions(+), 638 deletions(-) delete mode 100755 tests/scripts/test_translate_ciphers_format.sh delete mode 100755 tests/scripts/test_translate_ciphers_names.py diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index c3517b1403..fbb55db8e9 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2750,9 +2750,8 @@ component_check_test_helpers () { # harmless info on stdout so it can be suppress with --quiet. ./tests/scripts/test_generate_test_code.py 2>&1 - msg "test: translate_ciphers.py" - ./tests/scripts/test_translate_ciphers_format.sh - ./tests/scripts/test_translate_ciphers_names.py + msg "unit test: translate_ciphers.py" + python3 -m unittest tests/scripts/translate_ciphers.py 2>&1 } ################################################################ diff --git a/tests/scripts/test_translate_ciphers_format.sh b/tests/scripts/test_translate_ciphers_format.sh deleted file mode 100755 index 1dc7bbc0e8..0000000000 --- a/tests/scripts/test_translate_ciphers_format.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/sh - -# test_translate_ciphers_format.sh -# -# Copyright The Mbed TLS Contributors -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Purpose -# -# Test translate_ciphers.py formatting by comparing the translated -# ciphersuite names to the true names. As in compat.sh, the spaces between -# the ciphersuite names are normalised. -# -# On fail, the translated cipher suite names do not match the correct ones. -# In this case the difference will be printed in stdout. -# -# This files main purpose is to ensure translate_ciphers.py can take strings -# in the expected format and return them in the format compat.sh will expect. - -set -eu - -if cd $( dirname $0 ); then :; else - echo "cd $( dirname $0 ) failed" >&2 - exit 1 -fi - -fail=0 - -# Initalize ciphers translated from Mbed TLS using translate_ciphers.py -O_TRANSLATED_CIPHERS="" -G_TRANSLATED_CIPHERS="" - -# Initalize ciphers that are known to be in the correct format -O_CIPHERS="" -G_CIPHERS="" - -# Mbed TLS ciphersuite names to be translated -# into GnuTLS and OpenSSL -CIPHERS="TLS-ECDHE-ECDSA-WITH-NULL-SHA \ - TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ - TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ - TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ - " - -G=$(./translate_ciphers.py g $CIPHERS) || fail=1 -G_TRANSLATED_CIPHERS="$G_TRANSLATED_CIPHERS $G" - -O=$(./translate_ciphers.py o $CIPHERS) || fail=1 -O_TRANSLATED_CIPHERS="$O_TRANSLATED_CIPHERS $O" - -G_CIPHERS="$G_CIPHERS \ - +ECDHE-ECDSA:+NULL:+SHA1 \ - +ECDHE-ECDSA:+3DES-CBC:+SHA1 \ - +ECDHE-ECDSA:+AES-128-CBC:+SHA1 \ - +ECDHE-ECDSA:+AES-256-CBC:+SHA1 \ - " -O_CIPHERS="$O_CIPHERS \ - ECDHE-ECDSA-NULL-SHA \ - ECDHE-ECDSA-DES-CBC3-SHA \ - ECDHE-ECDSA-AES128-SHA \ - ECDHE-ECDSA-AES256-SHA \ - " - -# Mbed TLS ciphersuite names to be translated -# into GnuTLS and OpenSSL -CIPHERS="TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ - TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ - TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ - TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ - " - -G=$(./translate_ciphers.py g $CIPHERS) || fail=1 -G_TRANSLATED_CIPHERS="$G_TRANSLATED_CIPHERS $G" - -O=$(./translate_ciphers.py o $CIPHERS) || fail=1 -O_TRANSLATED_CIPHERS="$O_TRANSLATED_CIPHERS $O" - -G_CIPHERS="$G_CIPHERS \ - +ECDHE-ECDSA:+AES-128-CBC:+SHA256 \ - +ECDHE-ECDSA:+AES-256-CBC:+SHA384 \ - +ECDHE-ECDSA:+AES-128-GCM:+AEAD \ - +ECDHE-ECDSA:+AES-256-GCM:+AEAD \ - " -O_CIPHERS="$O_CIPHERS \ - ECDHE-ECDSA-AES128-SHA256 \ - ECDHE-ECDSA-AES256-SHA384 \ - ECDHE-ECDSA-AES128-GCM-SHA256 \ - ECDHE-ECDSA-AES256-GCM-SHA384 \ - " - -# Normalise spacing -G_TRANSLATED_CIPHERS=$( echo $G_TRANSLATED_CIPHERS ) -O_TRANSLATED_CIPHERS=$( echo $O_TRANSLATED_CIPHERS ) - -G_CIPHERS=$( echo $G_CIPHERS ) -O_CIPHERS=$( echo $O_CIPHERS ) - -# Compare the compat.sh names with the translated names -# Upon fail, print them to view the differences -if [ "$G_TRANSLATED_CIPHERS" != "$G_CIPHERS" ] -then - echo "GnuTLS Translated: $G_TRANSLATED_CIPHERS" - echo "GnuTLS Original: $G_CIPHERS" - fail=1 -fi -if [ "$O_TRANSLATED_CIPHERS" != "$O_CIPHERS" ] -then - echo "OpenSSL Translated: $O_TRANSLATED_CIPHERS" - echo "OpenSSL Original: $O_CIPHERS" - fail=1 -fi - -exit $fail diff --git a/tests/scripts/test_translate_ciphers_names.py b/tests/scripts/test_translate_ciphers_names.py deleted file mode 100755 index 59ebef1d46..0000000000 --- a/tests/scripts/test_translate_ciphers_names.py +++ /dev/null @@ -1,508 +0,0 @@ -#!/usr/bin/env python3 - -# test_translate_ciphers_names.py -# -# Copyright The Mbed TLS Contributors -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -""" -Test translate_ciphers.py by running every Mbed TLS ciphersuite name -combination through the translate functions and comparing them to their -correct GNUTLS or OpenSSL counterpart. -""" -from translate_ciphers import translate_gnutls, translate_ossl - -def assert_equal(translate, original): - """ - Compare the translated ciphersuite name against the original - On fail, print the mismatch on the screen to directly compare the - differences - """ - try: - assert translate == original - except AssertionError: - print("%s\n%s\n" %(translate, original)) - raise AssertionError - -def test_all_common(): - """ - Translate the Mbed TLS ciphersuite names to the common OpenSSL and - GnuTLS ciphersuite names, and compare them with the true, expected - corresponding OpenSSL and GnuTLS ciphersuite names - """ - ciphers = [ - ("TLS-ECDHE-ECDSA-WITH-NULL-SHA", - "+ECDHE-ECDSA:+NULL:+SHA1", - "ECDHE-ECDSA-NULL-SHA"), - ("TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", - "+ECDHE-ECDSA:+3DES-CBC:+SHA1", - "ECDHE-ECDSA-DES-CBC3-SHA"), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", - "+ECDHE-ECDSA:+AES-128-CBC:+SHA1", - "ECDHE-ECDSA-AES128-SHA"), - ("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", - "+ECDHE-ECDSA:+AES-256-CBC:+SHA1", - "ECDHE-ECDSA-AES256-SHA"), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", - "+ECDHE-ECDSA:+AES-128-CBC:+SHA256", - "ECDHE-ECDSA-AES128-SHA256"), - ("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", - "+ECDHE-ECDSA:+AES-256-CBC:+SHA384", - "ECDHE-ECDSA-AES256-SHA384"), - ("TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", - "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", - "ECDHE-ECDSA-AES128-GCM-SHA256"), - ("TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", - "+ECDHE-ECDSA:+AES-256-GCM:+AEAD", - "ECDHE-ECDSA-AES256-GCM-SHA384"), - ("TLS-DHE-RSA-WITH-AES-128-CBC-SHA", - "+DHE-RSA:+AES-128-CBC:+SHA1", - "DHE-RSA-AES128-SHA"), - ("TLS-DHE-RSA-WITH-AES-256-CBC-SHA", - "+DHE-RSA:+AES-256-CBC:+SHA1", - "DHE-RSA-AES256-SHA"), - ("TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", - "+DHE-RSA:+CAMELLIA-128-CBC:+SHA1", - "DHE-RSA-CAMELLIA128-SHA"), - ("TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", - "+DHE-RSA:+CAMELLIA-256-CBC:+SHA1", - "DHE-RSA-CAMELLIA256-SHA"), - ("TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", - "+DHE-RSA:+3DES-CBC:+SHA1", - "EDH-RSA-DES-CBC3-SHA"), - ("TLS-RSA-WITH-AES-256-CBC-SHA", - "+RSA:+AES-256-CBC:+SHA1", - "AES256-SHA"), - ("TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", - "+RSA:+CAMELLIA-256-CBC:+SHA1", - "CAMELLIA256-SHA"), - ("TLS-RSA-WITH-AES-128-CBC-SHA", - "+RSA:+AES-128-CBC:+SHA1", - "AES128-SHA"), - ("TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", - "+RSA:+CAMELLIA-128-CBC:+SHA1", - "CAMELLIA128-SHA"), - ("TLS-RSA-WITH-3DES-EDE-CBC-SHA", - "+RSA:+3DES-CBC:+SHA1", - "DES-CBC3-SHA"), - ("TLS-RSA-WITH-NULL-MD5", - "+RSA:+NULL:+MD5", - "NULL-MD5"), - ("TLS-RSA-WITH-NULL-SHA", - "+RSA:+NULL:+SHA1", - "NULL-SHA"), - ("TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", - "+ECDHE-RSA:+AES-128-CBC:+SHA1", - "ECDHE-RSA-AES128-SHA"), - ("TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", - "+ECDHE-RSA:+AES-256-CBC:+SHA1", - "ECDHE-RSA-AES256-SHA"), - ("TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", - "+ECDHE-RSA:+3DES-CBC:+SHA1", - "ECDHE-RSA-DES-CBC3-SHA"), - ("TLS-ECDHE-RSA-WITH-NULL-SHA", - "+ECDHE-RSA:+NULL:+SHA1", - "ECDHE-RSA-NULL-SHA"), - ("TLS-RSA-WITH-AES-128-CBC-SHA256", - "+RSA:+AES-128-CBC:+SHA256", - "AES128-SHA256"), - ("TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", - "+DHE-RSA:+AES-128-CBC:+SHA256", - "DHE-RSA-AES128-SHA256"), - ("TLS-RSA-WITH-AES-256-CBC-SHA256", - "+RSA:+AES-256-CBC:+SHA256", - "AES256-SHA256"), - ("TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", - "+DHE-RSA:+AES-256-CBC:+SHA256", - "DHE-RSA-AES256-SHA256"), - ("TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", - "+ECDHE-RSA:+AES-128-CBC:+SHA256", - "ECDHE-RSA-AES128-SHA256"), - ("TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", - "+ECDHE-RSA:+AES-256-CBC:+SHA384", - "ECDHE-RSA-AES256-SHA384"), - ("TLS-RSA-WITH-AES-128-GCM-SHA256", - "+RSA:+AES-128-GCM:+AEAD", - "AES128-GCM-SHA256"), - ("TLS-RSA-WITH-AES-256-GCM-SHA384", - "+RSA:+AES-256-GCM:+AEAD", - "AES256-GCM-SHA384"), - ("TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", - "+DHE-RSA:+AES-128-GCM:+AEAD", - "DHE-RSA-AES128-GCM-SHA256"), - ("TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", - "+DHE-RSA:+AES-256-GCM:+AEAD", - "DHE-RSA-AES256-GCM-SHA384"), - ("TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", - "+ECDHE-RSA:+AES-128-GCM:+AEAD", - "ECDHE-RSA-AES128-GCM-SHA256"), - ("TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", - "+ECDHE-RSA:+AES-256-GCM:+AEAD", - "ECDHE-RSA-AES256-GCM-SHA384"), - ("TLS-PSK-WITH-3DES-EDE-CBC-SHA", - "+PSK:+3DES-CBC:+SHA1", - "PSK-3DES-EDE-CBC-SHA"), - ("TLS-PSK-WITH-AES-128-CBC-SHA", - "+PSK:+AES-128-CBC:+SHA1", - "PSK-AES128-CBC-SHA"), - ("TLS-PSK-WITH-AES-256-CBC-SHA", - "+PSK:+AES-256-CBC:+SHA1", - "PSK-AES256-CBC-SHA"), - - ("TLS-ECDH-ECDSA-WITH-NULL-SHA", - None, - "ECDH-ECDSA-NULL-SHA"), - ("TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", - None, - "ECDH-ECDSA-DES-CBC3-SHA"), - ("TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", - None, - "ECDH-ECDSA-AES128-SHA"), - ("TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", - None, - "ECDH-ECDSA-AES256-SHA"), - ("TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", - None, - "ECDH-ECDSA-AES128-SHA256"), - ("TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", - None, - "ECDH-ECDSA-AES256-SHA384"), - ("TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", - None, - "ECDH-ECDSA-AES128-GCM-SHA256"), - ("TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", - None, - "ECDH-ECDSA-AES256-GCM-SHA384"), - ("TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", - None, - "ECDHE-ECDSA-ARIA256-GCM-SHA384"), - ("TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", - None, - "ECDHE-ECDSA-ARIA128-GCM-SHA256"), - ("TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", - None, - "ECDHE-ECDSA-CHACHA20-POLY1305"), - ("TLS-RSA-WITH-DES-CBC-SHA", - None, - "DES-CBC-SHA"), - ("TLS-DHE-RSA-WITH-DES-CBC-SHA", - None, - "EDH-RSA-DES-CBC-SHA"), - ("TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", - None, - "ECDHE-ARIA256-GCM-SHA384"), - ("TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", - None, - "DHE-RSA-ARIA256-GCM-SHA384"), - ("TLS-RSA-WITH-ARIA-256-GCM-SHA384", - None, - "ARIA256-GCM-SHA384"), - ("TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", - None, - "ECDHE-ARIA128-GCM-SHA256"), - ("TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", - None, - "DHE-RSA-ARIA128-GCM-SHA256"), - ("TLS-RSA-WITH-ARIA-128-GCM-SHA256", - None, - "ARIA128-GCM-SHA256"), - ("TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", - None, - "DHE-RSA-CHACHA20-POLY1305"), - ("TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", - None, - "ECDHE-RSA-CHACHA20-POLY1305"), - ("TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", - None, - "DHE-PSK-ARIA256-GCM-SHA384"), - ("TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", - None, - "DHE-PSK-ARIA128-GCM-SHA256"), - ("TLS-PSK-WITH-ARIA-256-GCM-SHA384", - None, - "PSK-ARIA256-GCM-SHA384"), - ("TLS-PSK-WITH-ARIA-128-GCM-SHA256", - None, - "PSK-ARIA128-GCM-SHA256"), - ("TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", - None, - "PSK-CHACHA20-POLY1305"), - ("TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", - None, - "ECDHE-PSK-CHACHA20-POLY1305"), - ("TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", - None, - "DHE-PSK-CHACHA20-POLY1305"), - - ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", - "+ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", - "+ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", - "+ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", - "+ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM", - "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-AES-256-CCM", - "+ECDHE-ECDSA:+AES-256-CCM:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", - "+ECDHE-ECDSA:+AES-128-CCM-8:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", - "+ECDHE-ECDSA:+AES-256-CCM-8:+AEAD", - None), - ("TLS-RSA-WITH-NULL-SHA256", - "+RSA:+NULL:+SHA256", - None), - ("TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "+ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", - "+ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "+RSA:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", - "+RSA:+CAMELLIA-256-CBC:+SHA256", - None), - ("TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "+DHE-RSA:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", - "+DHE-RSA:+CAMELLIA-256-CBC:+SHA256", - None), - ("TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "+ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "+ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "+DHE-RSA:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "+DHE-RSA:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "+RSA:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "+RSA:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-RSA-WITH-AES-128-CCM", - "+RSA:+AES-128-CCM:+AEAD", - None), - ("TLS-RSA-WITH-AES-256-CCM", - "+RSA:+AES-256-CCM:+AEAD", - None), - ("TLS-DHE-RSA-WITH-AES-128-CCM", - "+DHE-RSA:+AES-128-CCM:+AEAD", - None), - ("TLS-DHE-RSA-WITH-AES-256-CCM", - "+DHE-RSA:+AES-256-CCM:+AEAD", - None), - ("TLS-RSA-WITH-AES-128-CCM-8", - "+RSA:+AES-128-CCM-8:+AEAD", - None), - ("TLS-RSA-WITH-AES-256-CCM-8", - "+RSA:+AES-256-CCM-8:+AEAD", - None), - ("TLS-DHE-RSA-WITH-AES-128-CCM-8", - "+DHE-RSA:+AES-128-CCM-8:+AEAD", - None), - ("TLS-DHE-RSA-WITH-AES-256-CCM-8", - "+DHE-RSA:+AES-256-CCM-8:+AEAD", - None), - ("TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", - "+DHE-PSK:+3DES-CBC:+SHA1", - None), - ("TLS-DHE-PSK-WITH-AES-128-CBC-SHA", - "+DHE-PSK:+AES-128-CBC:+SHA1", - None), - ("TLS-DHE-PSK-WITH-AES-256-CBC-SHA", - "+DHE-PSK:+AES-256-CBC:+SHA1", - None), - ("TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", - "+ECDHE-PSK:+AES-256-CBC:+SHA1", - None), - ("TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", - "+ECDHE-PSK:+AES-128-CBC:+SHA1", - None), - ("TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", - "+ECDHE-PSK:+3DES-CBC:+SHA1", - None), - ("TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", - "+RSA-PSK:+3DES-CBC:+SHA1", - None), - ("TLS-RSA-PSK-WITH-AES-256-CBC-SHA", - "+RSA-PSK:+AES-256-CBC:+SHA1", - None), - ("TLS-RSA-PSK-WITH-AES-128-CBC-SHA", - "+RSA-PSK:+AES-128-CBC:+SHA1", - None), - ("TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", - "+ECDHE-PSK:+AES-256-CBC:+SHA384", - None), - ("TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "+ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", - "+ECDHE-PSK:+AES-128-CBC:+SHA256", - None), - ("TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "+ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-ECDHE-PSK-WITH-NULL-SHA384", - "+ECDHE-PSK:+NULL:+SHA384", - None), - ("TLS-ECDHE-PSK-WITH-NULL-SHA256", - "+ECDHE-PSK:+NULL:+SHA256", - None), - ("TLS-PSK-WITH-AES-128-CBC-SHA256", - "+PSK:+AES-128-CBC:+SHA256", - None), - ("TLS-PSK-WITH-AES-256-CBC-SHA384", - "+PSK:+AES-256-CBC:+SHA384", - None), - ("TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", - "+DHE-PSK:+AES-128-CBC:+SHA256", - None), - ("TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", - "+DHE-PSK:+AES-256-CBC:+SHA384", - None), - ("TLS-PSK-WITH-NULL-SHA256", - "+PSK:+NULL:+SHA256", - None), - ("TLS-PSK-WITH-NULL-SHA384", - "+PSK:+NULL:+SHA384", - None), - ("TLS-DHE-PSK-WITH-NULL-SHA256", - "+DHE-PSK:+NULL:+SHA256", - None), - ("TLS-DHE-PSK-WITH-NULL-SHA384", - "+DHE-PSK:+NULL:+SHA384", - None), - ("TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", - "+RSA-PSK:+AES-256-CBC:+SHA384", - None), - ("TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", - "+RSA-PSK:+AES-128-CBC:+SHA256", - None), - ("TLS-RSA-PSK-WITH-NULL-SHA256", - "+RSA-PSK:+NULL:+SHA256", - None), - ("TLS-RSA-PSK-WITH-NULL-SHA384", - "+RSA-PSK:+NULL:+SHA384", - None), - ("TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "+DHE-PSK:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "+DHE-PSK:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "+PSK:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "+PSK:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "+RSA-PSK:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "+RSA-PSK:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-PSK-WITH-AES-128-GCM-SHA256", - "+PSK:+AES-128-GCM:+AEAD", - None), - ("TLS-PSK-WITH-AES-256-GCM-SHA384", - "+PSK:+AES-256-GCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", - "+DHE-PSK:+AES-128-GCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", - "+DHE-PSK:+AES-256-GCM:+AEAD", - None), - ("TLS-PSK-WITH-AES-128-CCM", - "+PSK:+AES-128-CCM:+AEAD", - None), - ("TLS-PSK-WITH-AES-256-CCM", - "+PSK:+AES-256-CCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-128-CCM", - "+DHE-PSK:+AES-128-CCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-256-CCM", - "+DHE-PSK:+AES-256-CCM:+AEAD", - None), - ("TLS-PSK-WITH-AES-128-CCM-8", - "+PSK:+AES-128-CCM-8:+AEAD", - None), - ("TLS-PSK-WITH-AES-256-CCM-8", - "+PSK:+AES-256-CCM-8:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-128-CCM-8", - "+DHE-PSK:+AES-128-CCM-8:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-256-CCM-8", - "+DHE-PSK:+AES-256-CCM-8:+AEAD", - None), - ("TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "+RSA-PSK:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "+RSA-PSK:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "+PSK:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "+PSK:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "+DHE-PSK:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "+DHE-PSK:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", - "+RSA-PSK:+AES-256-GCM:+AEAD", - None), - ("TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", - "+RSA-PSK:+AES-128-GCM:+AEAD", - None), - ] - - for m, g_exp, o_exp in ciphers: - - if g_exp is not None: - g = translate_gnutls(m) - assert_equal(g, g_exp) - - if o_exp is not None: - o = translate_ossl(m) - assert_equal(o, o_exp) - -test_all_common() diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index eec340735b..44ffb400bb 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -21,12 +21,541 @@ Translate ciphersuite names in MBedTLS format to OpenSSL and GNUTLS standards. -sys.argv[1] should be "g" or "o" for GNUTLS or OpenSSL. -sys.argv[2] should be a string containing one or more ciphersuite names. +To test the translation functions run: +python3 -m unittest translate_cipher.py """ import re import argparse +import unittest + +class TestTranslateCiphers(unittest.TestCase): + """ + Ensure translate_ciphers.py translates and formats ciphersuite names + correctly + """ + def test_translate_all_cipher_names(self): + """ + Translate the Mbed TLS ciphersuite names to the common OpenSSL and + GnuTLS ciphersuite names, and compare them with the true, expected + corresponding OpenSSL and GnuTLS ciphersuite names + """ + ciphers = [ + ("TLS-ECDHE-ECDSA-WITH-NULL-SHA", + "+ECDHE-ECDSA:+NULL:+SHA1", + "ECDHE-ECDSA-NULL-SHA"), + ("TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", + "+ECDHE-ECDSA:+3DES-CBC:+SHA1", + "ECDHE-ECDSA-DES-CBC3-SHA"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", + "+ECDHE-ECDSA:+AES-128-CBC:+SHA1", + "ECDHE-ECDSA-AES128-SHA"), + ("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", + "+ECDHE-ECDSA:+AES-256-CBC:+SHA1", + "ECDHE-ECDSA-AES256-SHA"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", + "+ECDHE-ECDSA:+AES-128-CBC:+SHA256", + "ECDHE-ECDSA-AES128-SHA256"), + ("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", + "+ECDHE-ECDSA:+AES-256-CBC:+SHA384", + "ECDHE-ECDSA-AES256-SHA384"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", + "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", + "ECDHE-ECDSA-AES128-GCM-SHA256"), + ("TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", + "+ECDHE-ECDSA:+AES-256-GCM:+AEAD", + "ECDHE-ECDSA-AES256-GCM-SHA384"), + ("TLS-DHE-RSA-WITH-AES-128-CBC-SHA", + "+DHE-RSA:+AES-128-CBC:+SHA1", + "DHE-RSA-AES128-SHA"), + ("TLS-DHE-RSA-WITH-AES-256-CBC-SHA", + "+DHE-RSA:+AES-256-CBC:+SHA1", + "DHE-RSA-AES256-SHA"), + ("TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", + "+DHE-RSA:+CAMELLIA-128-CBC:+SHA1", + "DHE-RSA-CAMELLIA128-SHA"), + ("TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", + "+DHE-RSA:+CAMELLIA-256-CBC:+SHA1", + "DHE-RSA-CAMELLIA256-SHA"), + ("TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", + "+DHE-RSA:+3DES-CBC:+SHA1", + "EDH-RSA-DES-CBC3-SHA"), + ("TLS-RSA-WITH-AES-256-CBC-SHA", + "+RSA:+AES-256-CBC:+SHA1", + "AES256-SHA"), + ("TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", + "+RSA:+CAMELLIA-256-CBC:+SHA1", + "CAMELLIA256-SHA"), + ("TLS-RSA-WITH-AES-128-CBC-SHA", + "+RSA:+AES-128-CBC:+SHA1", + "AES128-SHA"), + ("TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", + "+RSA:+CAMELLIA-128-CBC:+SHA1", + "CAMELLIA128-SHA"), + ("TLS-RSA-WITH-3DES-EDE-CBC-SHA", + "+RSA:+3DES-CBC:+SHA1", + "DES-CBC3-SHA"), + ("TLS-RSA-WITH-NULL-MD5", + "+RSA:+NULL:+MD5", + "NULL-MD5"), + ("TLS-RSA-WITH-NULL-SHA", + "+RSA:+NULL:+SHA1", + "NULL-SHA"), + ("TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", + "+ECDHE-RSA:+AES-128-CBC:+SHA1", + "ECDHE-RSA-AES128-SHA"), + ("TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", + "+ECDHE-RSA:+AES-256-CBC:+SHA1", + "ECDHE-RSA-AES256-SHA"), + ("TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", + "+ECDHE-RSA:+3DES-CBC:+SHA1", + "ECDHE-RSA-DES-CBC3-SHA"), + ("TLS-ECDHE-RSA-WITH-NULL-SHA", + "+ECDHE-RSA:+NULL:+SHA1", + "ECDHE-RSA-NULL-SHA"), + ("TLS-RSA-WITH-AES-128-CBC-SHA256", + "+RSA:+AES-128-CBC:+SHA256", + "AES128-SHA256"), + ("TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", + "+DHE-RSA:+AES-128-CBC:+SHA256", + "DHE-RSA-AES128-SHA256"), + ("TLS-RSA-WITH-AES-256-CBC-SHA256", + "+RSA:+AES-256-CBC:+SHA256", + "AES256-SHA256"), + ("TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", + "+DHE-RSA:+AES-256-CBC:+SHA256", + "DHE-RSA-AES256-SHA256"), + ("TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", + "+ECDHE-RSA:+AES-128-CBC:+SHA256", + "ECDHE-RSA-AES128-SHA256"), + ("TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", + "+ECDHE-RSA:+AES-256-CBC:+SHA384", + "ECDHE-RSA-AES256-SHA384"), + ("TLS-RSA-WITH-AES-128-GCM-SHA256", + "+RSA:+AES-128-GCM:+AEAD", + "AES128-GCM-SHA256"), + ("TLS-RSA-WITH-AES-256-GCM-SHA384", + "+RSA:+AES-256-GCM:+AEAD", + "AES256-GCM-SHA384"), + ("TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", + "+DHE-RSA:+AES-128-GCM:+AEAD", + "DHE-RSA-AES128-GCM-SHA256"), + ("TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", + "+DHE-RSA:+AES-256-GCM:+AEAD", + "DHE-RSA-AES256-GCM-SHA384"), + ("TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", + "+ECDHE-RSA:+AES-128-GCM:+AEAD", + "ECDHE-RSA-AES128-GCM-SHA256"), + ("TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", + "+ECDHE-RSA:+AES-256-GCM:+AEAD", + "ECDHE-RSA-AES256-GCM-SHA384"), + ("TLS-PSK-WITH-3DES-EDE-CBC-SHA", + "+PSK:+3DES-CBC:+SHA1", + "PSK-3DES-EDE-CBC-SHA"), + ("TLS-PSK-WITH-AES-128-CBC-SHA", + "+PSK:+AES-128-CBC:+SHA1", + "PSK-AES128-CBC-SHA"), + ("TLS-PSK-WITH-AES-256-CBC-SHA", + "+PSK:+AES-256-CBC:+SHA1", + "PSK-AES256-CBC-SHA"), + + ("TLS-ECDH-ECDSA-WITH-NULL-SHA", + None, + "ECDH-ECDSA-NULL-SHA"), + ("TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", + None, + "ECDH-ECDSA-DES-CBC3-SHA"), + ("TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", + None, + "ECDH-ECDSA-AES128-SHA"), + ("TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", + None, + "ECDH-ECDSA-AES256-SHA"), + ("TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", + None, + "ECDH-ECDSA-AES128-SHA256"), + ("TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", + None, + "ECDH-ECDSA-AES256-SHA384"), + ("TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", + None, + "ECDH-ECDSA-AES128-GCM-SHA256"), + ("TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", + None, + "ECDH-ECDSA-AES256-GCM-SHA384"), + ("TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", + None, + "ECDHE-ECDSA-ARIA256-GCM-SHA384"), + ("TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", + None, + "ECDHE-ECDSA-ARIA128-GCM-SHA256"), + ("TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", + None, + "ECDHE-ECDSA-CHACHA20-POLY1305"), + ("TLS-RSA-WITH-DES-CBC-SHA", + None, + "DES-CBC-SHA"), + ("TLS-DHE-RSA-WITH-DES-CBC-SHA", + None, + "EDH-RSA-DES-CBC-SHA"), + ("TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", + None, + "ECDHE-ARIA256-GCM-SHA384"), + ("TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", + None, + "DHE-RSA-ARIA256-GCM-SHA384"), + ("TLS-RSA-WITH-ARIA-256-GCM-SHA384", + None, + "ARIA256-GCM-SHA384"), + ("TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", + None, + "ECDHE-ARIA128-GCM-SHA256"), + ("TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", + None, + "DHE-RSA-ARIA128-GCM-SHA256"), + ("TLS-RSA-WITH-ARIA-128-GCM-SHA256", + None, + "ARIA128-GCM-SHA256"), + ("TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + None, + "DHE-RSA-CHACHA20-POLY1305"), + ("TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + None, + "ECDHE-RSA-CHACHA20-POLY1305"), + ("TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", + None, + "DHE-PSK-ARIA256-GCM-SHA384"), + ("TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", + None, + "DHE-PSK-ARIA128-GCM-SHA256"), + ("TLS-PSK-WITH-ARIA-256-GCM-SHA384", + None, + "PSK-ARIA256-GCM-SHA384"), + ("TLS-PSK-WITH-ARIA-128-GCM-SHA256", + None, + "PSK-ARIA128-GCM-SHA256"), + ("TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", + None, + "PSK-CHACHA20-POLY1305"), + ("TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + None, + "ECDHE-PSK-CHACHA20-POLY1305"), + ("TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + None, + "DHE-PSK-CHACHA20-POLY1305"), + + ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", + "+ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", + "+ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", + "+ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", + "+ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM", + "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-AES-256-CCM", + "+ECDHE-ECDSA:+AES-256-CCM:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", + "+ECDHE-ECDSA:+AES-128-CCM-8:+AEAD", + None), + ("TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", + "+ECDHE-ECDSA:+AES-256-CCM-8:+AEAD", + None), + ("TLS-RSA-WITH-NULL-SHA256", + "+RSA:+NULL:+SHA256", + None), + ("TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "+ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", + "+ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "+RSA:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", + "+RSA:+CAMELLIA-256-CBC:+SHA256", + None), + ("TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", + "+DHE-RSA:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", + "+DHE-RSA:+CAMELLIA-256-CBC:+SHA256", + None), + ("TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "+ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "+ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "+DHE-RSA:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "+DHE-RSA:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", + "+RSA:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", + "+RSA:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-RSA-WITH-AES-128-CCM", + "+RSA:+AES-128-CCM:+AEAD", + None), + ("TLS-RSA-WITH-AES-256-CCM", + "+RSA:+AES-256-CCM:+AEAD", + None), + ("TLS-DHE-RSA-WITH-AES-128-CCM", + "+DHE-RSA:+AES-128-CCM:+AEAD", + None), + ("TLS-DHE-RSA-WITH-AES-256-CCM", + "+DHE-RSA:+AES-256-CCM:+AEAD", + None), + ("TLS-RSA-WITH-AES-128-CCM-8", + "+RSA:+AES-128-CCM-8:+AEAD", + None), + ("TLS-RSA-WITH-AES-256-CCM-8", + "+RSA:+AES-256-CCM-8:+AEAD", + None), + ("TLS-DHE-RSA-WITH-AES-128-CCM-8", + "+DHE-RSA:+AES-128-CCM-8:+AEAD", + None), + ("TLS-DHE-RSA-WITH-AES-256-CCM-8", + "+DHE-RSA:+AES-256-CCM-8:+AEAD", + None), + ("TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", + "+DHE-PSK:+3DES-CBC:+SHA1", + None), + ("TLS-DHE-PSK-WITH-AES-128-CBC-SHA", + "+DHE-PSK:+AES-128-CBC:+SHA1", + None), + ("TLS-DHE-PSK-WITH-AES-256-CBC-SHA", + "+DHE-PSK:+AES-256-CBC:+SHA1", + None), + ("TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", + "+ECDHE-PSK:+AES-256-CBC:+SHA1", + None), + ("TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", + "+ECDHE-PSK:+AES-128-CBC:+SHA1", + None), + ("TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", + "+ECDHE-PSK:+3DES-CBC:+SHA1", + None), + ("TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", + "+RSA-PSK:+3DES-CBC:+SHA1", + None), + ("TLS-RSA-PSK-WITH-AES-256-CBC-SHA", + "+RSA-PSK:+AES-256-CBC:+SHA1", + None), + ("TLS-RSA-PSK-WITH-AES-128-CBC-SHA", + "+RSA-PSK:+AES-128-CBC:+SHA1", + None), + ("TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", + "+ECDHE-PSK:+AES-256-CBC:+SHA384", + None), + ("TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "+ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", + "+ECDHE-PSK:+AES-128-CBC:+SHA256", + None), + ("TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "+ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-ECDHE-PSK-WITH-NULL-SHA384", + "+ECDHE-PSK:+NULL:+SHA384", + None), + ("TLS-ECDHE-PSK-WITH-NULL-SHA256", + "+ECDHE-PSK:+NULL:+SHA256", + None), + ("TLS-PSK-WITH-AES-128-CBC-SHA256", + "+PSK:+AES-128-CBC:+SHA256", + None), + ("TLS-PSK-WITH-AES-256-CBC-SHA384", + "+PSK:+AES-256-CBC:+SHA384", + None), + ("TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", + "+DHE-PSK:+AES-128-CBC:+SHA256", + None), + ("TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", + "+DHE-PSK:+AES-256-CBC:+SHA384", + None), + ("TLS-PSK-WITH-NULL-SHA256", + "+PSK:+NULL:+SHA256", + None), + ("TLS-PSK-WITH-NULL-SHA384", + "+PSK:+NULL:+SHA384", + None), + ("TLS-DHE-PSK-WITH-NULL-SHA256", + "+DHE-PSK:+NULL:+SHA256", + None), + ("TLS-DHE-PSK-WITH-NULL-SHA384", + "+DHE-PSK:+NULL:+SHA384", + None), + ("TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", + "+RSA-PSK:+AES-256-CBC:+SHA384", + None), + ("TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", + "+RSA-PSK:+AES-128-CBC:+SHA256", + None), + ("TLS-RSA-PSK-WITH-NULL-SHA256", + "+RSA-PSK:+NULL:+SHA256", + None), + ("TLS-RSA-PSK-WITH-NULL-SHA384", + "+RSA-PSK:+NULL:+SHA384", + None), + ("TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "+DHE-PSK:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "+DHE-PSK:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "+PSK:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "+PSK:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", + "+RSA-PSK:+CAMELLIA-256-CBC:+SHA384", + None), + ("TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", + "+RSA-PSK:+CAMELLIA-128-CBC:+SHA256", + None), + ("TLS-PSK-WITH-AES-128-GCM-SHA256", + "+PSK:+AES-128-GCM:+AEAD", + None), + ("TLS-PSK-WITH-AES-256-GCM-SHA384", + "+PSK:+AES-256-GCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", + "+DHE-PSK:+AES-128-GCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", + "+DHE-PSK:+AES-256-GCM:+AEAD", + None), + ("TLS-PSK-WITH-AES-128-CCM", + "+PSK:+AES-128-CCM:+AEAD", + None), + ("TLS-PSK-WITH-AES-256-CCM", + "+PSK:+AES-256-CCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-128-CCM", + "+DHE-PSK:+AES-128-CCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-256-CCM", + "+DHE-PSK:+AES-256-CCM:+AEAD", + None), + ("TLS-PSK-WITH-AES-128-CCM-8", + "+PSK:+AES-128-CCM-8:+AEAD", + None), + ("TLS-PSK-WITH-AES-256-CCM-8", + "+PSK:+AES-256-CCM-8:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-128-CCM-8", + "+DHE-PSK:+AES-128-CCM-8:+AEAD", + None), + ("TLS-DHE-PSK-WITH-AES-256-CCM-8", + "+DHE-PSK:+AES-256-CCM-8:+AEAD", + None), + ("TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "+RSA-PSK:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "+RSA-PSK:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "+PSK:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "+PSK:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", + "+DHE-PSK:+CAMELLIA-128-GCM:+AEAD", + None), + ("TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", + "+DHE-PSK:+CAMELLIA-256-GCM:+AEAD", + None), + ("TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", + "+RSA-PSK:+AES-256-GCM:+AEAD", + None), + ("TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", + "+RSA-PSK:+AES-128-GCM:+AEAD", + None), + ] + + for m, g_exp, o_exp in ciphers: + + if g_exp is not None: + g = translate_gnutls(m) + self.assertEqual(g, g_exp) + + if o_exp is not None: + o = translate_ossl(m) + self.assertEqual(o, o_exp) + + def test_cipher_format(self): + """ + Ensure translate_ciphers.py can take names in the expected + format and return them in the format compat.sh will expect. + """ + # Ciphers in Mbed TLS format + ciphers = "TLS-ECDHE-ECDSA-WITH-NULL-SHA \ + TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ + TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ + TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ + " + ciphers = "%s \ + TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ + TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ + TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ + " % ciphers + + # Corresponding ciphers in GnuTLS format + g_ciphers = "+ECDHE-ECDSA:+NULL:+SHA1 \ + +ECDHE-ECDSA:+3DES-CBC:+SHA1 \ + +ECDHE-ECDSA:+AES-128-CBC:+SHA1 \ + +ECDHE-ECDSA:+AES-256-CBC:+SHA1 \ + " + g_ciphers = "%s \ + +ECDHE-ECDSA:+AES-128-CBC:+SHA256 \ + +ECDHE-ECDSA:+AES-256-CBC:+SHA384 \ + +ECDHE-ECDSA:+AES-128-GCM:+AEAD \ + +ECDHE-ECDSA:+AES-256-GCM:+AEAD \ + " % g_ciphers + + # Corresponding ciphers in OpenSSL format + o_ciphers = "ECDHE-ECDSA-NULL-SHA \ + ECDHE-ECDSA-DES-CBC3-SHA \ + ECDHE-ECDSA-AES128-SHA \ + ECDHE-ECDSA-AES256-SHA \ + " + o_ciphers = "%s \ + ECDHE-ECDSA-AES128-SHA256 \ + ECDHE-ECDSA-AES256-SHA384 \ + ECDHE-ECDSA-AES128-GCM-SHA256 \ + ECDHE-ECDSA-AES256-GCM-SHA384 \ + " % o_ciphers + + # Translate ciphers in mbedtls format + g_translated = format_ciphersuite_names("g", ciphers.split()) + o_translated = format_ciphersuite_names("o", ciphers.split()) + + # Normalise whitespace + g_ciphers = (" ").join(g_ciphers.split()) + o_ciphers = (" ").join(o_ciphers.split()) + + self.assertEqual(g_translated, g_ciphers) + self.assertEqual(o_translated, o_ciphers) def translate_gnutls(m_cipher): """ From 79f579037044f66c2aa2adec586776af9aad59ef Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 6 Aug 2021 09:46:42 +0100 Subject: [PATCH 447/966] Remove test_translate_format() As test_translate_ciphers_format.sh was made as a testing ground before utilising translate_ciphers.py in compat.sh, once it was translated to python code - as a unit test, it became redundant. Signed-off-by: Joe Subbiani --- tests/scripts/translate_ciphers.py | 55 ------------------------------ 1 file changed, 55 deletions(-) diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index 44ffb400bb..7bbc1d74d0 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -502,61 +502,6 @@ class TestTranslateCiphers(unittest.TestCase): o = translate_ossl(m) self.assertEqual(o, o_exp) - def test_cipher_format(self): - """ - Ensure translate_ciphers.py can take names in the expected - format and return them in the format compat.sh will expect. - """ - # Ciphers in Mbed TLS format - ciphers = "TLS-ECDHE-ECDSA-WITH-NULL-SHA \ - TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ - TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ - TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ - " - ciphers = "%s \ - TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ - TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ - TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ - TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ - " % ciphers - - # Corresponding ciphers in GnuTLS format - g_ciphers = "+ECDHE-ECDSA:+NULL:+SHA1 \ - +ECDHE-ECDSA:+3DES-CBC:+SHA1 \ - +ECDHE-ECDSA:+AES-128-CBC:+SHA1 \ - +ECDHE-ECDSA:+AES-256-CBC:+SHA1 \ - " - g_ciphers = "%s \ - +ECDHE-ECDSA:+AES-128-CBC:+SHA256 \ - +ECDHE-ECDSA:+AES-256-CBC:+SHA384 \ - +ECDHE-ECDSA:+AES-128-GCM:+AEAD \ - +ECDHE-ECDSA:+AES-256-GCM:+AEAD \ - " % g_ciphers - - # Corresponding ciphers in OpenSSL format - o_ciphers = "ECDHE-ECDSA-NULL-SHA \ - ECDHE-ECDSA-DES-CBC3-SHA \ - ECDHE-ECDSA-AES128-SHA \ - ECDHE-ECDSA-AES256-SHA \ - " - o_ciphers = "%s \ - ECDHE-ECDSA-AES128-SHA256 \ - ECDHE-ECDSA-AES256-SHA384 \ - ECDHE-ECDSA-AES128-GCM-SHA256 \ - ECDHE-ECDSA-AES256-GCM-SHA384 \ - " % o_ciphers - - # Translate ciphers in mbedtls format - g_translated = format_ciphersuite_names("g", ciphers.split()) - o_translated = format_ciphersuite_names("o", ciphers.split()) - - # Normalise whitespace - g_ciphers = (" ").join(g_ciphers.split()) - o_ciphers = (" ").join(o_ciphers.split()) - - self.assertEqual(g_translated, g_ciphers) - self.assertEqual(o_translated, o_ciphers) - def translate_gnutls(m_cipher): """ Translate m_cipher from MBedTLS ciphersuite naming convention From 1d592cba5c0c6b8ca2db64718a05a0e01dd899d9 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 13 Aug 2021 12:30:28 +0100 Subject: [PATCH 448/966] Remove NULL-SHA256 specific to OpenSSL Instead add TLS-RSA-WITH-NULL-SHA256 to list of common ciphersuites. It therefore has to be removed from GnuTLS as it could then duplicate. Signed-off-by: Joe Subbiani --- tests/compat.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index 4e18fce2d2..dbd5e39009 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -313,8 +313,8 @@ add_common_ciphersuites() TLS-DHE-RSA-WITH-AES-256-GCM-SHA384 \ TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384 \ + TLS-RSA-WITH-NULL-SHA256 \ " - O_CIPHERS="$O_CIPHERS NULL-SHA256" fi ;; @@ -449,10 +449,6 @@ add_gnutls_ciphersuites() ;; "RSA") - if [ `minor_ver "$MODE"` -gt 0 ] - then - CIPHERS="$CIPHERS TLS-RSA-WITH-NULL-SHA256" - fi if [ `minor_ver "$MODE"` -ge 3 ] then CIPHERS="$CIPHERS \ From b0aba9a46e4c327b0da97139e23fa477ed06fc75 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Wed, 25 Aug 2021 09:56:57 +0100 Subject: [PATCH 449/966] Improve comments to be more accurate Signed-off-by: Joe Subbiani --- tests/compat.sh | 16 ++++++++-------- tests/scripts/translate_ciphers.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index dbd5e39009..f4c611ae77 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -339,10 +339,10 @@ add_common_ciphersuites() } # Ciphersuites usable only with Mbed TLS and OpenSSL -# Each ciphersuite is compiled case by case in the MBedTLS standard, and -# is appended to the list of MBedTLS ciphersuites $M_CIPHERS. The same list -# is translated to the OpenSSL naming standard and appended to the list of -# OpenSSL ciphersuites $O_CIPHERS +# A list of ciphersuites in the Mbed TLS convention is compiled and +# appended to the list of Mbed TLS ciphersuites $M_CIPHERS. The same list +# is translated to the OpenSSL naming convention and appended to the list of +# OpenSSL ciphersuites $O_CIPHERS. # # NOTE: for some reason RSA-PSK doesn't work with OpenSSL, # so RSA-PSK ciphersuites need to go in other sections, see @@ -423,10 +423,10 @@ add_openssl_ciphersuites() } # Ciphersuites usable only with Mbed TLS and GnuTLS -# Each ciphersuite is compiled case by case in the MBedTLS standard, and -# is appended to the list of MBedTLS ciphersuites $M_CIPHERS. The same list -# is translated to the GnuTLS naming standard and appended to the list of -# GnuTLS ciphersuites $G_CIPHERS +# A list of ciphersuites in the Mbed TLS convention is compiled and +# appended to the list of Mbed TLS ciphersuites $M_CIPHERS. The same list +# is translated to the GnuTLS naming convention and appended to the list of +# GnuTLS ciphersuites $G_CIPHERS. add_gnutls_ciphersuites() { CIPHERS="" diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index 7bbc1d74d0..6f6c5d8243 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -18,7 +18,7 @@ # limitations under the License. """ -Translate ciphersuite names in MBedTLS format to OpenSSL and GNUTLS +Translate ciphersuite names in Mbed TLS format to OpenSSL and GNUTLS standards. To test the translation functions run: @@ -504,7 +504,7 @@ class TestTranslateCiphers(unittest.TestCase): def translate_gnutls(m_cipher): """ - Translate m_cipher from MBedTLS ciphersuite naming convention + Translate m_cipher from Mbed TLS ciphersuite naming convention and return the GnuTLS naming convention """ @@ -532,7 +532,7 @@ def translate_gnutls(m_cipher): def translate_ossl(m_cipher): """ - Translate m_cipher from MBedTLS ciphersuite naming convention + Translate m_cipher from Mbed TLS ciphersuite naming convention and return the OpenSSL naming convention """ From 54110b3b6f571b9e1195a3f1e4094bb24d1eafac Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 2 Sep 2021 13:02:29 +0100 Subject: [PATCH 450/966] Reduce translate_ciphers.py test list Having a list of every ciphersuite suggests that it should be maintained with any new ciphersuites that are added in the future. This in turn almost defeats the purpose of having translation functions to begin with Instead, the unit test now only test a much smaller subset of ciphersuite names that exercise each stage in the OpenSSL and GnuTLS translate functions. In the future, if a new cipersuite is added that requires an extra stage in translation, then that cipher can be added to the test suite, otherwise it should not be necessary. Signed-off-by: Joe Subbiani --- tests/scripts/translate_ciphers.py | 470 ++--------------------------- 1 file changed, 18 insertions(+), 452 deletions(-) diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index 6f6c5d8243..d04b8f32fa 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -36,460 +36,26 @@ class TestTranslateCiphers(unittest.TestCase): """ def test_translate_all_cipher_names(self): """ - Translate the Mbed TLS ciphersuite names to the common OpenSSL and - GnuTLS ciphersuite names, and compare them with the true, expected - corresponding OpenSSL and GnuTLS ciphersuite names + Translate MbedTLS ciphersuite names to their OpenSSL and + GnuTLS counterpart. Use only a small subset of ciphers + that exercise each step of the translate functions """ ciphers = [ - ("TLS-ECDHE-ECDSA-WITH-NULL-SHA", - "+ECDHE-ECDSA:+NULL:+SHA1", - "ECDHE-ECDSA-NULL-SHA"), - ("TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", - "+ECDHE-ECDSA:+3DES-CBC:+SHA1", - "ECDHE-ECDSA-DES-CBC3-SHA"), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", - "+ECDHE-ECDSA:+AES-128-CBC:+SHA1", - "ECDHE-ECDSA-AES128-SHA"), - ("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", - "+ECDHE-ECDSA:+AES-256-CBC:+SHA1", - "ECDHE-ECDSA-AES256-SHA"), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", - "+ECDHE-ECDSA:+AES-128-CBC:+SHA256", - "ECDHE-ECDSA-AES128-SHA256"), - ("TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", - "+ECDHE-ECDSA:+AES-256-CBC:+SHA384", - "ECDHE-ECDSA-AES256-SHA384"), - ("TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", - "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", - "ECDHE-ECDSA-AES128-GCM-SHA256"), - ("TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", - "+ECDHE-ECDSA:+AES-256-GCM:+AEAD", - "ECDHE-ECDSA-AES256-GCM-SHA384"), - ("TLS-DHE-RSA-WITH-AES-128-CBC-SHA", - "+DHE-RSA:+AES-128-CBC:+SHA1", - "DHE-RSA-AES128-SHA"), - ("TLS-DHE-RSA-WITH-AES-256-CBC-SHA", - "+DHE-RSA:+AES-256-CBC:+SHA1", - "DHE-RSA-AES256-SHA"), - ("TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", - "+DHE-RSA:+CAMELLIA-128-CBC:+SHA1", - "DHE-RSA-CAMELLIA128-SHA"), - ("TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", - "+DHE-RSA:+CAMELLIA-256-CBC:+SHA1", - "DHE-RSA-CAMELLIA256-SHA"), - ("TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", - "+DHE-RSA:+3DES-CBC:+SHA1", - "EDH-RSA-DES-CBC3-SHA"), - ("TLS-RSA-WITH-AES-256-CBC-SHA", - "+RSA:+AES-256-CBC:+SHA1", - "AES256-SHA"), - ("TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", - "+RSA:+CAMELLIA-256-CBC:+SHA1", - "CAMELLIA256-SHA"), - ("TLS-RSA-WITH-AES-128-CBC-SHA", - "+RSA:+AES-128-CBC:+SHA1", - "AES128-SHA"), - ("TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", - "+RSA:+CAMELLIA-128-CBC:+SHA1", - "CAMELLIA128-SHA"), - ("TLS-RSA-WITH-3DES-EDE-CBC-SHA", - "+RSA:+3DES-CBC:+SHA1", - "DES-CBC3-SHA"), - ("TLS-RSA-WITH-NULL-MD5", - "+RSA:+NULL:+MD5", - "NULL-MD5"), - ("TLS-RSA-WITH-NULL-SHA", - "+RSA:+NULL:+SHA1", - "NULL-SHA"), - ("TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", - "+ECDHE-RSA:+AES-128-CBC:+SHA1", - "ECDHE-RSA-AES128-SHA"), - ("TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", - "+ECDHE-RSA:+AES-256-CBC:+SHA1", - "ECDHE-RSA-AES256-SHA"), - ("TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", - "+ECDHE-RSA:+3DES-CBC:+SHA1", - "ECDHE-RSA-DES-CBC3-SHA"), - ("TLS-ECDHE-RSA-WITH-NULL-SHA", - "+ECDHE-RSA:+NULL:+SHA1", - "ECDHE-RSA-NULL-SHA"), - ("TLS-RSA-WITH-AES-128-CBC-SHA256", - "+RSA:+AES-128-CBC:+SHA256", - "AES128-SHA256"), - ("TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", - "+DHE-RSA:+AES-128-CBC:+SHA256", - "DHE-RSA-AES128-SHA256"), - ("TLS-RSA-WITH-AES-256-CBC-SHA256", - "+RSA:+AES-256-CBC:+SHA256", - "AES256-SHA256"), - ("TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", - "+DHE-RSA:+AES-256-CBC:+SHA256", - "DHE-RSA-AES256-SHA256"), - ("TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", - "+ECDHE-RSA:+AES-128-CBC:+SHA256", - "ECDHE-RSA-AES128-SHA256"), - ("TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", - "+ECDHE-RSA:+AES-256-CBC:+SHA384", - "ECDHE-RSA-AES256-SHA384"), - ("TLS-RSA-WITH-AES-128-GCM-SHA256", - "+RSA:+AES-128-GCM:+AEAD", - "AES128-GCM-SHA256"), - ("TLS-RSA-WITH-AES-256-GCM-SHA384", - "+RSA:+AES-256-GCM:+AEAD", - "AES256-GCM-SHA384"), - ("TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", - "+DHE-RSA:+AES-128-GCM:+AEAD", - "DHE-RSA-AES128-GCM-SHA256"), - ("TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", - "+DHE-RSA:+AES-256-GCM:+AEAD", - "DHE-RSA-AES256-GCM-SHA384"), - ("TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", - "+ECDHE-RSA:+AES-128-GCM:+AEAD", - "ECDHE-RSA-AES128-GCM-SHA256"), - ("TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", - "+ECDHE-RSA:+AES-256-GCM:+AEAD", - "ECDHE-RSA-AES256-GCM-SHA384"), - ("TLS-PSK-WITH-3DES-EDE-CBC-SHA", - "+PSK:+3DES-CBC:+SHA1", - "PSK-3DES-EDE-CBC-SHA"), - ("TLS-PSK-WITH-AES-128-CBC-SHA", - "+PSK:+AES-128-CBC:+SHA1", - "PSK-AES128-CBC-SHA"), - ("TLS-PSK-WITH-AES-256-CBC-SHA", - "+PSK:+AES-256-CBC:+SHA1", - "PSK-AES256-CBC-SHA"), - - ("TLS-ECDH-ECDSA-WITH-NULL-SHA", - None, - "ECDH-ECDSA-NULL-SHA"), - ("TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", - None, - "ECDH-ECDSA-DES-CBC3-SHA"), - ("TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", - None, - "ECDH-ECDSA-AES128-SHA"), - ("TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", - None, - "ECDH-ECDSA-AES256-SHA"), - ("TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", - None, - "ECDH-ECDSA-AES128-SHA256"), - ("TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", - None, - "ECDH-ECDSA-AES256-SHA384"), - ("TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", - None, - "ECDH-ECDSA-AES128-GCM-SHA256"), - ("TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", - None, - "ECDH-ECDSA-AES256-GCM-SHA384"), - ("TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", - None, - "ECDHE-ECDSA-ARIA256-GCM-SHA384"), - ("TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", - None, - "ECDHE-ECDSA-ARIA128-GCM-SHA256"), - ("TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", - None, - "ECDHE-ECDSA-CHACHA20-POLY1305"), - ("TLS-RSA-WITH-DES-CBC-SHA", - None, - "DES-CBC-SHA"), - ("TLS-DHE-RSA-WITH-DES-CBC-SHA", - None, - "EDH-RSA-DES-CBC-SHA"), - ("TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", - None, - "ECDHE-ARIA256-GCM-SHA384"), - ("TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", - None, - "DHE-RSA-ARIA256-GCM-SHA384"), - ("TLS-RSA-WITH-ARIA-256-GCM-SHA384", - None, - "ARIA256-GCM-SHA384"), - ("TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", - None, - "ECDHE-ARIA128-GCM-SHA256"), - ("TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", - None, - "DHE-RSA-ARIA128-GCM-SHA256"), - ("TLS-RSA-WITH-ARIA-128-GCM-SHA256", - None, - "ARIA128-GCM-SHA256"), - ("TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", - None, - "DHE-RSA-CHACHA20-POLY1305"), - ("TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", - None, - "ECDHE-RSA-CHACHA20-POLY1305"), - ("TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", - None, - "DHE-PSK-ARIA256-GCM-SHA384"), - ("TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", - None, - "DHE-PSK-ARIA128-GCM-SHA256"), - ("TLS-PSK-WITH-ARIA-256-GCM-SHA384", - None, - "PSK-ARIA256-GCM-SHA384"), - ("TLS-PSK-WITH-ARIA-128-GCM-SHA256", - None, - "PSK-ARIA128-GCM-SHA256"), - ("TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", - None, - "PSK-CHACHA20-POLY1305"), - ("TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", - None, - "ECDHE-PSK-CHACHA20-POLY1305"), - ("TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", - None, - "DHE-PSK-CHACHA20-POLY1305"), - - ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", - "+ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", - "+ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", - "+ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", - "+ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM", - "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-AES-256-CCM", - "+ECDHE-ECDSA:+AES-256-CCM:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", - "+ECDHE-ECDSA:+AES-128-CCM-8:+AEAD", - None), - ("TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", - "+ECDHE-ECDSA:+AES-256-CCM-8:+AEAD", - None), - ("TLS-RSA-WITH-NULL-SHA256", - "+RSA:+NULL:+SHA256", - None), - ("TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "+ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", - "+ECDHE-RSA:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "+RSA:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", - "+RSA:+CAMELLIA-256-CBC:+SHA256", - None), - ("TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", - "+DHE-RSA:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", - "+DHE-RSA:+CAMELLIA-256-CBC:+SHA256", - None), - ("TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "+ECDHE-RSA:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "+ECDHE-RSA:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "+DHE-RSA:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "+DHE-RSA:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", - "+RSA:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", - "+RSA:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-RSA-WITH-AES-128-CCM", - "+RSA:+AES-128-CCM:+AEAD", - None), - ("TLS-RSA-WITH-AES-256-CCM", - "+RSA:+AES-256-CCM:+AEAD", - None), - ("TLS-DHE-RSA-WITH-AES-128-CCM", - "+DHE-RSA:+AES-128-CCM:+AEAD", - None), - ("TLS-DHE-RSA-WITH-AES-256-CCM", - "+DHE-RSA:+AES-256-CCM:+AEAD", - None), - ("TLS-RSA-WITH-AES-128-CCM-8", - "+RSA:+AES-128-CCM-8:+AEAD", - None), - ("TLS-RSA-WITH-AES-256-CCM-8", - "+RSA:+AES-256-CCM-8:+AEAD", - None), - ("TLS-DHE-RSA-WITH-AES-128-CCM-8", - "+DHE-RSA:+AES-128-CCM-8:+AEAD", - None), - ("TLS-DHE-RSA-WITH-AES-256-CCM-8", - "+DHE-RSA:+AES-256-CCM-8:+AEAD", - None), - ("TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", - "+DHE-PSK:+3DES-CBC:+SHA1", - None), - ("TLS-DHE-PSK-WITH-AES-128-CBC-SHA", - "+DHE-PSK:+AES-128-CBC:+SHA1", - None), - ("TLS-DHE-PSK-WITH-AES-256-CBC-SHA", - "+DHE-PSK:+AES-256-CBC:+SHA1", - None), - ("TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", - "+ECDHE-PSK:+AES-256-CBC:+SHA1", - None), - ("TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", - "+ECDHE-PSK:+AES-128-CBC:+SHA1", - None), - ("TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", - "+ECDHE-PSK:+3DES-CBC:+SHA1", - None), - ("TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", - "+RSA-PSK:+3DES-CBC:+SHA1", - None), - ("TLS-RSA-PSK-WITH-AES-256-CBC-SHA", - "+RSA-PSK:+AES-256-CBC:+SHA1", - None), - ("TLS-RSA-PSK-WITH-AES-128-CBC-SHA", - "+RSA-PSK:+AES-128-CBC:+SHA1", - None), - ("TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", - "+ECDHE-PSK:+AES-256-CBC:+SHA384", - None), - ("TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "+ECDHE-PSK:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", - "+ECDHE-PSK:+AES-128-CBC:+SHA256", - None), - ("TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "+ECDHE-PSK:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-ECDHE-PSK-WITH-NULL-SHA384", - "+ECDHE-PSK:+NULL:+SHA384", - None), - ("TLS-ECDHE-PSK-WITH-NULL-SHA256", - "+ECDHE-PSK:+NULL:+SHA256", - None), - ("TLS-PSK-WITH-AES-128-CBC-SHA256", - "+PSK:+AES-128-CBC:+SHA256", - None), - ("TLS-PSK-WITH-AES-256-CBC-SHA384", - "+PSK:+AES-256-CBC:+SHA384", - None), - ("TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", - "+DHE-PSK:+AES-128-CBC:+SHA256", - None), - ("TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", - "+DHE-PSK:+AES-256-CBC:+SHA384", - None), - ("TLS-PSK-WITH-NULL-SHA256", - "+PSK:+NULL:+SHA256", - None), - ("TLS-PSK-WITH-NULL-SHA384", - "+PSK:+NULL:+SHA384", - None), - ("TLS-DHE-PSK-WITH-NULL-SHA256", - "+DHE-PSK:+NULL:+SHA256", - None), - ("TLS-DHE-PSK-WITH-NULL-SHA384", - "+DHE-PSK:+NULL:+SHA384", - None), - ("TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", - "+RSA-PSK:+AES-256-CBC:+SHA384", - None), - ("TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", - "+RSA-PSK:+AES-128-CBC:+SHA256", - None), - ("TLS-RSA-PSK-WITH-NULL-SHA256", - "+RSA-PSK:+NULL:+SHA256", - None), - ("TLS-RSA-PSK-WITH-NULL-SHA384", - "+RSA-PSK:+NULL:+SHA384", - None), - ("TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "+DHE-PSK:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "+DHE-PSK:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "+PSK:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "+PSK:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", - "+RSA-PSK:+CAMELLIA-256-CBC:+SHA384", - None), - ("TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", - "+RSA-PSK:+CAMELLIA-128-CBC:+SHA256", - None), - ("TLS-PSK-WITH-AES-128-GCM-SHA256", - "+PSK:+AES-128-GCM:+AEAD", - None), - ("TLS-PSK-WITH-AES-256-GCM-SHA384", - "+PSK:+AES-256-GCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", - "+DHE-PSK:+AES-128-GCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", - "+DHE-PSK:+AES-256-GCM:+AEAD", - None), - ("TLS-PSK-WITH-AES-128-CCM", - "+PSK:+AES-128-CCM:+AEAD", - None), - ("TLS-PSK-WITH-AES-256-CCM", - "+PSK:+AES-256-CCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-128-CCM", - "+DHE-PSK:+AES-128-CCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-256-CCM", - "+DHE-PSK:+AES-256-CCM:+AEAD", - None), - ("TLS-PSK-WITH-AES-128-CCM-8", - "+PSK:+AES-128-CCM-8:+AEAD", - None), - ("TLS-PSK-WITH-AES-256-CCM-8", - "+PSK:+AES-256-CCM-8:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-128-CCM-8", - "+DHE-PSK:+AES-128-CCM-8:+AEAD", - None), - ("TLS-DHE-PSK-WITH-AES-256-CCM-8", - "+DHE-PSK:+AES-256-CCM-8:+AEAD", - None), - ("TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "+RSA-PSK:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "+RSA-PSK:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "+PSK:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "+PSK:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", - "+DHE-PSK:+CAMELLIA-128-GCM:+AEAD", - None), - ("TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", - "+DHE-PSK:+CAMELLIA-256-GCM:+AEAD", - None), - ("TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", - "+RSA-PSK:+AES-256-GCM:+AEAD", - None), - ("TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", - "+RSA-PSK:+AES-128-GCM:+AEAD", - None), + ("TLS-ECDHE-ECDSA-WITH-NULL-SHA", + "+ECDHE-ECDSA:+NULL:+SHA1", + "ECDHE-ECDSA-NULL-SHA"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", + "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", + "ECDHE-ECDSA-AES128-GCM-SHA256"), + ("TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", + "+DHE-RSA:+3DES-CBC:+SHA1", + "EDH-RSA-DES-CBC3-SHA"), + ("TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", + None, + "ECDHE-ECDSA-CHACHA20-POLY1305"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM", + "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", + None), ] for m, g_exp, o_exp in ciphers: From 49d57bcf19cdbd54c81bbeaad8a1ac002ae0248a Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Thu, 2 Sep 2021 18:50:30 +0100 Subject: [PATCH 451/966] Improve indentation according to pylint Signed-off-by: Joe Subbiani --- tests/scripts/translate_ciphers.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index d04b8f32fa..207c884cf6 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -41,21 +41,21 @@ class TestTranslateCiphers(unittest.TestCase): that exercise each step of the translate functions """ ciphers = [ - ("TLS-ECDHE-ECDSA-WITH-NULL-SHA", - "+ECDHE-ECDSA:+NULL:+SHA1", - "ECDHE-ECDSA-NULL-SHA"), - ("TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", - "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", - "ECDHE-ECDSA-AES128-GCM-SHA256"), - ("TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", - "+DHE-RSA:+3DES-CBC:+SHA1", - "EDH-RSA-DES-CBC3-SHA"), - ("TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", - None, - "ECDHE-ECDSA-CHACHA20-POLY1305"), - ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM", - "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", - None), + ("TLS-ECDHE-ECDSA-WITH-NULL-SHA", + "+ECDHE-ECDSA:+NULL:+SHA1", + "ECDHE-ECDSA-NULL-SHA"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", + "+ECDHE-ECDSA:+AES-128-GCM:+AEAD", + "ECDHE-ECDSA-AES128-GCM-SHA256"), + ("TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", + "+DHE-RSA:+3DES-CBC:+SHA1", + "EDH-RSA-DES-CBC3-SHA"), + ("TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", + None, + "ECDHE-ECDSA-CHACHA20-POLY1305"), + ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM", + "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", + None), ] for m, g_exp, o_exp in ciphers: From e5d6106071654c505b07c76e5be6469e4092ef00 Mon Sep 17 00:00:00 2001 From: Joe Subbiani Date: Fri, 3 Sep 2021 13:30:44 +0100 Subject: [PATCH 452/966] Extend test in translate_ciphers.py The list was trimmed previously according to code coverage, however this did not really evalute all test cases, e.g in the case of re.sub or m_cipher.replace. These lines are executed no matter what, so code coverage is not suitable. I have gone through each step in the translate functions and made sure there is at least one ciphersuite per step Signed-off-by: Joe Subbiani --- tests/scripts/translate_ciphers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/scripts/translate_ciphers.py b/tests/scripts/translate_ciphers.py index 207c884cf6..d5f847fd54 100755 --- a/tests/scripts/translate_ciphers.py +++ b/tests/scripts/translate_ciphers.py @@ -50,12 +50,21 @@ class TestTranslateCiphers(unittest.TestCase): ("TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", "+DHE-RSA:+3DES-CBC:+SHA1", "EDH-RSA-DES-CBC3-SHA"), + ("TLS-RSA-WITH-AES-256-CBC-SHA", + "+RSA:+AES-256-CBC:+SHA1", + "AES256-SHA"), + ("TLS-PSK-WITH-3DES-EDE-CBC-SHA", + "+PSK:+3DES-CBC:+SHA1", + "PSK-3DES-EDE-CBC-SHA"), ("TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", None, "ECDHE-ECDSA-CHACHA20-POLY1305"), ("TLS-ECDHE-ECDSA-WITH-AES-128-CCM", "+ECDHE-ECDSA:+AES-128-CCM:+AEAD", None), + ("TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", + None, + "ECDHE-ARIA256-GCM-SHA384"), ] for m, g_exp, o_exp in ciphers: From 8c02bb4b7194631f1a901745400ac76e1180f1a3 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 3 Sep 2021 21:09:22 +0800 Subject: [PATCH 453/966] fix various comment issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 6 +++--- library/ssl_tls13_client.c | 16 +++++----------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index e16c674cb0..7035c278cf 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -132,10 +132,10 @@ #define MBEDTLS_SSL_EXT_KEY_SHARE ( 1 << 21 ) /* - * Helper macros for function call with returen check. + * Helper macros for function call with return check. */ /* - * Exit and print debug message when return none zero value + * Exit when return non-zero value */ #define MBEDTLS_SSL_PROC_CHK( f ) \ do { \ @@ -146,7 +146,7 @@ } \ } while( 0 ) /* - * Exit and print debug message when return negative value + * Exit when return negative value */ #define MBEDTLS_SSL_PROC_CHK_NEG( f ) \ do { \ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 262481c6a7..f8779a09fd 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -164,8 +164,8 @@ static int ssl_tls13_write_client_hello_cipher_suites( ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( cipher_suite ); if( ciphersuite_info == NULL ) continue; - if( ciphersuite_info->min_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 || - ciphersuite_info->max_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 ) + if( !( MBEDTLS_SSL_MINOR_VERSION_4 > ciphersuite_info->min_minor_ver && + MBEDTLS_SSL_MINOR_VERSION_4 < ciphersuite_info->max_minor_ver ) ) continue; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x, %s", @@ -173,7 +173,7 @@ static int ssl_tls13_write_client_hello_cipher_suites( ciphersuite_info->name ) ); /* Check there is space for the cipher suite identifier (2 bytes). */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); + MBEDTLS_SSL_CHK_BUF_PTR( cipher_suites_iter, end, 2 ); MBEDTLS_PUT_UINT16_BE( cipher_suite, cipher_suites_iter, 0 ); cipher_suites_iter += 2; } @@ -210,7 +210,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, { int ret; - unsigned char *extensions_len_ptr; /* Pointer of extensions length */ + unsigned char *extensions_len_ptr; /* Pointer to extensions length */ size_t output_len; /* Length of buffer used by function */ size_t extensions_len; /* Length of the list of extensions*/ @@ -362,7 +362,7 @@ static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) ssl->handshake->randbytes, CLIENT_HELLO_RANDOM_LEN ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "f_rng", ret ); return( ret ); } @@ -410,12 +410,6 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) { int ret = 0; - if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER || ssl->handshake == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "Handshake completed but ssl->handshake is NULL.\n" ) ); - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - } - MBEDTLS_SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); switch( ssl->state ) From dbfb7bd873dfa8e5bf9afb5aae3aa2680e9e2fd4 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sat, 4 Sep 2021 09:58:58 +0800 Subject: [PATCH 454/966] fix various issues - wrong cipher suite filter condition - name conversion - format issue Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 6 +++--- library/ssl_tls13_generic.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index f8779a09fd..2a62dc6fdd 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -164,8 +164,8 @@ static int ssl_tls13_write_client_hello_cipher_suites( ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( cipher_suite ); if( ciphersuite_info == NULL ) continue; - if( !( MBEDTLS_SSL_MINOR_VERSION_4 > ciphersuite_info->min_minor_ver && - MBEDTLS_SSL_MINOR_VERSION_4 < ciphersuite_info->max_minor_ver ) ) + if( !( MBEDTLS_SSL_MINOR_VERSION_4 >= ciphersuite_info->min_minor_ver && + MBEDTLS_SSL_MINOR_VERSION_4 <= ciphersuite_info->max_minor_ver ) ) continue; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x, %s", @@ -259,7 +259,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, /* Write cipher_suites */ ret = ssl_tls13_write_client_hello_cipher_suites( ssl, buf, end, &output_len ); - if( ret != 0) + if( ret != 0 ) return( ret ); buf += output_len; diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 3c49a379bd..ca4c167132 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -53,10 +53,12 @@ int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, size_t msg_len ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + size_t msg_len_with_header; ((void) buf_len); /* Add reserved 4 bytes for handshake header */ - ssl->out_msglen = msg_len + 4; + msg_len_with_header = msg_len + 4; + ssl->out_msglen = msg_len_with_header; MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext( ssl, 0 ) ); cleanup: From cd975e4645bbf6057d0aff68866bb655a822b202 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 2 Sep 2021 13:25:19 +0200 Subject: [PATCH 455/966] Extend CCM corner cases tests. Add tests for passing incomplete input data in the first call and too much data in the second call. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 32 ++++++++++++ tests/suites/test_suite_ccm.function | 77 ++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index c8f6351633..169a885f94 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -1562,6 +1562,10 @@ CCM encrypt, full ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" +CCM encrypt, incomplete ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" + CCM encrypt, overflow update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" @@ -1574,6 +1578,10 @@ CCM encrypt, full update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T= depends_on:MBEDTLS_AES_C mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" +CCM encrypt, incomplete update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_update_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" + CCM decrypt, overflow ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" @@ -1586,6 +1594,10 @@ CCM decrypt, full ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" +CCM decrypt, incomplete ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" + CCM decrypt, overflow update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16)) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" @@ -1598,6 +1610,10 @@ CCM decrypt, full update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T= depends_on:MBEDTLS_AES_C mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" +CCM decrypt, incomplete update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_update_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" + CCM* encrypt, overflow ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" @@ -1614,6 +1630,10 @@ CCM* encrypt, overflow update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" +CCM* encrypt, incomplete ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" + CCM* encrypt, incomplete update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_incomplete_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" @@ -1622,6 +1642,10 @@ CCM* encrypt, full update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T depends_on:MBEDTLS_AES_C mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" +CCM* encrypt, incomplete update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_update_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" + CCM* decrypt, overflow ad NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" @@ -1634,6 +1658,10 @@ CCM* decrypt, full ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_full_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" +CCM* decrypt, incomplete ad and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_ad_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"a6f73242f2f227350c0277e4e72cdaa6" + CCM* decrypt, overflow update NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_overflow_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" @@ -1646,6 +1674,10 @@ CCM* decrypt, full update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T depends_on:MBEDTLS_AES_C mbedtls_ccm_full_update_and_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" +CCM* decrypt, incomplete update and overflow NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_incomplete_update_overflow:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" + CCM encrypt, instant finish NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98" diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 57f13e3d85..311ccc429d 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -591,6 +591,41 @@ exit: } /* END_CASE */ +/* Provide incomplete auth data on first update_ad. + * Provide too much auth data on second update_ad */ +/* BEGIN_CASE */ +void mbedtls_ccm_incomplete_ad_and_overflow( int cipher_id, int mode, + data_t * key, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + + /* New auth buffer containing same data as original one, + * with added extra byte at the end */ + uint8_t* add_extended = NULL; + ASSERT_ALLOC( add_extended, add->len + 1 ); + if( add_extended ) + { + memcpy( add_extended, add->x, add->len ); + add_extended[add->len] = 0xAB; // some magic value + } + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded values for msg length and tag length. They are not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, 16, 16 ) ); + + // pass incomplete auth data + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add_extended, add->len - 1) ); + // pass 2 extra bytes (1 missing byte from previous incomplete pass, and 1 unexpected byte) + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update_ad( &ctx, add_extended + add->len - 1, 2) ); +exit: + mbedtls_free( add_extended ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + /* Provide too much plaintext/ciphertext */ /* BEGIN_CASE */ void mbedtls_ccm_overflow_update( int cipher_id, int mode, @@ -683,6 +718,48 @@ exit: } /* END_CASE */ +/* Provide incomplete plaintext/ciphertext of first update + * Provide too much plaintext/ciphertext on second update */ +/* BEGIN_CASE */ +void mbedtls_ccm_incomplete_update_overflow( int cipher_id, int mode, + data_t * key, data_t * msg, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + size_t olen; + + /* New plaintext/ciphertext buffer containing same data as original one, + * with added extra byte at the end */ + uint8_t* msg_extended = NULL; + ASSERT_ALLOC( msg_extended, msg->len + 1 ); + if( msg_extended ) + { + memcpy( msg_extended, msg->x, msg->len ); + msg_extended[msg->len] = 0xAB; // some magic value + } + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded value for tag length. It is a not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, msg->len, 16 ) ); + + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); + + ASSERT_ALLOC( output, msg->len + 1 ); + // pass incomplete text + TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg_extended, msg->len - 1, output, msg->len + 1, &olen ) ); + // pass 2 extra bytes (1 missing byte from previous incomplete pass, and 1 unexpected byte) + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, \ + mbedtls_ccm_update( &ctx, msg_extended + msg->len - 1, 2, output + msg->len - 1, 2, &olen ) ); +exit: + mbedtls_free( msg_extended ); + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + /* Finish without passing any auth data or plaintext/ciphertext input */ /* BEGIN_CASE */ void mbedtls_ccm_instant_finish( int cipher_id, int mode, From 5d7f6b1fd5ae89282d3cd0806a37dcfca14d06bc Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 2 Sep 2021 15:11:14 +0200 Subject: [PATCH 456/966] Remove rendundat ctx->add_len check. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ccm.c b/library/ccm.c index ca95b8eeb7..15efff79f0 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -266,7 +266,7 @@ int mbedtls_ccm_update_ad( mbedtls_ccm_context *ctx, return MBEDTLS_ERR_CCM_BAD_INPUT; } - if( ctx->add_len > 0 && add_len > 0 ) + if( add_len > 0 ) { if( ctx->state & CCM_STATE__AUTH_DATA_FINISHED ) { From efec38bb292f9c74050c3816443333eae7be5d5a Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Fri, 3 Sep 2021 11:59:26 +0200 Subject: [PATCH 457/966] Extend CCM corner cases tests. Add tests covering skipped update() or update_ad() for empty plaintext/ciphertext and empty auth data. Test vector for P=0, A=0 generated using python's cryptography.hazmat library. Python script used for test vector generation: ``` import os from cryptography.hazmat.primitives.ciphers.aead import AESCCM def encrypt(key, iv, plaintext, associated_data): key = bytes.fromhex(key) iv = bytes.fromhex(iv) plaintext = bytes.fromhex(plaintext) associated_data = bytes.fromhex(associated_data) aesccm = AESCCM(key) ct = aesccm.encrypt(iv, plaintext, associated_data) return ct.hex() def decrypt(key, associated_data, iv, ciphertext): key = bytes.fromhex(key) associated_data = bytes.fromhex(associated_data) iv = bytes.fromhex(iv) ciphertext = bytes.fromhex(ciphertext) aesccm = AESCCM(key) pt = aesccm.decrypt(iv, ciphertext, associated_data) return pt.hex() key = "54caf96ef6d448734700aadab50faf7a" plaintext = "" iv = "a3803e752ae849c910d8da36af" aad = "" encrypted = encrypt(key, iv, plaintext, aad) print(f"key: {key}") print(f"iv: {iv}") print(f"encrypted: {encrypted}") print("--------------------------------------") decrypted = decrypt( key, aad, iv, encrypted ) print(f"decrypted: {decrypted}") ``` Results: ``` key: 54caf96ef6d448734700aadab50faf7a iv: a3803e752ae849c910d8da36af encrypted: eba8347baa6d61f87b67c2dd7c6d2053 -------------------------------------- decrypted: ``` Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index 169a885f94..05c20fd40b 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -174,6 +174,10 @@ CCM encrypt and tag RFC 3610 #24 depends_on:MBEDTLS_AES_C mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"D7828D13B2B0BDC325A76236DF93CC6B":"ABF21C0B02FEB88F856DF4A37381BCE3CC128517D4":"008D493B30AE8B3C9696766CFA":"6E37A6EF546D955D34AB6059":"F32905B88A641B04B9C9FFB58CC390900F3DA12AB16DCE9E82EFA16DA62059" +CCM encrypt and tag AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"54caf96ef6d448734700aadab50faf7a":"":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + CCM encrypt and tag NIST VTT AES-128 #1 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"43b1a6bc8d0d22d6d1ca95c18593cca5":"a2b381c7d1545c408fe29817a21dc435a154c87256346b05":"9882578e750b9682c6ca7f8f86":"2084f3861c9ad0ccee7c63a7e05aece5db8b34bd8724cc06b4ca99a7f9c4914f":"cc69ed76985e0ed4c8365a72775e5a19bfccc71aeb116c85a8c74677" @@ -1518,6 +1522,22 @@ CCM-Camellia encrypt and tag RFC 5528 #24 depends_on:MBEDTLS_CAMELLIA_C mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_CAMELLIA:"D75C2778078CA93D971F96FDE720F4CD":"9DC9EDAE2FF5DF8636E8C6DE0EED55F7867E33337D":"003B8FD8D3A937B160B6A31C1C":"A4D499F78419728C19178B0C":"4B198156393B0F7796086AAFB454F8C3F034CCA966945F1FCEA7E11BEE6A2F" +CCM encrypt, skip ad AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"54caf96ef6d448734700aadab50faf7a":"":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + +CCM* encrypt, skip ad AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"54caf96ef6d448734700aadab50faf7a":"":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + +CCM decrypt, skip ad AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"54caf96ef6d448734700aadab50faf7a":"":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + +CCM* decrypt, skip ad AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"54caf96ef6d448734700aadab50faf7a":"":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + CCM encrypt, skip ad NIST VADT AES-128 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d24a3d3dde8c84830280cb87abad0bb3":"7c86135ed9c2a515aaae0e9a208133897269220f30870006":"f1100035bb24a8d26004e0e24b":"1faeb0ee2ca2cd52f0aa3966578344f24e69b742c4ab37ab":"1123301219c70599b7c373ad4b3ad67b" @@ -1534,6 +1554,22 @@ CCM* decrypt, skip ad NIST DVPT AES-192 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C mbedtls_ccm_skip_ad:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22":"ddc93a54" +CCM encrypt, skip update AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + +CCM decrypt, skip update AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + +CCM* encrypt, skip update AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + +CCM* decrypt, skip update AES-128 (P=0, N=13, A=0, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af":"":"eba8347baa6d61f87b67c2dd7c6d2053" + CCM encrypt, skip update NIST VPT AES-128 #1 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_skip_update:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"2ebf60f0969013a54a3dedb19d20f6c8":"1de8c5e21f9db33123ff870add":"e1de6c6119d7db471136285d10b47a450221b16978569190ef6a22b055295603":"0ead29ef205fbb86d11abe5ed704b880" @@ -1689,3 +1725,15 @@ mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"d3208 CCM* decrypt, instant finish NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98" + +CCM encrypt, instant finish AES-128 (P=0, N=13, A=0, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af" + +CCM decrypt, instant finish AES-128 (P=0, N=13, A=0, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_DECRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af" + +CCM* encrypt, instant finish AES-128 (P=0, N=13, A=0, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af" + +CCM* decrypt, instant finish AES-128 (P=0, N=13, A=0, T=16) +mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af" From 83e4c1270a24c7a63ea1cb8f799478172ecdaa96 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Fri, 3 Sep 2021 14:07:21 +0200 Subject: [PATCH 458/966] Add CCM tests for passing unexpected input. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 7 +++++ tests/suites/test_suite_ccm.function | 47 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index 05c20fd40b..591e0d9067 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -1737,3 +1737,10 @@ mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"54caf CCM* decrypt, instant finish AES-128 (P=0, N=13, A=0, T=16) mbedtls_ccm_instant_finish:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"54caf96ef6d448734700aadab50faf7a":"a3803e752ae849c910d8da36af" + +CCM pass unexpected auth data, NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +mbedtls_ccm_unexpected_ad::MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" + +CCM encrypt, unexpected ciphertext/plaintext data, NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_unexpected_text:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 311ccc429d..472be64540 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -542,6 +542,53 @@ exit: } /* END_CASE */ +/* Provide unexpected auth data */ +/* BEGIN_CASE */ +void mbedtls_ccm_unexpected_ad( int cipher_id, int mode, + data_t * key, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded values for msg length and tag length. They are not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, 0, 16, 16 ) ); + + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); +exit: + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + +/* Provide unexpected plaintext/ciphertext data */ +/* BEGIN_CASE */ +void mbedtls_ccm_unexpected_text( int cipher_id, int mode, + data_t * key, data_t * msg, data_t * iv, + data_t * add ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + size_t olen; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + // use hardcoded value for tag length. It is not a part of this test + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, 0, 16 ) ); + + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len) ); + + ASSERT_ALLOC( output, msg->len ); + olen = 0xdeadbeef; + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update( &ctx, msg->x, msg->len, output, msg->len, &olen ) ); +exit: + mbedtls_free( output ); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + /* Provide incomplete auth data and finish */ /* BEGIN_CASE */ void mbedtls_ccm_incomplete_ad( int cipher_id, int mode, From bbe09526b78746e37ebdfcb4d62a0f66581412a4 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 6 Sep 2021 21:17:54 +0800 Subject: [PATCH 459/966] fix name conversion issues Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 74 +++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 2a62dc6fdd..fe2e6f850b 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -133,8 +133,8 @@ static int ssl_tls13_write_client_hello_cipher_suites( size_t *olen ) { const int *ciphersuite_list; - unsigned char *cipher_suites_start; /* Start of the cipher_suites list */ - unsigned char *cipher_suites_iter; /* Iteration over the cipher_suites list */ + unsigned char *cipher_suites_ptr; /* Start of the cipher_suites list */ + unsigned char *p; /* Iteration over the cipher_suites list */ size_t cipher_suites_len; *olen = 0 ; @@ -153,8 +153,8 @@ static int ssl_tls13_write_client_hello_cipher_suites( MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); /* Write cipher_suites */ - cipher_suites_start = buf + 2; - cipher_suites_iter = cipher_suites_start; + cipher_suites_ptr = buf + 2; + p = cipher_suites_ptr; for ( size_t i = 0; ciphersuite_list[i] != 0; i++ ) { @@ -173,20 +173,20 @@ static int ssl_tls13_write_client_hello_cipher_suites( ciphersuite_info->name ) ); /* Check there is space for the cipher suite identifier (2 bytes). */ - MBEDTLS_SSL_CHK_BUF_PTR( cipher_suites_iter, end, 2 ); - MBEDTLS_PUT_UINT16_BE( cipher_suite, cipher_suites_iter, 0 ); - cipher_suites_iter += 2; + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); + MBEDTLS_PUT_UINT16_BE( cipher_suite, p, 0 ); + p += 2; } /* Write the cipher_suites length in number of bytes */ - cipher_suites_len = cipher_suites_iter - cipher_suites_start; + cipher_suites_len = p - cipher_suites_ptr; MBEDTLS_PUT_UINT16_BE( cipher_suites_len, buf, 0 ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, got %" MBEDTLS_PRINTF_SIZET " cipher suites", cipher_suites_len/2 ) ); /* Output the total length of cipher_suites field. */ - *olen = cipher_suites_iter - buf; + *olen = p - buf; return( 0 ); } @@ -215,7 +215,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, size_t extensions_len; /* Length of the list of extensions*/ /* Buffer management */ - unsigned char *start = buf; + unsigned char *p = buf; *olen = 0; @@ -230,16 +230,16 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * For TLS 1.3 we use the legacy version number {0x03, 0x03} * instead of the true version number. */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_LEGACY_VERSION_LEN ); - MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0 ); - buf += CLIENT_HELLO_LEGACY_VERSION_LEN; + MBEDTLS_SSL_CHK_BUF_PTR( p, end, CLIENT_HELLO_LEGACY_VERSION_LEN ); + MBEDTLS_PUT_UINT16_BE( 0x0303, p, 0 ); + p += CLIENT_HELLO_LEGACY_VERSION_LEN; /* Write the random bytes ( random ).*/ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RANDOM_LEN ); - memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RANDOM_LEN ); + MBEDTLS_SSL_CHK_BUF_PTR( p, end, CLIENT_HELLO_RANDOM_LEN ); + memcpy( p, ssl->handshake->randbytes, CLIENT_HELLO_RANDOM_LEN ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", - buf, CLIENT_HELLO_RANDOM_LEN ); - buf += CLIENT_HELLO_RANDOM_LEN; + p, CLIENT_HELLO_RANDOM_LEN ); + p += CLIENT_HELLO_RANDOM_LEN; /* * Write legacy_session_id @@ -254,14 +254,14 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * ( also known as ossification ). Otherwise, it MUST be set as a zero-length * vector ( i.e., a zero-valued single byte length field ). */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 1 ); - *buf++ = 0; /* session id length set to zero */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 1 ); + *p++ = 0; /* session id length set to zero */ /* Write cipher_suites */ - ret = ssl_tls13_write_client_hello_cipher_suites( ssl, buf, end, &output_len ); + ret = ssl_tls13_write_client_hello_cipher_suites( ssl, p, end, &output_len ); if( ret != 0 ) return( ret ); - buf += output_len; + p += output_len; /* Write legacy_compression_methods * @@ -269,9 +269,9 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * one byte set to zero, which corresponds to the 'null' compression * method in prior versions of TLS. */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); - *buf++ = 1; - *buf++ = MBEDTLS_SSL_COMPRESS_NULL; + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); + *p++ = 1; + *p++ = MBEDTLS_SSL_COMPRESS_NULL; /* Write extensions */ @@ -279,28 +279,28 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; /* First write extensions, then the total length */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); - extensions_len_ptr = buf; - buf += 2; + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); + extensions_len_ptr = p; + p += 2; /* Write supported_versions extension * * Supported Versions Extension is mandatory with TLS 1.3. */ - ret = ssl_tls13_write_supported_versions_ext( ssl, buf, end, &output_len ); + ret = ssl_tls13_write_supported_versions_ext( ssl, p, end, &output_len ); if( ret != 0 ) return( ret ); - buf += output_len; + p += output_len; #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* Write supported_groups extension * * It is REQUIRED for ECDHE cipher_suites. */ - ret = ssl_tls13_write_supported_groups_ext( ssl, buf, end, &output_len ); + ret = ssl_tls13_write_supported_groups_ext( ssl, p, end, &output_len ); if( ret != 0 ) return( ret ); - buf += output_len; + p += output_len; /* Write key_share extension * @@ -313,32 +313,32 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * 3) Or, in case all ciphers are supported ( which includes #1 and #2 * from above ) */ - ret = ssl_tls13_write_key_shares_ext( ssl, buf, end, &output_len ); + ret = ssl_tls13_write_key_shares_ext( ssl, p, end, &output_len ); if( ret != 0 ) return( ret ); - buf += output_len; + p += output_len; /* Write signature_algorithms extension * * It is REQUIRED for certificate authenticated cipher_suites. */ - ret = mbedtls_ssl_tls13_write_sig_alg_ext( ssl, buf, end, &output_len ); + ret = mbedtls_ssl_tls13_write_sig_alg_ext( ssl, p, end, &output_len ); if( ret != 0 ) return( ret ); - buf += output_len; + p += output_len; #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ /* Add more extensions here */ /* Write the length of the list of extensions. */ - extensions_len = buf - extensions_len_ptr - 2; + extensions_len = p - extensions_len_ptr - 2; MBEDTLS_PUT_UINT16_BE( extensions_len, extensions_len_ptr, 0 ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, total extension length: %" MBEDTLS_PRINTF_SIZET , extensions_len ) ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extensions_len_ptr, extensions_len ); - *olen = buf - start; + *olen = p - buf; return( 0 ); } From 4e388286af740564055f004e99ae133f65b9aece Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 6 Sep 2021 21:28:08 +0800 Subject: [PATCH 460/966] fix usage of iteration Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index fe2e6f850b..b10e33bfbf 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -132,9 +132,9 @@ static int ssl_tls13_write_client_hello_cipher_suites( unsigned char *end, size_t *olen ) { + unsigned char *p = buf; /* Iteration over the cipher_suites list */ const int *ciphersuite_list; unsigned char *cipher_suites_ptr; /* Start of the cipher_suites list */ - unsigned char *p; /* Iteration over the cipher_suites list */ size_t cipher_suites_len; *olen = 0 ; @@ -150,12 +150,11 @@ static int ssl_tls13_write_client_hello_cipher_suites( ciphersuite_list = ssl->conf->ciphersuite_list; /* Check there is space for the cipher suite list length (2 bytes). */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); + p += 2; /* Write cipher_suites */ - cipher_suites_ptr = buf + 2; - p = cipher_suites_ptr; - + cipher_suites_ptr = p; for ( size_t i = 0; ciphersuite_list[i] != 0; i++ ) { int cipher_suite = ciphersuite_list[i]; From fec982eacc184b08d00eaeb118c06918147bcfe7 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 7 Sep 2021 17:26:06 +0800 Subject: [PATCH 461/966] fix coding style issues Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index b10e33bfbf..41c7a4d144 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -31,7 +31,6 @@ #include #define CLIENT_HELLO_RANDOM_LEN 32 -#define CLIENT_HELLO_LEGACY_VERSION_LEN 2 /* Write extensions */ @@ -132,7 +131,7 @@ static int ssl_tls13_write_client_hello_cipher_suites( unsigned char *end, size_t *olen ) { - unsigned char *p = buf; /* Iteration over the cipher_suites list */ + unsigned char *p = buf; const int *ciphersuite_list; unsigned char *cipher_suites_ptr; /* Start of the cipher_suites list */ size_t cipher_suites_len; @@ -229,9 +228,9 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * For TLS 1.3 we use the legacy version number {0x03, 0x03} * instead of the true version number. */ - MBEDTLS_SSL_CHK_BUF_PTR( p, end, CLIENT_HELLO_LEGACY_VERSION_LEN ); + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); MBEDTLS_PUT_UINT16_BE( 0x0303, p, 0 ); - p += CLIENT_HELLO_LEGACY_VERSION_LEN; + p += 2; /* Write the random bytes ( random ).*/ MBEDTLS_SSL_CHK_BUF_PTR( p, end, CLIENT_HELLO_RANDOM_LEN ); From 7533635e5acbc3d28d1da334ebc006a57386feff Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 1 Sep 2021 15:59:36 +0800 Subject: [PATCH 462/966] Change dummy extension return With error return, server can not receive Client Hello message. If received , we can test current status. Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 10 ++++++---- library/ssl_tls13_generic.c | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 41c7a4d144..426568cce8 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -101,8 +101,9 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, ((void) ssl); ((void) buf); ((void) end); - ((void) olen); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + *olen = 0; + MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported groups extension is not available" ) ); + return( 0 ); } static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, @@ -113,8 +114,9 @@ static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, ((void) ssl); ((void) buf); ((void) end); - ((void) olen); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + *olen = 0; + MBEDTLS_SSL_DEBUG_MSG( 3, ( "key share extension is not available" ) ); + return( 0 ); } #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index ca4c167132..1ff23bc012 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -24,9 +24,11 @@ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #include "mbedtls/error.h" +#include "mbedtls/debug.h" #include "ssl_misc.h" + int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, @@ -108,8 +110,9 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, ((void) ssl); ((void) buf); ((void) end); - ((void) olen); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + *olen = 0; + MBEDTLS_SSL_DEBUG_MSG( 3, ( "signature_algorithm extension is not available" ) ); + return( 0 ); } #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ From 26f4d15d13ea4587da32229dec3551ec1cd76a4c Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 23 Aug 2021 17:42:37 +0800 Subject: [PATCH 463/966] Add key exchange modes helper functions Add helper functions for `tls13_kex_modes` Signed-off-by: Jerry Yu --- library/ssl_misc.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 7035c278cf..9cd1b35728 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1348,6 +1348,49 @@ void mbedtls_ssl_buffering_free( mbedtls_ssl_context *ssl ); void mbedtls_ssl_flight_free( mbedtls_ssl_flight_item *flight ); #endif /* MBEDTLS_SSL_PROTO_DTLS */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +/* + * Helper functions around key exchange modes. + */ +static inline unsigned mbedtls_ssl_conf_tls13_kex_modes_check( mbedtls_ssl_context *ssl, + int kex_mode_mask ) +{ + return( ( ssl->conf->tls13_kex_modes & kex_mode_mask ) != 0 ); +} + +static inline int mbedtls_ssl_conf_tls13_pure_psk_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ) ); +} + +static inline int mbedtls_ssl_conf_tls13_psk_ephemeral_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) ); +} + +static inline int mbedtls_ssl_conf_tls13_pure_ephemeral_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) ); +} + +static inline int mbedtls_ssl_conf_tls13_some_ephemeral_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL ) ); +} + +static inline int mbedtls_ssl_conf_tls13_some_psk_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); +} + +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /** * ssl utils functions for checking configuration. */ From e226cef124aa7bd79880bc0e5bda9c1fb14a13c6 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 27 Aug 2021 22:06:20 +0800 Subject: [PATCH 464/966] Add NamedGroup IANA values and helper functions Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 31 +++++++++++++++++++++++++++++++ library/ssl_misc.h | 18 ++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index f533859959..725b156d5d 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -169,6 +169,37 @@ /** Invalid value in SSL config */ #define MBEDTLS_ERR_SSL_BAD_CONFIG -0x5E80 +/* + * TLS 1.3 NamedGroup values + * + * From RF 8446 + * enum { + * // Elliptic Curve Groups (ECDHE) + * secp256r1(0x0017), secp384r1(0x0018), secp521r1(0x0019), + * x25519(0x001D), x448(0x001E), + * // Finite Field Groups (DHE) + * ffdhe2048(0x0100), ffdhe3072(0x0101), ffdhe4096(0x0102), + * ffdhe6144(0x0103), ffdhe8192(0x0104), + * // Reserved Code Points + * ffdhe_private_use(0x01FC..0x01FF), + * ecdhe_private_use(0xFE00..0xFEFF), + * (0xFFFF) + * } NamedGroup; + * + */ +/* Elliptic Curve Groups (ECDHE) */ +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP256R1 0x0017 +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP384R1 0x0018 +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP521R1 0x0019 +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_X25519 0x001D +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_X448 0x001E +/* Finite Field Groups (DHE) */ +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE2048 0x0100 +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE3072 0x0101 +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE4096 0x0102 +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE6144 0x0103 +#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE8192 0x0104 + /* * TLS 1.3 Key Exchange Modes * diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 9cd1b35728..d9c82960f4 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1439,6 +1439,24 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +/* + * Helper functions for NamedGroup. + */ +static inline int mbedtls_ssl_named_group_is_ecdhe( uint16_t named_group ) +{ + return( named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP256R1 || + named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP384R1 || + named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP521R1 || + named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_X25519 || + named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_X448 ); +} + +static inline int mbedtls_ssl_named_group_is_dhe( uint16_t named_group ) +{ + return( named_group >= MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE2048 && + named_group <= MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE8192 ); +} + static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl, mbedtls_ssl_states state ) { From 6b64fe31ce63b2a49effc2f7342905d14d316c0c Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 1 Sep 2021 17:05:13 +0800 Subject: [PATCH 465/966] add supported groups extension Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 163 +++++++++++++++++++++++++++++++++++-- 1 file changed, 157 insertions(+), 6 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 426568cce8..df2f9eb7dc 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -93,17 +93,168 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) -static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +/* + * Functions for writing supported_groups extension. + * + * Stucture of supported_groups: + * enum { + * secp256r1(0x0017), secp384r1(0x0018), secp521r1(0x0019), + * x25519(0x001D), x448(0x001E), + * ffdhe2048(0x0100), ffdhe3072(0x0101), ffdhe4096(0x0102), + * ffdhe6144(0x0103), ffdhe8192(0x0104), + * ffdhe_private_use(0x01FC..0x01FF), + * ecdhe_private_use(0xFE00..0xFEFF), + * (0xFFFF) + * } NamedGroup; + * struct { + * NamedGroup named_group_list<2..2^16-1>; + * } NamedGroupList; + */ +/* Find out available ecdhe named groups in current configuration */ +#if defined(MBEDTLS_ECDH_C) +/* + * In versions of TLS prior to TLS 1.3, this extension was named + * 'elliptic_curves' and only contained elliptic curve groups. + */ +static int ssl_tls13_write_named_group_ecdhe( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) +{ + unsigned char *p = buf; +#if !defined(MBEDTLS_ECP_C) + ((void) ssl); +#endif + + *olen = 0; + +#if defined(MBEDTLS_ECP_C) + for ( const mbedtls_ecp_group_id *grp_id = ssl->conf->curve_list; + *grp_id != MBEDTLS_ECP_DP_NONE; + grp_id++ ) + { + const mbedtls_ecp_curve_info *info; + info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); + if( info == NULL ) + continue; +#else + for ( const mbedtls_ecp_curve_info *info = mbedtls_ecp_curve_list(); + info->grp_id != MBEDTLS_ECP_DP_NONE; + info++ ) + { +#endif + if( !mbedtls_ssl_named_group_is_ecdhe( info->tls_id ) ) + continue; + + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2); + MBEDTLS_PUT_UINT16_BE( info->tls_id, p, 0 ); + p += 2; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "NamedGroup: %s ( %x )", + mbedtls_ecp_curve_info_from_tls_id( info->tls_id )->name, + info->tls_id ) ); + } + + *olen = p - buf; + + return( 0 ); +} +#else +static int ssl_tls13_write_named_group_ecdhe( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); ((void) end); *olen = 0; - MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported groups extension is not available" ) ); - return( 0 ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} +#endif /* MBEDTLS_ECDH_C */ + +/* Find out available dhe named groups in current configuration */ +static int ssl_tls13_write_named_group_dhe( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) +{ + ((void) ssl); + ((void) buf); + ((void) end); + *olen = 0; + MBEDTLS_SSL_DEBUG_MSG( 3, ( "write_named_group_dhe is not implemented" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + +/* + * Supported Groups Extension (supported_groups) + */ +static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) +{ + unsigned char *p = buf ; + unsigned char *named_group_ptr; /* Start of named_group_list */ + size_t named_group_len = 0; + int ret = 0, ret_ecdhe, ret_dhe; + + *olen = 0; + + if( !mbedtls_ssl_conf_tls13_some_ephemeral_enabled( ssl ) ) + return( 0 ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported_groups extension" ) ); + + /* Check there is space for extension header */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); + p += 6; + + named_group_ptr = p; + ret_ecdhe = ssl_tls13_write_named_group_ecdhe( ssl, p, end, &named_group_len ); + if( ret_ecdhe != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_tls13_write_named_group_ecdhe", ret ); + } + p += named_group_len; + + ret_dhe = ssl_tls13_write_named_group_dhe( ssl, p, end, &named_group_len ); + if( ret_dhe != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_tls13_write_named_group_dhe", ret ); + } + p += named_group_len; + + /* Both ECDHE and DHE Fail. */ + if( ret_ecdhe != 0 && ret_dhe != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Both ECDHE and DHE groups are fail. " ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* Length of named_group_list*/ + named_group_len = p - named_group_ptr; + if( named_group_len == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "No Named Group Available." ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* Write extension_type */ + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_GROUPS, buf, 0 ); + /* Write extension_data_length */ + MBEDTLS_PUT_UINT16_BE( named_group_len + 2, buf, 2 ); + /* Write length of named_group_list */ + MBEDTLS_PUT_UINT16_BE( named_group_len, buf, 4 ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "Supported groups extension", buf + 4, named_group_len + 2 ); + + *olen = p - buf; + + ssl->handshake->extensions_present |= MBEDTLS_SSL_EXT_SUPPORTED_GROUPS; + + return( ret ); } static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, From 7236994aa9b57c7675fee71512581a19293c5dcb Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 31 Aug 2021 15:41:21 +0800 Subject: [PATCH 466/966] add signature algorithms extension Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 57 ++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 1ff23bc012..79ecfff3ea 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -107,11 +107,60 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *end, size_t *olen ) { - ((void) ssl); - ((void) buf); - ((void) end); + unsigned char *p = buf; + unsigned char *sig_alg_ptr; /* Start of supported_signature_algorithms */ + size_t sig_alg_len = 0; /* Length of supported_signature_algorithms */ + *olen = 0; - MBEDTLS_SSL_DEBUG_MSG( 3, ( "signature_algorithm extension is not available" ) ); + + /* Skip the extension on the client if all allowed key exchanges + * are PSK-based. */ +#if defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT && + !mbedtls_ssl_conf_tls13_some_ephemeral_enabled( ssl ) ) + { + return( 0 ); + } +#endif /* MBEDTLS_SSL_CLI_C */ + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "adding signature_algorithms extension" ) ); + + /* Check there is space for extension header */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); + p += 6; + + /* + * Write supported_signature_algorithms + */ + sig_alg_ptr = p; + for( const uint16_t *sig_alg = ssl->conf->tls13_sig_algs; + *sig_alg != MBEDTLS_TLS13_SIG_NONE; sig_alg++ ) + { + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); + MBEDTLS_PUT_UINT16_BE( *sig_alg, p, 0 ); + p += 2; + MBEDTLS_SSL_DEBUG_MSG( 3, ( "signature scheme [%x]", *sig_alg ) ); + } + + /* Length of supported_signature_algorithms*/ + sig_alg_len = p - sig_alg_ptr; + if( sig_alg_len == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "No signature algorithms defined." ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + /* Write extension_type */ + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SIG_ALG, buf, 0 ); + /* Write extension_data_length */ + MBEDTLS_PUT_UINT16_BE( sig_alg_len + 2, buf, 2 ); + /* Write length of supported_signature_algorithms */ + MBEDTLS_PUT_UINT16_BE( sig_alg_len, buf, 4 ); + + /* Output the total length of signature algorithms extension. */ + *olen = p - buf; + + ssl->handshake->extensions_present |= MBEDTLS_SSL_EXT_SIG_ALG; return( 0 ); } From 56fc07f7aee15d27e3465481838cf6b060f75dd7 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 1 Sep 2021 17:48:49 +0800 Subject: [PATCH 467/966] add key_share extension Signed-off-by: Jerry Yu --- library/ecdh.c | 85 +++++++++++++++ library/ssl_misc.h | 20 ++++ library/ssl_tls13_client.c | 217 ++++++++++++++++++++++++++++++++++--- 3 files changed, 308 insertions(+), 14 deletions(-) diff --git a/library/ecdh.c b/library/ecdh.c index 9dfa868063..ac60165443 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -31,6 +31,7 @@ #include "mbedtls/ecdh.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" +#include "ssl_misc.h" #include @@ -726,4 +727,88 @@ int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, #endif } +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +static int ecdh_tls13_make_params_internal( mbedtls_ecdh_context_mbed *ctx, + size_t *olen, int point_format, + unsigned char *buf, size_t blen, + int ( *f_rng )( void *, + unsigned char *, + size_t), + void *p_rng, int restart_enabled ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; +#if defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_ecp_restart_ctx *rs_ctx = NULL; +#endif + + if( ctx->grp.pbits == 0 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( restart_enabled ) + rs_ctx = &ctx->rs; +#else + (void) restart_enabled; +#endif + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ( ret = ecdh_gen_public_restartable( &ctx->grp, &ctx->d, &ctx->Q, + f_rng, p_rng, rs_ctx ) ) != 0 ) + return( ret ); +#else + if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, + f_rng, p_rng ) ) != 0 ) + return( ret ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ + + ret = mbedtls_ecp_point_write_binary( &ctx->grp, &ctx->Q, point_format, + olen, buf, blen ); + if( ret != 0 ) + return( ret ); + + return( 0 ); +} + +int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int ( *f_rng )( void *, unsigned char *, size_t ), + void *p_rng ) +{ + int restart_enabled = 0; + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( olen != NULL ); + ECDH_VALIDATE_RET( buf != NULL ); + ECDH_VALIDATE_RET( f_rng != NULL ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + restart_enabled = ctx->restart_enabled; +#else + (void) restart_enabled; +#endif + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_tls13_make_params_internal( ctx, olen, ctx->point_format, buf, blen, + f_rng, p_rng, restart_enabled ) ); +#else + switch( ctx->var ) + { +#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) + case MBEDTLS_ECDH_VARIANT_EVEREST: + return( mbedtls_everest_make_params( &ctx->ctx.everest_ecdh, olen, + buf, blen, f_rng, p_rng ) ); +#endif + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_tls13_make_params_internal( &ctx->ctx.mbed_ecdh, olen, + ctx->point_format, buf, blen, + f_rng, p_rng, + restart_enabled ) ); + default: + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } +#endif +} + +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #endif /* MBEDTLS_ECDH_C */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index d9c82960f4..f8f5fe6c93 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -649,6 +649,16 @@ struct mbedtls_ssl_handshake_params void (*calc_finished)(mbedtls_ssl_context *, unsigned char *, int); mbedtls_ssl_tls_prf_cb *tls_prf; +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + uint16_t offered_group_id; /* The NamedGroup value for the group + * that is being used for ephemeral + * key exchange. + * + * On the client: Defaults to the first + * entry in the client's group list, + * but can be overwritten by the HRR. */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + mbedtls_ssl_ciphersuite_t const *ciphersuite_info; size_t pmslen; /*!< premaster length */ @@ -1491,6 +1501,16 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen); +#if defined(MBEDTLS_ECDH_C) +/* + * TLS 1.3 version of mbedtls_ecdh_make_params in ecdh.h + */ +int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int ( *f_rng )( void *, unsigned char *, size_t ), + void *p_rng ); +#endif /* MBEDTLS_ECDH_C */ + #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index df2f9eb7dc..8323b67782 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -28,7 +28,8 @@ #include #include "ssl_misc.h" -#include +#include "mbedtls/debug.h" +#include "mbedtls/error.h" #define CLIENT_HELLO_RANDOM_LEN 32 @@ -257,24 +258,212 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, return( ret ); } -static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +/* + * Functions for writing key_share extension. + */ +#if defined(MBEDTLS_ECDH_C) +static int ssl_key_share_gen_and_write_ecdhe( mbedtls_ssl_context *ssl, + uint16_t named_group, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { - ((void) ssl); - ((void) buf); - ((void) end); - *olen = 0; - MBEDTLS_SSL_DEBUG_MSG( 3, ( "key share extension is not available" ) ); + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + const mbedtls_ecp_curve_info *curve_info = + mbedtls_ecp_curve_info_from_tls_id( named_group ); + + if( curve_info == NULL ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "offer curve %s", curve_info->name ) ); + + if( ( ret = mbedtls_ecdh_setup( &ssl->handshake->ecdh_ctx, + curve_info->grp_id ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecp_group_load", ret ); + return( ret ); + } + + ret = mbedtls_ecdh_tls13_make_params( &ssl->handshake->ecdh_ctx, olen, + buf, end - buf, + ssl->conf->f_rng, ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_tls13_make_params", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_Q ); return( 0 ); } +#endif /* MBEDTLS_ECDH_C */ + +static int ssl_named_group_get_default_id( mbedtls_ssl_context *ssl, + uint16_t *named_group_id ) +{ + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + + /* Pick first entry of curve list. + * + * TODO: When we introduce PQC KEMs, we'll have a NamedGroup + * list instead, and can just return its first element. + */ + + /* Check if ecdhe named groups are available and pick first entry */ +#if defined(MBEDTLS_ECDH_C) +#if !defined(MBEDTLS_ECP_C) + ((void) ssl); +#endif +#if defined(MBEDTLS_ECP_C) + for ( const mbedtls_ecp_group_id * grp_id = ssl->conf->curve_list; + *grp_id != MBEDTLS_ECP_DP_NONE; + grp_id++ ) + { + const mbedtls_ecp_curve_info *info; + info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); +#else + for ( const mbedtls_ecp_curve_info *info = mbedtls_ecp_curve_list(); + info->grp_id != MBEDTLS_ECP_DP_NONE; + info++ ) + { +#endif + if( info != NULL && mbedtls_ssl_named_group_is_ecdhe( info->tls_id ) ) + { + *named_group_id = info->tls_id; + return( 0 ); + } + } +#else + ((void) ssl); + ((void) named_group_id); +#endif /* MBEDTLS_ECDH_C */ + + /* + * Add DHE named groups here. + * Check if ecdhe named groups are available and pick first entry + */ + + return( ret ); +} + +/* + * ssl_tls13_write_key_share_ext + * + * Structure of key_share extension in ClientHelo: + * + * struct { + * NamedGroup group; + * opaque key_exchange<1..2^16-1>; + * } KeyShareEntry; + * struct { + * KeyShareEntry client_shares<0..2^16-1>; + * } KeyShareClientHello; + */ +static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) +{ + unsigned char *p = buf; + unsigned char *client_shares_ptr; /* Start of client_shares */ + uint16_t group_id; + + int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + + *olen = 0; + + if( !mbedtls_ssl_conf_tls13_some_ephemeral_enabled( ssl ) ) + return( 0 ); + + /* Check if we have space for headers and length fields: + * - extension_type (2 bytes) + * - extension_data_length (2 bytes) + * - client_shares_length (2 bytes) + */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); + p += 6; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello: adding key share extension" ) ); + + /* HRR could already have requested something else. */ + group_id = ssl->handshake->offered_group_id; + if( !mbedtls_ssl_named_group_is_ecdhe( group_id ) && + !mbedtls_ssl_named_group_is_dhe( group_id ) ) + { + MBEDTLS_SSL_PROC_CHK( ssl_named_group_get_default_id( ssl, + &group_id ) ); + } + + /* + * Dispatch to type-specific key generation function. + * + * So far, we're only supporting ECDHE. With the introduction + * of PQC KEMs, we'll want to have multiple branches, one per + * type of KEM, and dispatch to the corresponding crypto. And + * only one key share entry is allowed. + */ + client_shares_ptr = p; +#if defined(MBEDTLS_ECDH_C) + if( mbedtls_ssl_named_group_is_ecdhe( group_id ) ) + { + /* Pointer of group */ + unsigned char *group_id_ptr = p; + /* Length of key_exchange */ + size_t key_exchange_len; + + /* Check there is space for header of KeyShareEntry + * - group (2 bytes) + * - key_exchange_length (2 bytes) + */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); + p += 4; + ret = ssl_key_share_gen_and_write_ecdhe( ssl, group_id, + p, end, + &key_exchange_len ); + p += key_exchange_len; + if( ret != 0 ) + return( ret ); + + /* Write group */ + MBEDTLS_PUT_UINT16_BE( group_id, group_id_ptr, 0 ); + /* Write key_exchange_length */ + MBEDTLS_PUT_UINT16_BE( key_exchange_len, group_id_ptr, 2 ); + } + else +#endif /* MBEDTLS_ECDH_C */ + if( 0 /* other KEMs? */ ) + { + /* Do something */ + } + else + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + /* Write extension_type */ + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_KEY_SHARE, buf, 0 ); + /* Write extension_data_length */ + MBEDTLS_PUT_UINT16_BE( p - client_shares_ptr + 2, buf, 2 ); + /* Write client_shares_length */ + MBEDTLS_PUT_UINT16_BE( p - client_shares_ptr, buf, 4 ); + + /* Update offered_group_id field */ + ssl->handshake->offered_group_id = group_id; + + /* Output the total length of key_share extension. */ + *olen = p - buf; + + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, key_share extension", buf, *olen ); + + ssl->handshake->extensions_present |= MBEDTLS_SSL_EXT_KEY_SHARE; + +cleanup: + + return( ret ); +} #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ -/* - * Functions for writing ClientHello message. - */ /* Write cipher_suites * CipherSuite cipher_suites<2..2^16-2>; */ @@ -464,7 +653,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, * 3) Or, in case all ciphers are supported ( which includes #1 and #2 * from above ) */ - ret = ssl_tls13_write_key_shares_ext( ssl, p, end, &output_len ); + ret = ssl_tls13_write_key_share_ext( ssl, p, end, &output_len ); if( ret != 0 ) return( ret ); p += output_len; From ed2ef2d9e084a024eb999834540f2d8749216f18 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 19 Aug 2021 18:11:43 +0800 Subject: [PATCH 468/966] add client hello msg test Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 3e199e2881..9170136038 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1322,6 +1322,11 @@ if [ -n "${OPENSSL_LEGACY:-}" ]; then O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT" fi +if [ -n "${OPENSSL_NEXT:-}" ]; then + O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT" + O_NEXT_CLI="$O_NEXT_CLI -connect localhost:+SRV_PORT" +fi + if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT" fi @@ -8661,6 +8666,15 @@ run_test "TLS1.3: handshake dispatch test: tls1_3 only" \ -s "SSL - The requested feature is not available" \ -c "SSL - The requested feature is not available" +requires_openssl_tls1_3 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +run_test "TLS1.3: Test client hello msg work" \ + "$O_NEXT_SRV -tls1_3 -msg" \ + "$P_CLI min_version=tls1_3 max_version=tls1_3" \ + 1 \ + -c "SSL - The requested feature is not available" \ + -s "ServerHello" + # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C From b60e3cf4242825740d485ad46a0cac53c6c7ab18 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 8 Sep 2021 16:41:02 +0800 Subject: [PATCH 469/966] fix various issues - format problems - name conversion issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 20 +++--- library/ssl_tls13_client.c | 132 +++++++++++++++++++----------------- library/ssl_tls13_generic.c | 24 ++++--- 3 files changed, 91 insertions(+), 85 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index f8f5fe6c93..fb843848bf 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1363,39 +1363,39 @@ void mbedtls_ssl_flight_free( mbedtls_ssl_flight_item *flight ); /* * Helper functions around key exchange modes. */ -static inline unsigned mbedtls_ssl_conf_tls13_kex_modes_check( mbedtls_ssl_context *ssl, +static inline unsigned mbedtls_ssl_conf_tls13_check_kex_modes( mbedtls_ssl_context *ssl, int kex_mode_mask ) { return( ( ssl->conf->tls13_kex_modes & kex_mode_mask ) != 0 ); } -static inline int mbedtls_ssl_conf_tls13_pure_psk_enabled( mbedtls_ssl_context *ssl ) +static inline int mbedtls_ssl_conf_tls13_psk_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + return( mbedtls_ssl_conf_tls13_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ) ); } static inline int mbedtls_ssl_conf_tls13_psk_ephemeral_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + return( mbedtls_ssl_conf_tls13_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) ); } -static inline int mbedtls_ssl_conf_tls13_pure_ephemeral_enabled( mbedtls_ssl_context *ssl ) +static inline int mbedtls_ssl_conf_tls13_ephemeral_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + return( mbedtls_ssl_conf_tls13_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) ); } static inline int mbedtls_ssl_conf_tls13_some_ephemeral_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + return( mbedtls_ssl_conf_tls13_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL ) ); } static inline int mbedtls_ssl_conf_tls13_some_psk_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_conf_tls13_kex_modes_check( ssl, + return( mbedtls_ssl_conf_tls13_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); } @@ -1452,7 +1452,7 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf /* * Helper functions for NamedGroup. */ -static inline int mbedtls_ssl_named_group_is_ecdhe( uint16_t named_group ) +static inline int mbedtls_ssl_tls13_named_group_is_ecdhe( uint16_t named_group ) { return( named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP256R1 || named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP384R1 || @@ -1461,7 +1461,7 @@ static inline int mbedtls_ssl_named_group_is_ecdhe( uint16_t named_group ) named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_X448 ); } -static inline int mbedtls_ssl_named_group_is_dhe( uint16_t named_group ) +static inline int mbedtls_ssl_tls13_named_group_is_dhe( uint16_t named_group ) { return( named_group >= MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE2048 && named_group <= MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE8192 ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 8323b67782..d3eab84490 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -53,13 +53,11 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported versions extension" ) ); - /* - * Check space for extension header. - * - * extension_type 2 - * extension_data_length 2 - * version_length 1 - * versions 2 + /* Check if we have space for header and length fields: + * - extension_type (2 bytes) + * - extension_data_length (2 bytes) + * - versions_length (1 byte ) + * - versions (2 bytes) */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); @@ -111,16 +109,15 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, * NamedGroup named_group_list<2..2^16-1>; * } NamedGroupList; */ -/* Find out available ecdhe named groups in current configuration */ #if defined(MBEDTLS_ECDH_C) /* * In versions of TLS prior to TLS 1.3, this extension was named * 'elliptic_curves' and only contained elliptic curve groups. */ -static int ssl_tls13_write_named_group_ecdhe( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +static int ssl_tls13_write_named_group_list_ecdhe( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { unsigned char *p = buf; #if !defined(MBEDTLS_ECP_C) @@ -144,7 +141,7 @@ static int ssl_tls13_write_named_group_ecdhe( mbedtls_ssl_context *ssl, info++ ) { #endif - if( !mbedtls_ssl_named_group_is_ecdhe( info->tls_id ) ) + if( !mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) continue; MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2); @@ -161,10 +158,10 @@ static int ssl_tls13_write_named_group_ecdhe( mbedtls_ssl_context *ssl, return( 0 ); } #else -static int ssl_tls13_write_named_group_ecdhe( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +static int ssl_tls13_write_named_group_list_ecdhe( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); @@ -174,11 +171,10 @@ static int ssl_tls13_write_named_group_ecdhe( mbedtls_ssl_context *ssl, } #endif /* MBEDTLS_ECDH_C */ -/* Find out available dhe named groups in current configuration */ -static int ssl_tls13_write_named_group_dhe( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +static int ssl_tls13_write_named_group_list_dhe( mbedtls_ssl_context *ssl, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { ((void) ssl); ((void) buf); @@ -188,18 +184,15 @@ static int ssl_tls13_write_named_group_dhe( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); } -/* - * Supported Groups Extension (supported_groups) - */ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ) { unsigned char *p = buf ; - unsigned char *named_group_ptr; /* Start of named_group_list */ - size_t named_group_len = 0; - int ret = 0, ret_ecdhe, ret_dhe; + unsigned char *name_group_list_ptr; /* Start of named_group_list */ + size_t output_len = 0; + int ret_ecdhe, ret_dhe; *olen = 0; @@ -208,24 +201,28 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported_groups extension" ) ); - /* Check there is space for extension header */ + /* Check if we have space for header and length fields: + * - extension_type (2 bytes) + * - extension_data_length (2 bytes) + * - named_group_list_length (2 bytes) + */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); p += 6; - named_group_ptr = p; - ret_ecdhe = ssl_tls13_write_named_group_ecdhe( ssl, p, end, &named_group_len ); + name_group_list_ptr = p; + ret_ecdhe = ssl_tls13_write_named_group_list_ecdhe( ssl, p, end, &output_len ); if( ret_ecdhe != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "ssl_tls13_write_named_group_ecdhe", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_tls13_write_named_group_list_ecdhe", ret_ecdhe ); } - p += named_group_len; + p += output_len; - ret_dhe = ssl_tls13_write_named_group_dhe( ssl, p, end, &named_group_len ); + ret_dhe = ssl_tls13_write_named_group_list_dhe( ssl, p, end, &output_len ); if( ret_dhe != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "ssl_tls13_write_named_group_dhe", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_tls13_write_named_group_list_dhe", ret_dhe ); } - p += named_group_len; + p += output_len; /* Both ECDHE and DHE Fail. */ if( ret_ecdhe != 0 && ret_dhe != 0 ) @@ -235,8 +232,8 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, } /* Length of named_group_list*/ - named_group_len = p - named_group_ptr; - if( named_group_len == 0 ) + size_t named_group_list_len = p - name_group_list_ptr; + if( named_group_list_len == 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "No Named Group Available." ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); @@ -245,31 +242,31 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, /* Write extension_type */ MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_GROUPS, buf, 0 ); /* Write extension_data_length */ - MBEDTLS_PUT_UINT16_BE( named_group_len + 2, buf, 2 ); + MBEDTLS_PUT_UINT16_BE( named_group_list_len + 2, buf, 2 ); /* Write length of named_group_list */ - MBEDTLS_PUT_UINT16_BE( named_group_len, buf, 4 ); + MBEDTLS_PUT_UINT16_BE( named_group_list_len, buf, 4 ); - MBEDTLS_SSL_DEBUG_BUF( 3, "Supported groups extension", buf + 4, named_group_len + 2 ); + MBEDTLS_SSL_DEBUG_BUF( 3, "Supported groups extension", buf + 4, named_group_list_len + 2 ); *olen = p - buf; ssl->handshake->extensions_present |= MBEDTLS_SSL_EXT_SUPPORTED_GROUPS; - return( ret ); + return( 0 ); } /* * Functions for writing key_share extension. */ #if defined(MBEDTLS_ECDH_C) -static int ssl_key_share_gen_and_write_ecdhe( mbedtls_ssl_context *ssl, - uint16_t named_group, - unsigned char *buf, - unsigned char *end, - size_t *olen ) +static int ssl_tls13_generate_and_write_ecdh_key_exchange( + mbedtls_ssl_context *ssl, + uint16_t named_group, + unsigned char *buf, + unsigned char *end, + size_t *olen ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - const mbedtls_ecp_curve_info *curve_info = mbedtls_ecp_curve_info_from_tls_id( named_group ); @@ -300,8 +297,8 @@ static int ssl_key_share_gen_and_write_ecdhe( mbedtls_ssl_context *ssl, } #endif /* MBEDTLS_ECDH_C */ -static int ssl_named_group_get_default_id( mbedtls_ssl_context *ssl, - uint16_t *named_group_id ) +static int ssl_tls13_get_default_group_id( mbedtls_ssl_context *ssl, + uint16_t *group_id ) { int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; @@ -329,15 +326,15 @@ static int ssl_named_group_get_default_id( mbedtls_ssl_context *ssl, info++ ) { #endif - if( info != NULL && mbedtls_ssl_named_group_is_ecdhe( info->tls_id ) ) + if( info != NULL && mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) { - *named_group_id = info->tls_id; + *group_id = info->tls_id; return( 0 ); } } #else ((void) ssl); - ((void) named_group_id); + ((void) group_id); #endif /* MBEDTLS_ECDH_C */ /* @@ -368,8 +365,8 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, { unsigned char *p = buf; unsigned char *client_shares_ptr; /* Start of client_shares */ + size_t client_shares_len; /* Length of client_shares */ uint16_t group_id; - int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; *olen = 0; @@ -377,7 +374,7 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, if( !mbedtls_ssl_conf_tls13_some_ephemeral_enabled( ssl ) ) return( 0 ); - /* Check if we have space for headers and length fields: + /* Check if we have space for header and length fields: * - extension_type (2 bytes) * - extension_data_length (2 bytes) * - client_shares_length (2 bytes) @@ -389,10 +386,10 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, /* HRR could already have requested something else. */ group_id = ssl->handshake->offered_group_id; - if( !mbedtls_ssl_named_group_is_ecdhe( group_id ) && - !mbedtls_ssl_named_group_is_dhe( group_id ) ) + if( !mbedtls_ssl_tls13_named_group_is_ecdhe( group_id ) && + !mbedtls_ssl_tls13_named_group_is_dhe( group_id ) ) { - MBEDTLS_SSL_PROC_CHK( ssl_named_group_get_default_id( ssl, + MBEDTLS_SSL_PROC_CHK( ssl_tls13_get_default_group_id( ssl, &group_id ) ); } @@ -406,7 +403,7 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, */ client_shares_ptr = p; #if defined(MBEDTLS_ECDH_C) - if( mbedtls_ssl_named_group_is_ecdhe( group_id ) ) + if( mbedtls_ssl_tls13_named_group_is_ecdhe( group_id ) ) { /* Pointer of group */ unsigned char *group_id_ptr = p; @@ -419,9 +416,9 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 4 ); p += 4; - ret = ssl_key_share_gen_and_write_ecdhe( ssl, group_id, - p, end, - &key_exchange_len ); + ret = ssl_tls13_generate_and_write_ecdh_key_exchange( ssl, group_id, + p, end, + &key_exchange_len ); p += key_exchange_len; if( ret != 0 ) return( ret ); @@ -440,12 +437,19 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, else return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + /* Length of client_shares */ + client_shares_len = p - client_shares_ptr; + if( client_shares_len == 0) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "No key share defined." ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } /* Write extension_type */ MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_KEY_SHARE, buf, 0 ); /* Write extension_data_length */ - MBEDTLS_PUT_UINT16_BE( p - client_shares_ptr + 2, buf, 2 ); + MBEDTLS_PUT_UINT16_BE( client_shares_len + 2, buf, 2 ); /* Write client_shares_length */ - MBEDTLS_PUT_UINT16_BE( p - client_shares_ptr, buf, 4 ); + MBEDTLS_PUT_UINT16_BE( client_shares_len, buf, 4 ); /* Update offered_group_id field */ ssl->handshake->offered_group_id = group_id; diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 79ecfff3ea..5c20f29283 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -28,7 +28,6 @@ #include "ssl_misc.h" - int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, @@ -101,15 +100,14 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, * * Only if we handle at least one key exchange that needs signatures. */ - int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen ) { unsigned char *p = buf; - unsigned char *sig_alg_ptr; /* Start of supported_signature_algorithms */ - size_t sig_alg_len = 0; /* Length of supported_signature_algorithms */ + unsigned char *supported_sig_alg_ptr; /* Start of supported_signature_algorithms */ + size_t supported_sig_alg_len = 0; /* Length of supported_signature_algorithms */ *olen = 0; @@ -125,14 +123,18 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "adding signature_algorithms extension" ) ); - /* Check there is space for extension header */ + /* Check if we have space for header and length field: + * - extension_type (2 bytes) + * - extension_data_length (2 bytes) + * - supported_signature_algorithms_length (2 bytes) + */ MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); p += 6; /* * Write supported_signature_algorithms */ - sig_alg_ptr = p; + supported_sig_alg_ptr = p; for( const uint16_t *sig_alg = ssl->conf->tls13_sig_algs; *sig_alg != MBEDTLS_TLS13_SIG_NONE; sig_alg++ ) { @@ -142,9 +144,9 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "signature scheme [%x]", *sig_alg ) ); } - /* Length of supported_signature_algorithms*/ - sig_alg_len = p - sig_alg_ptr; - if( sig_alg_len == 0 ) + /* Length of supported_signature_algorithms */ + supported_sig_alg_len = p - supported_sig_alg_ptr; + if( supported_sig_alg_len == 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "No signature algorithms defined." ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); @@ -153,9 +155,9 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, /* Write extension_type */ MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SIG_ALG, buf, 0 ); /* Write extension_data_length */ - MBEDTLS_PUT_UINT16_BE( sig_alg_len + 2, buf, 2 ); + MBEDTLS_PUT_UINT16_BE( supported_sig_alg_len + 2, buf, 2 ); /* Write length of supported_signature_algorithms */ - MBEDTLS_PUT_UINT16_BE( sig_alg_len, buf, 4 ); + MBEDTLS_PUT_UINT16_BE( supported_sig_alg_len, buf, 4 ); /* Output the total length of signature algorithms extension. */ *olen = p - buf; From 7c522d4941b198e44a3d311f9e3766fcfb716ca1 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 8 Sep 2021 17:55:09 +0800 Subject: [PATCH 470/966] Remove ecp_c undefine routines Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index d3eab84490..1b55abab6d 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -120,13 +120,12 @@ static int ssl_tls13_write_named_group_list_ecdhe( mbedtls_ssl_context *ssl, size_t *olen ) { unsigned char *p = buf; -#if !defined(MBEDTLS_ECP_C) - ((void) ssl); -#endif *olen = 0; -#if defined(MBEDTLS_ECP_C) + if( ssl->conf->curve_list == NULL ) + return( MBEDTLS_ERR_SSL_BAD_CONFIG ); + for ( const mbedtls_ecp_group_id *grp_id = ssl->conf->curve_list; *grp_id != MBEDTLS_ECP_DP_NONE; grp_id++ ) @@ -135,12 +134,7 @@ static int ssl_tls13_write_named_group_list_ecdhe( mbedtls_ssl_context *ssl, info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); if( info == NULL ) continue; -#else - for ( const mbedtls_ecp_curve_info *info = mbedtls_ecp_curve_list(); - info->grp_id != MBEDTLS_ECP_DP_NONE; - info++ ) - { -#endif + if( !mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) continue; @@ -259,7 +253,7 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, * Functions for writing key_share extension. */ #if defined(MBEDTLS_ECDH_C) -static int ssl_tls13_generate_and_write_ecdh_key_exchange( +static int ssl_tls13_generate_and_write_ecdh_key_exchange( mbedtls_ssl_context *ssl, uint16_t named_group, unsigned char *buf, @@ -443,7 +437,7 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, { MBEDTLS_SSL_DEBUG_MSG( 1, ( "No key share defined." ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); - } + } /* Write extension_type */ MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_KEY_SHARE, buf, 0 ); /* Write extension_data_length */ From ddae0f5642c1a63e3d648f1176e66aa06a854749 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 24 Aug 2021 15:39:44 +0200 Subject: [PATCH 471/966] Clarify psa_get_and_lock_transparent_key_slot_with_policy() purpose Clarify the purpose of psa_get_and_lock_transparent_key_slot_with_policy() and define it even when MBEDTLS_PSA_CRYPTO_SE_C is disabled for the purpose of static drivers. Signed-off-by: Ronald Cron --- library/psa_crypto.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 4670a06e2d..d88836b0a0 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -944,16 +944,16 @@ error: /** Get a key slot containing a transparent key and lock it. * * A transparent key is a key for which the key material is directly - * available, as opposed to a key in a secure element. + * available, as opposed to a key in a secure element and/or to be used + * by a secure element. * - * This is a temporary function to use instead of - * psa_get_and_lock_key_slot_with_policy() until secure element support is - * fully implemented. + * This is a temporary function that may be used instead of + * psa_get_and_lock_key_slot_with_policy() when there is no opaque key support + * for a cryptographic operation. * * On success, the returned key slot is locked. It is the responsibility of the * caller to unlock the key slot when it does not access it anymore. */ -#if defined(MBEDTLS_PSA_CRYPTO_SE_C) static psa_status_t psa_get_and_lock_transparent_key_slot_with_policy( mbedtls_svc_key_id_t key, psa_key_slot_t **p_slot, @@ -965,7 +965,7 @@ static psa_status_t psa_get_and_lock_transparent_key_slot_with_policy( if( status != PSA_SUCCESS ) return( status ); - if( psa_key_slot_is_external( *p_slot ) ) + if( psa_key_lifetime_is_external( (*p_slot)->attr.lifetime ) ) { psa_unlock_key_slot( *p_slot ); *p_slot = NULL; @@ -974,11 +974,6 @@ static psa_status_t psa_get_and_lock_transparent_key_slot_with_policy( return( PSA_SUCCESS ); } -#else /* MBEDTLS_PSA_CRYPTO_SE_C */ -/* With no secure element support, all keys are transparent. */ -#define psa_get_and_lock_transparent_key_slot_with_policy( key, p_slot, usage, alg ) \ - psa_get_and_lock_key_slot_with_policy( key, p_slot, usage, alg ) -#endif /* MBEDTLS_PSA_CRYPTO_SE_C */ psa_status_t psa_remove_key_data_from_memory( psa_key_slot_t *slot ) { From 512ad813182862a9b6e64db2da4cd55b561dc0bd Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 24 Aug 2021 15:50:05 +0200 Subject: [PATCH 472/966] psa: Fix slot number key attribute Slot number key attribute is specific of dynamically registered drivers and should thus not be computed/ returned in case of keys associated to drivers implementing the new unified driver interface. Signed-off-by: Ronald Cron --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index d88836b0a0..7a6bb37834 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1201,7 +1201,7 @@ psa_status_t psa_get_key_attributes( mbedtls_svc_key_id_t key, MBEDTLS_PSA_KA_MASK_DUAL_USE ); #if defined(MBEDTLS_PSA_CRYPTO_SE_C) - if( psa_key_slot_is_external( slot ) ) + if( psa_get_se_driver_entry( slot->attr.lifetime ) != NULL ) psa_set_key_slot_number( attributes, psa_key_slot_get_slot_number( slot ) ); #endif /* MBEDTLS_PSA_CRYPTO_SE_C */ From 9b8b69c30a8d1d842388f7840e79d770fdf5cac0 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 24 Aug 2021 16:00:51 +0200 Subject: [PATCH 473/966] psa: Remove buggy report of RSA public exponent for opaque keys The report of RSA public exponent for opaque keys is not supported. Do not attempt to compute the RSA public exponent of an RSA opaque key associated to a driver implementing the new driver interface when MBEDTLS_PSA_CRYPTO_SE_C is disabled. Signed-off-by: Ronald Cron --- library/psa_crypto.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 7a6bb37834..e57184919b 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1212,14 +1212,11 @@ psa_status_t psa_get_key_attributes( mbedtls_svc_key_id_t key, defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY) case PSA_KEY_TYPE_RSA_KEY_PAIR: case PSA_KEY_TYPE_RSA_PUBLIC_KEY: -#if defined(MBEDTLS_PSA_CRYPTO_SE_C) /* TODO: reporting the public exponent for opaque keys * is not yet implemented. * https://github.com/ARMmbed/mbed-crypto/issues/216 */ - if( psa_key_slot_is_external( slot ) ) - break; -#endif /* MBEDTLS_PSA_CRYPTO_SE_C */ + if( ! psa_key_lifetime_is_external( slot->attr.lifetime ) ) { mbedtls_rsa_context *rsa = NULL; From 3b097eb68f41e6b037dcd12981348d246be2c8d7 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 24 Aug 2021 18:05:41 +0200 Subject: [PATCH 474/966] psa: Remove psa_key_slot_is_external() Remove psa_key_slot_is_external() that is not used anymore. Signed-off-by: Ronald Cron --- library/psa_crypto.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index e57184919b..e962e29cb4 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -322,13 +322,6 @@ psa_status_t mbedtls_to_psa_error( int ret ) /* Key management */ /****************************************************************/ -#if defined(MBEDTLS_PSA_CRYPTO_SE_C) -static inline int psa_key_slot_is_external( const psa_key_slot_t *slot ) -{ - return( psa_key_lifetime_is_external( slot->attr.lifetime ) ); -} -#endif /* MBEDTLS_PSA_CRYPTO_SE_C */ - /* For now the MBEDTLS_PSA_ACCEL_ guards are also used here since the * current test driver in key_management.c is using this function * when accelerators are used for ECC key pair and public key. From d8a83dc17235b13a3ed1bd7db8afde1d3111fc73 Mon Sep 17 00:00:00 2001 From: Archana Date: Mon, 14 Jun 2021 10:04:16 +0530 Subject: [PATCH 475/966] Sizing of key buffer for opaque keys Create a new sizing function for determining the size required for key storage based on the input key data. This is required for key imports where the key length might need to be derived from the data. Signed-off-by: Archana --- library/psa_crypto.c | 30 ++++++++++++----- library/psa_crypto_driver_wrappers.c | 49 +++++++++++++++++++++++++--- library/psa_crypto_driver_wrappers.h | 6 ++++ 3 files changed, 73 insertions(+), 12 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index e962e29cb4..d70dccbf7d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1891,6 +1891,7 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes, psa_key_slot_t *slot = NULL; psa_se_drv_table_entry_t *driver = NULL; size_t bits; + size_t storage_size = data_length; *key = MBEDTLS_SVC_KEY_ID_INIT; @@ -1906,12 +1907,18 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes, goto exit; /* In the case of a transparent key or an opaque key stored in local - * storage (thus not in the case of generating a key in a secure element - * or cryptoprocessor with storage), we have to allocate a buffer to - * hold the generated key material. */ + * storage, we have to allocate a buffer to hold the generated key + * material. */ if( slot->key.data == NULL ) { - status = psa_allocate_buffer_to_slot( slot, data_length ); + if( psa_key_lifetime_is_external( attributes->core.lifetime ) ) + { + status = psa_driver_wrapper_get_key_buffer_size_from_key_data( attributes, data, + data_length , &storage_size ); + if( status != PSA_SUCCESS ) + goto exit; + } + status = psa_allocate_buffer_to_slot( slot, storage_size ); if( status != PSA_SUCCESS ) goto exit; } @@ -4142,6 +4149,7 @@ static psa_status_t psa_generate_derived_key_internal( { uint8_t *data = NULL; size_t bytes = PSA_BITS_TO_BYTES( bits ); + size_t storage_size = bytes; psa_status_t status; if( ! key_type_is_raw_bytes( slot->attr.type ) ) @@ -4160,15 +4168,21 @@ static psa_status_t psa_generate_derived_key_internal( psa_des_set_key_parity( data, bytes ); #endif /* MBEDTLS_PSA_BUILTIN_KEY_TYPE_DES */ - status = psa_allocate_buffer_to_slot( slot, bytes ); - if( status != PSA_SUCCESS ) - goto exit; - slot->attr.bits = (psa_key_bits_t) bits; psa_key_attributes_t attributes = { .core = slot->attr }; + if( psa_key_lifetime_is_external( attributes.core.lifetime ) ) + { + status = psa_driver_wrapper_get_key_buffer_size( &attributes, &storage_size ); + if( status != PSA_SUCCESS ) + goto exit; + } + status = psa_allocate_buffer_to_slot( slot, storage_size ); + if( status != PSA_SUCCESS ) + goto exit; + status = psa_driver_wrapper_import_key( &attributes, data, bytes, slot->key.data, diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 38d0e300e2..2974d6f93d 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -380,8 +380,49 @@ psa_status_t psa_driver_wrapper_verify_hash( } } +/** calculate the key buffer size required to store the key material of a key + * associated with an opaque driver from input key data. + * + * + * \param[in] attributes The key attributes + * \param[in] data The input key data. + * \param[in] data_length The input data length. + * \param[out] key_buffer_size Minimum buffer size to contain the key material. + * + * \retval #PSA_SUCCESS + * \retval #PSA_ERROR_INVALID_ARGUMENT + * \retval #PSA_ERROR_NOT_SUPPORTED + */ +psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data( + const psa_key_attributes_t *attributes, + const uint8_t *data, + size_t data_length, + size_t *key_buffer_size ) +{ + psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); + psa_key_type_t key_type = attributes->core.type; + + *key_buffer_size = 0; + switch( location ) + { +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TEST_DRIVER_LOCATION: + *key_buffer_size = mbedtls_test_opaque_size_function( key_type, + PSA_BYTES_TO_BITS( data_length ) ); + return( ( *key_buffer_size != 0 ) ? + PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED ); +#endif /* PSA_CRYPTO_DRIVER_TEST */ + + default: + (void)key_type; + (void)data; + (void)data_length; + return( PSA_ERROR_INVALID_ARGUMENT ); + } +} + /** Get the key buffer size required to store the key material of a key - * associated with an opaque driver without storage. + * associated with an opaque driver. * * \param[in] attributes The key attributes. * \param[out] key_buffer_size Minimum buffer size to contain the key material @@ -389,11 +430,11 @@ psa_status_t psa_driver_wrapper_verify_hash( * \retval #PSA_SUCCESS * The minimum size for a buffer to contain the key material has been * returned successfully. - * \retval #PSA_ERROR_INVALID_ARGUMENT - * The size in bits of the key is not valid. * \retval #PSA_ERROR_NOT_SUPPORTED * The type and/or the size in bits of the key or the combination of * the two is not supported. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The key is declared with a lifetime not known to us. */ psa_status_t psa_driver_wrapper_get_key_buffer_size( const psa_key_attributes_t *attributes, @@ -426,7 +467,7 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size( default: (void)key_type; (void)key_bits; - return( PSA_ERROR_NOT_SUPPORTED ); + return( PSA_ERROR_INVALID_ARGUMENT ); } } diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h index 38a6ee82a7..99455a8a6c 100644 --- a/library/psa_crypto_driver_wrappers.h +++ b/library/psa_crypto_driver_wrappers.h @@ -85,6 +85,12 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size( const psa_key_attributes_t *attributes, size_t *key_buffer_size ); +psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data( + const psa_key_attributes_t *attributes, + const uint8_t *data, + size_t data_length, + size_t *key_buffer_size ); + psa_status_t psa_driver_wrapper_generate_key( const psa_key_attributes_t *attributes, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length ); From 4d7ae1d8cfb1046f681d51eb9dd3c5ae05c3274f Mon Sep 17 00:00:00 2001 From: Archana Date: Wed, 7 Jul 2021 02:50:22 +0530 Subject: [PATCH 476/966] Add test driver support for opaque key import -Add test driver support to import/export while wrapping keys meant to be stored in the PSA core as opaque( emulating an SE without storage ). -Export validate_unstructured_key_bit_size as psa_validate_unstructured_key_bit_size, thereby changing its scope. -Improve the import/export test cases in test_suite_psa_crypto to also cover opaque keys, thereby avoiding duplication. Signed-off-by: Archana --- library/psa_crypto.c | 23 +- library/psa_crypto_core.h | 19 + library/psa_crypto_driver_wrappers.c | 16 +- library/psa_crypto_ecp.c | 4 +- library/psa_crypto_ecp.h | 4 +- library/psa_crypto_rsa.c | 4 +- library/psa_crypto_rsa.h | 4 +- tests/include/test/drivers/key_management.h | 24 ++ tests/include/test/drivers/size.h | 33 -- tests/include/test/drivers/test_driver.h | 1 - .../src/drivers/test_driver_key_management.c | 350 +++++++++++++++--- tests/src/drivers/test_driver_size.c | 97 ----- tests/suites/test_suite_psa_crypto.data | 316 +++++++++++++--- tests/suites/test_suite_psa_crypto.function | 35 +- 14 files changed, 650 insertions(+), 280 deletions(-) delete mode 100644 tests/include/test/drivers/size.h delete mode 100644 tests/src/drivers/test_driver_size.c diff --git a/library/psa_crypto.c b/library/psa_crypto.c index d70dccbf7d..cea165cbbc 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -430,8 +430,8 @@ mbedtls_ecp_group_id mbedtls_ecc_group_of_psa( psa_ecc_family_t curve, * defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || * defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) */ -static psa_status_t validate_unstructured_key_bit_size( psa_key_type_t type, - size_t bits ) +psa_status_t psa_validate_unstructured_key_bit_size( psa_key_type_t type, + size_t bits ) { /* Check that the bit size is acceptable for the key type */ switch( type ) @@ -560,14 +560,14 @@ psa_status_t psa_import_key_into_slot( /* Ensure that the bytes-to-bits conversion hasn't overflown. */ if( data_length > SIZE_MAX / 8 ) - return( PSA_ERROR_NOT_SUPPORTED ); + return( status ); /* Enforce a size limit, and in particular ensure that the bit * size fits in its representation type. */ if( ( *bits ) > PSA_MAX_KEY_BITS ) - return( PSA_ERROR_NOT_SUPPORTED ); + return( status ); - status = validate_unstructured_key_bit_size( type, *bits ); + status = psa_validate_unstructured_key_bit_size( attributes->core.type, *bits ); if( status != PSA_SUCCESS ) return( status ); @@ -1907,8 +1907,9 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes, goto exit; /* In the case of a transparent key or an opaque key stored in local - * storage, we have to allocate a buffer to hold the generated key - * material. */ + * storage( thus not in the case of the old-style secure element interface + * (MBEDTLS_PSA_CRYPTO_SE_C)),we have to allocate a buffer to hold the + * imported key material. */ if( slot->key.data == NULL ) { if( psa_key_lifetime_is_external( attributes->core.lifetime ) ) @@ -5061,7 +5062,7 @@ static psa_status_t psa_validate_key_type_and_size_for_key_generation( if( key_type_is_raw_bytes( type ) ) { - status = validate_unstructured_key_bit_size( type, bits ); + status = psa_validate_unstructured_key_bit_size( type, bits ); if( status != PSA_SUCCESS ) return( status ); } @@ -5171,9 +5172,9 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes, goto exit; /* In the case of a transparent key or an opaque key stored in local - * storage (thus not in the case of generating a key in a secure element - * or cryptoprocessor with storage), we have to allocate a buffer to - * hold the generated key material. */ + * storage( thus not in the case of the old-style secure element interface + * (MBEDTLS_PSA_CRYPTO_SE_C)),we have to allocate a buffer to hold the + * imported key material. */ if( slot->key.data == NULL ) { if ( PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ) == diff --git a/library/psa_crypto_core.h b/library/psa_crypto_core.h index 91757b5fdb..4a3fa5079b 100644 --- a/library/psa_crypto_core.h +++ b/library/psa_crypto_core.h @@ -528,4 +528,23 @@ psa_status_t psa_verify_hash_builtin( psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, const uint8_t *signature, size_t signature_length ); +/** + * \brief Validate the key bit size for unstructured keys. + * + * \note Check that the bit size is acceptable for a given key type for + * unstructured keys. + * + * \param[in] type The key type + * \param[in] bits The number of bits of the key + * + * \retval #PSA_SUCCESS + * The key type and size are valid. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * The size in bits of the key is not valid. + * \retval #PSA_ERROR_NOT_SUPPORTED + * The type and/or the size in bits of the key or the combination of + * the two is not supported. + */ +psa_status_t psa_validate_unstructured_key_bit_size( psa_key_type_t type, + size_t bits ); #endif /* PSA_CRYPTO_CORE_H */ diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 2974d6f93d..e145dd4d62 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -459,7 +459,7 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size( return( PSA_SUCCESS ); } #endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */ - *key_buffer_size = mbedtls_test_size_function( key_type, key_bits ); + *key_buffer_size = mbedtls_test_opaque_size_function( key_type, key_bits ); return( ( *key_buffer_size != 0 ) ? PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED ); #endif /* PSA_CRYPTO_DRIVER_TEST */ @@ -607,10 +607,18 @@ psa_status_t psa_driver_wrapper_import_key( data, data_length, key_buffer, key_buffer_size, key_buffer_length, bits ) ); - + /* Add cases for opaque driver here */ +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TEST_DRIVER_LOCATION: + return( mbedtls_test_opaque_import_key( + attributes, + data, data_length, + key_buffer, key_buffer_size, + key_buffer_length, bits ) ); +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ default: - /* Importing a key with external storage in not yet supported. - * Return in error indicating that the lifetime is not valid. */ (void)status; return( PSA_ERROR_INVALID_ARGUMENT ); } diff --git a/library/psa_crypto_ecp.c b/library/psa_crypto_ecp.c index 3ce232c6b2..144ba1c1b3 100644 --- a/library/psa_crypto_ecp.c +++ b/library/psa_crypto_ecp.c @@ -572,7 +572,7 @@ psa_status_t mbedtls_psa_ecdsa_verify_hash( #if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || \ defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) -psa_status_t mbedtls_transparent_test_driver_ecp_import_key( +psa_status_t mbedtls_test_driver_ecp_import_key( const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, uint8_t *key_buffer, size_t key_buffer_size, @@ -583,7 +583,7 @@ psa_status_t mbedtls_transparent_test_driver_ecp_import_key( key_buffer_length, bits ) ); } -psa_status_t mbedtls_transparent_test_driver_ecp_export_public_key( +psa_status_t mbedtls_test_driver_ecp_export_public_key( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, uint8_t *data, size_t data_size, size_t *data_length ) diff --git a/library/psa_crypto_ecp.h b/library/psa_crypto_ecp.h index 0c2b92895f..dc9e887eff 100644 --- a/library/psa_crypto_ecp.h +++ b/library/psa_crypto_ecp.h @@ -224,13 +224,13 @@ psa_status_t mbedtls_psa_ecdsa_verify_hash( #if defined(PSA_CRYPTO_DRIVER_TEST) -psa_status_t mbedtls_transparent_test_driver_ecp_import_key( +psa_status_t mbedtls_test_driver_ecp_import_key( const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length, size_t *bits ); -psa_status_t mbedtls_transparent_test_driver_ecp_export_public_key( +psa_status_t mbedtls_test_driver_ecp_export_public_key( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, uint8_t *data, size_t data_size, size_t *data_length ); diff --git a/library/psa_crypto_rsa.c b/library/psa_crypto_rsa.c index d85b86c45d..2c357c91ce 100644 --- a/library/psa_crypto_rsa.c +++ b/library/psa_crypto_rsa.c @@ -611,7 +611,7 @@ psa_status_t mbedtls_psa_rsa_verify_hash( #if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) || \ defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY) -psa_status_t mbedtls_transparent_test_driver_rsa_import_key( +psa_status_t mbedtls_test_driver_rsa_import_key( const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, uint8_t *key_buffer, size_t key_buffer_size, @@ -622,7 +622,7 @@ psa_status_t mbedtls_transparent_test_driver_rsa_import_key( key_buffer_length, bits ) ); } -psa_status_t mbedtls_transparent_test_driver_rsa_export_public_key( +psa_status_t mbedtls_test_driver_rsa_export_public_key( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, uint8_t *data, size_t data_size, size_t *data_length ) diff --git a/library/psa_crypto_rsa.h b/library/psa_crypto_rsa.h index 41a90f78ec..55406843d3 100644 --- a/library/psa_crypto_rsa.h +++ b/library/psa_crypto_rsa.h @@ -218,13 +218,13 @@ psa_status_t mbedtls_psa_rsa_verify_hash( #if defined(PSA_CRYPTO_DRIVER_TEST) -psa_status_t mbedtls_transparent_test_driver_rsa_import_key( +psa_status_t mbedtls_test_driver_rsa_import_key( const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length, size_t *bits ); -psa_status_t mbedtls_transparent_test_driver_rsa_export_public_key( +psa_status_t mbedtls_test_driver_rsa_export_public_key( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, uint8_t *data, size_t data_size, size_t *data_length ); diff --git a/tests/include/test/drivers/key_management.h b/tests/include/test/drivers/key_management.h index 16e1f755ca..3cde1aaff9 100644 --- a/tests/include/test/drivers/key_management.h +++ b/tests/include/test/drivers/key_management.h @@ -49,6 +49,21 @@ static inline mbedtls_test_driver_key_management_hooks_t return( v ); } +/* + * In order to convert the plain text keys to Opaque, the size of the key is + * padded up by PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE in addition to xor mangling + * the key. The pad prefix needs to be accounted for while sizing for the key. + */ +#define PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX 0xBEEFED00U +#define PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE sizeof( PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX ) + +size_t mbedtls_test_opaque_get_base_size(); + +size_t mbedtls_test_opaque_size_function( + const psa_key_type_t key_type, + const size_t key_bits ); + + extern mbedtls_test_driver_key_management_hooks_t mbedtls_test_driver_key_management_hooks; @@ -84,6 +99,15 @@ psa_status_t mbedtls_test_transparent_import_key( size_t *key_buffer_length, size_t *bits); +psa_status_t mbedtls_test_opaque_import_key( + const psa_key_attributes_t *attributes, + const uint8_t *data, + size_t data_length, + uint8_t *key_buffer, + size_t key_buffer_size, + size_t *key_buffer_length, + size_t *bits); + psa_status_t mbedtls_test_opaque_get_builtin_key( psa_drv_slot_number_t slot_number, psa_key_attributes_t *attributes, diff --git a/tests/include/test/drivers/size.h b/tests/include/test/drivers/size.h deleted file mode 100644 index 4e3301c4ae..0000000000 --- a/tests/include/test/drivers/size.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Test driver for context size functions - */ -/* Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PSA_CRYPTO_TEST_DRIVERS_SIZE_H -#define PSA_CRYPTO_TEST_DRIVERS_SIZE_H - -#include "mbedtls/build_info.h" - -#if defined(PSA_CRYPTO_DRIVER_TEST) -#include - -size_t mbedtls_test_size_function( - const psa_key_type_t key_type, - const size_t key_bits ); - -#endif /* PSA_CRYPTO_DRIVER_TEST */ -#endif /* PSA_CRYPTO_TEST_DRIVERS_SIZE_H */ diff --git a/tests/include/test/drivers/test_driver.h b/tests/include/test/drivers/test_driver.h index 5b60932d3a..47e92b7071 100644 --- a/tests/include/test/drivers/test_driver.h +++ b/tests/include/test/drivers/test_driver.h @@ -28,6 +28,5 @@ #include "test/drivers/mac.h" #include "test/drivers/key_management.h" #include "test/drivers/signature.h" -#include "test/drivers/size.h" #endif /* PSA_CRYPTO_TEST_DRIVER_H */ diff --git a/tests/src/drivers/test_driver_key_management.c b/tests/src/drivers/test_driver_key_management.c index afa1fc261e..7ad7f73bdb 100644 --- a/tests/src/drivers/test_driver_key_management.c +++ b/tests/src/drivers/test_driver_key_management.c @@ -56,6 +56,88 @@ const uint8_t mbedtls_test_driver_ecdsa_pubkey[65] = 0xbc, 0x25, 0x16, 0xc3, 0xd2, 0x70, 0x2d, 0x79, 0x2f, 0x13, 0x1a, 0x92, 0x20, 0x95, 0xfd, 0x6c }; + +/* + * This macro returns the base size for the key context when SE does not support storage. + * It is the size of the metadata that gets added to the wrapped key. + * In its test functionality the metadata is just some padded prefixing to the key. + */ +#define TEST_DRIVER_KEY_CONTEXT_BASE_SIZE PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE + + +size_t mbedtls_test_opaque_size_function( + const psa_key_type_t key_type, + const size_t key_bits ) +{ + size_t key_buffer_size = 0; + + key_buffer_size = PSA_EXPORT_KEY_OUTPUT_SIZE( key_type, key_bits ); + if( key_buffer_size == 0 ) + return( key_buffer_size ); + /* Include spacing for base size overhead over the key size + * */ + key_buffer_size += TEST_DRIVER_KEY_CONTEXT_BASE_SIZE; + return( key_buffer_size ); +} + +size_t mbedtls_test_opaque_get_base_size() +{ + return TEST_DRIVER_KEY_CONTEXT_BASE_SIZE; +} + +/* + * The wrap function mbedtls_test_opaque_wrap_key pads and wraps the clear key. + * It expects the clear and wrap buffers to be passed in. + * key_buffer_size is the size of the clear key to be wrapped. + * wrap_buffer_size is the size of the output buffer wrap_key. + * The argument key_buffer_length is filled with the wrapped key_size on success. + * */ +static psa_status_t mbedtls_test_opaque_wrap_key( + const uint8_t *key_buffer, + size_t key_buffer_size, + uint8_t *wrap_key, + size_t wrap_buffer_size, + size_t *key_buffer_length ) +{ + size_t opaque_key_base_size = mbedtls_test_opaque_get_base_size(); + uint64_t prefix = PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX; + if( key_buffer_size + opaque_key_base_size > wrap_buffer_size ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + /* Write in the opaque pad prefix */ + memcpy( wrap_key, &prefix, opaque_key_base_size); + wrap_key += opaque_key_base_size; + *key_buffer_length = key_buffer_size + opaque_key_base_size; + while( key_buffer_size-- ) + wrap_key[key_buffer_size] = key_buffer[key_buffer_size] ^ 0xFF; + return( PSA_SUCCESS ); +} + +/* + * The unwrap function mbedtls_test_opaque_unwrap_key removes a pad prefix and unwraps + * the wrapped key. It expects the clear and wrap buffers to be passed in. + * wrapped_key_buffer_size is the size of the wrapped key, + * key_buffer_size is the size of the output buffer clear_key. + * The argument key_buffer_length is filled with the unwrapped(clear) key_size on success. + * */ +static psa_status_t mbedtls_test_opaque_unwrap_key( + const uint8_t *wrapped_key, + size_t wrapped_key_buffer_size, + uint8_t *key_buffer, + size_t key_buffer_size, + size_t *key_buffer_length) +{ + /* Remove the pad prefis from the wrapped key */ + size_t opaque_key_base_size = mbedtls_test_opaque_get_base_size(); + size_t clear_key_size = wrapped_key_buffer_size - opaque_key_base_size; + wrapped_key += opaque_key_base_size; + if( clear_key_size > key_buffer_size ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + *key_buffer_length = clear_key_size; + while( clear_key_size-- ) + key_buffer[clear_key_size] = wrapped_key[clear_key_size] ^ 0xFF; + return( PSA_SUCCESS ); +} + psa_status_t mbedtls_test_transparent_generate_key( const psa_key_attributes_t *attributes, uint8_t *key, size_t key_size, size_t *key_length ) @@ -131,7 +213,7 @@ psa_status_t mbedtls_test_transparent_import_key( defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) if( PSA_KEY_TYPE_IS_ECC( type ) ) { - status = mbedtls_transparent_test_driver_ecp_import_key( + status = mbedtls_test_driver_ecp_import_key( attributes, data, data_length, key_buffer, key_buffer_size, @@ -143,7 +225,7 @@ psa_status_t mbedtls_test_transparent_import_key( defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY) if( PSA_KEY_TYPE_IS_RSA( type ) ) { - status = mbedtls_transparent_test_driver_rsa_import_key( + status = mbedtls_test_driver_rsa_import_key( attributes, data, data_length, key_buffer, key_buffer_size, @@ -165,69 +247,178 @@ psa_status_t mbedtls_test_transparent_import_key( return( status ); } + +psa_status_t mbedtls_test_opaque_import_key( + const psa_key_attributes_t *attributes, + const uint8_t *data, + size_t data_length, + uint8_t *key_buffer, + size_t key_buffer_size, + size_t *key_buffer_length, + size_t *bits) +{ + + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + psa_key_type_t type = psa_get_key_type( attributes ); + /* This buffer will be used as an intermediate placeholder for the clear + * key till we wrap it */ + uint8_t *key_buffer_temp; + key_buffer_temp = mbedtls_calloc( 1, key_buffer_size ); + + if( !key_buffer_temp ) + return( PSA_ERROR_INSUFFICIENT_MEMORY ); + if( PSA_KEY_TYPE_IS_UNSTRUCTURED( type ) ) + { + *bits = PSA_BYTES_TO_BITS( data_length ); + + /* Ensure that the bytes-to-bits conversion hasn't overflown. */ + if( data_length > SIZE_MAX / 8 ) + goto exit; + + /* Enforce a size limit, and in particular ensure that the bit + * size fits in its representation type. */ + if( ( *bits ) > PSA_MAX_KEY_BITS ) + goto exit; + + status = psa_validate_unstructured_key_bit_size( attributes->core.type, *bits ); + if( status != PSA_SUCCESS ) + goto exit; + + /* Copy the key material accounting for opaque key padding. */ + memcpy( key_buffer_temp, data, data_length ); + *key_buffer_length = data_length; + } +#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || \ + defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) + else if( PSA_KEY_TYPE_IS_ECC( type ) ) + { + status = mbedtls_test_driver_ecp_import_key( + attributes, + data, data_length, + key_buffer_temp, + key_buffer_size, + key_buffer_length, bits ); + if( status != PSA_SUCCESS ) + goto exit; + } + else +#endif +#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) || \ + defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY) + if( PSA_KEY_TYPE_IS_RSA( type ) ) + { + status = mbedtls_test_driver_rsa_import_key( + attributes, + data, data_length, + key_buffer_temp, + key_buffer_size, + key_buffer_length, bits ); + if( status != PSA_SUCCESS ) + goto exit; + } + else +#endif + { + status = PSA_ERROR_INVALID_ARGUMENT; + (void)data; + (void)data_length; + (void)key_buffer; + (void)key_buffer_size; + (void)key_buffer_length; + (void)bits; + (void)type; + goto exit; + } + status = mbedtls_test_opaque_wrap_key( key_buffer_temp, *key_buffer_length, + key_buffer, key_buffer_size, key_buffer_length ); +exit: + free( key_buffer_temp ); + return( status ); +} + psa_status_t mbedtls_test_opaque_export_key( const psa_key_attributes_t *attributes, const uint8_t *key, size_t key_length, uint8_t *data, size_t data_size, size_t *data_length ) { - if( key_length != sizeof( psa_drv_slot_number_t ) ) + if( key_length == sizeof( psa_drv_slot_number_t ) ) { - /* Test driver does not support generic opaque key handling yet. */ - return( PSA_ERROR_NOT_SUPPORTED ); + /* Assume this is a builtin key based on the key material length. */ + psa_drv_slot_number_t slot_number = *( ( psa_drv_slot_number_t* ) key ); + + switch( slot_number ) + { + case PSA_CRYPTO_TEST_DRIVER_BUILTIN_ECDSA_KEY_SLOT: + /* This is the ECDSA slot. Verify the key's attributes before + * returning the private key. */ + if( psa_get_key_type( attributes ) != + PSA_KEY_TYPE_ECC_KEY_PAIR( PSA_ECC_FAMILY_SECP_R1 ) ) + return( PSA_ERROR_CORRUPTION_DETECTED ); + if( psa_get_key_bits( attributes ) != 256 ) + return( PSA_ERROR_CORRUPTION_DETECTED ); + if( psa_get_key_algorithm( attributes ) != + PSA_ALG_ECDSA( PSA_ALG_ANY_HASH ) ) + return( PSA_ERROR_CORRUPTION_DETECTED ); + if( ( psa_get_key_usage_flags( attributes ) & + PSA_KEY_USAGE_EXPORT ) == 0 ) + return( PSA_ERROR_CORRUPTION_DETECTED ); + + if( data_size < sizeof( mbedtls_test_driver_ecdsa_key ) ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + + memcpy( data, mbedtls_test_driver_ecdsa_key, + sizeof( mbedtls_test_driver_ecdsa_key ) ); + *data_length = sizeof( mbedtls_test_driver_ecdsa_key ); + return( PSA_SUCCESS ); + + case PSA_CRYPTO_TEST_DRIVER_BUILTIN_AES_KEY_SLOT: + /* This is the AES slot. Verify the key's attributes before + * returning the key. */ + if( psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES ) + return( PSA_ERROR_CORRUPTION_DETECTED ); + if( psa_get_key_bits( attributes ) != 128 ) + return( PSA_ERROR_CORRUPTION_DETECTED ); + if( psa_get_key_algorithm( attributes ) != PSA_ALG_CTR ) + return( PSA_ERROR_CORRUPTION_DETECTED ); + if( ( psa_get_key_usage_flags( attributes ) & + PSA_KEY_USAGE_EXPORT ) == 0 ) + return( PSA_ERROR_CORRUPTION_DETECTED ); + + if( data_size < sizeof( mbedtls_test_driver_aes_key ) ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + + memcpy( data, mbedtls_test_driver_aes_key, + sizeof( mbedtls_test_driver_aes_key ) ); + *data_length = sizeof( mbedtls_test_driver_aes_key ); + return( PSA_SUCCESS ); + + default: + return( PSA_ERROR_DOES_NOT_EXIST ); + } } - - /* Assume this is a builtin key based on the key material length. */ - psa_drv_slot_number_t slot_number = *( ( psa_drv_slot_number_t* ) key ); - - switch( slot_number ) + else { - case PSA_CRYPTO_TEST_DRIVER_BUILTIN_ECDSA_KEY_SLOT: - /* This is the ECDSA slot. Verify the key's attributes before - * returning the private key. */ - if( psa_get_key_type( attributes ) != - PSA_KEY_TYPE_ECC_KEY_PAIR( PSA_ECC_FAMILY_SECP_R1 ) ) - return( PSA_ERROR_CORRUPTION_DETECTED ); - if( psa_get_key_bits( attributes ) != 256 ) - return( PSA_ERROR_CORRUPTION_DETECTED ); - if( psa_get_key_algorithm( attributes ) != - PSA_ALG_ECDSA( PSA_ALG_ANY_HASH ) ) - return( PSA_ERROR_CORRUPTION_DETECTED ); - if( ( psa_get_key_usage_flags( attributes ) & - PSA_KEY_USAGE_EXPORT ) == 0 ) - return( PSA_ERROR_CORRUPTION_DETECTED ); + /* This buffer will be used as an intermediate placeholder for the opaque key + * till we unwrap the key into key_buffer */ + uint8_t *key_buffer_temp; + size_t status = PSA_ERROR_BUFFER_TOO_SMALL; + psa_key_type_t type = psa_get_key_type( attributes ); - if( data_size < sizeof( mbedtls_test_driver_ecdsa_key ) ) - return( PSA_ERROR_BUFFER_TOO_SMALL ); - - memcpy( data, mbedtls_test_driver_ecdsa_key, - sizeof( mbedtls_test_driver_ecdsa_key ) ); - *data_length = sizeof( mbedtls_test_driver_ecdsa_key ); - return( PSA_SUCCESS ); - - case PSA_CRYPTO_TEST_DRIVER_BUILTIN_AES_KEY_SLOT: - /* This is the AES slot. Verify the key's attributes before - * returning the key. */ - if( psa_get_key_type( attributes ) != PSA_KEY_TYPE_AES ) - return( PSA_ERROR_CORRUPTION_DETECTED ); - if( psa_get_key_bits( attributes ) != 128 ) - return( PSA_ERROR_CORRUPTION_DETECTED ); - if( psa_get_key_algorithm( attributes ) != PSA_ALG_CTR ) - return( PSA_ERROR_CORRUPTION_DETECTED ); - if( ( psa_get_key_usage_flags( attributes ) & - PSA_KEY_USAGE_EXPORT ) == 0 ) - return( PSA_ERROR_CORRUPTION_DETECTED ); - - if( data_size < sizeof( mbedtls_test_driver_aes_key ) ) - return( PSA_ERROR_BUFFER_TOO_SMALL ); - - memcpy( data, mbedtls_test_driver_aes_key, - sizeof( mbedtls_test_driver_aes_key ) ); - *data_length = sizeof( mbedtls_test_driver_aes_key ); - return( PSA_SUCCESS ); - - default: - return( PSA_ERROR_DOES_NOT_EXIST ); + if( PSA_KEY_TYPE_IS_UNSTRUCTURED( type ) || + PSA_KEY_TYPE_IS_RSA( type ) || + PSA_KEY_TYPE_IS_ECC( type ) ) + { + key_buffer_temp = mbedtls_calloc( 1, key_length ); + if( !key_buffer_temp ) + return( PSA_ERROR_INSUFFICIENT_MEMORY ); + memcpy( key_buffer_temp, key, key_length ); + status = mbedtls_test_opaque_unwrap_key( key_buffer_temp, key_length, + data, data_size, data_length ); + mbedtls_free( key_buffer_temp ); + return( status ); + } } + return( PSA_ERROR_NOT_SUPPORTED ); } psa_status_t mbedtls_test_transparent_export_public_key( @@ -258,7 +449,7 @@ psa_status_t mbedtls_test_transparent_export_public_key( defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) if( PSA_KEY_TYPE_IS_ECC( key_type ) ) { - status = mbedtls_transparent_test_driver_ecp_export_public_key( + status = mbedtls_test_driver_ecp_export_public_key( attributes, key_buffer, key_buffer_size, data, data_size, data_length ); @@ -269,7 +460,7 @@ psa_status_t mbedtls_test_transparent_export_public_key( defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY) if( PSA_KEY_TYPE_IS_RSA( key_type ) ) { - status = mbedtls_transparent_test_driver_rsa_export_public_key( + status = mbedtls_test_driver_rsa_export_public_key( attributes, key_buffer, key_buffer_size, data, data_size, data_length ); @@ -293,8 +484,48 @@ psa_status_t mbedtls_test_opaque_export_public_key( { if( key_length != sizeof( psa_drv_slot_number_t ) ) { - /* Test driver does not support generic opaque key handling yet. */ - return( PSA_ERROR_NOT_SUPPORTED ); + psa_status_t status = PSA_ERROR_NOT_SUPPORTED; + psa_key_type_t key_type = psa_get_key_type( attributes ); + uint8_t *key_buffer_temp; + key_buffer_temp = mbedtls_calloc( 1, key_length ); + if( !key_buffer_temp ) + return( PSA_ERROR_INSUFFICIENT_MEMORY ); + #if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || \ + defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) + if( PSA_KEY_TYPE_IS_ECC( key_type ) ) + { + status = mbedtls_test_opaque_unwrap_key( key, key_length, + key_buffer_temp, key_length, data_length ); + if( status == PSA_SUCCESS ) + status = mbedtls_test_driver_ecp_export_public_key( + attributes, + key_buffer_temp, *data_length, + data, data_size, data_length ); + } + else + #endif + #if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) || \ + defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY) + if( PSA_KEY_TYPE_IS_RSA( key_type ) ) + { + status = mbedtls_test_opaque_unwrap_key( key, key_length, + key_buffer_temp, key_length, data_length ); + if( status == PSA_SUCCESS ) + status = mbedtls_test_driver_rsa_export_public_key( + attributes, + key_buffer_temp, *data_length, + data, data_size, data_length ); + } + else + #endif + { + status = PSA_ERROR_NOT_SUPPORTED; + (void)key; + (void)key_length; + (void)key_type; + } + mbedtls_free( key_buffer_temp ); + return( status ); } /* Assume this is a builtin key based on the key material length. */ @@ -384,5 +615,4 @@ psa_status_t mbedtls_test_opaque_get_builtin_key( return( PSA_ERROR_DOES_NOT_EXIST ); } } - #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ diff --git a/tests/src/drivers/test_driver_size.c b/tests/src/drivers/test_driver_size.c deleted file mode 100644 index 033cf32de0..0000000000 --- a/tests/src/drivers/test_driver_size.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Test driver for retrieving key context size. - * Only used by opaque drivers. - */ -/* Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST) - -#include "test/drivers/size.h" -#include "psa/crypto.h" - -typedef struct { - unsigned int context; -} test_driver_key_context_t; - -/* - * This macro returns the base size for the key context. It is the size of the - * driver specific information stored in each key context. - */ -#define TEST_DRIVER_KEY_CONTEXT_BASE_SIZE sizeof( test_driver_key_context_t ) - -/* - * Number of bytes included in every key context for a key pair. - * - * This pair size is for an ECC 256-bit private/public key pair. - * Based on this value, the size of the private key can be derived by - * subtracting the public key size below from this one. - */ -#define TEST_DRIVER_KEY_CONTEXT_KEY_PAIR_SIZE 65 - -/* - * Number of bytes included in every key context for a public key. - * - * For ECC public keys, it needs 257 bits so 33 bytes. - */ -#define TEST_DRIVER_KEY_CONTEXT_PUBLIC_KEY_SIZE 33 - -/* - * Every key context for a symmetric key includes this many times the key size. - */ -#define TEST_DRIVER_KEY_CONTEXT_SYMMETRIC_FACTOR 0 - -/* - * If this is true for a key pair, the key context includes space for the public key. - * If this is false, no additional space is added for the public key. - * - * For this instance, store the public key with the private one. - */ -#define TEST_DRIVER_KEY_CONTEXT_STORE_PUBLIC_KEY 1 - -size_t mbedtls_test_size_function( - const psa_key_type_t key_type, - const size_t key_bits ) -{ - size_t key_buffer_size = 0; - - if( PSA_KEY_TYPE_IS_KEY_PAIR( key_type ) ) - { - int public_key_overhead = - ( ( TEST_DRIVER_KEY_CONTEXT_STORE_PUBLIC_KEY == 1 ) - ? PSA_EXPORT_KEY_OUTPUT_SIZE( key_type, key_bits ) : 0 ); - key_buffer_size = TEST_DRIVER_KEY_CONTEXT_BASE_SIZE + - TEST_DRIVER_KEY_CONTEXT_PUBLIC_KEY_SIZE + - public_key_overhead; - } - else if( PSA_KEY_TYPE_IS_PUBLIC_KEY( key_type ) ) - { - key_buffer_size = TEST_DRIVER_KEY_CONTEXT_BASE_SIZE + - TEST_DRIVER_KEY_CONTEXT_PUBLIC_KEY_SIZE; - } - else if ( !PSA_KEY_TYPE_IS_KEY_PAIR( key_type ) && - !PSA_KEY_TYPE_IS_PUBLIC_KEY ( key_type ) ) - { - key_buffer_size = TEST_DRIVER_KEY_CONTEXT_BASE_SIZE + - ( TEST_DRIVER_KEY_CONTEXT_SYMMETRIC_FACTOR * - ( ( key_bits + 7 ) / 8 ) ); - } - - return( key_buffer_size ); -} -#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index bc4edb2b7b..89254cd374 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2,25 +2,49 @@ PSA compile-time sanity checks static_checks: PSA import/export raw: 1 bytes -import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:8:0:PSA_SUCCESS:1 +import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:0:8:0:PSA_SUCCESS:1 PSA import/export raw: 1 bytes, larger buffer -import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:8:1:PSA_SUCCESS:1 +import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:0:8:1:PSA_SUCCESS:1 PSA import/export raw: 2 bytes, buffer too small -import_export:"2a2b":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:16:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 +import_export:"2a2b":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:0:16:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export AES-128 depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -import_export:"0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:128:0:PSA_SUCCESS:1 +import_export:"0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:128:0:PSA_SUCCESS:1 PSA import/export AES-192 depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -import_export:"0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:192:0:PSA_SUCCESS:1 +import_export:"0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:192:0:PSA_SUCCESS:1 PSA import/export AES-256 depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -import_export:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:256:0:PSA_SUCCESS:1 +import_export:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:256:0:PSA_SUCCESS:1 + +PSA import/export raw: 1 bytes, opaque +depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):8:0:PSA_SUCCESS:1 + +PSA import/export raw: 1 bytes, larger buffer, opaque +depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):8:1:PSA_SUCCESS:1 + +PSA import/export raw: 2 bytes, buffer too small, opaque +depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"2a2b":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):16:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 + +PSA import/export AES-128, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):128:0:PSA_SUCCESS:1 + +PSA import/export AES-192, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):192:0:PSA_SUCCESS:1 + +PSA import/export AES-256, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import: bad usage flag import_with_policy:PSA_KEY_TYPE_RAW_DATA:0x40000000:0:PSA_ERROR_INVALID_ARGUMENT @@ -31,55 +55,107 @@ import_with_data:"0123456789abcdef":PSA_KEY_TYPE_AES:0:PSA_ERROR_INVALID_ARGUMEN PSA import/export RSA public key: good, 1024-bit depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:0:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:0:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (+1 byte) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:1:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:1:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2-1) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:161:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:161:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:162:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:162:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2+1) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:163:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:163:PSA_SUCCESS:1 PSA import/export RSA public key: export buffer too small depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export RSA keypair: good, 1024-bit depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:0:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:0:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (+1 byte) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:1:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:1:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2-1) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:609:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:609:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:610:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:610:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2+1) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:611:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:611:PSA_SUCCESS:1 PSA import/export RSA keypair: export buffer too small depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export RSA keypair: trailing garbage ignored depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:-1:PSA_SUCCESS:0 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:-1:PSA_SUCCESS:0 + +PSA import/export RSA public key: good, 1024-bit, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:0:PSA_SUCCESS:1 + +PSA import/export RSA public key: good, larger buffer (+1 byte), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:1:PSA_SUCCESS:1 + +PSA import/export RSA public key: good, larger buffer (*2-1), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:161:PSA_SUCCESS:1 + +PSA import/export RSA public key: good, larger buffer (*2), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:162:PSA_SUCCESS:1 + +PSA import/export RSA public key: good, larger buffer (*2+1), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:163:PSA_SUCCESS:1 + +PSA import/export RSA public key: export buffer too small, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 + +PSA import/export RSA keypair: good, 1024-bit, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:0:PSA_SUCCESS:1 + +PSA import/export RSA keypair: good, larger buffer (+1 byte), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:1:PSA_SUCCESS:1 + +PSA import/export RSA keypair: good, larger buffer (*2-1), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:609:PSA_SUCCESS:1 + +PSA import/export RSA keypair: good, larger buffer (*2), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:610:PSA_SUCCESS:1 + +PSA import/export RSA keypair: good, larger buffer (*2+1), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:611:PSA_SUCCESS:1 + +PSA import/export RSA keypair: export buffer too small, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 + +PSA import/export RSA keypair: trailing garbage ignored, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:-1:PSA_SUCCESS:0 PSA import RSA keypair: truncated depends_on:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C @@ -99,27 +175,51 @@ import_with_data:"3077020101042049c9a8c18c4b885638c431cf1df1c994131609b580d4fd43 PSA import/export-public RSA public key: good, 1024-bit depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" +import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA keypair: good, 1024-bit depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" +import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA public key: buffer too small depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" +import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA keypair: buffer too small depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" +import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" + +PSA import/export-public RSA public key: good, 1024-bit, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" + +PSA import/export-public RSA keypair: good, 1024-bit, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" + +PSA import/export-public RSA public key: buffer too small, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" + +PSA import/export-public RSA keypair: buffer too small, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export RSA public key: 1016-bit (good) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"30818802818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1016:0:PSA_SUCCESS:1 +import_export:"30818802818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1016:0:PSA_SUCCESS:1 PSA import/export RSA keypair: 1016-bit (good) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025802010002818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001028180009dd9c34411e769a540e7e9c03682abb4e95ad2d5c2297c6b7eb2fa5415dfa081adb42bff344ea36a31e8bb36593fa69e843f053fa916f8c6ae4c423fa4c1edbcfa7e8079bc19a738f4f861c198cf277d2c89fe3deab06db5a3a09f8d1622033a618fbfbab92b50a13f77cdb53b56d38bec4cdd8cbe65e8b30ab4e77565842102400eec9285833f973372458f354bff7d35bcb04f3b26f5b58a025887a966ca951b6667651a46034bbc99f9d688dfbcb4297a4d86824dd73abdfa7deeb232b1642902400dcbe74d51f3b93afe2a22e2be0c3c56911ef771fd8eb01f64d95d018315baf4144aeb957be95a77f17f2b8a12c2d3b87a1281f9c66d839fa603fbbe7381783d0240035398154a7c1227d580cbbb05859d532d0bdf9d3fc1e5052e20ad9c84dd02ff6884037527c5f44bc5c67a9b67c39824e6ae011d6a5c5f2b997a188a7fe22a810240076bf41ec5023e57bcd87ff1c7d89f30d65a793469f933478021ea056135f45f4ef74aaa1c8158b883422cf2d6cad5c83c6aee5ea65ecd5ab99d14f4cc000ee5024006d13905db5556627066596da3383458aea6ba5e2f94ccc5b922117a1ed3ae7a26c59e68c3885a41b366f1a5c8bff7ec8853ef8d32addb818141352b2da553dc":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1016:0:PSA_SUCCESS:1 +import_export:"3082025802010002818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001028180009dd9c34411e769a540e7e9c03682abb4e95ad2d5c2297c6b7eb2fa5415dfa081adb42bff344ea36a31e8bb36593fa69e843f053fa916f8c6ae4c423fa4c1edbcfa7e8079bc19a738f4f861c198cf277d2c89fe3deab06db5a3a09f8d1622033a618fbfbab92b50a13f77cdb53b56d38bec4cdd8cbe65e8b30ab4e77565842102400eec9285833f973372458f354bff7d35bcb04f3b26f5b58a025887a966ca951b6667651a46034bbc99f9d688dfbcb4297a4d86824dd73abdfa7deeb232b1642902400dcbe74d51f3b93afe2a22e2be0c3c56911ef771fd8eb01f64d95d018315baf4144aeb957be95a77f17f2b8a12c2d3b87a1281f9c66d839fa603fbbe7381783d0240035398154a7c1227d580cbbb05859d532d0bdf9d3fc1e5052e20ad9c84dd02ff6884037527c5f44bc5c67a9b67c39824e6ae011d6a5c5f2b997a188a7fe22a810240076bf41ec5023e57bcd87ff1c7d89f30d65a793469f933478021ea056135f45f4ef74aaa1c8158b883422cf2d6cad5c83c6aee5ea65ecd5ab99d14f4cc000ee5024006d13905db5556627066596da3383458aea6ba5e2f94ccc5b922117a1ed3ae7a26c59e68c3885a41b366f1a5c8bff7ec8853ef8d32addb818141352b2da553dc":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1016:0:PSA_SUCCESS:1 + +PSA import/export RSA public key: 1016-bit (good), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"30818802818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1016:0:PSA_SUCCESS:1 + +PSA import/export RSA keypair: 1016-bit (good), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025802010002818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001028180009dd9c34411e769a540e7e9c03682abb4e95ad2d5c2297c6b7eb2fa5415dfa081adb42bff344ea36a31e8bb36593fa69e843f053fa916f8c6ae4c423fa4c1edbcfa7e8079bc19a738f4f861c198cf277d2c89fe3deab06db5a3a09f8d1622033a618fbfbab92b50a13f77cdb53b56d38bec4cdd8cbe65e8b30ab4e77565842102400eec9285833f973372458f354bff7d35bcb04f3b26f5b58a025887a966ca951b6667651a46034bbc99f9d688dfbcb4297a4d86824dd73abdfa7deeb232b1642902400dcbe74d51f3b93afe2a22e2be0c3c56911ef771fd8eb01f64d95d018315baf4144aeb957be95a77f17f2b8a12c2d3b87a1281f9c66d839fa603fbbe7381783d0240035398154a7c1227d580cbbb05859d532d0bdf9d3fc1e5052e20ad9c84dd02ff6884037527c5f44bc5c67a9b67c39824e6ae011d6a5c5f2b997a188a7fe22a810240076bf41ec5023e57bcd87ff1c7d89f30d65a793469f933478021ea056135f45f4ef74aaa1c8158b883422cf2d6cad5c83c6aee5ea65ecd5ab99d14f4cc000ee5024006d13905db5556627066596da3383458aea6ba5e2f94ccc5b922117a1ed3ae7a26c59e68c3885a41b366f1a5c8bff7ec8853ef8d32addb818141352b2da553dc":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1016:0:PSA_SUCCESS:1 PSA import RSA public key: 1022-bit (not supported) depends_on:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_RSA_C @@ -139,75 +239,75 @@ import_with_data:"3082025a0201000281806c49704e91f3df44fc99e9b3c0fee5025cc04d0952 PSA import/export EC secp224r1 key pair: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224 -import_export:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:224:0:PSA_SUCCESS:1 +import_export:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:224:0:PSA_SUCCESS:1 PSA import/export-public EC secp224r1: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224 -import_export_public_key:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:0:PSA_SUCCESS:"041693a290f7f0b571fe2b41d5d84b01327631f4a860f995fa332c097f54192bb10f00113f2affb13c1a24ce44914571a95440ae014a00cbf7" +import_export_public_key:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"041693a290f7f0b571fe2b41d5d84b01327631f4a860f995fa332c097f54192bb10f00113f2affb13c1a24ce44914571a95440ae014a00cbf7" PSA import/export EC secp256r1 key pair: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -import_export:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:256:0:PSA_SUCCESS:1 +import_export:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:256:0:PSA_SUCCESS:1 PSA import/export-public EC secp256r1: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -import_export_public_key:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:0:PSA_SUCCESS:"047772656f814b399279d5e1f1781fac6f099a3c5ca1b0e35351834b08b65e0b572590cdaf8f769361bcf34acfc11e5e074e8426bdde04be6e653945449617de45" +import_export_public_key:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"047772656f814b399279d5e1f1781fac6f099a3c5ca1b0e35351834b08b65e0b572590cdaf8f769361bcf34acfc11e5e074e8426bdde04be6e653945449617de45" PSA import/export EC secp384r1 key pair: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384 -import_export:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:384:0:PSA_SUCCESS:1 +import_export:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:384:0:PSA_SUCCESS:1 PSA import/export-public EC secp384r1: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384 -import_export_public_key:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:0:PSA_SUCCESS:"04d9c662b50ba29ca47990450e043aeaf4f0c69b15676d112f622a71c93059af999691c5680d2b44d111579db12f4a413a2ed5c45fcfb67b5b63e00b91ebe59d09a6b1ac2c0c4282aa12317ed5914f999bc488bb132e8342cc36f2ca5e3379c747" +import_export_public_key:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"04d9c662b50ba29ca47990450e043aeaf4f0c69b15676d112f622a71c93059af999691c5680d2b44d111579db12f4a413a2ed5c45fcfb67b5b63e00b91ebe59d09a6b1ac2c0c4282aa12317ed5914f999bc488bb132e8342cc36f2ca5e3379c747" PSA import/export EC secp521r1 key pair: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521 -import_export:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:521:0:PSA_SUCCESS:1 +import_export:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:521:0:PSA_SUCCESS:1 PSA import/export-public EC secp521r1: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521 -import_export_public_key:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:0:PSA_SUCCESS:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1" +import_export_public_key:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1" PSA import/export EC brainpool256r1 key pair: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256 -import_export:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:256:0:PSA_SUCCESS:1 +import_export:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:256:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool256r1: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256 -import_export_public_key:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:0:PSA_SUCCESS:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d" +import_export_public_key:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d" PSA import/export EC brainpool384r1 key pair: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384 -import_export:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:384:0:PSA_SUCCESS:1 +import_export:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:384:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool384r1: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384 -import_export_public_key:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:0:PSA_SUCCESS:"04719f9d093a627e0d350385c661cebf00c61923566fe9006a3107af1d871bc6bb68985fd722ea32be316f8e783b7cd1957785f66cfc0cb195dd5c99a8e7abaa848553a584dfd2b48e76d445fe00dd8be59096d877d4696d23b4bc8db14724e66a" +import_export_public_key:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"04719f9d093a627e0d350385c661cebf00c61923566fe9006a3107af1d871bc6bb68985fd722ea32be316f8e783b7cd1957785f66cfc0cb195dd5c99a8e7abaa848553a584dfd2b48e76d445fe00dd8be59096d877d4696d23b4bc8db14724e66a" PSA import/export EC brainpool512r1 key pair: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512 -import_export:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:512:0:PSA_SUCCESS:1 +import_export:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:512:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool512r1: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512 -import_export_public_key:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:0:PSA_SUCCESS:"0438b7ec92b61c5c6c7fbc28a4ec759d48fcd4e2e374defd5c4968a54dbef7510e517886fbfc38ea39aa529359d70a7156c35d3cbac7ce776bdb251dd64bce71234424ee7049eed072f0dbc4d79996e175d557e263763ae97095c081e73e7db2e38adc3d4c9a0487b1ede876dc1fca61c902e9a1d8722b8612928f18a24845591a" +import_export_public_key:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"0438b7ec92b61c5c6c7fbc28a4ec759d48fcd4e2e374defd5c4968a54dbef7510e517886fbfc38ea39aa529359d70a7156c35d3cbac7ce776bdb251dd64bce71234424ee7049eed072f0dbc4d79996e175d557e263763ae97095c081e73e7db2e38adc3d4c9a0487b1ede876dc1fca61c902e9a1d8722b8612928f18a24845591a" PSA import/export EC curve25519 key pair: good (already properly masked) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255 -import_export:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:255:0:PSA_SUCCESS:1 +import_export:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:0:255:0:PSA_SUCCESS:1 PSA import/export EC curve25519 key pair: unmasked input (check export-import-export yields properly masked output) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255 -import_export:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:255:0:PSA_SUCCESS:0 +import_export:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:0:255:0:PSA_SUCCESS:0 PSA import/export-public EC curve25519: accept unmasked input depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255 -import_export_public_key:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" +import_export_public_key:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:0:0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" PSA import/export-public EC curve25519: accept masked input depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255 -import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" +import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:0:0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" PSA import/export EC curve448 key pair: good (already properly masked, key from RFC 7748 6.2 Alice)) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448 @@ -227,23 +327,23 @@ import_export_public_key:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c2 PSA import/export-public: cannot export-public a symmetric key depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:0:PSA_ERROR_INVALID_ARGUMENT:"2b7e151628aed2a6abf7158809cf4f3c" +import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:0:0:PSA_ERROR_INVALID_ARGUMENT:"2b7e151628aed2a6abf7158809cf4f3c" PSA import/export EC secp256r1 public key: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -import_export:"04dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:256:0:PSA_SUCCESS:1 +import_export:"04dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:256:0:PSA_SUCCESS:1 PSA import/export EC secp521r1 public key: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521 -import_export:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:521:0:PSA_SUCCESS:1 +import_export:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:521:0:PSA_SUCCESS:1 PSA import/export EC brainpoolP256r1 public key: good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256 -import_export:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:256:0:PSA_SUCCESS:1 +import_export:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:0:256:0:PSA_SUCCESS:1 PSA import/export curve25519 public key: good depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255 -import_export:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:255:0:PSA_SUCCESS:1 +import_export:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:0:255:0:PSA_SUCCESS:1 PSA import/export curve448 Public Key: good (key from RFC 7748 6.2 Alice) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448 @@ -251,29 +351,137 @@ import_export:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc PSA import/export AES key: policy forbids export depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:128:0:PSA_ERROR_NOT_PERMITTED:1 +import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:128:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export HMAC key: policy forbids export depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):256:0:PSA_ERROR_NOT_PERMITTED:1 +import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):0:256:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export RSA keypair: policy forbids export (crypt) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_CRYPT:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_RSA_PKCS1V15_CRYPT:1024:0:PSA_ERROR_NOT_PERMITTED:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_RSA_PKCS1V15_CRYPT:0:1024:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export RSA keypair: policy forbids export (sign) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:0:PSA_ERROR_NOT_PERMITTED:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:0:PSA_ERROR_NOT_PERMITTED:1 + +PSA import/export EC secp224r1 key pair: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):224:0:PSA_SUCCESS:1 + +PSA import/export-public EC secp224r1: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"041693a290f7f0b571fe2b41d5d84b01327631f4a860f995fa332c097f54192bb10f00113f2affb13c1a24ce44914571a95440ae014a00cbf7" + +PSA import/export EC secp256r1 key pair: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 + +PSA import/export-public EC secp256r1: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"047772656f814b399279d5e1f1781fac6f099a3c5ca1b0e35351834b08b65e0b572590cdaf8f769361bcf34acfc11e5e074e8426bdde04be6e653945449617de45" + +PSA import/export EC secp384r1 key pair: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):384:0:PSA_SUCCESS:1 + +PSA import/export-public EC secp384r1: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04d9c662b50ba29ca47990450e043aeaf4f0c69b15676d112f622a71c93059af999691c5680d2b44d111579db12f4a413a2ed5c45fcfb67b5b63e00b91ebe59d09a6b1ac2c0c4282aa12317ed5914f999bc488bb132e8342cc36f2ca5e3379c747" + +PSA import/export EC secp521r1 key pair: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):521:0:PSA_SUCCESS:1 + +PSA import/export-public EC secp521r1: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1" + +PSA import/export EC brainpool256r1 key pair: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY::PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 + +PSA import/export-public EC brainpool256r1: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d" + +PSA import/export EC brainpool384r1 key pair: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):384:0:PSA_SUCCESS:1 + +PSA import/export-public EC brainpool384r1: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04719f9d093a627e0d350385c661cebf00c61923566fe9006a3107af1d871bc6bb68985fd722ea32be316f8e783b7cd1957785f66cfc0cb195dd5c99a8e7abaa848553a584dfd2b48e76d445fe00dd8be59096d877d4696d23b4bc8db14724e66a" + +PSA import/export EC brainpool512r1 key pair: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):512:0:PSA_SUCCESS:1 + +PSA import/export-public EC brainpool512r1: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"0438b7ec92b61c5c6c7fbc28a4ec759d48fcd4e2e374defd5c4968a54dbef7510e517886fbfc38ea39aa529359d70a7156c35d3cbac7ce776bdb251dd64bce71234424ee7049eed072f0dbc4d79996e175d557e263763ae97095c081e73e7db2e38adc3d4c9a0487b1ede876dc1fca61c902e9a1d8722b8612928f18a24845591a" + +PSA import/export EC curve25519 key pair: good (already properly masked), opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 + +PSA import/export EC curve25519 key pair: unmasked input (check export-import-export yields properly masked output), opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:0 + +PSA import/export-public EC curve25519: accept unmasked input, opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" + +PSA import/export-public EC curve25519: accept masked input, opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" + +PSA import/export-public: cannot export-public a symmetric key, opaque +depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_ERROR_INVALID_ARGUMENT:"2b7e151628aed2a6abf7158809cf4f3c" + +PSA import/export EC secp256r1 public key: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"04dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 + +PSA import/export EC secp521r1 public key: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):521:0:PSA_SUCCESS:1 + +PSA import/export EC brainpoolP256r1 public key: good, opaque +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 + +PSA import/export curve25519 public key: good, opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 + +PSA import/export AES key: policy forbids export, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):128:0:PSA_ERROR_NOT_PERMITTED:1 + +PSA import/export HMAC key: policy forbids export, opaque +depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_ERROR_NOT_PERMITTED:1 + +PSA import/export RSA keypair: policy forbids export (crypt), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_CRYPT:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_RSA_PKCS1V15_CRYPT:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:0:PSA_ERROR_NOT_PERMITTED:1 + +PSA import/export RSA keypair: policy forbids export (sign), opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:0:PSA_ERROR_NOT_PERMITTED:1 # Test PEM import. Note that this is not a PSA feature, it's an Mbed TLS # extension which we may drop in the future. PSA import/export RSA public key: import PEM depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PEM_PARSE_C:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"2d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d4947664d413047435371475349623344514542415155414134474e4144434269514b4267514376425830356275685074312f6274634b7850482f6c706c53710a69714a4843315165346636777353306c7835635255784a4a34524b574b41517475376242494e46454e5354765441357548596c57377249486576456a536433750a355553447641624378686c497a514b7941756557727232553036664c2b466e43775947634d6b79344b357a545474346d4f69712f2f6b637a384865476e6f5a670a3939614454615539615137336d46397277774944415141420a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d0a00":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:0:PSA_SUCCESS:0 +import_export:"2d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d4947664d413047435371475349623344514542415155414134474e4144434269514b4267514376425830356275685074312f6274634b7850482f6c706c53710a69714a4843315165346636777353306c7835635255784a4a34524b574b41517475376242494e46454e5354765441357548596c57377249486576456a536433750a355553447641624378686c497a514b7941756557727232553036664c2b466e43775947634d6b79344b357a545474346d4f69712f2f6b637a384865476e6f5a670a3939614454615539615137336d46397277774944415141420a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d0a00":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:0:PSA_SUCCESS:0 PSA import/export RSA keypair: import PEM depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PEM_PARSE_C:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:1024:0:PSA_SUCCESS:0 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:0:PSA_SUCCESS:0 PSA import: reject raw data key of length 0 # The spec allows either INVALID_ARGUMENT or NOT_SUPPORTED diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 8df2ceafef..7e9a743e7e 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -15,6 +15,9 @@ #include "test/asn1_helpers.h" #include "test/psa_crypto_helpers.h" #include "test/psa_exercise_key.h" +#if defined(PSA_CRYPTO_DRIVER_TEST) +#include "test/drivers/test_driver.h" +#endif /* If this comes up, it's a bug in the test code or in the test data. */ #define UNUSED 0xdeadbeef @@ -484,6 +487,7 @@ exit: void import_export( data_t *data, int type_arg, int usage_arg, int alg_arg, + int lifetime_arg, int expected_bits, int export_size_delta, int expected_export_status_arg, @@ -494,6 +498,7 @@ void import_export( data_t *data, psa_algorithm_t alg = alg_arg; psa_status_t expected_export_status = expected_export_status_arg; psa_status_t status; + psa_key_lifetime_t lifetime = lifetime_arg; unsigned char *exported = NULL; unsigned char *reexported = NULL; size_t export_size; @@ -508,6 +513,7 @@ void import_export( data_t *data, ASSERT_ALLOC( reexported, export_size ); PSA_ASSERT( psa_crypto_init( ) ); + psa_set_key_lifetime( &attributes, lifetime ); psa_set_key_usage_flags( &attributes, usage_arg ); psa_set_key_algorithm( &attributes, alg ); psa_set_key_type( &attributes, type ); @@ -543,8 +549,11 @@ void import_export( data_t *data, * this validates the canonical representations. For canonical inputs, * this doesn't directly validate the implementation, but it still helps * by cross-validating the test data with the sanity check code. */ - if( ! mbedtls_test_psa_exercise_key( key, usage_arg, 0 ) ) - goto exit; + if( !psa_key_lifetime_is_external( lifetime ) ) + { + if( ! mbedtls_test_psa_exercise_key( key, usage_arg, 0 ) ) + goto exit; + } if( canonical_input ) ASSERT_COMPARE( data->x, data->len, exported, exported_length ); @@ -552,17 +561,17 @@ void import_export( data_t *data, { mbedtls_svc_key_id_t key2 = MBEDTLS_SVC_KEY_ID_INIT; PSA_ASSERT( psa_import_key( &attributes, exported, exported_length, - &key2 ) ); + &key2 ) ); PSA_ASSERT( psa_export_key( key2, - reexported, - export_size, - &reexported_length ) ); + reexported, + export_size, + &reexported_length ) ); ASSERT_COMPARE( exported, exported_length, - reexported, reexported_length ); + reexported, reexported_length ); PSA_ASSERT( psa_destroy_key( key2 ) ); } TEST_ASSERT( exported_length <= - PSA_EXPORT_KEY_OUTPUT_SIZE( type, + PSA_EXPORT_KEY_OUTPUT_SIZE( type, psa_get_key_bits( &got_attributes ) ) ); TEST_ASSERT( exported_length <= PSA_EXPORT_KEY_PAIR_MAX_SIZE ); @@ -577,7 +586,7 @@ exit: * thus reset them as required. */ psa_reset_key_attributes( &got_attributes ); - + psa_destroy_key( key ) ; mbedtls_free( exported ); mbedtls_free( reexported ); PSA_DONE( ); @@ -588,6 +597,7 @@ exit: void import_export_public_key( data_t *data, int type_arg, int alg_arg, + int lifetime_arg, int export_size_delta, int expected_export_status_arg, data_t *expected_public_key ) @@ -597,6 +607,7 @@ void import_export_public_key( data_t *data, psa_algorithm_t alg = alg_arg; psa_status_t expected_export_status = expected_export_status_arg; psa_status_t status; + psa_key_lifetime_t lifetime = lifetime_arg; unsigned char *exported = NULL; size_t export_size = expected_public_key->len + export_size_delta; size_t exported_length = INVALID_EXPORT_LENGTH; @@ -604,6 +615,7 @@ void import_export_public_key( data_t *data, PSA_ASSERT( psa_crypto_init( ) ); + psa_set_key_lifetime( &attributes, lifetime ); psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_EXPORT ); psa_set_key_algorithm( &attributes, alg ); psa_set_key_type( &attributes, type ); @@ -614,8 +626,8 @@ void import_export_public_key( data_t *data, /* Export the public key */ ASSERT_ALLOC( exported, export_size ); status = psa_export_public_key( key, - exported, export_size, - &exported_length ); + exported, export_size, + &exported_length ); TEST_EQUAL( status, expected_export_status ); if( status == PSA_SUCCESS ) { @@ -632,7 +644,6 @@ void import_export_public_key( data_t *data, ASSERT_COMPARE( expected_public_key->x, expected_public_key->len, exported, exported_length ); } - exit: /* * Key attributes may have been returned by psa_get_key_attributes() From 6ed4bda2c69cc81cec1a92364a8c116718dc05e7 Mon Sep 17 00:00:00 2001 From: Archana Date: Wed, 4 Aug 2021 10:47:15 +0530 Subject: [PATCH 477/966] pre-existing validation extended The validation against key width and max key bits is extended to all key types from the existing validation for only symmetric keys. Signed-off-by: Archana --- library/psa_crypto.c | 20 ++++++++++--------- .../src/drivers/test_driver_key_management.c | 9 --------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index cea165cbbc..aea9f9c72b 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -558,15 +558,6 @@ psa_status_t psa_import_key_into_slot( { *bits = PSA_BYTES_TO_BITS( data_length ); - /* Ensure that the bytes-to-bits conversion hasn't overflown. */ - if( data_length > SIZE_MAX / 8 ) - return( status ); - - /* Enforce a size limit, and in particular ensure that the bit - * size fits in its representation type. */ - if( ( *bits ) > PSA_MAX_KEY_BITS ) - return( status ); - status = psa_validate_unstructured_key_bit_size( attributes->core.type, *bits ); if( status != PSA_SUCCESS ) return( status ); @@ -1901,6 +1892,10 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes, if( data_length == 0 ) return( PSA_ERROR_INVALID_ARGUMENT ); + /* Ensure that the bytes-to-bits conversion hasn't overflown. */ + if( data_length > SIZE_MAX / 8 ) + return( PSA_ERROR_NOT_SUPPORTED ); + status = psa_start_key_creation( PSA_KEY_CREATION_IMPORT, attributes, &slot, &driver ); if( status != PSA_SUCCESS ) @@ -1941,6 +1936,13 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes, goto exit; } + /* Enforce a size limit, and in particular ensure that the bit + * size fits in its representation type.*/ + if( bits > PSA_MAX_KEY_BITS ) + { + status = PSA_ERROR_NOT_SUPPORTED; + goto exit; + } status = psa_validate_optional_attributes( slot, attributes ); if( status != PSA_SUCCESS ) goto exit; diff --git a/tests/src/drivers/test_driver_key_management.c b/tests/src/drivers/test_driver_key_management.c index 7ad7f73bdb..0f6a2bd583 100644 --- a/tests/src/drivers/test_driver_key_management.c +++ b/tests/src/drivers/test_driver_key_management.c @@ -271,15 +271,6 @@ psa_status_t mbedtls_test_opaque_import_key( { *bits = PSA_BYTES_TO_BITS( data_length ); - /* Ensure that the bytes-to-bits conversion hasn't overflown. */ - if( data_length > SIZE_MAX / 8 ) - goto exit; - - /* Enforce a size limit, and in particular ensure that the bit - * size fits in its representation type. */ - if( ( *bits ) > PSA_MAX_KEY_BITS ) - goto exit; - status = psa_validate_unstructured_key_bit_size( attributes->core.type, *bits ); if( status != PSA_SUCCESS ) goto exit; From 8a180368fb16b922b9508ed52951c65a58cb6640 Mon Sep 17 00:00:00 2001 From: Archana Date: Mon, 5 Jul 2021 02:18:48 +0530 Subject: [PATCH 478/966] Add opaque test driver support for copy key A minimal test driver extension is added to support copy of opaque keys within the same location. Test vector support is extended to cover opaque keys. Signed-off-by: Archana --- library/psa_crypto.c | 57 ++- library/psa_crypto_driver_wrappers.c | 41 ++ library/psa_crypto_driver_wrappers.h | 4 + tests/include/test/drivers/key_management.h | 9 + .../src/drivers/test_driver_key_management.c | 20 + tests/suites/test_suite_psa_crypto.data | 358 ++++++++++++------ tests/suites/test_suite_psa_crypto.function | 25 +- 7 files changed, 378 insertions(+), 136 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index aea9f9c72b..ee16983416 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2015,10 +2015,11 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, psa_key_slot_t *target_slot = NULL; psa_key_attributes_t actual_attributes = *specified_attributes; psa_se_drv_table_entry_t *driver = NULL; + size_t storage_size = 0; *target_key = MBEDTLS_SVC_KEY_ID_INIT; - status = psa_get_and_lock_transparent_key_slot_with_policy( + status = psa_get_and_lock_key_slot_with_policy( source_key, &source_slot, PSA_KEY_USAGE_COPY, 0 ); if( status != PSA_SUCCESS ) goto exit; @@ -2038,31 +2039,49 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, &target_slot, &driver ); if( status != PSA_SUCCESS ) goto exit; - -#if defined(MBEDTLS_PSA_CRYPTO_SE_C) - if( driver != NULL ) + if( PSA_KEY_LIFETIME_GET_LOCATION( target_slot->attr.lifetime ) != + PSA_KEY_LIFETIME_GET_LOCATION( source_slot->attr.lifetime ) ) { - /* Copying to a secure element is not implemented yet. */ + /* + * If the source and target keys are stored across different locations, + * the source key would need to be exported as plaintext and re-imported + * in the other location. This has security implications which have not + * been fully mapped.For now, this can be acheived through + * appropriate API invocations from the application, if needed. + * */ status = PSA_ERROR_NOT_SUPPORTED; goto exit; } -#endif /* MBEDTLS_PSA_CRYPTO_SE_C */ - + /* + * When the source and target keys are within the same location, + * - For transparent keys it is a blind copy sans any driver invocation, + * - For opaque keys this translates to an invocation of the drivers' + * copy_key entry point through the dispatch layer. + * */ if( psa_key_lifetime_is_external( actual_attributes.core.lifetime ) ) { - /* - * Copying through an opaque driver is not implemented yet, consider - * a lifetime with an external location as an invalid parameter for - * now. - */ - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; + status = psa_driver_wrapper_get_key_buffer_size( &actual_attributes, + &storage_size ); + if( status != PSA_SUCCESS ) + goto exit; + status = psa_allocate_buffer_to_slot( target_slot, storage_size ); + if( status != PSA_SUCCESS ) + goto exit; + status = psa_driver_wrapper_copy_key( &actual_attributes, + source_slot->key.data, + source_slot->key.bytes, + target_slot->key.data, + target_slot->key.bytes, + &target_slot->key.bytes ); + if( status != PSA_SUCCESS ) + goto exit; + } + else + { + status = psa_copy_key_material( source_slot, target_slot ); + if( status != PSA_SUCCESS ) + goto exit; } - - status = psa_copy_key_material( source_slot, target_slot ); - if( status != PSA_SUCCESS ) - goto exit; - status = psa_finish_key_creation( target_slot, driver, target_key ); exit: if( status != PSA_SUCCESS ) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index e145dd4d62..1597b00d0f 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -782,6 +782,47 @@ psa_status_t psa_driver_wrapper_get_builtin_key( } } +psa_status_t psa_driver_wrapper_copy_key( + psa_key_attributes_t *attributes, + const uint8_t *source_key, size_t source_key_size, + uint8_t *target_key_buffer, size_t target_buffer_size, size_t *key_length ) +{ + psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; + psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); +#if defined(MBEDTLS_PSA_CRYPTO_SE_C) + const psa_drv_se_t *drv; + psa_drv_se_context_t *drv_context; + + if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) ) + { + /* Copying to a secure element is not implemented yet. */ + return( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_CRYPTO_SE_C */ + + switch( location ) + { +#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) +#if defined(PSA_CRYPTO_DRIVER_TEST) + case PSA_CRYPTO_TEST_DRIVER_LOCATION: + return( mbedtls_test_opaque_copy_key( attributes, source_key, + source_key_size, + target_key_buffer, + target_buffer_size, + key_length ) ); +#endif /* PSA_CRYPTO_DRIVER_TEST */ +#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ + default: + (void)source_key; + (void)source_key_size; + (void)target_key_buffer; + (void)target_buffer_size; + (void)key_length; + status = PSA_ERROR_INVALID_ARGUMENT; + } + return( status ); +} + /* * Cipher functions */ diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h index 99455a8a6c..7c45fbfce2 100644 --- a/library/psa_crypto_driver_wrappers.h +++ b/library/psa_crypto_driver_wrappers.h @@ -100,6 +100,10 @@ psa_status_t psa_driver_wrapper_get_builtin_key( psa_key_attributes_t *attributes, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length ); +psa_status_t psa_driver_wrapper_copy_key( + psa_key_attributes_t *attributes, + const uint8_t *source_key, size_t source_key_size, + uint8_t *target_key_buffer, size_t target_buffer_size, size_t *key_length ); /* * Cipher functions */ diff --git a/tests/include/test/drivers/key_management.h b/tests/include/test/drivers/key_management.h index 3cde1aaff9..ed0b5ebbca 100644 --- a/tests/include/test/drivers/key_management.h +++ b/tests/include/test/drivers/key_management.h @@ -113,5 +113,14 @@ psa_status_t mbedtls_test_opaque_get_builtin_key( psa_key_attributes_t *attributes, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length ); +psa_status_t mbedtls_test_opaque_copy_key( + psa_key_attributes_t *attributes, + const uint8_t *source_key, + size_t source_key_size, + uint8_t *target_key_buffer, + size_t target_buffer_size, + size_t *key_length ); + + #endif /* PSA_CRYPTO_DRIVER_TEST */ #endif /* PSA_CRYPTO_TEST_DRIVERS_KEY_MANAGEMENT_H */ diff --git a/tests/src/drivers/test_driver_key_management.c b/tests/src/drivers/test_driver_key_management.c index 0f6a2bd583..fec0a3e484 100644 --- a/tests/src/drivers/test_driver_key_management.c +++ b/tests/src/drivers/test_driver_key_management.c @@ -606,4 +606,24 @@ psa_status_t mbedtls_test_opaque_get_builtin_key( return( PSA_ERROR_DOES_NOT_EXIST ); } } + +psa_status_t mbedtls_test_opaque_copy_key( + psa_key_attributes_t *attributes, + const uint8_t *source_key_buffer, size_t source_key_buffer_size, + uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length) +{ + /* This is a case where the opaque test driver emulates an SE without storage. + * With that all key context is stored in the wrapped buffer. + * So no additional house keeping is necessary to reference count the + * copied keys. This could change when the opaque test driver is extended + * to support SE with storage, or to emulate an SE without storage but + * still holding some slot references */ + if( source_key_buffer_size > key_buffer_size ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + memcpy( key_buffer, source_key_buffer, source_key_buffer_size ); + *key_buffer_length = source_key_buffer_size; + (void)attributes; + return( PSA_SUCCESS ); +} + #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 89254cd374..94a4c71f56 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -23,28 +23,28 @@ depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES import_export:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:256:0:PSA_SUCCESS:1 PSA import/export raw: 1 bytes, opaque -depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):8:0:PSA_SUCCESS:1 +depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):8:0:PSA_SUCCESS:1 PSA import/export raw: 1 bytes, larger buffer, opaque -depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):8:1:PSA_SUCCESS:1 +depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):8:1:PSA_SUCCESS:1 PSA import/export raw: 2 bytes, buffer too small, opaque depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"2a2b":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):16:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 +import_export:"2a2b":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):16:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export AES-128, opaque depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):128:0:PSA_SUCCESS:1 +import_export:"0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):128:0:PSA_SUCCESS:1 PSA import/export AES-192, opaque depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):192:0:PSA_SUCCESS:1 +import_export:"0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):192:0:PSA_SUCCESS:1 PSA import/export AES-256, opaque depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 +import_export:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import: bad usage flag import_with_policy:PSA_KEY_TYPE_RAW_DATA:0x40000000:0:PSA_ERROR_INVALID_ARGUMENT @@ -107,55 +107,55 @@ import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa24 PSA import/export RSA public key: good, 1024-bit, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:0:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:0:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (+1 byte), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:1:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:1:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2-1), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:161:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:161:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:162:PSA_SUCCESS:1 +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:162:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2+1), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:163:PSA_SUCCESS:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:163:PSA_SUCCESS:1 PSA import/export RSA public key: export buffer too small, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 +import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export RSA keypair: good, 1024-bit, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:0:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:0:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (+1 byte), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:1:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:1:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2-1), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:609:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:609:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:610:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:610:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2+1), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:611:PSA_SUCCESS:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:611:PSA_SUCCESS:1 PSA import/export RSA keypair: export buffer too small, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export RSA keypair: trailing garbage ignored, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:-1:PSA_SUCCESS:0 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:-1:PSA_SUCCESS:0 PSA import RSA keypair: truncated depends_on:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C @@ -191,19 +191,19 @@ import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5 PSA import/export-public RSA public key: good, 1024-bit, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" +import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA keypair: good, 1024-bit, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" +import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA public key: buffer too small, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" +import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA keypair: buffer too small, opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" +import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export RSA public key: 1016-bit (good) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C @@ -215,11 +215,11 @@ import_export:"3082025802010002818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5f PSA import/export RSA public key: 1016-bit (good), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"30818802818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1016:0:PSA_SUCCESS:1 +import_export:"30818802818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1016:0:PSA_SUCCESS:1 PSA import/export RSA keypair: 1016-bit (good), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025802010002818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001028180009dd9c34411e769a540e7e9c03682abb4e95ad2d5c2297c6b7eb2fa5415dfa081adb42bff344ea36a31e8bb36593fa69e843f053fa916f8c6ae4c423fa4c1edbcfa7e8079bc19a738f4f861c198cf277d2c89fe3deab06db5a3a09f8d1622033a618fbfbab92b50a13f77cdb53b56d38bec4cdd8cbe65e8b30ab4e77565842102400eec9285833f973372458f354bff7d35bcb04f3b26f5b58a025887a966ca951b6667651a46034bbc99f9d688dfbcb4297a4d86824dd73abdfa7deeb232b1642902400dcbe74d51f3b93afe2a22e2be0c3c56911ef771fd8eb01f64d95d018315baf4144aeb957be95a77f17f2b8a12c2d3b87a1281f9c66d839fa603fbbe7381783d0240035398154a7c1227d580cbbb05859d532d0bdf9d3fc1e5052e20ad9c84dd02ff6884037527c5f44bc5c67a9b67c39824e6ae011d6a5c5f2b997a188a7fe22a810240076bf41ec5023e57bcd87ff1c7d89f30d65a793469f933478021ea056135f45f4ef74aaa1c8158b883422cf2d6cad5c83c6aee5ea65ecd5ab99d14f4cc000ee5024006d13905db5556627066596da3383458aea6ba5e2f94ccc5b922117a1ed3ae7a26c59e68c3885a41b366f1a5c8bff7ec8853ef8d32addb818141352b2da553dc":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1016:0:PSA_SUCCESS:1 +import_export:"3082025802010002818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001028180009dd9c34411e769a540e7e9c03682abb4e95ad2d5c2297c6b7eb2fa5415dfa081adb42bff344ea36a31e8bb36593fa69e843f053fa916f8c6ae4c423fa4c1edbcfa7e8079bc19a738f4f861c198cf277d2c89fe3deab06db5a3a09f8d1622033a618fbfbab92b50a13f77cdb53b56d38bec4cdd8cbe65e8b30ab4e77565842102400eec9285833f973372458f354bff7d35bcb04f3b26f5b58a025887a966ca951b6667651a46034bbc99f9d688dfbcb4297a4d86824dd73abdfa7deeb232b1642902400dcbe74d51f3b93afe2a22e2be0c3c56911ef771fd8eb01f64d95d018315baf4144aeb957be95a77f17f2b8a12c2d3b87a1281f9c66d839fa603fbbe7381783d0240035398154a7c1227d580cbbb05859d532d0bdf9d3fc1e5052e20ad9c84dd02ff6884037527c5f44bc5c67a9b67c39824e6ae011d6a5c5f2b997a188a7fe22a810240076bf41ec5023e57bcd87ff1c7d89f30d65a793469f933478021ea056135f45f4ef74aaa1c8158b883422cf2d6cad5c83c6aee5ea65ecd5ab99d14f4cc000ee5024006d13905db5556627066596da3383458aea6ba5e2f94ccc5b922117a1ed3ae7a26c59e68c3885a41b366f1a5c8bff7ec8853ef8d32addb818141352b2da553dc":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1016:0:PSA_SUCCESS:1 PSA import RSA public key: 1022-bit (not supported) depends_on:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_RSA_C @@ -367,55 +367,55 @@ import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa24 PSA import/export EC secp224r1 key pair: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):224:0:PSA_SUCCESS:1 +import_export:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):224:0:PSA_SUCCESS:1 PSA import/export-public EC secp224r1: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"041693a290f7f0b571fe2b41d5d84b01327631f4a860f995fa332c097f54192bb10f00113f2affb13c1a24ce44914571a95440ae014a00cbf7" +import_export_public_key:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"041693a290f7f0b571fe2b41d5d84b01327631f4a860f995fa332c097f54192bb10f00113f2affb13c1a24ce44914571a95440ae014a00cbf7" PSA import/export EC secp256r1 key pair: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 +import_export:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import/export-public EC secp256r1: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"047772656f814b399279d5e1f1781fac6f099a3c5ca1b0e35351834b08b65e0b572590cdaf8f769361bcf34acfc11e5e074e8426bdde04be6e653945449617de45" +import_export_public_key:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"047772656f814b399279d5e1f1781fac6f099a3c5ca1b0e35351834b08b65e0b572590cdaf8f769361bcf34acfc11e5e074e8426bdde04be6e653945449617de45" PSA import/export EC secp384r1 key pair: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):384:0:PSA_SUCCESS:1 +import_export:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):384:0:PSA_SUCCESS:1 PSA import/export-public EC secp384r1: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04d9c662b50ba29ca47990450e043aeaf4f0c69b15676d112f622a71c93059af999691c5680d2b44d111579db12f4a413a2ed5c45fcfb67b5b63e00b91ebe59d09a6b1ac2c0c4282aa12317ed5914f999bc488bb132e8342cc36f2ca5e3379c747" +import_export_public_key:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04d9c662b50ba29ca47990450e043aeaf4f0c69b15676d112f622a71c93059af999691c5680d2b44d111579db12f4a413a2ed5c45fcfb67b5b63e00b91ebe59d09a6b1ac2c0c4282aa12317ed5914f999bc488bb132e8342cc36f2ca5e3379c747" PSA import/export EC secp521r1 key pair: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):521:0:PSA_SUCCESS:1 +import_export:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):521:0:PSA_SUCCESS:1 PSA import/export-public EC secp521r1: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1" +import_export_public_key:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1" PSA import/export EC brainpool256r1 key pair: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY::PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 +import_export:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY::PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool256r1: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d" +import_export_public_key:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d" PSA import/export EC brainpool384r1 key pair: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):384:0:PSA_SUCCESS:1 +import_export:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):384:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool384r1: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04719f9d093a627e0d350385c661cebf00c61923566fe9006a3107af1d871bc6bb68985fd722ea32be316f8e783b7cd1957785f66cfc0cb195dd5c99a8e7abaa848553a584dfd2b48e76d445fe00dd8be59096d877d4696d23b4bc8db14724e66a" +import_export_public_key:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04719f9d093a627e0d350385c661cebf00c61923566fe9006a3107af1d871bc6bb68985fd722ea32be316f8e783b7cd1957785f66cfc0cb195dd5c99a8e7abaa848553a584dfd2b48e76d445fe00dd8be59096d877d4696d23b4bc8db14724e66a" PSA import/export EC brainpool512r1 key pair: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):512:0:PSA_SUCCESS:1 +import_export:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):512:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool512r1: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512:MBEDTLS_PSA_CRYPTO_DRIVERS @@ -423,55 +423,55 @@ import_export_public_key:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51 PSA import/export EC curve25519 key pair: good (already properly masked), opaque depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 +import_export:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 PSA import/export EC curve25519 key pair: unmasked input (check export-import-export yields properly masked output), opaque depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:0 +import_export:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:0 PSA import/export-public EC curve25519: accept unmasked input, opaque depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" +import_export_public_key:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" PSA import/export-public EC curve25519: accept masked input, opaque depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" +import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" PSA import/export-public: cannot export-public a symmetric key, opaque depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):0:PSA_ERROR_INVALID_ARGUMENT:"2b7e151628aed2a6abf7158809cf4f3c" +import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_ERROR_INVALID_ARGUMENT:"2b7e151628aed2a6abf7158809cf4f3c" PSA import/export EC secp256r1 public key: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"04dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 +import_export:"04dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import/export EC secp521r1 public key: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):521:0:PSA_SUCCESS:1 +import_export:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):521:0:PSA_SUCCESS:1 PSA import/export EC brainpoolP256r1 public key: good, opaque depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 +import_export:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import/export curve25519 public key: good, opaque depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 +import_export:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 PSA import/export AES key: policy forbids export, opaque depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):128:0:PSA_ERROR_NOT_PERMITTED:1 +import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):128:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export HMAC key: policy forbids export, opaque depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):256:0:PSA_ERROR_NOT_PERMITTED:1 +import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export RSA keypair: policy forbids export (crypt), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_CRYPT:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_RSA_PKCS1V15_CRYPT:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:0:PSA_ERROR_NOT_PERMITTED:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_RSA_PKCS1V15_CRYPT:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export RSA keypair: policy forbids export (sign), opaque depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS -import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, PSA_CRYPTO_TEST_DRIVER_LOCATION ):1024:0:PSA_ERROR_NOT_PERMITTED:1 +import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:0:PSA_ERROR_NOT_PERMITTED:1 # Test PEM import. Note that this is not a PSA feature, it's an Mbed TLS # extension which we may drop in the future. @@ -1049,225 +1049,361 @@ depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_SHA_256:PSA_WANT_ALG_ECDSA:PSA_WANT_KE key_policy_alg2:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256) Copy key: raw, 1 byte -copy_success:PSA_KEY_USAGE_COPY:0:0:PSA_KEY_TYPE_RAW_DATA:"2a":1:-1:-1:0:PSA_KEY_USAGE_COPY:0:0 +copy_success:PSA_KEY_USAGE_COPY:0:0:0:PSA_KEY_TYPE_RAW_DATA:"2a":1:-1:-1:0:0:PSA_KEY_USAGE_COPY:0:0 Copy key: AES, copy attributes depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":1:-1:-1:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":1:-1:-1:0:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 Copy key: AES, same usage flags depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 Copy key: AES, fewer usage flags (-EXPORT) depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: AES, fewer usage flags (-COPY) depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 Copy key: AES, 1 more usage flag depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: AES, 2 more usage flags depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: AES, intersect usage flags #1 depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: AES, intersect usage flags #2 depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:0:PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: RSA key pair, same usage flags depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, extended usage flags depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, fewer usage flags depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, more usage flags depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, intersect usage flags #0 depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:0:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, intersect usage flags #1 depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, wildcard algorithm in source depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, wildcard algorithm in target depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, wildcard algorithm in source and target depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0 Copy key: source=ECDSA+ECDH, target=ECDSA+ECDH depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH Copy key: source=ECDSA+ECDH, target=ECDSA+ECDH, extended usage flags depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH Copy key: source=ECDSA+ECDH, target=ECDSA+0 depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0 Copy key: source=ECDSA+ECDH, target=0+ECDH depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:0:PSA_ALG_ECDH:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:0:PSA_ALG_ECDH +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:0:PSA_ALG_ECDH:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:0:PSA_ALG_ECDH Copy key: source=ECDSA(any)+ECDH, target=ECDSA(SHA256)+ECDH depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):PSA_ALG_ECDH:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):PSA_ALG_ECDH:0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH Copy key: source=ECDH+ECDSA(any), target=ECDH+ECDSA(SHA256) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256) +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256) + +Copy key: raw, 1 byte, opaque +depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY:0:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RAW_DATA:"2a":1:-1:-1:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY:0:0 + +Copy key: AES, copy attributes, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":1:-1:-1:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 + +Copy key: AES, same usage flags, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 + +Copy key: AES, fewer usage flags (-EXPORT), opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 + +Copy key: AES, fewer usage flags (-COPY), opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 + +Copy key: AES, 1 more usage flag, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 + +Copy key: AES, 2 more usage flags, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 + +Copy key: AES, intersect usage flags #1, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 + +Copy key: AES, intersect usage flags #2, opaque +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 + +Copy key: RSA key pair, same usage flags, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 + +Copy key: RSA key pair, extended usage flags, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 + +Copy key: RSA key pair, fewer usage flags, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 + +Copy key: RSA key pair, more usage flags, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 + +Copy key: RSA key pair, intersect usage flags #0, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 + +Copy key: RSA key pair, intersect usage flags #1, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 + +Copy key: RSA key pair, wildcard algorithm in source, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 + +Copy key: RSA key pair, wildcard algorithm in target, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 + +Copy key: RSA key pair, wildcard algorithm in source and target, opaque +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0 + +Copy key: source=ECDSA+ECDH, target=ECDSA+ECDH, opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH + +Copy key: source=ECDSA+ECDH, target=ECDSA+ECDH, extended usage flags, opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH + +Copy key: source=ECDSA+ECDH, target=ECDSA+0, opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0 + +Copy key: source=ECDSA+ECDH, target=0+ECDH, opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:0:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:0:PSA_ALG_ECDH + +Copy key: source=ECDSA(any)+ECDH, target=ECDSA(SHA256)+ECDH, opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH + +Copy key: source=ECDH+ECDSA(any), target=ECDH+ECDSA(SHA256), opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256) Copy fail: raw data, no COPY flag -copy_fail:PSA_KEY_USAGE_EXPORT:0:0:PSA_KEY_TYPE_RAW_DATA:"404142434445464748494a4b4c4d4e4f":0:0:PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_NOT_PERMITTED +copy_fail:PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_TYPE_RAW_DATA:"404142434445464748494a4b4c4d4e4f":0:0:PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_NOT_PERMITTED Copy key: AES, no COPY flag depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_fail:PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:0:PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_NOT_PERMITTED +copy_fail:PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:0:PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_NOT_PERMITTED Copy fail: AES, incompatible target policy depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_CBC_NO_PADDING:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_CBC_NO_PADDING:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy key: source=MAC, target=MAC extended usage flags depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_HMAC(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_HMAC(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_HMAC(PSA_ALG_SHA_256):0 +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_HMAC(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_HMAC(PSA_ALG_SHA_256):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_HMAC(PSA_ALG_SHA_256):0 Copy key: source=MAC min-length, target=MAC length > min-length depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0 +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0 Copy key: source=MAC min-length, target=MAC length = min-length depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 Copy fail: source=MAC min-length, target=MAC length < min-length depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_fail:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:256:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 16):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:256:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 16):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy key: source=MAC min-length, target=MAC min-length, src > tgt depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0 +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0 Copy key: source=MAC min-length, target=MAC min-length, src = tgt depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 Copy key: source=MAC min-length, target=MAC min-length, src < tgt depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0 +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0 Copy fail: source=MAC, target=MAC min-length > length depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_fail:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:256:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:256:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 24):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy key: source=MAC, target=MAC min-length = length depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 Copy key: source=MAC, target=MAC min-length < length depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC -copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 16):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:0:PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 16):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 Copy key: source=AEAD min-length, target=AEAD length > min-length depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0 +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0 Copy key: source=AEAD min-length, target=AEAD length = min-length depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0 +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0 Copy fail: source=AEAD min-length, target=AEAD length < min-length depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_fail:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:128:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:128:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy key: source=AEAD min-length, target=AEAD min-length, src > tgt depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 Copy key: source=AEAD min-length, target=AEAD min-length, src = tgt depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 Copy key: source=AEAD min-length, target=AEAD min-length, src < tgt depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 + +Copy key: source=MAC, target=MAC min-length = length, opaque +depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 + +Copy key: source=MAC, target=MAC min-length < length, opaque +depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 16):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 + +Copy key: source=AEAD min-length, target=AEAD length > min-length, opaque +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0 + +Copy key: source=AEAD min-length, target=AEAD length = min-length, opaque +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0 + +Copy key: source=AEAD min-length, target=AEAD min-length, src > tgt, opaque +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 + +Copy key: source=AEAD min-length, target=AEAD min-length, src = tgt, opaque +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION )::PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 + +Copy key: source=AEAD min-length, target=AEAD min-length, src < tgt, opaque +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 Copy fail: source=AEAD, target=AEAD min-length > length depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_fail:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:128:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:128:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy key: source=AEAD, target=AEAD min-length = length depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0 +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0 Copy key: source=AEAD, target=AEAD min-length < length depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0 +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0 + +Copy key: source=AEAD, target=AEAD min-length = length, opaque +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0 + +Copy key: source=AEAD, target=AEAD min-length < length, opaque +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0 Copy fail: RSA, incompatible target policy (source wildcard) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy fail: RSA, incompatible target policy (target wildcard) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PSS(PSA_ALG_ANY_HASH):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PSS(PSA_ALG_ANY_HASH):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy fail: RSA, incompatible target policy (source and target wildcard) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PSS(PSA_ALG_ANY_HASH):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PSS(PSA_ALG_ANY_HASH):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy fail: RSA, ANY_HASH is not meaningful with OAEP depends_on:PSA_WANT_ALG_RSA_OAEP:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_OAEP(PSA_ALG_ANY_HASH):0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_OAEP(PSA_ALG_SHA_256):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_OAEP(PSA_ALG_ANY_HASH):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:0:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_OAEP(PSA_ALG_SHA_256):0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy fail: incorrect type in attributes depends_on:PSA_WANT_KEY_TYPE_AES -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:0:0:PSA_KEY_TYPE_RAW_DATA:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_TYPE_RAW_DATA:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy fail: incorrect size in attributes -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:0:0:PSA_KEY_TYPE_RAW_DATA:"404142434445464748494a4b4c4d4e4f":0:42:PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_TYPE_RAW_DATA:"404142434445464748494a4b4c4d4e4f":0:42:PSA_KEY_USAGE_EXPORT:0:0:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy fail: source=ECDSA(SHA224)+ECDH, target=ECDSA(SHA256)+ECDH depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_224:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_224):PSA_ALG_ECDH:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_224):PSA_ALG_ECDH:0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy fail: source=ECDH+ECDSA(SHA224), target=ECDH+ECDSA(SHA256) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_224:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256 -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_224):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_224):0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT Copy fail: AES, invalid persistent key identifier in attributes depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_STORAGE_C -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_LIFETIME_PERSISTENT:PSA_ERROR_INVALID_ARGUMENT +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_LIFETIME_PERSISTENT:PSA_ERROR_INVALID_ARGUMENT Copy fail: AES, invalid lifetime (unknown location) in attributes -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_STORAGE_C -copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:1:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_LIFETIME_PERSISTENT, 11):PSA_ERROR_INVALID_ARGUMENT +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_STORAGE_C:!MBEDTLS_PSA_CRYPTO_DRIVERS +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:1:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_DEFAULT, 11):PSA_ERROR_INVALID_ARGUMENT + +Copy fail: AES, across locations (unsupported) in attributes +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:1:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_VOLATILE, 0):PSA_ERROR_NOT_SUPPORTED Hash operation object initializers zero properly hash_operation_init: diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 7e9a743e7e..2b5727345d 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -17,6 +17,9 @@ #include "test/psa_exercise_key.h" #if defined(PSA_CRYPTO_DRIVER_TEST) #include "test/drivers/test_driver.h" +#define TEST_DRIVER_LOCATION PSA_CRYPTO_TEST_DRIVER_LOCATION +#else +#define TEST_DRIVER_LOCATION 0x7fffff #endif /* If this comes up, it's a bug in the test code or in the test data. */ @@ -1305,10 +1308,12 @@ exit: /* BEGIN_CASE */ void copy_success( int source_usage_arg, int source_alg_arg, int source_alg2_arg, + unsigned int source_lifetime_arg, int type_arg, data_t *material, int copy_attributes, int target_usage_arg, int target_alg_arg, int target_alg2_arg, + unsigned int target_lifetime_arg, int expected_usage_arg, int expected_alg_arg, int expected_alg2_arg ) { @@ -1317,6 +1322,8 @@ void copy_success( int source_usage_arg, psa_key_usage_t expected_usage = expected_usage_arg; psa_algorithm_t expected_alg = expected_alg_arg; psa_algorithm_t expected_alg2 = expected_alg2_arg; + psa_key_lifetime_t source_lifetime = source_lifetime_arg; + psa_key_lifetime_t target_lifetime = target_lifetime_arg; mbedtls_svc_key_id_t source_key = MBEDTLS_SVC_KEY_ID_INIT; mbedtls_svc_key_id_t target_key = MBEDTLS_SVC_KEY_ID_INIT; uint8_t *export_buffer = NULL; @@ -1328,6 +1335,7 @@ void copy_success( int source_usage_arg, psa_set_key_algorithm( &source_attributes, source_alg_arg ); psa_set_key_enrollment_algorithm( &source_attributes, source_alg2_arg ); psa_set_key_type( &source_attributes, type_arg ); + psa_set_key_lifetime( &source_attributes, source_lifetime); PSA_ASSERT( psa_import_key( &source_attributes, material->x, material->len, &source_key ) ); @@ -1337,9 +1345,8 @@ void copy_success( int source_usage_arg, if( copy_attributes ) { target_attributes = source_attributes; - /* Set volatile lifetime to reset the key identifier to 0. */ - psa_set_key_lifetime( &target_attributes, PSA_KEY_LIFETIME_VOLATILE ); } + psa_set_key_lifetime( &target_attributes, target_lifetime); if( target_usage_arg != -1 ) psa_set_key_usage_flags( &target_attributes, target_usage_arg ); @@ -1348,6 +1355,7 @@ void copy_success( int source_usage_arg, if( target_alg2_arg != -1 ) psa_set_key_enrollment_algorithm( &target_attributes, target_alg2_arg ); + /* Copy the key. */ PSA_ASSERT( psa_copy_key( source_key, &target_attributes, &target_key ) ); @@ -1375,10 +1383,13 @@ void copy_success( int source_usage_arg, export_buffer, length ); } - if( ! mbedtls_test_psa_exercise_key( target_key, expected_usage, expected_alg ) ) - goto exit; - if( ! mbedtls_test_psa_exercise_key( target_key, expected_usage, expected_alg2 ) ) - goto exit; + if( !psa_key_lifetime_is_external( target_lifetime ) ) + { + if( ! mbedtls_test_psa_exercise_key( target_key, expected_usage, expected_alg ) ) + goto exit; + if( ! mbedtls_test_psa_exercise_key( target_key, expected_usage, expected_alg2 ) ) + goto exit; + } PSA_ASSERT( psa_destroy_key( target_key ) ); @@ -1398,6 +1409,7 @@ exit: /* BEGIN_CASE */ void copy_fail( int source_usage_arg, int source_alg_arg, int source_alg2_arg, + int source_lifetime_arg, int type_arg, data_t *material, int target_type_arg, int target_bits_arg, int target_usage_arg, @@ -1418,6 +1430,7 @@ void copy_fail( int source_usage_arg, psa_set_key_algorithm( &source_attributes, source_alg_arg ); psa_set_key_enrollment_algorithm( &source_attributes, source_alg2_arg ); psa_set_key_type( &source_attributes, type_arg ); + psa_set_key_lifetime( &source_attributes, source_lifetime_arg ); PSA_ASSERT( psa_import_key( &source_attributes, material->x, material->len, &source_key ) ); From 449608bc610aa4c126f064b8cd6ac1339c6356dc Mon Sep 17 00:00:00 2001 From: Archana Date: Wed, 8 Sep 2021 15:36:05 +0530 Subject: [PATCH 479/966] Code style improvements Signed-off-by: Archana --- library/psa_crypto.c | 32 ++--- library/psa_crypto_core.h | 2 +- library/psa_crypto_driver_wrappers.c | 35 ++--- library/psa_crypto_driver_wrappers.h | 3 +- tests/include/test/drivers/key_management.h | 15 +-- .../src/drivers/test_driver_key_management.c | 127 +++++++++--------- 6 files changed, 107 insertions(+), 107 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ee16983416..b105890fb3 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -431,7 +431,7 @@ mbedtls_ecp_group_id mbedtls_ecc_group_of_psa( psa_ecc_family_t curve, * defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) */ psa_status_t psa_validate_unstructured_key_bit_size( psa_key_type_t type, - size_t bits ) + size_t bits ) { /* Check that the bit size is acceptable for the key type */ switch( type ) @@ -558,7 +558,8 @@ psa_status_t psa_import_key_into_slot( { *bits = PSA_BYTES_TO_BITS( data_length ); - status = psa_validate_unstructured_key_bit_size( attributes->core.type, *bits ); + status = psa_validate_unstructured_key_bit_size( attributes->core.type, + *bits ); if( status != PSA_SUCCESS ) return( status ); @@ -1892,7 +1893,7 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes, if( data_length == 0 ) return( PSA_ERROR_INVALID_ARGUMENT ); - /* Ensure that the bytes-to-bits conversion hasn't overflown. */ + /* Ensure that the bytes-to-bits conversion cannot overflow. */ if( data_length > SIZE_MAX / 8 ) return( PSA_ERROR_NOT_SUPPORTED ); @@ -1902,15 +1903,15 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes, goto exit; /* In the case of a transparent key or an opaque key stored in local - * storage( thus not in the case of the old-style secure element interface - * (MBEDTLS_PSA_CRYPTO_SE_C)),we have to allocate a buffer to hold the - * imported key material. */ + * storage ( thus not in the case of importing a key in a secure element + * with storage ( MBEDTLS_PSA_CRYPTO_SE_C ) ),we have to allocate a + * buffer to hold the imported key material. */ if( slot->key.data == NULL ) { if( psa_key_lifetime_is_external( attributes->core.lifetime ) ) { - status = psa_driver_wrapper_get_key_buffer_size_from_key_data( attributes, data, - data_length , &storage_size ); + status = psa_driver_wrapper_get_key_buffer_size_from_key_data( + attributes, data, data_length, &storage_size ); if( status != PSA_SUCCESS ) goto exit; } @@ -2046,7 +2047,7 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, * If the source and target keys are stored across different locations, * the source key would need to be exported as plaintext and re-imported * in the other location. This has security implications which have not - * been fully mapped.For now, this can be acheived through + * been fully mapped. For now, this can be achieved through * appropriate API invocations from the application, if needed. * */ status = PSA_ERROR_NOT_SUPPORTED; @@ -2054,14 +2055,14 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, } /* * When the source and target keys are within the same location, - * - For transparent keys it is a blind copy sans any driver invocation, + * - For transparent keys it is a blind copy without any driver invocation, * - For opaque keys this translates to an invocation of the drivers' * copy_key entry point through the dispatch layer. * */ if( psa_key_lifetime_is_external( actual_attributes.core.lifetime ) ) { status = psa_driver_wrapper_get_key_buffer_size( &actual_attributes, - &storage_size ); + &storage_size ); if( status != PSA_SUCCESS ) goto exit; status = psa_allocate_buffer_to_slot( target_slot, storage_size ); @@ -4197,7 +4198,8 @@ static psa_status_t psa_generate_derived_key_internal( if( psa_key_lifetime_is_external( attributes.core.lifetime ) ) { - status = psa_driver_wrapper_get_key_buffer_size( &attributes, &storage_size ); + status = psa_driver_wrapper_get_key_buffer_size( &attributes, + &storage_size ); if( status != PSA_SUCCESS ) goto exit; } @@ -5193,9 +5195,9 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes, goto exit; /* In the case of a transparent key or an opaque key stored in local - * storage( thus not in the case of the old-style secure element interface - * (MBEDTLS_PSA_CRYPTO_SE_C)),we have to allocate a buffer to hold the - * imported key material. */ + * storage ( thus not in the case of generating a key in a secure element + * with storage ( MBEDTLS_PSA_CRYPTO_SE_C ) ),we have to allocate a + * buffer to hold the generated key material. */ if( slot->key.data == NULL ) { if ( PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ) == diff --git a/library/psa_crypto_core.h b/library/psa_crypto_core.h index 4a3fa5079b..8c91b04d03 100644 --- a/library/psa_crypto_core.h +++ b/library/psa_crypto_core.h @@ -546,5 +546,5 @@ psa_status_t psa_verify_hash_builtin( * the two is not supported. */ psa_status_t psa_validate_unstructured_key_bit_size( psa_key_type_t type, - size_t bits ); + size_t bits ); #endif /* PSA_CRYPTO_CORE_H */ diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 1597b00d0f..00c17063af 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -380,10 +380,9 @@ psa_status_t psa_driver_wrapper_verify_hash( } } -/** calculate the key buffer size required to store the key material of a key +/** Calculate the key buffer size required to store the key material of a key * associated with an opaque driver from input key data. * - * * \param[in] attributes The key attributes * \param[in] data The input key data. * \param[in] data_length The input data length. @@ -399,7 +398,8 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data( size_t data_length, size_t *key_buffer_size ) { - psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); + psa_key_location_t location = + PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); psa_key_type_t key_type = attributes->core.type; *key_buffer_size = 0; @@ -459,7 +459,8 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size( return( PSA_SUCCESS ); } #endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */ - *key_buffer_size = mbedtls_test_opaque_size_function( key_type, key_bits ); + *key_buffer_size = mbedtls_test_opaque_size_function( key_type, + key_bits ); return( ( *key_buffer_size != 0 ) ? PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED ); #endif /* PSA_CRYPTO_DRIVER_TEST */ @@ -785,20 +786,12 @@ psa_status_t psa_driver_wrapper_get_builtin_key( psa_status_t psa_driver_wrapper_copy_key( psa_key_attributes_t *attributes, const uint8_t *source_key, size_t source_key_size, - uint8_t *target_key_buffer, size_t target_buffer_size, size_t *key_length ) + uint8_t *target_key_buffer, size_t target_key_buffer_size, + size_t *target_key_buffer_length ) { - psa_status_t status = PSA_ERROR_INVALID_ARGUMENT; - psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); -#if defined(MBEDTLS_PSA_CRYPTO_SE_C) - const psa_drv_se_t *drv; - psa_drv_se_context_t *drv_context; - - if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) ) - { - /* Copying to a secure element is not implemented yet. */ - return( PSA_ERROR_NOT_SUPPORTED ); - } -#endif /* MBEDTLS_PSA_CRYPTO_SE_C */ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + psa_key_location_t location = + PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); switch( location ) { @@ -808,16 +801,16 @@ psa_status_t psa_driver_wrapper_copy_key( return( mbedtls_test_opaque_copy_key( attributes, source_key, source_key_size, target_key_buffer, - target_buffer_size, - key_length ) ); + target_key_buffer_size, + target_key_buffer_length) ); #endif /* PSA_CRYPTO_DRIVER_TEST */ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ default: (void)source_key; (void)source_key_size; (void)target_key_buffer; - (void)target_buffer_size; - (void)key_length; + (void)target_key_buffer_size; + (void)target_key_buffer_length; status = PSA_ERROR_INVALID_ARGUMENT; } return( status ); diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h index 7c45fbfce2..c186228fa0 100644 --- a/library/psa_crypto_driver_wrappers.h +++ b/library/psa_crypto_driver_wrappers.h @@ -103,7 +103,8 @@ psa_status_t psa_driver_wrapper_get_builtin_key( psa_status_t psa_driver_wrapper_copy_key( psa_key_attributes_t *attributes, const uint8_t *source_key, size_t source_key_size, - uint8_t *target_key_buffer, size_t target_buffer_size, size_t *key_length ); + uint8_t *target_key_buffer, size_t target_key_buffer_size, + size_t *target_key_buffer_length ); /* * Cipher functions */ diff --git a/tests/include/test/drivers/key_management.h b/tests/include/test/drivers/key_management.h index ed0b5ebbca..16ee0b2160 100644 --- a/tests/include/test/drivers/key_management.h +++ b/tests/include/test/drivers/key_management.h @@ -51,19 +51,18 @@ static inline mbedtls_test_driver_key_management_hooks_t /* * In order to convert the plain text keys to Opaque, the size of the key is - * padded up by PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE in addition to xor mangling - * the key. The pad prefix needs to be accounted for while sizing for the key. + * padded up by PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE in addition to + * xor mangling the key. The pad prefix needs to be accounted for while + * sizing for the key. */ #define PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX 0xBEEFED00U -#define PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE sizeof( PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX ) - -size_t mbedtls_test_opaque_get_base_size(); +#define PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE sizeof( \ + PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX ) size_t mbedtls_test_opaque_size_function( const psa_key_type_t key_type, const size_t key_bits ); - extern mbedtls_test_driver_key_management_hooks_t mbedtls_test_driver_key_management_hooks; @@ -118,8 +117,8 @@ psa_status_t mbedtls_test_opaque_copy_key( const uint8_t *source_key, size_t source_key_size, uint8_t *target_key_buffer, - size_t target_buffer_size, - size_t *key_length ); + size_t target_key_buffer_size, + size_t *target_key_buffer_length); #endif /* PSA_CRYPTO_DRIVER_TEST */ diff --git a/tests/src/drivers/test_driver_key_management.c b/tests/src/drivers/test_driver_key_management.c index fec0a3e484..2683edcd8c 100644 --- a/tests/src/drivers/test_driver_key_management.c +++ b/tests/src/drivers/test_driver_key_management.c @@ -58,11 +58,13 @@ const uint8_t mbedtls_test_driver_ecdsa_pubkey[65] = /* - * This macro returns the base size for the key context when SE does not support storage. - * It is the size of the metadata that gets added to the wrapped key. - * In its test functionality the metadata is just some padded prefixing to the key. + * This macro returns the base size for the key context when SE does not + * support storage. It is the size of the metadata that gets added to the + * wrapped key. In its test functionality the metadata is just some padded + * prefixing to the key. */ -#define TEST_DRIVER_KEY_CONTEXT_BASE_SIZE PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE +#define TEST_DRIVER_KEY_CONTEXT_BASE_SIZE \ + PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX_SIZE size_t mbedtls_test_opaque_size_function( @@ -80,62 +82,70 @@ size_t mbedtls_test_opaque_size_function( return( key_buffer_size ); } -size_t mbedtls_test_opaque_get_base_size() +static size_t mbedtls_test_opaque_get_base_size() { return TEST_DRIVER_KEY_CONTEXT_BASE_SIZE; } /* - * The wrap function mbedtls_test_opaque_wrap_key pads and wraps the clear key. - * It expects the clear and wrap buffers to be passed in. - * key_buffer_size is the size of the clear key to be wrapped. - * wrap_buffer_size is the size of the output buffer wrap_key. - * The argument key_buffer_length is filled with the wrapped key_size on success. + * The wrap function mbedtls_test_opaque_wrap_key pads and wraps the + * clear key. It expects the clear and wrap buffers to be passed in. + * key_length is the size of the clear key to be wrapped. + * wrapped_key_buffer_size is the size of the output buffer wrap_key. + * The argument wrapped_key_buffer_length is filled with the wrapped + * key_size on success. * */ static psa_status_t mbedtls_test_opaque_wrap_key( - const uint8_t *key_buffer, - size_t key_buffer_size, - uint8_t *wrap_key, - size_t wrap_buffer_size, - size_t *key_buffer_length ) + const uint8_t *key, + size_t key_length, + uint8_t *wrapped_key_buffer, + size_t wrapped_key_buffer_size, + size_t *wrapped_key_buffer_length ) { - size_t opaque_key_base_size = mbedtls_test_opaque_get_base_size(); - uint64_t prefix = PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX; - if( key_buffer_size + opaque_key_base_size > wrap_buffer_size ) - return( PSA_ERROR_BUFFER_TOO_SMALL ); - /* Write in the opaque pad prefix */ - memcpy( wrap_key, &prefix, opaque_key_base_size); - wrap_key += opaque_key_base_size; - *key_buffer_length = key_buffer_size + opaque_key_base_size; - while( key_buffer_size-- ) - wrap_key[key_buffer_size] = key_buffer[key_buffer_size] ^ 0xFF; - return( PSA_SUCCESS ); + size_t opaque_key_base_size = mbedtls_test_opaque_get_base_size(); + uint64_t prefix = PSA_CRYPTO_TEST_DRIVER_OPAQUE_PAD_PREFIX; + + if( key_length + opaque_key_base_size > wrapped_key_buffer_size ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + + /* Write in the opaque pad prefix */ + memcpy( wrapped_key_buffer, &prefix, opaque_key_base_size); + wrapped_key_buffer += opaque_key_base_size; + *wrapped_key_buffer_length = key_length + opaque_key_base_size; + + while( key_length-- ) + wrapped_key_buffer[key_length] = key[key_length] ^ 0xFF; + return( PSA_SUCCESS ); } /* - * The unwrap function mbedtls_test_opaque_unwrap_key removes a pad prefix and unwraps - * the wrapped key. It expects the clear and wrap buffers to be passed in. - * wrapped_key_buffer_size is the size of the wrapped key, + * The unwrap function mbedtls_test_opaque_unwrap_key removes a pad prefix + * and unwraps the wrapped key. It expects the clear and wrap buffers to be + * passed in. + * wrapped_key_length is the size of the wrapped key, * key_buffer_size is the size of the output buffer clear_key. - * The argument key_buffer_length is filled with the unwrapped(clear) key_size on success. + * The argument key_buffer_length is filled with the unwrapped(clear) + * key_size on success. * */ static psa_status_t mbedtls_test_opaque_unwrap_key( const uint8_t *wrapped_key, - size_t wrapped_key_buffer_size, + size_t wrapped_key_length, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length) { - /* Remove the pad prefis from the wrapped key */ - size_t opaque_key_base_size = mbedtls_test_opaque_get_base_size(); - size_t clear_key_size = wrapped_key_buffer_size - opaque_key_base_size; - wrapped_key += opaque_key_base_size; - if( clear_key_size > key_buffer_size ) - return( PSA_ERROR_BUFFER_TOO_SMALL ); - *key_buffer_length = clear_key_size; - while( clear_key_size-- ) - key_buffer[clear_key_size] = wrapped_key[clear_key_size] ^ 0xFF; - return( PSA_SUCCESS ); + /* Remove the pad prefix from the wrapped key */ + size_t opaque_key_base_size = mbedtls_test_opaque_get_base_size(); + size_t clear_key_size = wrapped_key_length - opaque_key_base_size; + + wrapped_key += opaque_key_base_size; + if( clear_key_size > key_buffer_size ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + + *key_buffer_length = clear_key_size; + while( clear_key_size-- ) + key_buffer[clear_key_size] = wrapped_key[clear_key_size] ^ 0xFF; + return( PSA_SUCCESS ); } psa_status_t mbedtls_test_transparent_generate_key( @@ -257,21 +267,22 @@ psa_status_t mbedtls_test_opaque_import_key( size_t *key_buffer_length, size_t *bits) { - psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_key_type_t type = psa_get_key_type( attributes ); - /* This buffer will be used as an intermediate placeholder for the clear - * key till we wrap it */ + /* This buffer will be used as an intermediate placeholder for + * the clear key till we wrap it */ uint8_t *key_buffer_temp; - key_buffer_temp = mbedtls_calloc( 1, key_buffer_size ); - if( !key_buffer_temp ) + key_buffer_temp = mbedtls_calloc( 1, key_buffer_size ); + if( key_buffer_temp == NULL ) return( PSA_ERROR_INSUFFICIENT_MEMORY ); + if( PSA_KEY_TYPE_IS_UNSTRUCTURED( type ) ) { *bits = PSA_BYTES_TO_BITS( data_length ); - status = psa_validate_unstructured_key_bit_size( attributes->core.type, *bits ); + status = psa_validate_unstructured_key_bit_size( attributes->core.type, + *bits ); if( status != PSA_SUCCESS ) goto exit; @@ -311,13 +322,6 @@ psa_status_t mbedtls_test_opaque_import_key( #endif { status = PSA_ERROR_INVALID_ARGUMENT; - (void)data; - (void)data_length; - (void)key_buffer; - (void)key_buffer_size; - (void)key_buffer_length; - (void)bits; - (void)type; goto exit; } status = mbedtls_test_opaque_wrap_key( key_buffer_temp, *key_buffer_length, @@ -389,10 +393,10 @@ psa_status_t mbedtls_test_opaque_export_key( } else { - /* This buffer will be used as an intermediate placeholder for the opaque key - * till we unwrap the key into key_buffer */ + /* This buffer will be used as an intermediate placeholder for + * the opaque key till we unwrap the key into key_buffer */ uint8_t *key_buffer_temp; - size_t status = PSA_ERROR_BUFFER_TOO_SMALL; + size_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_key_type_t type = psa_get_key_type( attributes ); if( PSA_KEY_TYPE_IS_UNSTRUCTURED( type ) || @@ -400,7 +404,7 @@ psa_status_t mbedtls_test_opaque_export_key( PSA_KEY_TYPE_IS_ECC( type ) ) { key_buffer_temp = mbedtls_calloc( 1, key_length ); - if( !key_buffer_temp ) + if( key_buffer_temp == NULL ) return( PSA_ERROR_INSUFFICIENT_MEMORY ); memcpy( key_buffer_temp, key, key_length ); status = mbedtls_test_opaque_unwrap_key( key_buffer_temp, key_length, @@ -475,12 +479,14 @@ psa_status_t mbedtls_test_opaque_export_public_key( { if( key_length != sizeof( psa_drv_slot_number_t ) ) { - psa_status_t status = PSA_ERROR_NOT_SUPPORTED; + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_key_type_t key_type = psa_get_key_type( attributes ); uint8_t *key_buffer_temp; + key_buffer_temp = mbedtls_calloc( 1, key_length ); - if( !key_buffer_temp ) + if( key_buffer_temp == NULL ) return( PSA_ERROR_INSUFFICIENT_MEMORY ); + #if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || \ defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) if( PSA_KEY_TYPE_IS_ECC( key_type ) ) @@ -512,7 +518,6 @@ psa_status_t mbedtls_test_opaque_export_public_key( { status = PSA_ERROR_NOT_SUPPORTED; (void)key; - (void)key_length; (void)key_type; } mbedtls_free( key_buffer_temp ); From 374fe5b8d2da303166dffaa27ddcc47f8367471e Mon Sep 17 00:00:00 2001 From: Archana Date: Wed, 8 Sep 2021 15:50:28 +0530 Subject: [PATCH 480/966] Handle zeroed attributes key bits and type in copy The target attributes for key copy could have key bits and type zeroed. If so, they need to be overwritten/ inherited from the source key. This is now forcefully overwritten after validating the optional attributes. As a result assigning attributes type and bits after copy are no longer necessary. Signed-off-by: Archana --- library/psa_crypto.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index b105890fb3..906e9b4579 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2000,9 +2000,6 @@ static psa_status_t psa_copy_key_material( const psa_key_slot_t *source, if( status != PSA_SUCCESS ) return( status ); - target->attr.type = source->attr.type; - target->attr.bits = source->attr.bits; - return( PSA_SUCCESS ); } @@ -2030,6 +2027,15 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, if( status != PSA_SUCCESS ) goto exit; + /* The actual attributes that we received from the user could have + * zero values for key bits and type.These optional attributes + * have been validated and so it is safe to inherit these + * from the source key. + * */ + actual_attributes.core.bits = source_slot->attr.bits; + actual_attributes.core.type = source_slot->attr.type; + + status = psa_restrict_key_policy( source_slot->attr.type, &actual_attributes.core.policy, &source_slot->attr.policy ); @@ -2065,9 +2071,11 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, &storage_size ); if( status != PSA_SUCCESS ) goto exit; + status = psa_allocate_buffer_to_slot( target_slot, storage_size ); if( status != PSA_SUCCESS ) goto exit; + status = psa_driver_wrapper_copy_key( &actual_attributes, source_slot->key.data, source_slot->key.bytes, From 74d99c6bfcf911945185317802177d380a9b4623 Mon Sep 17 00:00:00 2001 From: Archana Date: Wed, 8 Sep 2021 18:50:20 +0530 Subject: [PATCH 481/966] Add a test to validate copy to read only lifetime Signed-off-by: Archana --- tests/suites/test_suite_psa_crypto.data | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 94a4c71f56..25234fb6a8 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -1401,6 +1401,10 @@ Copy fail: AES, invalid lifetime (unknown location) in attributes depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_STORAGE_C:!MBEDTLS_PSA_CRYPTO_DRIVERS copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:1:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_DEFAULT, 11):PSA_ERROR_INVALID_ARGUMENT +Copy fail: AES, copy to a readonly lifetime in attributes +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_STORAGE_C +copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:1:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_READ_ONLY, 0 ):PSA_ERROR_INVALID_ARGUMENT + Copy fail: AES, across locations (unsupported) in attributes depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:1:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_VOLATILE, 0):PSA_ERROR_NOT_SUPPORTED From a316b7e42b231f8bb7dd34f567ae9242292c0728 Mon Sep 17 00:00:00 2001 From: Archana Date: Thu, 9 Sep 2021 08:45:19 +0530 Subject: [PATCH 482/966] Rebase and update signature for curve448 tests Also include the opaque test cases for curve448 vectors. Signed-off-by: Archana --- tests/suites/test_suite_psa_crypto.data | 30 ++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 25234fb6a8..a0efba3bd6 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -311,19 +311,19 @@ import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fb PSA import/export EC curve448 key pair: good (already properly masked, key from RFC 7748 6.2 Alice)) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448 -import_export:"988f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a59872eb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:448:0:PSA_SUCCESS:1 +import_export:"988f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a59872eb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:0:448:0:PSA_SUCCESS:1 PSA import/export EC curve448 key pair: unmasked input (check export-import-export yields properly masked output, key from RFC 7748 6.2 Alice)) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448 -import_export:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:448:0:PSA_SUCCESS:0 +import_export:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:0:448:0:PSA_SUCCESS:0 PSA import/export-public EC curve448: accept masked input (key from RFC 7748 6.2 Alice) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448 -import_export_public_key:"988f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a59872eb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:0:PSA_SUCCESS:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0" +import_export_public_key:"988f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a59872eb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:0:0:PSA_SUCCESS:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0" PSA import/export-public EC curve448: accept unmasked input (key from RFC 7748 6.2 Alice) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448 -import_export_public_key:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:0:PSA_SUCCESS:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0" +import_export_public_key:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:0:0:PSA_SUCCESS:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0" PSA import/export-public: cannot export-public a symmetric key depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C @@ -347,7 +347,7 @@ import_export:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" PSA import/export curve448 Public Key: good (key from RFC 7748 6.2 Alice) depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448 -import_export:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:448:0:PSA_SUCCESS:0 +import_export:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:0:448:0:PSA_SUCCESS:0 PSA import/export AES key: policy forbids export depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES @@ -437,6 +437,22 @@ PSA import/export-public EC curve25519: accept masked input, opaque depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" +PSA import/export EC curve448 key pair: good (already properly masked, key from RFC 7748 6.2 Alice)), opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"988f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a59872eb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):448:0:PSA_SUCCESS:1 + +PSA import/export EC curve448 key pair: unmasked input (check export-import-export yields properly masked output, key from RFC 7748 6.2 Alice)), opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):448:0:PSA_SUCCESS:0 + +PSA import/export-public EC curve448: accept masked input (key from RFC 7748 6.2 Alice), opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"988f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a59872eb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0" + +PSA import/export-public EC curve448: accept unmasked input (key from RFC 7748 6.2 Alice), opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export_public_key:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0" + PSA import/export-public: cannot export-public a symmetric key, opaque depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_ERROR_INVALID_ARGUMENT:"2b7e151628aed2a6abf7158809cf4f3c" @@ -457,6 +473,10 @@ PSA import/export curve25519 public key: good, opaque depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS import_export:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 +PSA import/export curve448 Public Key: good (key from RFC 7748 6.2 Alice), opaque +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +import_export:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):448:0:PSA_SUCCESS:0 + PSA import/export AES key: policy forbids export, opaque depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):128:0:PSA_ERROR_NOT_PERMITTED:1 From 9a2b6ff8f24a81cf837476d55b8c0d2aee3f99af Mon Sep 17 00:00:00 2001 From: Archana Date: Thu, 9 Sep 2021 12:28:24 +0530 Subject: [PATCH 483/966] Fix test vector dependency Fix opaque key test vector dependency to PSA_CRYPTO_DRIVER_TEST instead of MBEDTLS_PSA_CRYPTO_DRIVERS while validating with test drivers. Signed-off-by: Archana --- tests/suites/test_suite_psa_crypto.data | 182 ++++++++++++------------ 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index a0efba3bd6..d9eafc0277 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -23,27 +23,27 @@ depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES import_export:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:256:0:PSA_SUCCESS:1 PSA import/export raw: 1 bytes, opaque -depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_CRYPTO_DRIVER_TEST import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):8:0:PSA_SUCCESS:1 PSA import/export raw: 1 bytes, larger buffer, opaque -depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_CRYPTO_DRIVER_TEST import_export:"2a":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):8:1:PSA_SUCCESS:1 PSA import/export raw: 2 bytes, buffer too small, opaque -depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_CRYPTO_DRIVER_TEST import_export:"2a2b":PSA_KEY_TYPE_RAW_DATA:PSA_KEY_USAGE_EXPORT:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):16:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export AES-128, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST import_export:"0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):128:0:PSA_SUCCESS:1 PSA import/export AES-192, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST import_export:"0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):192:0:PSA_SUCCESS:1 PSA import/export AES-256, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST import_export:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import: bad usage flag @@ -106,55 +106,55 @@ depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:-1:PSA_SUCCESS:0 PSA import/export RSA public key: good, 1024-bit, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:0:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (+1 byte), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:1:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2-1), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:161:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:162:PSA_SUCCESS:1 PSA import/export RSA public key: good, larger buffer (*2+1), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:163:PSA_SUCCESS:1 PSA import/export RSA public key: export buffer too small, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export RSA keypair: good, 1024-bit, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:0:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (+1 byte), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:1:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2-1), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:609:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:610:PSA_SUCCESS:1 PSA import/export RSA keypair: good, larger buffer (*2+1), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:611:PSA_SUCCESS:1 PSA import/export RSA keypair: export buffer too small, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:-1:PSA_ERROR_BUFFER_TOO_SMALL:1 PSA import/export RSA keypair: trailing garbage ignored, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b2400":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:-1:PSA_SUCCESS:0 PSA import RSA keypair: truncated @@ -190,19 +190,19 @@ depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA public key: good, 1024-bit, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA keypair: good, 1024-bit, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA public key: buffer too small, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export-public RSA keypair: buffer too small, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):-1:PSA_ERROR_BUFFER_TOO_SMALL:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001" PSA import/export RSA public key: 1016-bit (good) @@ -214,11 +214,11 @@ depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS import_export:"3082025802010002818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001028180009dd9c34411e769a540e7e9c03682abb4e95ad2d5c2297c6b7eb2fa5415dfa081adb42bff344ea36a31e8bb36593fa69e843f053fa916f8c6ae4c423fa4c1edbcfa7e8079bc19a738f4f861c198cf277d2c89fe3deab06db5a3a09f8d1622033a618fbfbab92b50a13f77cdb53b56d38bec4cdd8cbe65e8b30ab4e77565842102400eec9285833f973372458f354bff7d35bcb04f3b26f5b58a025887a966ca951b6667651a46034bbc99f9d688dfbcb4297a4d86824dd73abdfa7deeb232b1642902400dcbe74d51f3b93afe2a22e2be0c3c56911ef771fd8eb01f64d95d018315baf4144aeb957be95a77f17f2b8a12c2d3b87a1281f9c66d839fa603fbbe7381783d0240035398154a7c1227d580cbbb05859d532d0bdf9d3fc1e5052e20ad9c84dd02ff6884037527c5f44bc5c67a9b67c39824e6ae011d6a5c5f2b997a188a7fe22a810240076bf41ec5023e57bcd87ff1c7d89f30d65a793469f933478021ea056135f45f4ef74aaa1c8158b883422cf2d6cad5c83c6aee5ea65ecd5ab99d14f4cc000ee5024006d13905db5556627066596da3383458aea6ba5e2f94ccc5b922117a1ed3ae7a26c59e68c3885a41b366f1a5c8bff7ec8853ef8d32addb818141352b2da553dc":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1016:0:PSA_SUCCESS:1 PSA import/export RSA public key: 1016-bit (good), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"30818802818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1016:0:PSA_SUCCESS:1 PSA import/export RSA keypair: 1016-bit (good), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025802010002818000cde684f1aee96917b89c8a0a72523cfce4686ed5a5fbd32abab12038fc75148e45314b7e31fe60d8258e7e78234a23df0f00cc20fd008b64cb5b0f4ced8c47aa048f767f859961adc22b3df14e63bd9e08c9707bbf4e0eba32b1cc35a020e7e815ca47e0d39601a80d683ab4a07f4d3a7acebaba6c87d25bce2d091ee115c50203010001028180009dd9c34411e769a540e7e9c03682abb4e95ad2d5c2297c6b7eb2fa5415dfa081adb42bff344ea36a31e8bb36593fa69e843f053fa916f8c6ae4c423fa4c1edbcfa7e8079bc19a738f4f861c198cf277d2c89fe3deab06db5a3a09f8d1622033a618fbfbab92b50a13f77cdb53b56d38bec4cdd8cbe65e8b30ab4e77565842102400eec9285833f973372458f354bff7d35bcb04f3b26f5b58a025887a966ca951b6667651a46034bbc99f9d688dfbcb4297a4d86824dd73abdfa7deeb232b1642902400dcbe74d51f3b93afe2a22e2be0c3c56911ef771fd8eb01f64d95d018315baf4144aeb957be95a77f17f2b8a12c2d3b87a1281f9c66d839fa603fbbe7381783d0240035398154a7c1227d580cbbb05859d532d0bdf9d3fc1e5052e20ad9c84dd02ff6884037527c5f44bc5c67a9b67c39824e6ae011d6a5c5f2b997a188a7fe22a810240076bf41ec5023e57bcd87ff1c7d89f30d65a793469f933478021ea056135f45f4ef74aaa1c8158b883422cf2d6cad5c83c6aee5ea65ecd5ab99d14f4cc000ee5024006d13905db5556627066596da3383458aea6ba5e2f94ccc5b922117a1ed3ae7a26c59e68c3885a41b366f1a5c8bff7ec8853ef8d32addb818141352b2da553dc":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1016:0:PSA_SUCCESS:1 PSA import RSA public key: 1022-bit (not supported) @@ -366,131 +366,131 @@ depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:0:1024:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export EC secp224r1 key pair: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224:PSA_CRYPTO_DRIVER_TEST import_export:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):224:0:PSA_SUCCESS:1 PSA import/export-public EC secp224r1: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_224:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"6849f97d1066f6997759637c7e3899464cee3ec7ac970653a0be0742":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"041693a290f7f0b571fe2b41d5d84b01327631f4a860f995fa332c097f54192bb10f00113f2affb13c1a24ce44914571a95440ae014a00cbf7" PSA import/export EC secp256r1 key pair: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST import_export:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import/export-public EC secp256r1: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"047772656f814b399279d5e1f1781fac6f099a3c5ca1b0e35351834b08b65e0b572590cdaf8f769361bcf34acfc11e5e074e8426bdde04be6e653945449617de45" PSA import/export EC secp384r1 key pair: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384:PSA_CRYPTO_DRIVER_TEST import_export:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):384:0:PSA_SUCCESS:1 PSA import/export-public EC secp384r1: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_384:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"3f5d8d9be280b5696cc5cc9f94cf8af7e6b61dd6592b2ab2b3a4c607450417ec327dcdcaed7c10053d719a0574f0a76a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04d9c662b50ba29ca47990450e043aeaf4f0c69b15676d112f622a71c93059af999691c5680d2b44d111579db12f4a413a2ed5c45fcfb67b5b63e00b91ebe59d09a6b1ac2c0c4282aa12317ed5914f999bc488bb132e8342cc36f2ca5e3379c747" PSA import/export EC secp521r1 key pair: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:PSA_CRYPTO_DRIVER_TEST import_export:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):521:0:PSA_SUCCESS:1 PSA import/export-public EC secp521r1: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"01b1b6ad07bb79e7320da59860ea28e055284f6058f279de666e06d435d2af7bda28d99fa47b7dd0963e16b0073078ee8b8a38d966a582f46d19ff95df3ad9685aae":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1" PSA import/export EC brainpool256r1 key pair: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:PSA_CRYPTO_DRIVER_TEST import_export:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY::PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool256r1: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"2161d6f2db76526fa62c16f356a80f01f32f776784b36aa99799a8b7662080ff":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d" PSA import/export EC brainpool384r1 key pair: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384:PSA_CRYPTO_DRIVER_TEST import_export:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):384:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool384r1: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_384:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"3dd92e750d90d7d39fc1885cd8ad12ea9441f22b9334b4d965202adb1448ce24c5808a85dd9afc229af0a3124f755bcb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"04719f9d093a627e0d350385c661cebf00c61923566fe9006a3107af1d871bc6bb68985fd722ea32be316f8e783b7cd1957785f66cfc0cb195dd5c99a8e7abaa848553a584dfd2b48e76d445fe00dd8be59096d877d4696d23b4bc8db14724e66a" PSA import/export EC brainpool512r1 key pair: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512:PSA_CRYPTO_DRIVER_TEST import_export:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):512:0:PSA_SUCCESS:1 PSA import/export-public EC brainpool512r1: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_512:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"372c9778f69f726cbca3f4a268f16b4d617d10280d79a6a029cd51879fe1012934dfe5395455337df6906dc7d6d2eea4dbb2065c0228f73b3ed716480e7d71d2":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_ALG_ECDSA_ANY:0:0:PSA_SUCCESS:"0438b7ec92b61c5c6c7fbc28a4ec759d48fcd4e2e374defd5c4968a54dbef7510e517886fbfc38ea39aa529359d70a7156c35d3cbac7ce776bdb251dd64bce71234424ee7049eed072f0dbc4d79996e175d557e263763ae97095c081e73e7db2e38adc3d4c9a0487b1ede876dc1fca61c902e9a1d8722b8612928f18a24845591a" PSA import/export EC curve25519 key pair: good (already properly masked), opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:PSA_CRYPTO_DRIVER_TEST import_export:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 PSA import/export EC curve25519 key pair: unmasked input (check export-import-export yields properly masked output), opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:PSA_CRYPTO_DRIVER_TEST import_export:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:0 PSA import/export-public EC curve25519: accept unmasked input, opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" PSA import/export-public EC curve25519: accept masked input, opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c6a":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a" PSA import/export EC curve448 key pair: good (already properly masked, key from RFC 7748 6.2 Alice)), opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:PSA_CRYPTO_DRIVER_TEST import_export:"988f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a59872eb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):448:0:PSA_SUCCESS:1 PSA import/export EC curve448 key pair: unmasked input (check export-import-export yields properly masked output, key from RFC 7748 6.2 Alice)), opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:PSA_CRYPTO_DRIVER_TEST import_export:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):448:0:PSA_SUCCESS:0 PSA import/export-public EC curve448: accept masked input (key from RFC 7748 6.2 Alice), opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"988f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a59872eb":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0" PSA import/export-public EC curve448: accept unmasked input (key from RFC 7748 6.2 Alice), opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_SUCCESS:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0" PSA import/export-public: cannot export-public a symmetric key, opaque -depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_CRYPTO_DRIVER_TEST import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_ERROR_INVALID_ARGUMENT:"2b7e151628aed2a6abf7158809cf4f3c" PSA import/export EC secp256r1 public key: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST import_export:"04dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import/export EC secp521r1 public key: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_521:PSA_CRYPTO_DRIVER_TEST import_export:"04001de142d54f69eb038ee4b7af9d3ca07736fd9cf719eb354d69879ee7f3c136fb0fbf9f08f86be5fa128ec1a051d3e6c643e85ada8ffacf3663c260bd2c844b6f5600cee8e48a9e65d09cadd89f235dee05f3b8a646be715f1f67d5b434e0ff23a1fc07ef7740193e40eeff6f3bcdfd765aa9155033524fe4f205f5444e292c4c2f6ac1":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):521:0:PSA_SUCCESS:1 PSA import/export EC brainpoolP256r1 public key: good, opaque -depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_BRAINPOOL_P_R1_256:PSA_CRYPTO_DRIVER_TEST import_export:"04768c8cae4abca6306db0ed81b0c4a6215c378066ec6d616c146e13f1c7df809b96ab6911c27d8a02339f0926840e55236d3d1efbe2669d090e4c4c660fada91d":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_BRAINPOOL_P_R1):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA_ANY:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_SUCCESS:1 PSA import/export curve25519 public key: good, opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_255:PSA_CRYPTO_DRIVER_TEST import_export:"8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):255:0:PSA_SUCCESS:1 PSA import/export curve448 Public Key: good (key from RFC 7748 6.2 Alice), opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_MONTGOMERY_448:PSA_CRYPTO_DRIVER_TEST import_export:"9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0":PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY):PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):448:0:PSA_SUCCESS:0 PSA import/export AES key: policy forbids export, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):128:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export HMAC key: policy forbids export, opaque -depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:PSA_CRYPTO_DRIVER_TEST import_export:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_HMAC:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):256:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export RSA keypair: policy forbids export (crypt), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_CRYPT:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_CRYPT:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_RSA_PKCS1V15_CRYPT:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:0:PSA_ERROR_NOT_PERMITTED:1 PSA import/export RSA keypair: policy forbids export (sign), opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST import_export:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):1024:0:PSA_ERROR_NOT_PERMITTED:1 # Test PEM import. Note that this is not a PSA feature, it's an Mbed TLS @@ -1164,99 +1164,99 @@ depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KE copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):0:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256) Copy key: raw, 1 byte, opaque -depends_on:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY:0:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RAW_DATA:"2a":1:-1:-1:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY:0:0 Copy key: AES, copy attributes, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":1:-1:-1:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 Copy key: AES, same usage flags, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 Copy key: AES, fewer usage flags (-EXPORT), opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: AES, fewer usage flags (-COPY), opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0 Copy key: AES, 1 more usage flag, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: AES, 2 more usage flags, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: AES, intersect usage flags #1, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: AES, intersect usage flags #2, opaque -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT:PSA_ALG_CTR:0 Copy key: RSA key pair, same usage flags, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, extended usage flags, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, fewer usage flags, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, more usage flags, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, intersect usage flags #0, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):0:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, intersect usage flags #1, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, wildcard algorithm in source, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, wildcard algorithm in target, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0 Copy key: RSA key pair, wildcard algorithm in source and target, opaque -depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_MD_C:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0:0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):0 Copy key: source=ECDSA+ECDH, target=ECDSA+ECDH, opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH Copy key: source=ECDSA+ECDH, target=ECDSA+ECDH, extended usage flags, opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH Copy key: source=ECDSA+ECDH, target=ECDSA+0, opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):0 Copy key: source=ECDSA+ECDH, target=0+ECDH, opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:0:PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:0:PSA_ALG_ECDH Copy key: source=ECDSA(any)+ECDH, target=ECDSA(SHA256)+ECDH, opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_ALG_ECDH Copy key: source=ECDH+ECDSA(any), target=ECDH+ECDSA(SHA256), opaque -depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_ECDH:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:PSA_WANT_ECC_SECP_R1_256:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":0:PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256):PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_DERIVE:PSA_ALG_ECDH:PSA_ALG_ECDSA(PSA_ALG_SHA_256) Copy fail: raw data, no COPY flag @@ -1335,31 +1335,31 @@ depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 Copy key: source=MAC, target=MAC min-length = length, opaque -depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 Copy key: source=MAC, target=MAC min-length < length, opaque -depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_HMAC:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_HMAC:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_HMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 16):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_VERIFY_MESSAGE | PSA_KEY_USAGE_EXPORT:PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 20):0 Copy key: source=AEAD min-length, target=AEAD length > min-length, opaque -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0 Copy key: source=AEAD min-length, target=AEAD length = min-length, opaque -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 4):0 Copy key: source=AEAD min-length, target=AEAD min-length, src > tgt, opaque -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 Copy key: source=AEAD min-length, target=AEAD min-length, src = tgt, opaque -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION )::PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 Copy key: source=AEAD min-length, target=AEAD min-length, src < tgt, opaque -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 4):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0 Copy fail: source=AEAD, target=AEAD min-length > length @@ -1375,11 +1375,11 @@ depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0:0:PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0 Copy key: source=AEAD, target=AEAD min-length = length, opaque -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 8):0 Copy key: source=AEAD, target=AEAD min-length < length, opaque -depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_success:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_TYPE_AES:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":0:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(PSA_ALG_CCM, 8):0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION ):PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, 12):0 Copy fail: RSA, incompatible target policy (source wildcard) @@ -1426,7 +1426,7 @@ depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_STORAGE_C copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:0:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:1:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION( PSA_KEY_PERSISTENCE_READ_ONLY, 0 ):PSA_ERROR_INVALID_ARGUMENT Copy fail: AES, across locations (unsupported) in attributes -depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PSA_CRYPTO_DRIVERS +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES:PSA_CRYPTO_DRIVER_TEST copy_fail:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_VOLATILE, TEST_DRIVER_LOCATION):PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_TYPE_AES:0:PSA_KEY_USAGE_COPY | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:0:1:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_VOLATILE, 0):PSA_ERROR_NOT_SUPPORTED Hash operation object initializers zero properly From 9d17bf42152a6ae2731d6cbcb6e4a8dc39c69f49 Mon Sep 17 00:00:00 2001 From: Archana Date: Fri, 10 Sep 2021 06:22:44 +0530 Subject: [PATCH 484/966] Styling and refactoring Signed-off-by: Archana --- library/psa_crypto.c | 30 +++++---------- library/psa_crypto_driver_wrappers.c | 17 +++++++-- library/psa_crypto_driver_wrappers.h | 2 +- tests/include/test/drivers/key_management.h | 2 +- .../src/drivers/test_driver_key_management.c | 37 ++++++++++--------- tests/suites/test_suite_psa_crypto.function | 14 +++---- 6 files changed, 53 insertions(+), 49 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 906e9b4579..bcbaa3d68a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1991,18 +1991,6 @@ exit: } #endif /* MBEDTLS_PSA_CRYPTO_SE_C */ -static psa_status_t psa_copy_key_material( const psa_key_slot_t *source, - psa_key_slot_t *target ) -{ - psa_status_t status = psa_copy_key_material_into_slot( target, - source->key.data, - source->key.bytes ); - if( status != PSA_SUCCESS ) - return( status ); - - return( PSA_SUCCESS ); -} - psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, const psa_key_attributes_t *specified_attributes, mbedtls_svc_key_id_t *target_key ) @@ -2027,13 +2015,13 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, if( status != PSA_SUCCESS ) goto exit; - /* The actual attributes that we received from the user could have - * zero values for key bits and type.These optional attributes - * have been validated and so it is safe to inherit these - * from the source key. + /* The target key type and number of bits have been validated by + * psa_validate_optional_attributes() to be either equal to zero or + * equal to the ones of the source key. So it is safe to inherit + * them from the source key now." * */ - actual_attributes.core.bits = source_slot->attr.bits; - actual_attributes.core.type = source_slot->attr.type; + actual_attributes.core.bits = source_slot->attr.bits; + actual_attributes.core.type = source_slot->attr.type; status = psa_restrict_key_policy( source_slot->attr.type, @@ -2050,7 +2038,7 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, PSA_KEY_LIFETIME_GET_LOCATION( source_slot->attr.lifetime ) ) { /* - * If the source and target keys are stored across different locations, + * If the source and target keys are stored in different locations, * the source key would need to be exported as plaintext and re-imported * in the other location. This has security implications which have not * been fully mapped. For now, this can be achieved through @@ -2087,7 +2075,9 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key, } else { - status = psa_copy_key_material( source_slot, target_slot ); + status = psa_copy_key_material_into_slot( target_slot, + source_slot->key.data, + source_slot->key.bytes ); if( status != PSA_SUCCESS ) goto exit; } diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 00c17063af..4123d8a560 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -785,7 +785,7 @@ psa_status_t psa_driver_wrapper_get_builtin_key( psa_status_t psa_driver_wrapper_copy_key( psa_key_attributes_t *attributes, - const uint8_t *source_key, size_t source_key_size, + const uint8_t *source_key, size_t source_key_length, uint8_t *target_key_buffer, size_t target_key_buffer_size, size_t *target_key_buffer_length ) { @@ -793,13 +793,24 @@ psa_status_t psa_driver_wrapper_copy_key( psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ); +#if defined(MBEDTLS_PSA_CRYPTO_SE_C) + const psa_drv_se_t *drv; + psa_drv_se_context_t *drv_context; + + if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) ) + { + /* Copying to a secure element is not implemented yet. */ + return( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_CRYPTO_SE_C */ + switch( location ) { #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) #if defined(PSA_CRYPTO_DRIVER_TEST) case PSA_CRYPTO_TEST_DRIVER_LOCATION: return( mbedtls_test_opaque_copy_key( attributes, source_key, - source_key_size, + source_key_length, target_key_buffer, target_key_buffer_size, target_key_buffer_length) ); @@ -807,7 +818,7 @@ psa_status_t psa_driver_wrapper_copy_key( #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ default: (void)source_key; - (void)source_key_size; + (void)source_key_length; (void)target_key_buffer; (void)target_key_buffer_size; (void)target_key_buffer_length; diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h index c186228fa0..c6e3d51a39 100644 --- a/library/psa_crypto_driver_wrappers.h +++ b/library/psa_crypto_driver_wrappers.h @@ -102,7 +102,7 @@ psa_status_t psa_driver_wrapper_get_builtin_key( psa_status_t psa_driver_wrapper_copy_key( psa_key_attributes_t *attributes, - const uint8_t *source_key, size_t source_key_size, + const uint8_t *source_key, size_t source_key_length, uint8_t *target_key_buffer, size_t target_key_buffer_size, size_t *target_key_buffer_length ); /* diff --git a/tests/include/test/drivers/key_management.h b/tests/include/test/drivers/key_management.h index 16ee0b2160..d147568cdc 100644 --- a/tests/include/test/drivers/key_management.h +++ b/tests/include/test/drivers/key_management.h @@ -115,7 +115,7 @@ psa_status_t mbedtls_test_opaque_get_builtin_key( psa_status_t mbedtls_test_opaque_copy_key( psa_key_attributes_t *attributes, const uint8_t *source_key, - size_t source_key_size, + size_t source_key_length, uint8_t *target_key_buffer, size_t target_key_buffer_size, size_t *target_key_buffer_length); diff --git a/tests/src/drivers/test_driver_key_management.c b/tests/src/drivers/test_driver_key_management.c index 2683edcd8c..61ebc8aa1a 100644 --- a/tests/src/drivers/test_driver_key_management.c +++ b/tests/src/drivers/test_driver_key_management.c @@ -75,7 +75,7 @@ size_t mbedtls_test_opaque_size_function( key_buffer_size = PSA_EXPORT_KEY_OUTPUT_SIZE( key_type, key_bits ); if( key_buffer_size == 0 ) - return( key_buffer_size ); + return( 0 ); /* Include spacing for base size overhead over the key size * */ key_buffer_size += TEST_DRIVER_KEY_CONTEXT_BASE_SIZE; @@ -109,7 +109,7 @@ static psa_status_t mbedtls_test_opaque_wrap_key( return( PSA_ERROR_BUFFER_TOO_SMALL ); /* Write in the opaque pad prefix */ - memcpy( wrapped_key_buffer, &prefix, opaque_key_base_size); + memcpy( wrapped_key_buffer, &prefix, opaque_key_base_size ); wrapped_key_buffer += opaque_key_base_size; *wrapped_key_buffer_length = key_length + opaque_key_base_size; @@ -136,7 +136,12 @@ static psa_status_t mbedtls_test_opaque_unwrap_key( { /* Remove the pad prefix from the wrapped key */ size_t opaque_key_base_size = mbedtls_test_opaque_get_base_size(); - size_t clear_key_size = wrapped_key_length - opaque_key_base_size; + size_t clear_key_size; + + /* Check for underflow */ + if( wrapped_key_length < opaque_key_base_size ) + return( PSA_ERROR_DATA_CORRUPT ); + clear_key_size = wrapped_key_length - opaque_key_base_size; wrapped_key += opaque_key_base_size; if( clear_key_size > key_buffer_size ) @@ -281,11 +286,14 @@ psa_status_t mbedtls_test_opaque_import_key( { *bits = PSA_BYTES_TO_BITS( data_length ); - status = psa_validate_unstructured_key_bit_size( attributes->core.type, + status = psa_validate_unstructured_key_bit_size( type, *bits ); if( status != PSA_SUCCESS ) goto exit; + if( data_length > key_buffer_size ) + return( PSA_ERROR_BUFFER_TOO_SMALL ); + /* Copy the key material accounting for opaque key padding. */ memcpy( key_buffer_temp, data, data_length ); *key_buffer_length = data_length; @@ -327,7 +335,7 @@ psa_status_t mbedtls_test_opaque_import_key( status = mbedtls_test_opaque_wrap_key( key_buffer_temp, *key_buffer_length, key_buffer, key_buffer_size, key_buffer_length ); exit: - free( key_buffer_temp ); + mbedtls_free( key_buffer_temp ); return( status ); } @@ -395,21 +403,15 @@ psa_status_t mbedtls_test_opaque_export_key( { /* This buffer will be used as an intermediate placeholder for * the opaque key till we unwrap the key into key_buffer */ - uint8_t *key_buffer_temp; - size_t status = PSA_ERROR_CORRUPTION_DETECTED; + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_key_type_t type = psa_get_key_type( attributes ); if( PSA_KEY_TYPE_IS_UNSTRUCTURED( type ) || PSA_KEY_TYPE_IS_RSA( type ) || PSA_KEY_TYPE_IS_ECC( type ) ) { - key_buffer_temp = mbedtls_calloc( 1, key_length ); - if( key_buffer_temp == NULL ) - return( PSA_ERROR_INSUFFICIENT_MEMORY ); - memcpy( key_buffer_temp, key, key_length ); - status = mbedtls_test_opaque_unwrap_key( key_buffer_temp, key_length, + status = mbedtls_test_opaque_unwrap_key( key, key_length, data, data_size, data_length ); - mbedtls_free( key_buffer_temp ); return( status ); } } @@ -614,7 +616,7 @@ psa_status_t mbedtls_test_opaque_get_builtin_key( psa_status_t mbedtls_test_opaque_copy_key( psa_key_attributes_t *attributes, - const uint8_t *source_key_buffer, size_t source_key_buffer_size, + const uint8_t *source_key, size_t source_key_length, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length) { /* This is a case where the opaque test driver emulates an SE without storage. @@ -623,10 +625,11 @@ psa_status_t mbedtls_test_opaque_copy_key( * copied keys. This could change when the opaque test driver is extended * to support SE with storage, or to emulate an SE without storage but * still holding some slot references */ - if( source_key_buffer_size > key_buffer_size ) + if( source_key_length > key_buffer_size ) return( PSA_ERROR_BUFFER_TOO_SMALL ); - memcpy( key_buffer, source_key_buffer, source_key_buffer_size ); - *key_buffer_length = source_key_buffer_size; + + memcpy( key_buffer, source_key, source_key_length ); + *key_buffer_length = source_key_length; (void)attributes; return( PSA_SUCCESS ); } diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 2b5727345d..01e5d5939b 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -564,18 +564,18 @@ void import_export( data_t *data, { mbedtls_svc_key_id_t key2 = MBEDTLS_SVC_KEY_ID_INIT; PSA_ASSERT( psa_import_key( &attributes, exported, exported_length, - &key2 ) ); + &key2 ) ); PSA_ASSERT( psa_export_key( key2, - reexported, - export_size, - &reexported_length ) ); + reexported, + export_size, + &reexported_length ) ); ASSERT_COMPARE( exported, exported_length, reexported, reexported_length ); PSA_ASSERT( psa_destroy_key( key2 ) ); } TEST_ASSERT( exported_length <= PSA_EXPORT_KEY_OUTPUT_SIZE( type, - psa_get_key_bits( &got_attributes ) ) ); + psa_get_key_bits( &got_attributes ) ) ); TEST_ASSERT( exported_length <= PSA_EXPORT_KEY_PAIR_MAX_SIZE ); destroy: @@ -629,8 +629,8 @@ void import_export_public_key( data_t *data, /* Export the public key */ ASSERT_ALLOC( exported, export_size ); status = psa_export_public_key( key, - exported, export_size, - &exported_length ); + exported, export_size, + &exported_length ); TEST_EQUAL( status, expected_export_status ); if( status == PSA_SUCCESS ) { From 72fc69bd40be61ba4d591abd9857417180caab78 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 10 Sep 2021 10:23:24 +0800 Subject: [PATCH 485/966] fix typo error Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 1b55abab6d..5d9e50b0d2 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -184,7 +184,8 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, size_t *olen ) { unsigned char *p = buf ; - unsigned char *name_group_list_ptr; /* Start of named_group_list */ + unsigned char *named_group_list_ptr; /* Start of named_group_list */ + size_t named_group_list_len; /* Length of named_group_list */ size_t output_len = 0; int ret_ecdhe, ret_dhe; @@ -203,7 +204,7 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); p += 6; - name_group_list_ptr = p; + named_group_list_ptr = p; ret_ecdhe = ssl_tls13_write_named_group_list_ecdhe( ssl, p, end, &output_len ); if( ret_ecdhe != 0 ) { @@ -226,10 +227,10 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, } /* Length of named_group_list*/ - size_t named_group_list_len = p - name_group_list_ptr; + named_group_list_len = p - named_group_list_ptr; if( named_group_list_len == 0 ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "No Named Group Available." ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "No group Available." ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } From 335aca9c52d50bf8bb1bd84a25d63ef0659da017 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sun, 12 Sep 2021 20:18:56 +0800 Subject: [PATCH 486/966] fix format issue Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 5d9e50b0d2..8ae8a56330 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -681,7 +681,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, return( 0 ); } -static int ssl_tls13_finalize_client_hello( mbedtls_ssl_context* ssl ) +static int ssl_tls13_finalize_client_hello( mbedtls_ssl_context *ssl ) { mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_HELLO ); return( 0 ); From 55dffe58a010298d81aa23832e2a3e4abb6d00f4 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 13 Sep 2021 09:33:28 +0200 Subject: [PATCH 487/966] Document the internal function psa_cipher_update_ecb Signed-off-by: Gilles Peskine --- library/psa_crypto_cipher.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index d8c722bb1b..f67b1ffed2 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -255,10 +255,30 @@ static psa_status_t cipher_set_iv( mbedtls_psa_cipher_operation_t *operation, iv, iv_length ) ) ); } -/* Process input for which the algorithm is set to ECB mode. This requires - * manual processing, since the PSA API is defined as being able to process - * arbitrary-length calls to psa_cipher_update() with ECB mode, but the - * underlying mbedtls_cipher_update only takes full blocks. */ +/** Process input for which the algorithm is set to ECB mode. + * + * This requires manual processing, since the PSA API is defined as being + * able to process arbitrary-length calls to psa_cipher_update() with ECB mode, + * but the underlying mbedtls_cipher_update only takes full blocks. + * + * \param ctx The mbedtls cipher context to use. It must have been + * set up for ECB. + * \param[in] input The input plaintext or ciphertext to process. + * \param input_length The number of bytes to process from \p input. + * This does not need to be aligned to a block boundary. + * If there is a partial block at the end of the input, + * it is stored in \p ctx for future processing. + * \param output The buffer where the output is written. + * \param output_size The size of \p output in bytes. + * It must be at least `floor((p + input_length) / BS)` + * where `p` is the number of bytes in the unprocessed + * partial block in \p ctx (`0 <= p <= BS - 1`) and + * `BS` is the block size. + * \param output_length On success, the number of bytes written to \p output. + * \c 0 on error. + * + * \return #PSA_SUCCESS or an error from a hardware accelerator + */ static psa_status_t psa_cipher_update_ecb( mbedtls_cipher_context_t *ctx, const uint8_t *input, From 1716f3286419bc68071d69db15daa5480c68df70 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 13 Sep 2021 09:36:28 +0200 Subject: [PATCH 488/966] psa_cipher_update_ecb: remove parameter output_size This parameter was set but not used, which was pointless. Clang 14 detects this and legitimately complains. Remove the parameter. This is an internal function, only called once. The caller already has a sufficient check on the output buffer size which applies in more cases, so there is no real gain in robustness in adding the same check inside the internal function. Signed-off-by: Gilles Peskine --- ChangeLog.d/psa_cipher_update_ecp.txt | 2 ++ library/psa_crypto_cipher.c | 9 ++------- 2 files changed, 4 insertions(+), 7 deletions(-) create mode 100644 ChangeLog.d/psa_cipher_update_ecp.txt diff --git a/ChangeLog.d/psa_cipher_update_ecp.txt b/ChangeLog.d/psa_cipher_update_ecp.txt new file mode 100644 index 0000000000..1c3fbc6b18 --- /dev/null +++ b/ChangeLog.d/psa_cipher_update_ecp.txt @@ -0,0 +1,2 @@ +Bugfix + * Fix a parameter set but unused in psa_crypto_cipher.c. Fixes #4935. diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index f67b1ffed2..5c78c23114 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -268,9 +268,8 @@ static psa_status_t cipher_set_iv( mbedtls_psa_cipher_operation_t *operation, * This does not need to be aligned to a block boundary. * If there is a partial block at the end of the input, * it is stored in \p ctx for future processing. - * \param output The buffer where the output is written. - * \param output_size The size of \p output in bytes. - * It must be at least `floor((p + input_length) / BS)` + * \param output The buffer where the output is written. Its size + * must be at least `floor((p + input_length) / BS)` * where `p` is the number of bytes in the unprocessed * partial block in \p ctx (`0 <= p <= BS - 1`) and * `BS` is the block size. @@ -284,7 +283,6 @@ static psa_status_t psa_cipher_update_ecb( const uint8_t *input, size_t input_length, uint8_t *output, - size_t output_size, size_t *output_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; @@ -324,7 +322,6 @@ static psa_status_t psa_cipher_update_ecb( goto exit; output += internal_output_length; - output_size -= internal_output_length; *output_length += internal_output_length; ctx->unprocessed_len = 0; } @@ -345,7 +342,6 @@ static psa_status_t psa_cipher_update_ecb( input += block_size; output += internal_output_length; - output_size -= internal_output_length; *output_length += internal_output_length; } @@ -400,7 +396,6 @@ static psa_status_t cipher_update( mbedtls_psa_cipher_operation_t *operation, input, input_length, output, - output_size, output_length ); } else From d87d87371f4e3d51be50313a4c2ec26a38ba6d21 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 13 Sep 2021 12:20:51 +0200 Subject: [PATCH 489/966] Fix the size in bytes Signed-off-by: Gilles Peskine --- library/psa_crypto_cipher.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index 5c78c23114..2268fc5850 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -268,11 +268,11 @@ static psa_status_t cipher_set_iv( mbedtls_psa_cipher_operation_t *operation, * This does not need to be aligned to a block boundary. * If there is a partial block at the end of the input, * it is stored in \p ctx for future processing. - * \param output The buffer where the output is written. Its size - * must be at least `floor((p + input_length) / BS)` - * where `p` is the number of bytes in the unprocessed - * partial block in \p ctx (`0 <= p <= BS - 1`) and - * `BS` is the block size. + * \param output The buffer where the output is written. It must be + * at least `BS * floor((p + input_length) / BS)` bytes + * long, where `p` is the number of bytes in the + * unprocessed partial block in \p ctx (with + * `0 <= p <= BS - 1`) and `BS` is the block size. * \param output_length On success, the number of bytes written to \p output. * \c 0 on error. * From bdc71888fcedae2d85b367452bc618c63c138a88 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 14 Sep 2021 19:30:36 +0800 Subject: [PATCH 490/966] Remove restartable and everest from tls1.3 Signed-off-by: Jerry Yu --- library/ecdh.c | 50 +++++++++++--------------------------- library/ecdh_misc.h | 41 +++++++++++++++++++++++++++++++ library/ssl_misc.h | 9 ------- library/ssl_tls13_client.c | 4 ++- 4 files changed, 58 insertions(+), 46 deletions(-) create mode 100644 library/ecdh_misc.h diff --git a/library/ecdh.c b/library/ecdh.c index ac60165443..b9319470e5 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -31,7 +31,8 @@ #include "mbedtls/ecdh.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" -#include "ssl_misc.h" + +#include "ecdh_misc.h" #include @@ -730,37 +731,17 @@ int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) static int ecdh_tls13_make_params_internal( mbedtls_ecdh_context_mbed *ctx, - size_t *olen, int point_format, - unsigned char *buf, size_t blen, - int ( *f_rng )( void *, - unsigned char *, - size_t), - void *p_rng, int restart_enabled ) + size_t *olen, int point_format, unsigned char *buf, size_t blen, + int ( *f_rng )( void *, unsigned char *, size_t), void *p_rng ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; -#if defined(MBEDTLS_ECP_RESTARTABLE) - mbedtls_ecp_restart_ctx *rs_ctx = NULL; -#endif if( ctx->grp.pbits == 0 ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); -#if defined(MBEDTLS_ECP_RESTARTABLE) - if( restart_enabled ) - rs_ctx = &ctx->rs; -#else - (void) restart_enabled; -#endif - -#if defined(MBEDTLS_ECP_RESTARTABLE) - if( ( ret = ecdh_gen_public_restartable( &ctx->grp, &ctx->d, &ctx->Q, - f_rng, p_rng, rs_ctx ) ) != 0 ) - return( ret ); -#else if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ) != 0 ) return( ret ); -#endif /* MBEDTLS_ECP_RESTARTABLE */ ret = mbedtls_ecp_point_write_binary( &ctx->grp, &ctx->Q, point_format, olen, buf, blen ); @@ -771,38 +752,35 @@ static int ecdh_tls13_make_params_internal( mbedtls_ecdh_context_mbed *ctx, } int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, - unsigned char *buf, size_t blen, - int ( *f_rng )( void *, unsigned char *, size_t ), - void *p_rng ) + unsigned char *buf, size_t blen, + int ( *f_rng )( void *, unsigned char *, size_t ), + void *p_rng ) { - int restart_enabled = 0; ECDH_VALIDATE_RET( ctx != NULL ); ECDH_VALIDATE_RET( olen != NULL ); ECDH_VALIDATE_RET( buf != NULL ); ECDH_VALIDATE_RET( f_rng != NULL ); + #if defined(MBEDTLS_ECP_RESTARTABLE) - restart_enabled = ctx->restart_enabled; -#else - (void) restart_enabled; + if( ctx-> restart_enabled ) + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); #endif #if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) - return( ecdh_tls13_make_params_internal( ctx, olen, ctx->point_format, buf, blen, - f_rng, p_rng, restart_enabled ) ); + return( ecdh_tls13_make_params_internal( ctx, olen, ctx->point_format, + buf, blen, f_rng, p_rng ) ); #else switch( ctx->var ) { #if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) case MBEDTLS_ECDH_VARIANT_EVEREST: - return( mbedtls_everest_make_params( &ctx->ctx.everest_ecdh, olen, - buf, blen, f_rng, p_rng ) ); + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); #endif case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: return( ecdh_tls13_make_params_internal( &ctx->ctx.mbed_ecdh, olen, ctx->point_format, buf, blen, - f_rng, p_rng, - restart_enabled ) ); + f_rng, p_rng ) ); default: return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; } diff --git a/library/ecdh_misc.h b/library/ecdh_misc.h new file mode 100644 index 0000000000..3d75b0fce0 --- /dev/null +++ b/library/ecdh_misc.h @@ -0,0 +1,41 @@ +/** + * \file ecdh_misc.h + * + * \brief Internal functions shared by the ECDH module + */ +/* + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 ( the "License" ); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#if !defined(MBEDTLS_ECDH_MISC_H) +#define MBEDTLS_ECDH_MISC_H + +#if defined(MBEDTLS_ECDH_C) + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +/* + * TLS 1.3 version of mbedtls_ecdh_make_params in ecdh.h + */ +int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int ( *f_rng )( void *, unsigned char *, size_t ), + void *p_rng ); + +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + +#endif /* MBEDTLS_ECDH_C */ + +#endif /* !MBEDTLS_ECDH_MISC_H */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index fb843848bf..c338d79eec 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1501,15 +1501,6 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf, unsigned char *end, size_t *olen); -#if defined(MBEDTLS_ECDH_C) -/* - * TLS 1.3 version of mbedtls_ecdh_make_params in ecdh.h - */ -int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, - unsigned char *buf, size_t blen, - int ( *f_rng )( void *, unsigned char *, size_t ), - void *p_rng ); -#endif /* MBEDTLS_ECDH_C */ #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 8ae8a56330..0190ee5f39 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -27,10 +27,12 @@ #include -#include "ssl_misc.h" #include "mbedtls/debug.h" #include "mbedtls/error.h" +#include "ssl_misc.h" +#include "ecdh_misc.h" + #define CLIENT_HELLO_RANDOM_LEN 32 /* Write extensions */ From dd1fb9e37eae2c53d42dd78bfed9f5f2766ba4eb Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 15 Sep 2021 11:10:15 +0800 Subject: [PATCH 491/966] add mbedtls_ecdh_setup_no_everest Setup ecdh without everest for TLS1.3 Signed-off-by: Jerry Yu --- library/ecdh.c | 19 +++++++++++++++++++ library/ecdh_misc.h | 10 ++++++++++ library/ssl_tls13_client.c | 4 ++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/library/ecdh.c b/library/ecdh.c index b9319470e5..4d73da0748 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -787,6 +787,25 @@ int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, #endif } +/* + * Setup context without everst + */ +int mbedtls_ecdh_setup_no_everest( mbedtls_ecdh_context *ctx, + mbedtls_ecp_group_id grp_id ) +{ + ECDH_VALIDATE_RET( ctx != NULL ); + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_setup_internal( ctx, grp_id ) ); +#else + ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED; + ctx->var = MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0; + ctx->grp_id = grp_id; + ecdh_init_internal( &ctx->ctx.mbed_ecdh ); + return( ecdh_setup_internal( &ctx->ctx.mbed_ecdh, grp_id ) ); +#endif +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_ECDH_C */ diff --git a/library/ecdh_misc.h b/library/ecdh_misc.h index 3d75b0fce0..c377e704c1 100644 --- a/library/ecdh_misc.h +++ b/library/ecdh_misc.h @@ -22,10 +22,19 @@ #if !defined(MBEDTLS_ECDH_MISC_H) #define MBEDTLS_ECDH_MISC_H +#include "mbedtls/ecdh.h" +#include "mbedtls/ecp.h" + #if defined(MBEDTLS_ECDH_C) #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +/* + * Setup context without everst + */ +int mbedtls_ecdh_setup_no_everest( mbedtls_ecdh_context *ctx, + mbedtls_ecp_group_id grp_id ); + /* * TLS 1.3 version of mbedtls_ecdh_make_params in ecdh.h */ @@ -34,6 +43,7 @@ int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, int ( *f_rng )( void *, unsigned char *, size_t ), void *p_rng ); + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_ECDH_C */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 0190ee5f39..91f1b0c867 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -272,8 +272,8 @@ static int ssl_tls13_generate_and_write_ecdh_key_exchange( MBEDTLS_SSL_DEBUG_MSG( 3, ( "offer curve %s", curve_info->name ) ); - if( ( ret = mbedtls_ecdh_setup( &ssl->handshake->ecdh_ctx, - curve_info->grp_id ) ) != 0 ) + if( ( ret = mbedtls_ecdh_setup_no_everest( &ssl->handshake->ecdh_ctx, + curve_info->grp_id ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecp_group_load", ret ); return( ret ); From d337fbc4cb1ded1d58a1c4fe92aa9988d68ec1f3 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 14 Sep 2021 00:13:05 +0200 Subject: [PATCH 492/966] x86_64 MULADDC assembly: add missing constraints about memory MULADDC_CORE reads from (%%rsi) and writes to (%%rdi). This fragment is repeated up to 16 times, and %%rsi and %%rdi are s and d on entry respectively. Hence the complete asm statement reads 16 64-bit words from memory starting at s, and writes 16 64-bit words starting at d. Without any declaration of modified memory, Clang 12 and Clang 13 generated non-working code for mbedtls_mpi_mod_exp. The constraints make the unit tests pass with Clang 12. Signed-off-by: Gilles Peskine --- ChangeLog.d/muladdc-amd64-memory.txt | 3 +++ library/bn_mul.h | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 ChangeLog.d/muladdc-amd64-memory.txt diff --git a/ChangeLog.d/muladdc-amd64-memory.txt b/ChangeLog.d/muladdc-amd64-memory.txt new file mode 100644 index 0000000000..1803e423d8 --- /dev/null +++ b/ChangeLog.d/muladdc-amd64-memory.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix missing constraints on x86_64 assembly code for bignum multiplication + that broke some bignum operations with (at least) Clang 12. Fixes #4786. diff --git a/library/bn_mul.h b/library/bn_mul.h index 6ddffc4765..328e765008 100644 --- a/library/bn_mul.h +++ b/library/bn_mul.h @@ -225,9 +225,9 @@ "addq $8, %%rdi\n" #define MULADDC_STOP \ - : "+c" (c), "+D" (d), "+S" (s) \ - : "b" (b) \ - : "rax", "rdx", "r8" \ + : "+c" (c), "+D" (d), "+S" (s), "+m" (*(uint64_t (*)[16]) d) \ + : "b" (b), "m" (*(const uint64_t (*)[16]) s) \ + : "rax", "rdx", "r8" \ ); #endif /* AMD64 */ From 388bd0d53c1789669f4f85e1178f7792918270ed Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 15 Sep 2021 18:41:02 +0800 Subject: [PATCH 493/966] fix various issues Signed-off-by: Jerry Yu --- library/ecdh.c | 2 +- library/ecdh_misc.h | 2 +- library/ssl_tls13_client.c | 45 ++++++++++++++------------------------ 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/library/ecdh.c b/library/ecdh.c index 4d73da0748..b72bd1fe08 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -788,7 +788,7 @@ int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, } /* - * Setup context without everst + * Setup context without Everest */ int mbedtls_ecdh_setup_no_everest( mbedtls_ecdh_context *ctx, mbedtls_ecp_group_id grp_id ) diff --git a/library/ecdh_misc.h b/library/ecdh_misc.h index c377e704c1..d1342f8b91 100644 --- a/library/ecdh_misc.h +++ b/library/ecdh_misc.h @@ -30,7 +30,7 @@ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) /* - * Setup context without everst + * Setup context without Everest */ int mbedtls_ecdh_setup_no_everest( mbedtls_ecdh_context *ctx, mbedtls_ecp_group_id grp_id ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 91f1b0c867..13e932c453 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -55,7 +55,7 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported versions extension" ) ); - /* Check if we have space for header and length fields: + /* Check if we have space to write the extension: * - extension_type (2 bytes) * - extension_data_length (2 bytes) * - versions_length (1 byte ) @@ -221,7 +221,7 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, } p += output_len; - /* Both ECDHE and DHE Fail. */ + /* Both ECDHE and DHE failed. */ if( ret_ecdhe != 0 && ret_dhe != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "Both ECDHE and DHE groups are fail. " ) ); @@ -232,7 +232,7 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, named_group_list_len = p - named_group_list_ptr; if( named_group_list_len == 0 ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "No group Available." ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "No group available." ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } @@ -275,7 +275,7 @@ static int ssl_tls13_generate_and_write_ecdh_key_exchange( if( ( ret = mbedtls_ecdh_setup_no_everest( &ssl->handshake->ecdh_ctx, curve_info->grp_id ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecp_group_load", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_setup_no_everest", ret ); return( ret ); } @@ -299,31 +299,20 @@ static int ssl_tls13_get_default_group_id( mbedtls_ssl_context *ssl, { int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; - /* Pick first entry of curve list. - * - * TODO: When we introduce PQC KEMs, we'll have a NamedGroup - * list instead, and can just return its first element. - */ - /* Check if ecdhe named groups are available and pick first entry */ #if defined(MBEDTLS_ECDH_C) -#if !defined(MBEDTLS_ECP_C) - ((void) ssl); -#endif -#if defined(MBEDTLS_ECP_C) - for ( const mbedtls_ecp_group_id * grp_id = ssl->conf->curve_list; + /* Pick first available ECDHE group compatible with TLS 1.3 */ + if( ssl->conf->curve_list == NULL ) + return( MBEDTLS_ERR_SSL_BAD_CONFIG ); + + for ( const mbedtls_ecp_group_id *grp_id = ssl->conf->curve_list; *grp_id != MBEDTLS_ECP_DP_NONE; grp_id++ ) { const mbedtls_ecp_curve_info *info; info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); -#else - for ( const mbedtls_ecp_curve_info *info = mbedtls_ecp_curve_list(); - info->grp_id != MBEDTLS_ECP_DP_NONE; - info++ ) - { -#endif - if( info != NULL && mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) + if( info != NULL && + mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) { *group_id = info->tls_id; return( 0 ); @@ -336,7 +325,7 @@ static int ssl_tls13_get_default_group_id( mbedtls_ssl_context *ssl, /* * Add DHE named groups here. - * Check if ecdhe named groups are available and pick first entry + * Pick first available DHE group compatible with TLS 1.3 */ return( ret ); @@ -345,7 +334,7 @@ static int ssl_tls13_get_default_group_id( mbedtls_ssl_context *ssl, /* * ssl_tls13_write_key_share_ext * - * Structure of key_share extension in ClientHelo: + * Structure of key_share extension in ClientHello: * * struct { * NamedGroup group; @@ -402,8 +391,8 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_ECDH_C) if( mbedtls_ssl_tls13_named_group_is_ecdhe( group_id ) ) { - /* Pointer of group */ - unsigned char *group_id_ptr = p; + /* Pointer to group */ + unsigned char *group_ptr = p; /* Length of key_exchange */ size_t key_exchange_len; @@ -421,9 +410,9 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl, return( ret ); /* Write group */ - MBEDTLS_PUT_UINT16_BE( group_id, group_id_ptr, 0 ); + MBEDTLS_PUT_UINT16_BE( group_id, group_ptr, 0 ); /* Write key_exchange_length */ - MBEDTLS_PUT_UINT16_BE( key_exchange_len, group_id_ptr, 2 ); + MBEDTLS_PUT_UINT16_BE( key_exchange_len, group_ptr, 2 ); } else #endif /* MBEDTLS_ECDH_C */ From 7a5ab044cae7ab148d643426a36694ad785aa4ff Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 15 Sep 2021 19:22:29 +0800 Subject: [PATCH 494/966] Add tls13 test with everst and ecp restartable Signed-off-by: Jerry Yu --- tests/scripts/all.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 9944a853f5..8c88b63532 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2565,6 +2565,8 @@ component_test_tls13_experimental () { make msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, without padding" make test + msg "ssl-opt.sh (TLS 1.3 experimental)" + if_build_succeeded tests/ssl-opt.sh } component_test_tls13_experimental_with_padding () { @@ -2579,6 +2581,31 @@ component_test_tls13_experimental_with_padding () { if_build_succeeded tests/ssl-opt.sh } +component_test_tls13_experimental_with_ecp_restartable () { + msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with ecp_restartable" + scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL + scripts/config.py set MBEDTLS_ECP_RESTARTABLE + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make + msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with ecp_restartable" + make test + msg "ssl-opt.sh (TLS 1.3 experimental)" + if_build_succeeded tests/ssl-opt.sh +} + +component_test_tls13_experimental_with_everest () { + msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with Everest" + scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL + scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED + scripts/config.py unset MBEDTLS_ECP_RESTARTABLE + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make + msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with Everest" + make test + msg "ssl-opt.sh (TLS 1.3 experimental)" + if_build_succeeded tests/ssl-opt.sh +} + component_build_mingw () { msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs From 5b1df10470f901a8cc2855f74137959176e0f2e2 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 15 Sep 2021 17:04:31 +0200 Subject: [PATCH 495/966] Update the list of issues fixed This had actually been reported multiple times. Signed-off-by: Gilles Peskine --- ChangeLog.d/muladdc-amd64-memory.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.d/muladdc-amd64-memory.txt b/ChangeLog.d/muladdc-amd64-memory.txt index 1803e423d8..b834331671 100644 --- a/ChangeLog.d/muladdc-amd64-memory.txt +++ b/ChangeLog.d/muladdc-amd64-memory.txt @@ -1,3 +1,4 @@ Bugfix * Fix missing constraints on x86_64 assembly code for bignum multiplication - that broke some bignum operations with (at least) Clang 12. Fixes #4786. + that broke some bignum operations with (at least) Clang 12. + Fixes #4116, #4786, #4917. From 133740b74e0cbdb078c1194bf7271e413d645bf7 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Fri, 17 Sep 2021 09:38:07 +0200 Subject: [PATCH 496/966] tests: Improve incomplete then overflow tests Signed-off-by: Ronald Cron --- tests/suites/test_suite_ccm.function | 34 ++++++++-------------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index 472be64540..e48b1f990a 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -646,16 +646,10 @@ void mbedtls_ccm_incomplete_ad_and_overflow( int cipher_id, int mode, data_t * add ) { mbedtls_ccm_context ctx; + uint8_t add_second_buffer[2]; - /* New auth buffer containing same data as original one, - * with added extra byte at the end */ - uint8_t* add_extended = NULL; - ASSERT_ALLOC( add_extended, add->len + 1 ); - if( add_extended ) - { - memcpy( add_extended, add->x, add->len ); - add_extended[add->len] = 0xAB; // some magic value - } + add_second_buffer[0] = add->x[ add->len - 1 ]; + add_second_buffer[1] = 0xAB; // some magic value mbedtls_ccm_init( &ctx ); TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); @@ -664,11 +658,10 @@ void mbedtls_ccm_incomplete_ad_and_overflow( int cipher_id, int mode, TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, add->len, 16, 16 ) ); // pass incomplete auth data - TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add_extended, add->len - 1) ); + TEST_EQUAL( 0, mbedtls_ccm_update_ad( &ctx, add->x, add->len - 1) ); // pass 2 extra bytes (1 missing byte from previous incomplete pass, and 1 unexpected byte) - TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update_ad( &ctx, add_extended + add->len - 1, 2) ); + TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, mbedtls_ccm_update_ad( &ctx, add_second_buffer, 2) ); exit: - mbedtls_free( add_extended ); mbedtls_ccm_free( &ctx ); } /* END_CASE */ @@ -775,16 +768,10 @@ void mbedtls_ccm_incomplete_update_overflow( int cipher_id, int mode, mbedtls_ccm_context ctx; uint8_t *output = NULL; size_t olen; + uint8_t msg_second_buffer[2]; - /* New plaintext/ciphertext buffer containing same data as original one, - * with added extra byte at the end */ - uint8_t* msg_extended = NULL; - ASSERT_ALLOC( msg_extended, msg->len + 1 ); - if( msg_extended ) - { - memcpy( msg_extended, msg->x, msg->len ); - msg_extended[msg->len] = 0xAB; // some magic value - } + msg_second_buffer[0] = msg->x[ msg->len - 1 ]; + msg_second_buffer[1] = 0xAB; // some magic value mbedtls_ccm_init( &ctx ); TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); @@ -796,12 +783,11 @@ void mbedtls_ccm_incomplete_update_overflow( int cipher_id, int mode, ASSERT_ALLOC( output, msg->len + 1 ); // pass incomplete text - TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg_extended, msg->len - 1, output, msg->len + 1, &olen ) ); + TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg->x, msg->len - 1, output, msg->len + 1, &olen ) ); // pass 2 extra bytes (1 missing byte from previous incomplete pass, and 1 unexpected byte) TEST_EQUAL( MBEDTLS_ERR_CCM_BAD_INPUT, \ - mbedtls_ccm_update( &ctx, msg_extended + msg->len - 1, 2, output + msg->len - 1, 2, &olen ) ); + mbedtls_ccm_update( &ctx, msg_second_buffer, 2, output + msg->len - 1, 2, &olen ) ); exit: - mbedtls_free( msg_extended ); mbedtls_free( output ); mbedtls_ccm_free( &ctx ); } From 2beb5f302a9ebe313fe1b93d43ec4add7bb9f9d0 Mon Sep 17 00:00:00 2001 From: openluopworld Date: Fri, 17 Sep 2021 16:40:22 +0800 Subject: [PATCH 497/966] bugfix: if the len of iv is not 96-bit, ghash is used to compute y0. An initialization vector IV can have any number of bits between 1 and 2^64. So it should be filled to the lower 64-bit in the last step when computing ghash. Signed-off-by: openluopworld --- library/gcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/gcm.c b/library/gcm.c index 910646b281..b575c8f316 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -254,6 +254,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, size_t i; const unsigned char *p; size_t use_len, olen = 0; + size_t iv_bits; GCM_VALIDATE_RET( ctx != NULL ); GCM_VALIDATE_RET( iv != NULL ); @@ -278,7 +279,9 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, else { memset( work_buf, 0x00, 16 ); - MBEDTLS_PUT_UINT32_BE( iv_len * 8, work_buf, 12 ); + iv_bits = iv_len << 3; + MBEDTLS_PUT_UINT32_BE( (iv_bits >> 32), work_buf, 8 ); + MBEDTLS_PUT_UINT32_BE( iv_bits, work_buf, 12 ); p = iv; while( iv_len > 0 ) From 6c8183f0c92c953d421289d22b75de76c2ab5347 Mon Sep 17 00:00:00 2001 From: openluopworld Date: Fri, 17 Sep 2021 22:15:49 +0800 Subject: [PATCH 498/966] bugfix: if the len of iv is not 96-bit, ghash is used to compute y0. An initialization vector IV can have any number of bits between 1 and 2^64. So it should be filled to the lower 64-bit in the last step when computing ghash. Signed-off-by: openluopworld --- library/gcm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/gcm.c b/library/gcm.c index b575c8f316..0810fd2205 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -254,7 +254,6 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, size_t i; const unsigned char *p; size_t use_len, olen = 0; - size_t iv_bits; GCM_VALIDATE_RET( ctx != NULL ); GCM_VALIDATE_RET( iv != NULL ); @@ -279,9 +278,8 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, else { memset( work_buf, 0x00, 16 ); - iv_bits = iv_len << 3; - MBEDTLS_PUT_UINT32_BE( (iv_bits >> 32), work_buf, 8 ); - MBEDTLS_PUT_UINT32_BE( iv_bits, work_buf, 12 ); + MBEDTLS_PUT_UINT32_BE( iv_len >> 29, work_buf, 8 ); + MBEDTLS_PUT_UINT32_BE( iv_len << 3, work_buf, 12 ); p = iv; while( iv_len > 0 ) From 08fd463ee45a0332f469a6de5acc977a50672999 Mon Sep 17 00:00:00 2001 From: openluopworld Date: Sun, 19 Sep 2021 11:18:04 +0800 Subject: [PATCH 499/966] bugfix: if the len of iv is not 96-bit, y0 can be calculated incorrectly An initialization vector IV can have any number of bits between 1 and 2^64. So it should be filled to the lower 64-bit in the last step when computing ghash. Signed-off-by: openluopworld --- library/gcm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/gcm.c b/library/gcm.c index 0810fd2205..e1c1c7d518 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -278,8 +278,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, else { memset( work_buf, 0x00, 16 ); - MBEDTLS_PUT_UINT32_BE( iv_len >> 29, work_buf, 8 ); - MBEDTLS_PUT_UINT32_BE( iv_len << 3, work_buf, 12 ); + MBEDTLS_PUT_UINT64_BE( iv_len * 8, work_buf, 8 ); p = iv; while( iv_len > 0 ) From e64deda873027d7e0a841fda47e741aa55cf2498 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 9 Sep 2021 14:07:23 +0100 Subject: [PATCH 500/966] Add missing check to multipart decrypt Ensure that the test actually does something, rather than skipping both parts, also add comment to this effect. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index a881087151..19b687e176 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3494,6 +3494,8 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, size_t ad_part_len = 0; size_t data_part_len = 0; + /* Ensure that either one part of the test or the other is done, i.e this + * test does something. */ TEST_ASSERT( do_test_ad_chunked || do_test_data_chunked ); /* Temporary whilst we have algorithms that cannot support chunking */ @@ -3588,6 +3590,10 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, size_t ad_part_len = 0; size_t data_part_len = 0; + /* Ensure that either one part of the test or the other is done, i.e this + * test does something. */ + TEST_ASSERT( do_test_ad_chunked || do_test_data_chunked ); + /* Temporary whilst we have algorithms that cannot support chunking */ if( do_test_ad_chunked == 1 ) { From 4023ffd275d27e5c4ae2c6dffff5c042c6b2566a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 10 Sep 2021 16:21:22 +0100 Subject: [PATCH 501/966] Re-add option of NULL buffer for nonce tests NULL/zero length or valid buffer/zero length both now tested Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 12 ++++++++++-- tests/suites/test_suite_psa_crypto.function | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 371fee0247..ff3718bd8d 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2598,10 +2598,14 @@ PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:12:"":"":PSA_SUCCESS -PSA Multipart Set Nonce, AES - GCM, IV = 0 +PSA Multipart Set Nonce, AES - GCM, IV = 0 (NULL) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"":"":PSA_ERROR_INVALID_ARGUMENT +PSA Multipart Set Nonce, AES - GCM, IV = 0 (Non-NULL) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):-1:"":"":PSA_ERROR_INVALID_ARGUMENT + PSA Multipart Set Nonce, AES - GCM, IV = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS @@ -2618,10 +2622,14 @@ PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 8 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:"":"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 +PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 (NULL) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"":"":PSA_ERROR_INVALID_ARGUMENT +PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 (Non-NULL) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:-1:"":"":PSA_ERROR_INVALID_ARGUMENT + PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:"":"":PSA_ERROR_INVALID_ARGUMENT diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 19b687e176..4dfaccb974 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3777,7 +3777,7 @@ exit: /* BEGIN_CASE */ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, int alg_arg, - int nonce_length, + int nonce_length_arg, data_t *additional_data, data_t *input_data, int expected_status_arg ) @@ -3793,12 +3793,13 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, psa_status_t expected_status = expected_status_arg; unsigned char *output = NULL; unsigned char *ciphertext = NULL; + size_t nonce_length; size_t output_size = 0; size_t ciphertext_size = 0; size_t ciphertext_length = 0; size_t tag_length = 0; uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; - int index = 0; + size_t index = 0; PSA_ASSERT( psa_crypto_init( ) ); @@ -3831,23 +3832,30 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, if( status == PSA_ERROR_NOT_SUPPORTED ) { MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); - MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_length ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_length_arg ); } PSA_ASSERT( status ); - if( nonce_length == 0 ) + /* -1 == zero length and valid buffer, 0 = zero length and NULL buffer. */ + if( nonce_length_arg == -1 ) { /* Arbitrary size buffer, to test zero length valid buffer. */ ASSERT_ALLOC( nonce_buffer, 4 ); + nonce_length = 0; } else { + /* If length is zero, then this will return NULL. */ + nonce_length = ( size_t ) nonce_length_arg; ASSERT_ALLOC( nonce_buffer, nonce_length ); - for( index = 0; index < nonce_length - 1; ++index) + if( nonce_buffer ) { - nonce_buffer[index] = 'a' + index; + for( index = 0; index < nonce_length - 1; ++index ) + { + nonce_buffer[index] = 'a' + index; + } } } From e58cb1e0cf2f517fb407e4808aee6bffd0a0b263 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 10 Sep 2021 18:36:00 +0100 Subject: [PATCH 502/966] Aligh finish_buffer_test vars with PSA standard Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 30 +++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 4dfaccb974..5c27a59579 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3976,7 +3976,7 @@ exit: /* BEGIN_CASE */ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, int alg_arg, - int buffer_size, + int finish_ciphertext_size_arg, data_t *nonce, data_t *additional_data, data_t *input_data, @@ -3990,10 +3990,11 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; - unsigned char *output_data = NULL; - unsigned char *final_data = NULL; - size_t output_size = 0; - size_t output_length = 0; + unsigned char *ciphertext = NULL; + unsigned char *finish_ciphertext = NULL; + size_t ciphertext_size = 0; + size_t ciphertext_length = 0; + size_t finish_ciphertext_size = ( size_t ) finish_ciphertext_size_arg; size_t tag_length = 0; uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; @@ -4008,13 +4009,13 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); - output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); + ciphertext_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len ); - ASSERT_ALLOC( output_data, output_size ); + ASSERT_ALLOC( ciphertext, ciphertext_size ); - TEST_ASSERT( buffer_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + TEST_ASSERT( finish_ciphertext_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - ASSERT_ALLOC( final_data, buffer_size ); + ASSERT_ALLOC( finish_ciphertext, finish_ciphertext_size ); operation = psa_aead_operation_init( ); @@ -4037,19 +4038,20 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, additional_data->len ) ); PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len, - output_data, output_size, &output_length ) ); + ciphertext, ciphertext_size, &ciphertext_length ) ); /* Ensure we can still complete operation. */ - status = psa_aead_finish( &operation, final_data, buffer_size, - &output_length, tag_buffer, + status = psa_aead_finish( &operation, finish_ciphertext, + finish_ciphertext_size, + &ciphertext_length, tag_buffer, PSA_AEAD_TAG_MAX_SIZE, &tag_length ); TEST_EQUAL( status, expected_status ); exit: psa_destroy_key( key ); - mbedtls_free( output_data ); - mbedtls_free( final_data ); + mbedtls_free( ciphertext ); + mbedtls_free( finish_ciphertext ); psa_aead_abort( &operation ); PSA_DONE( ); } From 719c1324a124dcb7f6744f206e2c930020032629 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 13 Sep 2021 18:27:22 +0100 Subject: [PATCH 503/966] Add tag buffer size tests to finish buffer tests Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 29 ++++++++++++++++----- tests/suites/test_suite_psa_crypto.function | 8 ++++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index ff3718bd8d..8bf7303879 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2650,17 +2650,34 @@ PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 130 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:130:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_SUCCESS -PSA AEAD finish buffer test: AES - GCM, BUF = 8 +PSA AEAD finish buffer test: AES - GCM, BUF = 8, TAG = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):8:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):8:16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL -PSA AEAD finish buffer test: AES - GCM, BUF = 15 +PSA AEAD finish buffer test: AES - GCM, BUF = 15, TAG = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:20:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS -PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0 +PSA AEAD finish buffer test: AES - GCM, BUF = 15, TAG = 15 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL + +PSA AEAD finish buffer test: AES - GCM, BUF = 15, TAG = 0 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:0:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL + +PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0, TAG = 20 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_SUCCESS +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:20:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_SUCCESS + +PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0, TAG = 15 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:15:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL + +PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0, TAG = 0 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL + PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 5c27a59579..eea0b68e03 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3977,6 +3977,7 @@ exit: void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, int alg_arg, int finish_ciphertext_size_arg, + int tag_size_arg, data_t *nonce, data_t *additional_data, data_t *input_data, @@ -3992,11 +3993,12 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, psa_status_t expected_status = expected_status_arg; unsigned char *ciphertext = NULL; unsigned char *finish_ciphertext = NULL; + unsigned char *tag_buffer = NULL; size_t ciphertext_size = 0; size_t ciphertext_length = 0; size_t finish_ciphertext_size = ( size_t ) finish_ciphertext_size_arg; + size_t tag_size = ( size_t ) tag_size_arg; size_t tag_length = 0; - uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; PSA_ASSERT( psa_crypto_init( ) ); @@ -4017,6 +4019,8 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, ASSERT_ALLOC( finish_ciphertext, finish_ciphertext_size ); + ASSERT_ALLOC( tag_buffer, tag_size ); + operation = psa_aead_operation_init( ); status = psa_aead_encrypt_setup( &operation, key, alg ); @@ -4044,7 +4048,7 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, status = psa_aead_finish( &operation, finish_ciphertext, finish_ciphertext_size, &ciphertext_length, tag_buffer, - PSA_AEAD_TAG_MAX_SIZE, &tag_length ); + tag_size, &tag_length ); TEST_EQUAL( status, expected_status ); From 06b6b8c8d6752d4da7d58f80cb52c41e2f2a30a5 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 13 Sep 2021 19:02:04 +0100 Subject: [PATCH 504/966] Add missing zeroize for sensitive tag data. Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 1dd3b2db92..5e7eb11ccf 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1760,6 +1760,8 @@ psa_status_t psa_driver_wrapper_aead_verify( status = PSA_ERROR_INVALID_SIGNATURE; } + mbedtls_platform_zeroize( check_tag, sizeof( check_tag ) ); + return( status ); } From b183d56b5f0a836af85c9bedaf9790ef0d0b284d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 13 Sep 2021 19:02:57 +0100 Subject: [PATCH 505/966] Use safer size for tag checking Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 5e7eb11ccf..4c56162f3b 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1749,7 +1749,7 @@ psa_status_t psa_driver_wrapper_aead_verify( plaintext_size, plaintext_length, check_tag, - tag_length, + sizeof( check_tag ), &check_tag_length ); if( status == PSA_SUCCESS ) From 5a9642ff287c96b19c5933b85f10c9c9f7e894fb Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 13 Sep 2021 19:13:22 +0100 Subject: [PATCH 506/966] Correct switched blocks for output sizes Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index eea0b68e03..b99be90ff8 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -372,13 +372,13 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, if( is_encrypt ) { - final_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( key_type, alg ); - TEST_ASSERT( final_output_size <= PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); + final_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); + TEST_ASSERT( final_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); } else { - final_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg ); - TEST_ASSERT( final_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); + final_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( key_type, alg ); + TEST_ASSERT( final_output_size <= PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE ); } ASSERT_ALLOC( final_data, final_output_size ); From 6bfd0fbbc6b24e1b8a5d76c226ff6c806fef49c1 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 14:15:55 +0100 Subject: [PATCH 507/966] Convert all uint32_t lengths over to size_t Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index b99be90ff8..da39502146 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -297,9 +297,9 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, int alg_arg, data_t *nonce, data_t *additional_data, - int ad_part_len, + int ad_part_len_arg, data_t *input_data, - int data_part_len, + int data_part_len_arg, int do_set_lengths, data_t *expected_output, int expect_valid_signature, @@ -321,16 +321,18 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, size_t output_length = 0; size_t key_bits = 0; size_t tag_length = 0; - uint32_t part_offset = 0; + size_t part_offset = 0; size_t part_length = 0; size_t output_part_length = 0; size_t tag_size = 0; + size_t ad_part_len = 0; + size_t data_part_len = 0; uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE]; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; int test_ok = 0; - uint32_t part_count = 0; + size_t part_count = 0; PSA_ASSERT( psa_crypto_init( ) ); @@ -423,9 +425,10 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, } } - if( ad_part_len != -1 ) + if( ad_part_len_arg != -1 ) { /* Pass additional data in parts */ + ad_part_len = (size_t) ad_part_len_arg; part_offset = 0; while( part_offset < additional_data->len ) @@ -436,8 +439,7 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, } else { - if( additional_data->len - part_offset < - ( uint32_t ) ad_part_len ) + if( additional_data->len - part_offset < ad_part_len ) { part_length = additional_data->len - part_offset; } @@ -461,9 +463,10 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, additional_data->len ) ); } - if( data_part_len != -1 ) + if( data_part_len_arg != -1 ) { /* Pass data in parts */ + data_part_len = ( size_t ) data_part_len_arg; part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len ); @@ -479,7 +482,7 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, } else { - if( ( data_true_size - part_offset ) < ( uint32_t ) data_part_len ) + if( ( data_true_size - part_offset ) < data_part_len ) { part_length = ( data_true_size - part_offset ); } From 9454cfa911ceb40d9caf83085ca739f03607af1f Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 14:21:55 +0100 Subject: [PATCH 508/966] Remove unneccesary safety check in test Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index da39502146..543b2f6b24 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4018,8 +4018,6 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, ASSERT_ALLOC( ciphertext, ciphertext_size ); - TEST_ASSERT( finish_ciphertext_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE ); - ASSERT_ALLOC( finish_ciphertext, finish_ciphertext_size ); ASSERT_ALLOC( tag_buffer, tag_size ); From 33746aac321225b0d546d1394b6ad3d65e6d8567 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 16:40:40 +0100 Subject: [PATCH 509/966] Convert set lengths options over to enum Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 107 ++++++++++++-------- 1 file changed, 67 insertions(+), 40 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 543b2f6b24..99183991d0 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -264,6 +264,13 @@ typedef enum { DERIVE_KEY = 2 } generate_method; +typedef enum +{ + DO_NOT_SET_LENGTHS = 0, + SET_LENGTHS_BEFORE_NONCE = 1, + SET_LENGTHS_AFTER_NONCE = 2 +} setlengths_method; + /*! * \brief Internal Function for AEAD multipart tests. * @@ -300,12 +307,11 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, int ad_part_len_arg, data_t *input_data, int data_part_len_arg, - int do_set_lengths, + setlengths_method set_lengths_method, data_t *expected_output, int expect_valid_signature, int is_encrypt, - int do_zero_parts, - int swap_set_functions ) + int do_zero_parts ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; @@ -404,25 +410,20 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, PSA_ASSERT( status ); - if( swap_set_functions ) + if( set_lengths_method == DO_NOT_SET_LENGTHS ) + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + else if( set_lengths_method == SET_LENGTHS_BEFORE_NONCE ) { - if( do_set_lengths ) - { - PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, - data_true_size ) ); - } - + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + data_true_size ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); } - else + else if( set_lengths_method == SET_LENGTHS_AFTER_NONCE ) { PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); - if( do_set_lengths ) - { - PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, - data_true_size ) ); - } + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + data_true_size ) ); } if( ad_part_len_arg != -1 ) @@ -3496,6 +3497,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, { size_t ad_part_len = 0; size_t data_part_len = 0; + setlengths_method set_lengths_method = DO_NOT_SET_LENGTHS; /* Ensure that either one part of the test or the other is done, i.e this * test does something. */ @@ -3509,16 +3511,23 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, { mbedtls_test_set_step( ad_part_len ); + if( do_set_lengths ) + { + if( ad_part_len & 0x01 ) + set_lengths_method = SET_LENGTHS_AFTER_NONCE; + else + set_lengths_method = SET_LENGTHS_BEFORE_NONCE; + } + /* Split ad into length(ad_part_len) parts. */ if( !aead_multipart_internal_func( key_type_arg, key_data, alg_arg, nonce, additional_data, ad_part_len, input_data, -1, - do_set_lengths, + set_lengths_method, expected_output, - 1, 1, 0, - ( ad_part_len & 0x01 ) ) ) + 1, 1, 0 ) ) break; /* length(0) part, length(ad_part_len) part, length(0) part... */ @@ -3529,10 +3538,9 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, additional_data, ad_part_len, input_data, -1, - do_set_lengths, + set_lengths_method, expected_output, - 1, 1, 1, - ( ad_part_len & 0x01 ) ) ) + 1, 1, 1 ) ) break; } } @@ -3546,14 +3554,21 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, /* Split data into length(data_part_len) parts. */ mbedtls_test_set_step( 2000 + data_part_len ); + if( do_set_lengths ) + { + if( data_part_len & 0x01 ) + set_lengths_method = SET_LENGTHS_AFTER_NONCE; + else + set_lengths_method = SET_LENGTHS_BEFORE_NONCE; + } + if( !aead_multipart_internal_func( key_type_arg, key_data, alg_arg, nonce, additional_data, -1, input_data, data_part_len, - do_set_lengths, + set_lengths_method, expected_output, - 1, 1, 0, - ( data_part_len & 0x01 ) ) ) + 1, 1, 0 ) ) break; /* length(0) part, length(data_part_len) part, length(0) part... */ @@ -3563,10 +3578,9 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, alg_arg, nonce, additional_data, -1, input_data, data_part_len, - do_set_lengths, + set_lengths_method, expected_output, - 1, 1, 1, - ( data_part_len & 0x01 ) ) ) + 1, 1, 1 ) ) break; } } @@ -3592,6 +3606,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, { size_t ad_part_len = 0; size_t data_part_len = 0; + setlengths_method set_lengths_method = DO_NOT_SET_LENGTHS; /* Ensure that either one part of the test or the other is done, i.e this * test does something. */ @@ -3606,16 +3621,23 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, /* Split ad into length(ad_part_len) parts. */ mbedtls_test_set_step( ad_part_len ); + if( do_set_lengths ) + { + if( ad_part_len & 0x01 ) + set_lengths_method = SET_LENGTHS_AFTER_NONCE; + else + set_lengths_method = SET_LENGTHS_BEFORE_NONCE; + } + if( !aead_multipart_internal_func( key_type_arg, key_data, alg_arg, nonce, additional_data, ad_part_len, input_data, -1, - do_set_lengths, + set_lengths_method, expected_output, expect_valid_signature, - 0, 0, - ( ad_part_len & 0x01 ) ) ) + 0, 0 ) ) break; /* length(0) part, length(ad_part_len) part, length(0) part... */ @@ -3626,11 +3648,10 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, additional_data, ad_part_len, input_data, -1, - do_set_lengths, + set_lengths_method, expected_output, expect_valid_signature, - 0, 1, - ( ad_part_len & 0x01 ) ) ) + 0, 1 ) ) break; } } @@ -3644,15 +3665,22 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, /* Split data into length(data_part_len) parts. */ mbedtls_test_set_step( 2000 + data_part_len ); + if( do_set_lengths ) + { + if( data_part_len & 0x01 ) + set_lengths_method = SET_LENGTHS_AFTER_NONCE; + else + set_lengths_method = SET_LENGTHS_BEFORE_NONCE; + } + if( !aead_multipart_internal_func( key_type_arg, key_data, alg_arg, nonce, additional_data, -1, input_data, data_part_len, - do_set_lengths, + set_lengths_method, expected_output, expect_valid_signature, - 0, 0, - ( data_part_len & 0x01 ) ) ) + 0, 0 ) ) break; /* length(0) part, length(data_part_len) part, length(0) part... */ @@ -3662,11 +3690,10 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, alg_arg, nonce, additional_data, -1, input_data, data_part_len, - do_set_lengths, + set_lengths_method, expected_output, expect_valid_signature, - 0, 1, - ( data_part_len & 0x01 ) ) ) + 0, 1 ) ) break; } } From 4e4d71a8388b3aec1779af1daa045652d450e506 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 16:50:01 +0100 Subject: [PATCH 510/966] Move hidden logic into loop 'for' statement Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 99183991d0..f5865bb741 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -430,11 +430,12 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, { /* Pass additional data in parts */ ad_part_len = (size_t) ad_part_len_arg; - part_offset = 0; - while( part_offset < additional_data->len ) + for( part_offset = 0, part_count = 0; + part_offset < additional_data->len; + part_offset += part_length, part_count++ ) { - if( do_zero_parts && part_count++ & 0x01 ) + if( do_zero_parts && ( part_count & 0x01 ) ) { part_length = 0; } @@ -454,7 +455,6 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, additional_data->x + part_offset, part_length ) ); - part_offset += part_length; } } else @@ -473,11 +473,11 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, ASSERT_ALLOC( part_data, part_data_size ); - part_offset = 0; - - while( part_offset < data_true_size ) + for( part_offset = 0, part_count = 0; + part_offset < data_true_size; + part_offset += part_length, part_count++ ) { - if( do_zero_parts && part_count++ & 0x01 ) + if( do_zero_parts && ( part_count & 0x01 ) ) { part_length = 0; } @@ -505,7 +505,6 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, output_part_length ); } - part_offset += part_length; output_length += output_part_length; } } From e49fe454785bfe1654ffe28f8be17e8113248877 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 16:52:11 +0100 Subject: [PATCH 511/966] Remove unneccesary nesting Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 26 ++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index f5865bb741..7c3e9904d8 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -439,16 +439,13 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, { part_length = 0; } + else if( additional_data->len - part_offset < ad_part_len ) + { + part_length = additional_data->len - part_offset; + } else { - if( additional_data->len - part_offset < ad_part_len ) - { - part_length = additional_data->len - part_offset; - } - else - { - part_length = ad_part_len; - } + part_length = ad_part_len; } PSA_ASSERT( psa_aead_update_ad( &operation, @@ -481,16 +478,13 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, { part_length = 0; } + else if( ( data_true_size - part_offset ) < data_part_len ) + { + part_length = ( data_true_size - part_offset ); + } else { - if( ( data_true_size - part_offset ) < data_part_len ) - { - part_length = ( data_true_size - part_offset ); - } - else - { - part_length = data_part_len; - } + part_length = data_part_len; } PSA_ASSERT( psa_aead_update( &operation, From f38adbe5588b90764de0e3882fc7eb6359a5cd1a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 17:04:19 +0100 Subject: [PATCH 512/966] Ensure tests expected to fail actually fail Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 7c3e9904d8..f9f013a227 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -524,16 +524,18 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, ( input_data->x + data_true_size ), tag_length ); - if( status != PSA_SUCCESS ) + if( expect_valid_signature ) + PSA_ASSERT( status ); + else { - if( !expect_valid_signature ) + TEST_ASSERT( status != PSA_SUCCESS ); + + if( status != PSA_SUCCESS ) { /* Expected failure. */ test_ok = 1; goto exit; } - else - PSA_ASSERT( status ); } } From a3d153f928373abdac80e736b99138fec718d6cd Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 17:37:41 +0100 Subject: [PATCH 513/966] Make nonce based test descriptions more clear Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 8bf7303879..9e0b574dba 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2570,67 +2570,67 @@ PSA Multipart AEAD decrypt: invalid algorithm (ChaCha20) depends_on:MBEDTLS_CHACHA20_C aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:0:"":0 -PSA Multipart Nonce Generation, AES - GCM, IV = 12 +PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 12 / Expect 12) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS -PSA Multipart Nonce Generation, AES - GCM, IV = 0 +PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 0 / Expect 0) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL -PSA Multipart Nonce Generation, AES - GCM, IV = 16 +PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 16 / Expect 12) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS -PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 12 +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 12 / Expect 12) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS -PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 8 +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 8 / Expect 0) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL -PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 0 +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 0 / Expect 0) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL -PSA Multipart Nonce Generation: ChaCha20 - Poly1305, IV = 16 +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 16 / Expect 12) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:12:"":"":PSA_SUCCESS -PSA Multipart Set Nonce, AES - GCM, IV = 0 (NULL) +PSA Multipart Set Nonce, AES - GCM, NONCE = 0 (NULL) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"":"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart Set Nonce, AES - GCM, IV = 0 (Non-NULL) +PSA Multipart Set Nonce, AES - GCM, NONCE = 0 (Non-NULL) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):-1:"":"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart Set Nonce, AES - GCM, IV = 16 +PSA Multipart Set Nonce, AES - GCM, NONCE = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS -PSA Multipart Set Nonce, AES - GCM, IV = 20 +PSA Multipart Set Nonce, AES - GCM, NONCE = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS -PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 12 +PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 12 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS -PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 8 +PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 8 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:"":"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 (NULL) +PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 0 (NULL) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"":"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 0 (Non-NULL) +PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 0 (Non-NULL) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:-1:"":"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart Set Nonce: ChaCha20 - Poly1305, IV = 16 +PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 16 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:"":"":PSA_ERROR_INVALID_ARGUMENT From 12acb6bb4c4136ee53876ee6e80948646d7abcd0 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 17:45:22 +0100 Subject: [PATCH 514/966] Remove missed references to aead_verify from docs Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index 5ed26d002e..9b6b798b66 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -325,14 +325,6 @@ psa_status_t mbedtls_psa_aead_set_lengths( * If this function returns an error status, the PSA core will call * mbedtls_psa_aead_abort(). * - * \warning When decrypting, until mbedtls_psa_aead_verify() has returned - * #PSA_SUCCESS, there is no guarantee that the input is valid. - * Therefore, until you have called mbedtls_psa_aead_verify() and it - * has returned #PSA_SUCCESS, treat the input as untrusted and prepare - * to undo any action that depends on the input if - * mbedtls_psa_aead_verify() returns an error status. - * - * * \param[in,out] operation Active AEAD operation. * \param[in] input Buffer containing the fragment of * additional data. @@ -370,9 +362,9 @@ psa_status_t mbedtls_psa_aead_update_ad( * particular block boundary. If the implementation can only process * a whole block at a time, it must consume all the input provided, but * it may delay the end of the corresponding output until a subsequent - * call to mbedtls_psa_aead_update(), mbedtls_psa_aead_finish() or - * mbedtls_psa_aead_verify() provides sufficient input. The amount of data that - * can be delayed in this way is bounded by #PSA_AEAD_UPDATE_OUTPUT_SIZE. + * call to mbedtls_psa_aead_update(), mbedtls_psa_aead_finish() provides + * sufficient input. The amount of data that can be delayed in this way is + * bounded by #PSA_AEAD_UPDATE_OUTPUT_SIZE. * * \param[in,out] operation Active AEAD operation. * \param[in] input Buffer containing the message fragment to @@ -501,8 +493,8 @@ psa_status_t mbedtls_psa_aead_finish( * been initialized as described in #mbedtls_psa_aead_operation_t. * * In particular, calling mbedtls_psa_aead_abort() after the operation has been - * terminated by a call to mbedtls_psa_aead_abort(), mbedtls_psa_aead_finish() - * or mbedtls_psa_aead_verify() is safe and has no effect. + * terminated by a call to mbedtls_psa_aead_abort() or + * mbedtls_psa_aead_finish() is safe and has no effect. * * \param[in,out] operation Initialized AEAD operation. * From eac6c757a27db9457b0f9301f4c0f654638b75d7 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 15 Sep 2021 19:08:27 +0100 Subject: [PATCH 515/966] Make nonce length check return error where it can Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 033dc82079..46eb1c9332 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -195,12 +195,10 @@ psa_status_t mbedtls_psa_aead_encrypt( } tag = ciphertext + plaintext_length; - if( mbedtls_aead_check_nonce_length( &operation, nonce_length ) - != PSA_SUCCESS ) - { - status = PSA_ERROR_NOT_SUPPORTED; + status = mbedtls_aead_check_nonce_length( &operation, nonce_length ); + + if( status != PSA_SUCCESS ) goto exit; - } #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation.alg == PSA_ALG_CCM ) @@ -310,12 +308,10 @@ psa_status_t mbedtls_psa_aead_decrypt( if( status != PSA_SUCCESS ) goto exit; - if( mbedtls_aead_check_nonce_length( &operation, nonce_length ) - != PSA_SUCCESS ) - { - status = PSA_ERROR_NOT_SUPPORTED; + status = mbedtls_aead_check_nonce_length( &operation, nonce_length ); + + if( status != PSA_SUCCESS ) goto exit; - } #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation.alg == PSA_ALG_CCM ) From 6a60b12ef98a9ee3aa8b3863354da58118103745 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 16 Sep 2021 17:12:12 +0100 Subject: [PATCH 516/966] Make buffer size checks +-1 from correct size i.e Check correct buffer size +1 and correct buffer size -1 (where applicable) to check too big and too small cases, and hopefully catch edge cases. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 9e0b574dba..bdf1a52d15 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2574,6 +2574,10 @@ PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 12 / Expect 12) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 11 / Expect 0) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):11:0:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_ERROR_BUFFER_TOO_SMALL + PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 0 / Expect 0) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL @@ -2586,9 +2590,9 @@ PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 12 / Expect 12 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS -PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 8 / Expect 0) +PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 11 / Expect 0) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:11:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 0 / Expect 0) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 @@ -2614,13 +2618,17 @@ PSA Multipart Set Nonce, AES - GCM, NONCE = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 11 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:11:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_ERROR_INVALID_ARGUMENT + PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 12 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:12:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_SUCCESS -PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 8 +PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 13 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:8:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:13:"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 0 (NULL) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 @@ -2630,21 +2638,17 @@ PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 0 (Non-NULL) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:-1:"":"":PSA_ERROR_INVALID_ARGUMENT -PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 16 -depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:16:"":"":PSA_ERROR_INVALID_ARGUMENT - -PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 10 +PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):10:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS -PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 10 +PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 129 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:10:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:129:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 130 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 @@ -2678,7 +2682,6 @@ PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0, TAG = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL - PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" From ce2c1faf1a8ffd5c3f2a03e58c683e7fdbfdd4d7 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 16 Sep 2021 17:56:23 +0100 Subject: [PATCH 517/966] Remove uneccesary postive buffer size tests Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index bdf1a52d15..cac6c68562 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2642,18 +2642,10 @@ PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL -PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 16 -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS - PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 129 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:129:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL -PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 130 -depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:130:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_SUCCESS - PSA AEAD finish buffer test: AES - GCM, BUF = 8, TAG = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):8:16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL From fd0c154ce367f39f64d634e77945dc5437a3729f Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 17 Sep 2021 18:03:52 +0100 Subject: [PATCH 518/966] Add tests to oversend data/ad when lengths set Previous tests only tested when the expected lengths were set to zero. New test sends all data/ad then goes over by one byte. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index f9f013a227..b6d52f7d66 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4467,6 +4467,24 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + TEST_EQUAL( psa_aead_update_ad( &operation, additional_data->x, + 1 ), + PSA_ERROR_INVALID_ARGUMENT ); + + psa_aead_abort( &operation ); + /* Test for sending too much data after setting lengths. */ operation = psa_aead_operation_init( ); @@ -4484,6 +4502,29 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + PSA_ASSERT( psa_aead_update( &operation, input_data->x, + input_data->len, output_data, + output_size, &output_length ) ); + + TEST_EQUAL( psa_aead_update( &operation, input_data->x, + 1, output_data, + output_size, &output_length ), + PSA_ERROR_INVALID_ARGUMENT ); + + psa_aead_abort( &operation ); + /* Test sending additional data after data. */ operation = psa_aead_operation_init( ); From 9961a668bd5885d0261985b558d6f813eec16547 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 17 Sep 2021 19:19:02 +0100 Subject: [PATCH 519/966] Remove negative tests from multipart_decrypt Multipart decrypt now always expects positive result (i.e. the plaintext that is passed in). Added new test that expects fail, and does no multipart versions and concentrates on aead_verify. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 176 ++++++++++---------- tests/suites/test_suite_psa_crypto.function | 118 ++++++++++--- 2 files changed, 175 insertions(+), 119 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index cac6c68562..645fe2af3c 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2310,221 +2310,205 @@ PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=48, TA depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":0:"e5f410fe939e79b7ad33fbd3aaf5856f":1:1:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" -PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 +PSA Multipart AEAD decrypt, AES - GCM, 144 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" -PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #1 (lengths set) +PSA Multipart AEAD decrypt, AES - GCM, 144 bytes #1 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" -PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 +PSA Multipart AEAD decrypt, AES - GCM, 144 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013" -PSA Multipart AEAD decrypt, AES-GCM, 144 bytes #2 (lengths set) +PSA Multipart AEAD decrypt, AES - GCM, 144 bytes #2 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013" -PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 +PSA Multipart AEAD decrypt, AES - GCM, 144 bytes, T = 4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,4):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" -PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=4 (lengths set) +PSA Multipart AEAD decrypt, AES - GCM, 144 bytes, T = 4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,4):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" -PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 +PSA Multipart AEAD decrypt, AES - GCM, 144 bytes, T = 15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" -PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=15 (lengths set) +PSA Multipart AEAD decrypt, AES - GCM, 144 bytes, T = 15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1 - -PSA Multipart AEAD decrypt, AES-GCM, invalid signature -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":0 - -PSA Multipart AEAD decrypt, AES-GCM, T=15 but passing 16 bytes -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":0 - -PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 0 -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 0 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":0 - -PSA Multipart AEAD decrypt: AES-GCM, invalid tag length 2 -depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":0:"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":1:0:"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":0 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:0:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:1:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:0:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:1:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:0:"b03c2c20f758a93a8d1220232ad87098":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:0:"b03c2c20f758a93a8d1220232ad87098" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:1:"b03c2c20f758a93a8d1220232ad87098":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:1:"b03c2c20f758a93a8d1220232ad87098" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:0:"b22b2dcdcc18adc30d16297b84b459d8":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:0:"b22b2dcdcc18adc30d16297b84b459d8" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:1:"b22b2dcdcc18adc30d16297b84b459d8":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:1:"b22b2dcdcc18adc30d16297b84b459d8" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:0:"7e5fd8b595ddc4753676107951d900e2":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:0:"7e5fd8b595ddc4753676107951d900e2" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:1:"7e5fd8b595ddc4753676107951d900e2":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:1:"7e5fd8b595ddc4753676107951d900e2" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:0:"37245449db8f72b1ecdb420f629d3d80":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:0:"37245449db8f72b1ecdb420f629d3d80" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:1:"37245449db8f72b1ecdb420f629d3d80":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:1:"37245449db8f72b1ecdb420f629d3d80" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:0:"496909523f574b205d757659c5":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:0:"496909523f574b205d757659c5" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:1:"496909523f574b205d757659c5":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:1:"496909523f574b205d757659c5" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:0:"b6e056de521a27266dffbc0d96":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:0:"b6e056de521a27266dffbc0d96" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:1:"b6e056de521a27266dffbc0d96":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:1:"b6e056de521a27266dffbc0d96" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:0:"f6d56f8c86f27d957fa63aea22":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:0:"f6d56f8c86f27d957fa63aea22" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:1:"f6d56f8c86f27d957fa63aea22":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:1:"f6d56f8c86f27d957fa63aea22" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:0:"bd94b34511bc65ae47684805cb":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:0:"bd94b34511bc65ae47684805cb" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:1:"bd94b34511bc65ae47684805cb":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:1:"bd94b34511bc65ae47684805cb" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:0:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:1:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:0:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:1:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:0:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:1:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:0:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:1:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:0:"7789b41cb3ee548814ca0b388c10b343":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:0:"7789b41cb3ee548814ca0b388c10b343" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:1:"7789b41cb3ee548814ca0b388c10b343":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:1:"7789b41cb3ee548814ca0b388c10b343" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:0:"4860116a6d2deb9bf794bfd6ac5bbbd6":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:0:"4860116a6d2deb9bf794bfd6ac5bbbd6" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:1:"4860116a6d2deb9bf794bfd6ac5bbbd6":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:1:"4860116a6d2deb9bf794bfd6ac5bbbd6" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:0:"ff426dd751190ff826e8b4a0792d746e":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:0:"ff426dd751190ff826e8b4a0792d746e" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:1:"ff426dd751190ff826e8b4a0792d746e":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:1:"ff426dd751190ff826e8b4a0792d746e" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:0:"0a0b284515694188b6b6c15bc8a09036":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:0:"0a0b284515694188b6b6c15bc8a09036" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:1:"0a0b284515694188b6b6c15bc8a09036":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:1:"0a0b284515694188b6b6c15bc8a09036" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:0:"f386b28e7eb4c2fb8eb5dc66a2":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:0:"f386b28e7eb4c2fb8eb5dc66a2" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:1:"f386b28e7eb4c2fb8eb5dc66a2":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:1:"f386b28e7eb4c2fb8eb5dc66a2" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:0:"da1c61fbfcdb73445ad4c7d889":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:0:"da1c61fbfcdb73445ad4c7d889" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:1:"da1c61fbfcdb73445ad4c7d889":1 +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:1:"da1c61fbfcdb73445ad4c7d889" PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 @@ -2542,33 +2526,41 @@ PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (zero-length input) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"":1:1:"a0784d7a4716f3feb4f64e7f4b39bf04" -PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) +PSA Multipart AEAD decrypt: ChaCha20 - Poly1305 (RFC7539, good tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" -PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, good tag) (lengths set) +PSA Multipart AEAD decrypt: ChaCha20 - Poly1305 (RFC7539, good tag) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" -PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (RFC7539, bad tag) +PSA Multipart AEAD decrypt: ChaCha20 - Poly1305 (good tag, zero - length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600690":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":0 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:0:"" -PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) +PSA Multipart AEAD decrypt: ChaCha20 - Poly1305 (good tag, zero - length input) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:0:"":1 +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:1:"" -PSA Multipart AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) (lengths set) +PSA Multipart AEAD verify, AES - GCM, invalid signature +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_verify:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f":"6bac793bdc2190a195122c98544ccf56":PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD verify, AES - GCM, T = 15 but passing 16 bytes +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c87281":"4365847fe0b7b7fbed325953df344a96":PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD verify: AES - GCM, invalid tag length 0 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,0):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart AEAD verify: AES - GCM, invalid tag length 2 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,2):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd":"10b6":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart AEAD verify: ChaCha20 - Poly1305 (RFC7539, bad tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:1:"":1 - -PSA Multipart AEAD decrypt: invalid algorithm (CTR) -depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":0:"":1:0:"":0 - -PSA Multipart AEAD decrypt: invalid algorithm (ChaCha20) -depends_on:MBEDTLS_CHACHA20_C -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:"":"":1:"":1:0:"":0 +aead_multipart_verify:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"1ae10b594f09e26a7e902ecbd0600690":PSA_ERROR_INVALID_SIGNATURE PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 12 / Expect 12) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index b6d52f7d66..f25872d168 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -309,7 +309,6 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, int data_part_len_arg, setlengths_method set_lengths_method, data_t *expected_output, - int expect_valid_signature, int is_encrypt, int do_zero_parts ) { @@ -518,25 +517,11 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, &tag_size ) ); else { - status = psa_aead_verify( &operation, final_data, + PSA_ASSERT( psa_aead_verify( &operation, final_data, final_output_size, &output_part_length, ( input_data->x + data_true_size ), - tag_length ); - - if( expect_valid_signature ) - PSA_ASSERT( status ); - else - { - TEST_ASSERT( status != PSA_SUCCESS ); - - if( status != PSA_SUCCESS ) - { - /* Expected failure. */ - test_ok = 1; - goto exit; - } - } + tag_length ) ); } if( output_data && output_part_length ) @@ -3522,7 +3507,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, -1, set_lengths_method, expected_output, - 1, 1, 0 ) ) + 1, 0 ) ) break; /* length(0) part, length(ad_part_len) part, length(0) part... */ @@ -3535,7 +3520,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, -1, set_lengths_method, expected_output, - 1, 1, 1 ) ) + 1, 1 ) ) break; } } @@ -3563,7 +3548,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, data_part_len, set_lengths_method, expected_output, - 1, 1, 0 ) ) + 1, 0 ) ) break; /* length(0) part, length(data_part_len) part, length(0) part... */ @@ -3575,7 +3560,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, input_data, data_part_len, set_lengths_method, expected_output, - 1, 1, 1 ) ) + 1, 1 ) ) break; } } @@ -3596,8 +3581,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, data_t *input_data, int do_test_data_chunked, int do_set_lengths, - data_t *expected_output, - int expect_valid_signature ) + data_t *expected_output ) { size_t ad_part_len = 0; size_t data_part_len = 0; @@ -3631,7 +3615,6 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, input_data, -1, set_lengths_method, expected_output, - expect_valid_signature, 0, 0 ) ) break; @@ -3645,7 +3628,6 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, input_data, -1, set_lengths_method, expected_output, - expect_valid_signature, 0, 1 ) ) break; } @@ -3674,7 +3656,6 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, input_data, data_part_len, set_lengths_method, expected_output, - expect_valid_signature, 0, 0 ) ) break; @@ -3687,7 +3668,6 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, input_data, data_part_len, set_lengths_method, expected_output, - expect_valid_signature, 0, 1 ) ) break; } @@ -4084,6 +4064,90 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void aead_multipart_verify( int key_type_arg, data_t *key_data, + int alg_arg, + data_t *nonce, + data_t *additional_data, + data_t *input_data, + data_t *tag, + int expected_status_arg ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + psa_status_t expected_status = expected_status_arg; + unsigned char *plaintext = NULL; + unsigned char *finish_plaintext = NULL; + size_t plaintext_size = 0; + size_t plaintext_length = 0; + size_t verify_plaintext_size = 0; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + PSA_ASSERT( psa_get_key_attributes( key, &attributes ) ); + + plaintext_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, + input_data->len ); + + ASSERT_ALLOC( plaintext, plaintext_size ); + + verify_plaintext_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( key_type, alg ); + + ASSERT_ALLOC( finish_plaintext, verify_plaintext_size ); + + operation = psa_aead_operation_init( ); + + status = psa_aead_decrypt_setup( &operation, key, alg ); + + /* If the operation is not supported, just skip and not fail in case the + * encryption involves a common limitation of cryptography hardwares and + * an alternative implementation. */ + if( status == PSA_ERROR_NOT_SUPPORTED ) + { + MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 ); + MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce->len ); + } + + PSA_ASSERT( status ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + PSA_ASSERT( psa_aead_update( &operation, input_data->x, + input_data->len, + plaintext, plaintext_size, + &plaintext_length ) ); + + status = psa_aead_verify( &operation, finish_plaintext, + verify_plaintext_size, + &plaintext_length, + tag->x, tag->len ); + + TEST_EQUAL( status, expected_status ); + +exit: + psa_destroy_key( key ); + mbedtls_free( plaintext ); + mbedtls_free( finish_plaintext ); + psa_aead_abort( &operation ); + PSA_DONE( ); +} +/* END_CASE */ + + /* BEGIN_CASE */ void aead_multipart_state_test( int key_type_arg, data_t *key_data, int alg_arg, From 1c67e0b38ccbd3a2e0daf55d5cbaeaa304c498eb Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 13:11:50 +0100 Subject: [PATCH 520/966] Add extra verify edge test cases Add ability to pass NULL tag buffer (with length zero) Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 22 ++++++++++++++++----- tests/suites/test_suite_psa_crypto.function | 19 ++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 645fe2af3c..12f7e7c8ad 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2544,23 +2544,35 @@ aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f90 PSA Multipart AEAD verify, AES - GCM, invalid signature depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_verify:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f":"6bac793bdc2190a195122c98544ccf56":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_verify:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"12195120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f":"6bac793bdc2190a195122c98544ccf56":1:PSA_ERROR_INVALID_SIGNATURE PSA Multipart AEAD verify, AES - GCM, T = 15 but passing 16 bytes depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c87281":"4365847fe0b7b7fbed325953df344a96":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c87281":"4365847fe0b7b7fbed325953df344a96":1:PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD verify, AES - GCM, T = 15 but passing 14 bytes +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c87281":"4365847fe0b7b7fbed325953df34":1:PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD verify, AES - GCM, T = 15 but passing 0 bytes (valid buffer) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c87281":"":1:PSA_ERROR_INVALID_SIGNATURE + +PSA Multipart AEAD verify, AES - GCM, T = 15 but passing 0 bytes (NULL buffer) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c87281":"":0:PSA_ERROR_INVALID_SIGNATURE PSA Multipart AEAD verify: AES - GCM, invalid tag length 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,0):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,0):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":1:PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD verify: AES - GCM, invalid tag length 2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,2):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd":"10b6":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_verify:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,2):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd":"10b6":1:PSA_ERROR_INVALID_ARGUMENT PSA Multipart AEAD verify: ChaCha20 - Poly1305 (RFC7539, bad tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_verify:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"1ae10b594f09e26a7e902ecbd0600690":PSA_ERROR_INVALID_SIGNATURE +aead_multipart_verify:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"1ae10b594f09e26a7e902ecbd0600690":1:PSA_ERROR_INVALID_SIGNATURE PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 12 / Expect 12) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index f25872d168..29cda92ebf 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -271,6 +271,12 @@ typedef enum SET_LENGTHS_AFTER_NONCE = 2 } setlengths_method; +typedef enum +{ + USE_NULL_TAG = 0, + USE_GIVEN_TAG = 1, +} tagusage_method; + /*! * \brief Internal Function for AEAD multipart tests. * @@ -4071,6 +4077,7 @@ void aead_multipart_verify( int key_type_arg, data_t *key_data, data_t *additional_data, data_t *input_data, data_t *tag, + int tag_usage_arg, int expected_status_arg ) { mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; @@ -4085,6 +4092,9 @@ void aead_multipart_verify( int key_type_arg, data_t *key_data, size_t plaintext_size = 0; size_t plaintext_length = 0; size_t verify_plaintext_size = 0; + tagusage_method tag_usage = tag_usage_arg; + unsigned char *tag_buffer = NULL; + size_t tag_size = 0; PSA_ASSERT( psa_crypto_init( ) ); @@ -4131,10 +4141,16 @@ void aead_multipart_verify( int key_type_arg, data_t *key_data, plaintext, plaintext_size, &plaintext_length ) ); + if( tag_usage == USE_GIVEN_TAG ) + { + tag_buffer = tag->x; + tag_size = tag->len; + } + status = psa_aead_verify( &operation, finish_plaintext, verify_plaintext_size, &plaintext_length, - tag->x, tag->len ); + tag_buffer, tag_size ); TEST_EQUAL( status, expected_status ); @@ -4147,7 +4163,6 @@ exit: } /* END_CASE */ - /* BEGIN_CASE */ void aead_multipart_state_test( int key_type_arg, data_t *key_data, int alg_arg, From 5221ef638a1aca1873a2947526198282c15a24a8 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 17:33:03 +0100 Subject: [PATCH 521/966] Add aead setup tests Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 8 ++++ tests/suites/test_suite_psa_crypto.function | 45 +++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 12f7e7c8ad..09ebcf08f3 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2678,6 +2678,14 @@ PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0, TAG = 0 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL +PSA AEAD setup: invalid algorithm (CTR) +depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C +aead_multipart_setup:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:PSA_ERROR_INVALID_ARGUMENT + +PSA AEAD setup: invalid algorithm (ChaCha20) +depends_on:MBEDTLS_CHACHA20_C +aead_multipart_setup:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:PSA_ERROR_INVALID_ARGUMENT + PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 29cda92ebf..9fb8363a42 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4163,6 +4163,51 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void aead_multipart_setup( int key_type_arg, data_t *key_data, + int alg_arg, int expected_status_arg ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_key_type_t key_type = key_type_arg; + psa_algorithm_t alg = alg_arg; + psa_aead_operation_t operation; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + psa_status_t status = PSA_ERROR_GENERIC_ERROR; + psa_status_t expected_status = expected_status_arg; + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, + PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + + mbedtls_test_set_step( 0 ); + + status = psa_aead_encrypt_setup( &operation, key, alg ); + + TEST_EQUAL( status, expected_status ); + + psa_aead_abort( &operation ); + + operation = psa_aead_operation_init( ); + + mbedtls_test_set_step( 1 ); + + status = psa_aead_decrypt_setup( &operation, key, alg ); + + TEST_EQUAL(status, expected_status ); + +exit: + psa_destroy_key( key ); + psa_aead_abort( &operation ); + PSA_DONE( ); +} +/* END_CASE */ + /* BEGIN_CASE */ void aead_multipart_state_test( int key_type_arg, data_t *key_data, int alg_arg, From f94bd993685eb0c15e843dbe336b52954c79a999 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 18:15:59 +0100 Subject: [PATCH 522/966] Add missing aead state tests. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 9fb8363a42..d23ef4d5a5 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4503,6 +4503,23 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* ------------------------------------------------------- */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len, output_data, output_size, &output_length ) ); @@ -4574,6 +4591,29 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* Test for not sending any data after setting a non-zero length for it.*/ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); + + PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, + input_data->len ) ); + + PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, + additional_data->len ) ); + + TEST_EQUAL( psa_aead_finish( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, tag_length, + &tag_size ), + PSA_ERROR_INVALID_ARGUMENT ); + + psa_aead_abort( &operation ); + /* Test for sending too much additional data after setting lengths. */ operation = psa_aead_operation_init( ); From 70f447dfe59261e28f175280643244fe519f335a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 18:21:58 +0100 Subject: [PATCH 523/966] Replace individual zeroization with memset Signed-off-by: Paul Elliott --- library/psa_crypto.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index b335aa37c5..15495626ba 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3819,12 +3819,7 @@ psa_status_t psa_aead_abort( psa_aead_operation_t *operation ) status = psa_driver_wrapper_aead_abort( operation ); - operation->id = 0; - operation->nonce_set = 0; - operation->lengths_set = 0; - operation->ad_started = 0; - operation->body_started = 0; - operation->is_encrypt = 0; + memset( operation, 0, sizeof( psa_aead_operation_t ) ); return( status ); } From 69bf5fc901d4d2838b8a2df03d7c733ade6d5602 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 18:26:37 +0100 Subject: [PATCH 524/966] Const correctness Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 15495626ba..8af26d33b0 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3713,7 +3713,7 @@ exit: return( status ); } -static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation ) +static psa_status_t psa_aead_final_checks( const psa_aead_operation_t *operation ) { if( operation->id == 0 || !operation->nonce_set ) return( PSA_ERROR_BAD_STATE ); From 4c916e8d74916ccaf0fce9600c03151f0b9e862e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 18:34:50 +0100 Subject: [PATCH 525/966] Improve comment on buffer clearing Signed-off-by: Paul Elliott --- library/psa_crypto.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 8af26d33b0..b5efc2de09 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3756,10 +3756,10 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, exit: /* In case the operation fails and the user fails to check for failure or - * the zero tag size, make sure the tag is set to something impossible. - * Even if the operation succeeds, make sure we set the rest of the - * buffer to something impossible to prevent potential leakage of - * anything previously placed in the same buffer.*/ + * the zero tag size, make sure the tag is set to something implausible. + * Even if the operation succeeds, make sure we clear the rest of the + * buffer to prevent potential leakage of anything previously placed in + * the same buffer.*/ if( status != PSA_SUCCESS ) memset( tag, '!', tag_size ); else if( *tag_length < tag_size ) From 8ff74217e46cd9c1ecea05dbfcf1a20926cc3d56 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 18:39:23 +0100 Subject: [PATCH 526/966] Add comment explaining finish output size Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 46eb1c9332..01d5d19d1c 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -677,6 +677,8 @@ psa_status_t mbedtls_psa_aead_finish( if( status == PSA_SUCCESS ) { + /* This will be zero for all supported algorithms currently, but left + * here for future support. */ *ciphertext_length = finish_output_size; *tag_length = operation->tag_length; } From ec95cc94890d77cb320549e61b5d413a40e04195 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 22:33:09 +0100 Subject: [PATCH 527/966] Add safety for NULL tag being passed to finish Signed-off-by: Paul Elliott --- library/psa_crypto.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index b5efc2de09..664b8aecce 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3760,10 +3760,13 @@ exit: * Even if the operation succeeds, make sure we clear the rest of the * buffer to prevent potential leakage of anything previously placed in * the same buffer.*/ - if( status != PSA_SUCCESS ) - memset( tag, '!', tag_size ); - else if( *tag_length < tag_size ) - memset( tag + *tag_length, '!', ( tag_size - *tag_length ) ); + if( tag ) + { + if( status != PSA_SUCCESS ) + memset( tag, '!', tag_size ); + else if( *tag_length < tag_size ) + memset( tag + *tag_length, '!', ( tag_size - *tag_length ) ); + } psa_aead_abort( operation ); From 8eec8d443689334304131670e8a2e084fed2127b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Sun, 19 Sep 2021 22:38:27 +0100 Subject: [PATCH 528/966] Fix missed documentation header Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index d23ef4d5a5..fa579e45ad 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -279,32 +279,29 @@ typedef enum /*! * \brief Internal Function for AEAD multipart tests. - * * \param key_type_arg Type of key passed in * \param key_data The encryption / decryption key data * \param alg_arg The type of algorithm used * \param nonce Nonce data * \param additional_data Additional data - * \param ad_part_len If not -1, the length of chunks to + * \param ad_part_len_arg If not -1, the length of chunks to * feed additional data in to be encrypted / * decrypted. If -1, no chunking. * \param input_data Data to encrypt / decrypt - * \param data_part_len If not -1, the length of chunks to feed the - * data in to be encrypted / decrypted. If -1, - * no chunking - * \param do_set_lengths If non-zero, then set lengths prior to - * calling encryption / decryption. + * \param data_part_len_arg If not -1, the length of chunks to feed + * the data in to be encrypted / decrypted. If + * -1, no chunking + * \param set_lengths_method A member of the setlengths_method enum is + * expected here, this controls whether or not + * to set lengths, and in what order with + * respect to set nonce. * \param expected_output Expected output * \param expect_valid_signature If non zero, we expect the signature to be * valid * \param is_encrypt If non-zero this is an encryption operation. * \param do_zero_parts If non-zero, interleave zero length chunks - * with normal length chunks - * \param swap_set_functions If non-zero, swap the order of set lengths - * and set nonce. - * + * with normal length chunks. * \return int Zero on failure, non-zero on success. - * */ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, int alg_arg, From 6043e49039ff221cdfc7d71b209e796cf1e4f5e7 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 20 Sep 2021 09:24:48 +0100 Subject: [PATCH 529/966] Fix missed documentation header pt 2 Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index fa579e45ad..a240df7bda 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -296,8 +296,6 @@ typedef enum * to set lengths, and in what order with * respect to set nonce. * \param expected_output Expected output - * \param expect_valid_signature If non zero, we expect the signature to be - * valid * \param is_encrypt If non-zero this is an encryption operation. * \param do_zero_parts If non-zero, interleave zero length chunks * with normal length chunks. From 4a760882bb45a937a1dc97965e7b6a9fe92fbf7a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 20 Sep 2021 09:42:21 +0100 Subject: [PATCH 530/966] Fix leaked test buffer Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index a240df7bda..2feadf800e 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4060,6 +4060,7 @@ exit: psa_destroy_key( key ); mbedtls_free( ciphertext ); mbedtls_free( finish_ciphertext ); + mbedtls_free( tag_buffer ); psa_aead_abort( &operation ); PSA_DONE( ); } From 396853ad03c21cac4d612e1bc2257f8b8dc09eaa Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 20 Sep 2021 18:57:55 +0200 Subject: [PATCH 531/966] 'make test': show failing test cases when cmake does When building with make, `make test` runs `run-test-suites.pl` which has a verbose mode that reports the failing test cases, but it didn't provide a way to enable this verbose mode. With the present commit, you can run `make test TEST_FLAGS=-v` to use verbose mode. Base the default for verbose mode on the same environment variable that `make test` uses when building with CMake: default off, but enabled if `CTEST_OUTPUT_ON_FAILURE` is true. In particular, verbose mode will now be on when building from `all.sh`. Signed-off-by: Gilles Peskine --- tests/Makefile | 5 ++++- tests/scripts/all.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 449fca2748..db642c7798 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -5,6 +5,9 @@ CFLAGS ?= -O2 WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral LDFLAGS ?= +# Set this to -v to see the details of failing test cases +TEST_FLAGS ?= $(if $(filter-out 0 OFF Off off NO No no FALSE False false N n,$(CTEST_OUTPUT_ON_FAILURE)),-v,) + default: all # Include public header files from ../include, test-specific header files @@ -195,7 +198,7 @@ endif # Test suites caught by SKIP_TEST_SUITES are built but not executed. check: $(BINARIES) - perl scripts/run-test-suites.pl --skip=$(SKIP_TEST_SUITES) + perl scripts/run-test-suites.pl $(TEST_FLAGS) --skip=$(SKIP_TEST_SUITES) test: check diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 9944a853f5..583743c2eb 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -178,7 +178,7 @@ pre_initialize_variables () { export MAKEFLAGS="-j" fi - # Include more verbose output for failing tests run by CMake + # Include more verbose output for failing tests run by CMake or make export CTEST_OUTPUT_ON_FAILURE=1 # CFLAGS and LDFLAGS for Asan builds that don't use CMake From 3587dfdce8535ee1fb2f08142c0830a9289055cc Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 20 Sep 2021 19:20:04 +0200 Subject: [PATCH 532/966] Move long -D lists from all.sh to a header file To facilitate maintenance and to make it easier to reproduce all.sh builds manually, remove the long, repeated list of -D options from component_test_psa_crypto_config_basic and component_test_psa_crypto_drivers and put it in a header file instead. Signed-off-by: Gilles Peskine --- tests/configs/user-config-for-test.h | 57 ++++++++++++++++++++++++++++ tests/scripts/all.sh | 54 ++------------------------ 2 files changed, 61 insertions(+), 50 deletions(-) create mode 100644 tests/configs/user-config-for-test.h diff --git a/tests/configs/user-config-for-test.h b/tests/configs/user-config-for-test.h new file mode 100644 index 0000000000..444a4bf00f --- /dev/null +++ b/tests/configs/user-config-for-test.h @@ -0,0 +1,57 @@ +/* MBEDTLS_USER_CONFIG_FILE for testing. + * Only used for a few test configurations. + * + * Typical usage (note multiple levels of quoting): + * make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" + */ + +/* + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined(PSA_CRYPTO_DRIVER_TEST_ALL) + +/* Enable the use of the test driver in the library, and build the generic + * part of the test driver. */ +#define PSA_CRYPTO_DRIVER_TEST + +/* Use the accelerator driver for all cryptographic mechanisms for which + * the test driver implemented. */ +#define MBEDTLS_PSA_ACCEL_KEY_TYPE_AES +#define MBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA +#define MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR +#define MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR +#define MBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING +#define MBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7 +#define MBEDTLS_PSA_ACCEL_ALG_CTR +#define MBEDTLS_PSA_ACCEL_ALG_CFB +#define MBEDTLS_PSA_ACCEL_ALG_ECDSA +#define MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA +#define MBEDTLS_PSA_ACCEL_ALG_MD5 +#define MBEDTLS_PSA_ACCEL_ALG_OFB +#define MBEDTLS_PSA_ACCEL_ALG_RIPEMD160 +#define MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN +#define MBEDTLS_PSA_ACCEL_ALG_RSA_PSS +#define MBEDTLS_PSA_ACCEL_ALG_SHA_1 +#define MBEDTLS_PSA_ACCEL_ALG_SHA_224 +#define MBEDTLS_PSA_ACCEL_ALG_SHA_256 +#define MBEDTLS_PSA_ACCEL_ALG_SHA_384 +#define MBEDTLS_PSA_ACCEL_ALG_SHA_512 +#define MBEDTLS_PSA_ACCEL_ALG_XTS +#define MBEDTLS_PSA_ACCEL_ALG_CMAC +#define MBEDTLS_PSA_ACCEL_ALG_HMAC + +#endif /* PSA_CRYPTO_DRIVER_TEST_ALL */ diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 583743c2eb..3294a6afe2 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1560,31 +1560,8 @@ component_test_psa_crypto_config_basic() { scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_DES scripts/config.py unset MBEDTLS_DES_C - # Need to define the correct symbol and include the test driver header path in order to build with the test driver - loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_AES" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CTR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CFB" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_ECDSA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_MD5" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_OFB" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_1" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_224" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_256" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_384" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_512" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_XTS" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CMAC" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_HMAC" + loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL" + loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" loc_cflags="${loc_cflags} -I../tests/include -O2" make CC=gcc CFLAGS="$loc_cflags" LDFLAGS="$ASAN_CFLAGS" @@ -2237,31 +2214,8 @@ component_test_psa_crypto_drivers () { scripts/config.py full scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS scripts/config.py set MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS - # Need to define the correct symbol and include the test driver header path in order to build with the test driver - loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_AES" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CTR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CFB" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_ECDSA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_MD5" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_OFB" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_1" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_224" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_256" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_384" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_512" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_XTS" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CMAC" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_HMAC" + loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL" + loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" loc_cflags="${loc_cflags} -I../tests/include -O2" make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS" From 64555bd98ca43be8667b83ad81e32232b016f957 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 20 Sep 2021 16:44:44 +0100 Subject: [PATCH 533/966] Add missing initialisation to setup test. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 2feadf800e..c91f744b89 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4181,6 +4181,8 @@ void aead_multipart_setup( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, &key ) ); + operation = psa_aead_operation_init( ); + mbedtls_test_set_step( 0 ); status = psa_aead_encrypt_setup( &operation, key, alg ); From 0f32b7d345ada2a5539faf230da9dec3b46a5043 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 20 Sep 2021 18:46:03 +0100 Subject: [PATCH 534/966] Apply fixes to test driver from lib implementation Signed-off-by: Paul Elliott --- tests/src/drivers/test_driver_aead.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index ac116ffb06..84e69e0f69 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -282,7 +282,7 @@ psa_status_t mbedtls_test_transparent_aead_verify( plaintext_size, plaintext_length, check_tag, - tag_length, + sizeof( check_tag ), &check_tag_length ); if( mbedtls_test_driver_aead_hooks.driver_status == PSA_SUCCESS ) @@ -293,6 +293,8 @@ psa_status_t mbedtls_test_transparent_aead_verify( mbedtls_test_driver_aead_hooks.driver_status = PSA_ERROR_INVALID_SIGNATURE; } + + mbedtls_platform_zeroize( check_tag, sizeof( check_tag ) ); } return( mbedtls_test_driver_aead_hooks.driver_status ); From 6c12a1e9f2375930e016e4c2efb95712856ab95c Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 21 Sep 2021 11:59:39 +0200 Subject: [PATCH 535/966] Add ARIA to the PSA API Use the encoding from an upcoming version of the specification. Add as much (or as little) testing as is currently present for Camellia. Signed-off-by: Gilles Peskine --- include/psa/crypto.h | 1 + include/psa/crypto_values.h | 4 +++ library/psa_crypto.c | 6 ++++ library/psa_crypto_cipher.c | 3 ++ .../test_suite_psa_crypto_metadata.data | 28 +++++++++++++++++++ .../test_suite_psa_crypto_se_driver_hal.data | 15 ++++++++++ 6 files changed, 57 insertions(+) diff --git a/include/psa/crypto.h b/include/psa/crypto.h index b3ef3631d4..5d9854a7ba 100644 --- a/include/psa/crypto.h +++ b/include/psa/crypto.h @@ -3682,6 +3682,7 @@ psa_status_t psa_key_derivation_output_bytes( * The following key types defined in this specification follow this scheme: * * - #PSA_KEY_TYPE_AES; + * - #PSA_KEY_TYPE_ARIA; * - #PSA_KEY_TYPE_CAMELLIA; * - #PSA_KEY_TYPE_DERIVE; * - #PSA_KEY_TYPE_HMAC; diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index daef9416cc..7442ec2c96 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -466,6 +466,10 @@ */ #define PSA_KEY_TYPE_AES ((psa_key_type_t)0x2400) +/** Key for a cipher, AEAD or MAC algorithm based on the + * ARIA block cipher. */ +#define PSA_KEY_TYPE_ARIA ((psa_key_type_t)0x2406) + /** Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES). * * The size of the key can be 64 bits (single DES), 128 bits (2-key 3DES) or diff --git a/library/psa_crypto.c b/library/psa_crypto.c index bcbaa3d68a..95a94278ef 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -446,6 +446,12 @@ psa_status_t psa_validate_unstructured_key_bit_size( psa_key_type_t type, return( PSA_ERROR_INVALID_ARGUMENT ); break; #endif +#if defined(PSA_WANT_KEY_TYPE_ARIA) + case PSA_KEY_TYPE_ARIA: + if( bits != 128 && bits != 192 && bits != 256 ) + return( PSA_ERROR_INVALID_ARGUMENT ); + break; +#endif #if defined(PSA_WANT_KEY_TYPE_CAMELLIA) case PSA_KEY_TYPE_CAMELLIA: if( bits != 128 && bits != 192 && bits != 256 ) diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index 2268fc5850..ce8ab5cd0a 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -115,6 +115,9 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_psa( case PSA_KEY_TYPE_AES: cipher_id_tmp = MBEDTLS_CIPHER_ID_AES; break; + case PSA_KEY_TYPE_ARIA: + cipher_id_tmp = MBEDTLS_CIPHER_ID_ARIA; + break; case PSA_KEY_TYPE_DES: /* key_bits is 64 for Single-DES, 128 for two-key Triple-DES, * and 192 for three-key Triple-DES. */ diff --git a/tests/suites/test_suite_psa_crypto_metadata.data b/tests/suites/test_suite_psa_crypto_metadata.data index a3668fcc94..0706b26413 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.data +++ b/tests/suites/test_suite_psa_crypto_metadata.data @@ -130,6 +130,18 @@ AEAD: CCM-AES-256 depends_on:PSA_WANT_KEY_TYPE_AES:PSA_WANT_ALG_CCM aead_algorithm:PSA_ALG_CCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_AES:256 +AEAD: CCM-ARIA-128 +depends_on:PSA_WANT_KEY_TYPE_ARIA:PSA_WANT_ALG_CCM +aead_algorithm:PSA_ALG_CCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_ARIA:128 + +AEAD: CCM-ARIA-192 +depends_on:PSA_WANT_KEY_TYPE_ARIA:PSA_WANT_ALG_CCM +aead_algorithm:PSA_ALG_CCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_ARIA:192 + +AEAD: CCM-ARIA-256 +depends_on:PSA_WANT_KEY_TYPE_ARIA:PSA_WANT_ALG_CCM +aead_algorithm:PSA_ALG_CCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_ARIA:256 + AEAD: CCM-CAMELLIA-128 depends_on:PSA_WANT_KEY_TYPE_CAMELLIA:PSA_WANT_ALG_CCM aead_algorithm:PSA_ALG_CCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_CAMELLIA:128 @@ -154,6 +166,18 @@ AEAD: GCM-AES-256 depends_on:PSA_WANT_KEY_TYPE_AES:PSA_WANT_ALG_GCM aead_algorithm:PSA_ALG_GCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_AES:256 +AEAD: GCM-ARIA-128 +depends_on:PSA_WANT_KEY_TYPE_ARIA:PSA_WANT_ALG_GCM +aead_algorithm:PSA_ALG_GCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_ARIA:128 + +AEAD: GCM-ARIA-192 +depends_on:PSA_WANT_KEY_TYPE_ARIA:PSA_WANT_ALG_GCM +aead_algorithm:PSA_ALG_GCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_ARIA:192 + +AEAD: GCM-ARIA-256 +depends_on:PSA_WANT_KEY_TYPE_ARIA:PSA_WANT_ALG_GCM +aead_algorithm:PSA_ALG_GCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_ARIA:256 + AEAD: GCM-CAMELLIA-128 depends_on:PSA_WANT_KEY_TYPE_CAMELLIA:PSA_WANT_ALG_GCM aead_algorithm:PSA_ALG_GCM:ALG_IS_AEAD_ON_BLOCK_CIPHER:16:PSA_KEY_TYPE_CAMELLIA:128 @@ -295,6 +319,10 @@ Block cipher key type: AES depends_on:PSA_WANT_KEY_TYPE_AES block_cipher_key_type:PSA_KEY_TYPE_AES:16 +Block cipher key type: ARIA +depends_on:PSA_WANT_KEY_TYPE_ARIA +block_cipher_key_type:PSA_KEY_TYPE_ARIA:16 + Block cipher key type: DES depends_on:PSA_WANT_KEY_TYPE_DES block_cipher_key_type:PSA_KEY_TYPE_DES:8 diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.data b/tests/suites/test_suite_psa_crypto_se_driver_hal.data index a57e9b360a..2bcf4e4b7b 100644 --- a/tests/suites/test_suite_psa_crypto_se_driver_hal.data +++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.data @@ -78,6 +78,21 @@ import_key_smoke:PSA_KEY_TYPE_AES:PSA_ALG_CCM:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" Key import smoke test: AES-GCM import_key_smoke:PSA_KEY_TYPE_AES:PSA_ALG_GCM:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +Key import smoke test: ARIA-CTR +import_key_smoke:PSA_KEY_TYPE_ARIA:PSA_ALG_CTR:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +Key import smoke test: ARIA-CBC +import_key_smoke:PSA_KEY_TYPE_ARIA:PSA_ALG_CBC_NO_PADDING:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +Key import smoke test: ARIA-CMAC +import_key_smoke:PSA_KEY_TYPE_ARIA:PSA_ALG_CMAC:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +Key import smoke test: ARIA-CCM +import_key_smoke:PSA_KEY_TYPE_ARIA:PSA_ALG_CCM:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +Key import smoke test: ARIA-GCM +import_key_smoke:PSA_KEY_TYPE_ARIA:PSA_ALG_GCM:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + Key import smoke test: CAMELLIA-CTR import_key_smoke:PSA_KEY_TYPE_CAMELLIA:PSA_ALG_CTR:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" From 13b0bebf7dc3689ef1c210ecf3b770213c444cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 20 Sep 2021 13:21:25 +0200 Subject: [PATCH 536/966] Add docs/use-psa-crypto.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- docs/use-psa-crypto.md | 19 +++++++++++++++++++ include/mbedtls/mbedtls_config.h | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 docs/use-psa-crypto.md diff --git a/docs/use-psa-crypto.md b/docs/use-psa-crypto.md new file mode 100644 index 0000000000..a4f43b7832 --- /dev/null +++ b/docs/use-psa-crypto.md @@ -0,0 +1,19 @@ +This document describes the compile-time configutation option +`MBEDTLS_USE_PSA_CRYPTO`: its current effects as well as some design +considerations and plans for the future. + +Current effects +=============== + +(To be written.) + +Parts that are not affected yet +=============================== + +(To be written.) + +Design considerations +===================== + +(To be written.) + diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index d470c0054b..0680dd98f8 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -1718,6 +1718,9 @@ * will still continue to work as usual, so enabling this option should not * break backwards compatibility. * + * \note See docs/use-psa-crypto.md for a complete description of what this + * option currently does, and of parts that are not affected by it so far. + * * \warning The PSA Crypto API is in beta stage. While you're welcome to * experiment using it, incompatible API changes are still possible, and some * parts may not have reached the same quality as the rest of Mbed TLS yet. From 1b08c5f042263b2919431eaa80797476a4876523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 21 Sep 2021 11:21:23 +0200 Subject: [PATCH 537/966] Document current effects of USE_PSA_CRYPTO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- docs/use-psa-crypto.md | 144 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 141 insertions(+), 3 deletions(-) diff --git a/docs/use-psa-crypto.md b/docs/use-psa-crypto.md index a4f43b7832..d1298af2b3 100644 --- a/docs/use-psa-crypto.md +++ b/docs/use-psa-crypto.md @@ -5,10 +5,148 @@ considerations and plans for the future. Current effects =============== -(To be written.) +General limitations +------------------- -Parts that are not affected yet -=============================== +Compile-time: enabling `MBEDTLS_USE_PSA_CRYPTO` requires +`MBEDTLS_ECP_RESTARTABLE` and +`MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER` to be disabled. + +Effect: `MBEDTLS_USE_PSA_CRYPTO` currently has no effect on TLS 1.3 (which is +itself experimental and only partially supported so far): TLS 1.3 always uses +the legacy APIs even when this option is set. + +Stability: any API that's only available when `MBEDTLS_USE_PSA_CRYPTO` is +defined is considered experimental and may change in incompatible ways at any +time. Said otherwise, these APIs are explicitly excluded from the usual API +stability promises. + +New APIs / API extensions +------------------------- + +Some of these APIs are meant for the application to use in place of +pre-existing APIs, in order to get access to the benefits; in the sub-sections +below these are indicated by "Use in (X.509 and) TLS: opt-in", meaning that +this requires changes to the application code for the (X.509 and) TLS layers +to pick up the improvements. + +Some of these APIs are mostly meant for internal use by the TLS (and X.509) +layers; they are indicated below by "Use in (X.509 and) TLS: automatic", +meaning that no changes to the application code are required for the TLS (and +X.509) layers to pick up the improvements. + +### PSA-held (opaque) keys in the PK layer + +Add `mbedtls_pk_setup_opaque()` to wrap a PSA keypair into a PK context. The key +can be used for private-key operations and its public part can be written out. + +Benefits: isolation of long-term secrets, use of PSA Crypto drivers. + +Limitations: only for private keys, only ECC. (That is, only ECDSA signature +generation.) The following operations are not supported with a context set +this way, while they would be available with a normal `ECKEY` context: +`mbedtls_pk_verify()`, `mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`. + +Use in X.509 and TLS: opt-in. The application needs to construct the PK context +using the new API in order to get the benefits; it can then pass the +resulting context to the following existing APIs: + +- `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the + key together with a certificate for ECDSA-based key exchanges; +- `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature + request). + +In the TLS and X.509 API, there's two other function which accept a key or +keypair as a PK context: `mbedtls_x509write_crt_set_subject_key()` and +`mbedtls_x509write_crt_set_issuer_key()`. Use of opaque contexts here probably +works but is so far untested. + +### PSA-held (opaque) keys for TLS 1.2 pre-shared keys (PSK) + +Add `mbedtls_ssl_conf_psk_opaque()` and `mbedtls_ssl_set_hs_psk_opaque()` to +register a PSA key for use with a PSK key exchange. + +Benefits: isolation of long-term secrets. + +Limitations: the key can only be used with with TLS 1.2, and only with "pure" +PSK key exchanges (ciphersuites starting with `TLS_PSK_WITH_`), to the +exclusion of RSA-PSK, DHE-PSK and ECDHE-PSK key exchanges. It is the responsibility of +the user to make sure that when provisioning an opaque pre-shared key, the +only PSK ciphersuites that can be negotiated are "pure" PSK; other XXX-PSK key +exchanges will result in a handshake failure with the handshake function +returning `MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE`. + +Use in TLS: opt-in. The application needs to register the key using the new +APIs to get the benefits. + +### PSA-based operations in the Cipher layer + +Add `mbedtls_cipher_setup_psa()` to set up a context that will call PSA to +store the key and perform the operations. + +Benefits: use of PSA Crypto drivers; partial isolation of short-term secrets +(still generated outside of PSA, but then held by PSA). + +Limitations: the key is still passed in the clear by the application. The +multi-part APIs are not supported, only the one-shot APIs. The only modes +supported are ECB, CBC without padding, GCM and CCM (this excludes stream +ciphers and ChachaPoly); the only cipher supported is AES (this excludes Aria, +Camellia, and ChachaPoly). + +Use in TLS: automatic. Used when the cipher and mode is supported (with +gracious fallback to the legacy API otherwise) in all places where a cipher is +used. There are two such places: in `ssl_tls.c` for record protection, and in +`ssl_ticket.c` for protecting tickets we issue. + +Internal changes +---------------- + +All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO` +is enabled, no change required on the application side. + +### TLS: cipher operations based on PSA + +See "PSA-based operations in the Cipher layer" above. + +### PK layer: ECDSA verification based on PSA + +Scope: `mbedtls_pk_verify()` will call to PSA for ECDSA signature +verification. + +Benefits: use of PSA Crypto drivers. + +Use in TLS and X.509: in all places where an ECDSA signature is verified. + +### TLS: ECDHE computation based on PSA + +Scope: Client-side, for ECDHE-RSA and ECDHE-ECDSA key exchanges, the +computation of the ECDHE key exchange is done by PSA. + +Limitations: client-side only, ECDHE-PSK not covered + +Benefits: use of PSA Crypto drivers. + +### TLS: handshake hashes and PRF computed with PSA + +Scope: with TLS 1.2, the following are computed with PSA: +- the running handshake hashes; +- the hash of the ServerKeyExchange part that is signed; +- the `verify_data` part of the Finished message; +- the TLS PRF. + +Benefits: use of PSA Crypto drivers. + +### X.509: some hashes computed with PSA + +Scope: the following hashes are computed with PSA: +- when verifying a certificate chain, hash of the child for verifying the + parent's signature; +- when writing a CSR, hash of the request for self-signing the request. + +Benefits: use of PSA Crypto drivers. + +Parts that are not covered yet +============================== (To be written.) From 200bcf77f820b45ebfffa4f193116792aecadb76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 21 Sep 2021 11:30:52 +0200 Subject: [PATCH 538/966] Remove warning about PSA Crypto being beta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API reached 1.0.0 some time ago, and we've caught up with the incompatible changes already. Signed-off-by: Manuel Pégourié-Gonnard --- include/mbedtls/mbedtls_config.h | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index 0680dd98f8..683c9131c6 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -1721,15 +1721,10 @@ * \note See docs/use-psa-crypto.md for a complete description of what this * option currently does, and of parts that are not affected by it so far. * - * \warning The PSA Crypto API is in beta stage. While you're welcome to - * experiment using it, incompatible API changes are still possible, and some - * parts may not have reached the same quality as the rest of Mbed TLS yet. - * - * \warning This option enables new Mbed TLS APIs that are dependent on the - * PSA Crypto API, so can't come with the same stability guarantees as the - * rest of the Mbed TLS APIs. You're welcome to experiment with them, but for - * now, access to these APIs is opt-in (via enabling the present option), in - * order to clearly differentiate them from the stable Mbed TLS APIs. + * \warning This option enables new Mbed TLS APIs which are currently + * considered experimental and may change in incompatible ways at any time. + * That is, the APIs enabled by this option are not covered by the usual + * promises of API stability. * * Requires: MBEDTLS_PSA_CRYPTO_C. * @@ -2595,10 +2590,6 @@ * * Enable the Platform Security Architecture cryptography API. * - * \warning The PSA Crypto API is still beta status. While you're welcome to - * experiment using it, incompatible API changes are still possible, and some - * parts may not have reached the same quality as the rest of Mbed TLS yet. - * * Module: library/psa_crypto.c * * Requires: either MBEDTLS_CTR_DRBG_C and MBEDTLS_ENTROPY_C, From 73a0e1da0d1acec38a54e0b3d84358dea0bfce09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 21 Sep 2021 13:55:00 +0200 Subject: [PATCH 539/966] Document parts not covered by USE_PSA_CRYPTO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, remove the section about design considerations for now. It's probably more suitable for a developer-oriented document that would also include considerations about possible paths for the future, which would better be separated from user documentation (separating the certain that is now, from the uncertain that might or might not be later). Signed-off-by: Manuel Pégourié-Gonnard --- docs/use-psa-crypto.md | 43 +++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/docs/use-psa-crypto.md b/docs/use-psa-crypto.md index d1298af2b3..c8f89d0c24 100644 --- a/docs/use-psa-crypto.md +++ b/docs/use-psa-crypto.md @@ -1,6 +1,6 @@ -This document describes the compile-time configutation option -`MBEDTLS_USE_PSA_CRYPTO`: its current effects as well as some design -considerations and plans for the future. +This document describes the compile-time configuration option +`MBEDTLS_USE_PSA_CRYPTO` from a user's perspective, more specifically its +current effects as well as the parts that aren't covered yet. Current effects =============== @@ -148,10 +148,39 @@ Benefits: use of PSA Crypto drivers. Parts that are not covered yet ============================== -(To be written.) +This is only a high-level overview, grouped by theme -Design considerations -===================== +TLS: key exchanges / asymmetric crypto +-------------------------------------- -(To be written.) +- RSA: not covered +- DHE-RSA: not covered +- ECDHE-RSA: ECDHE computation client-side only +- ECDHE-ECDSA: + - ECDHE computation client-side + - ECDSA verification both sides + - ECDSA signature (if using `mbedtls_pk_setup_opaque()`) +- PSK: client-side PSA-held using `mbedtls_ssl_conf_psk_opaque()` +- DHE-PSK: not covered +- RSA-PSK: not covered +- ECDHE-PSK: not covered +- ECDH-RSA: not covered +- ECDH-ECDSA: not covered +- ECJPAKE: not covered +TLS: symmetric crypto +--------------------- + +- some ciphers not supported via PSA yet: ARIA, Camellia, ChachaPoly (silent + fallback to the legacy APIs) +- the HMAC part of the CBC and NULL ciphersuites is not covered +- the HMAC computation in `ssl_cookie.c` + +X.509 +----- + +- most hash operations are still done via the legacy API, except the few that + are documented above as using PSA +- RSA PKCS#1 v1.5 signature generation (from PSA-held keys): not covered +- RSA PKCS#1 v1.5 signature verification: not covered +- RSA-PSS signature verification: not covered From a0b4b0c3cdfaa364cb12a020d1b7618d16e261f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 21 Sep 2021 14:06:33 +0200 Subject: [PATCH 540/966] Clean up some remnants of TLS pre-1.2 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that support for earlier version have been removed, we no longer need to care about them. Since TLS 1.3 is being gradually introduced, we might still need a version check in some places - but here the function is called ssl_tls12_populate_tranform() and TLS 1.3 has its own function mbedtls_ssl_tls13_populate_transform(), so when this function is called we just know we're using TLS 1.2. Reviewer hint: use the -b option of git diff / git show Signed-off-by: Manuel Pégourié-Gonnard --- library/ssl_tls.c | 81 +++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 55 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 360419240f..a4387d5690 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -973,39 +973,24 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, #endif #if defined(MBEDTLS_USE_PSA_CRYPTO) - - /* Only use PSA-based ciphers for TLS-1.2. - * That's relevant at least for TLS-1.0, where - * we assume that mbedtls_cipher_crypt() updates - * the structure field for the IV, which the PSA-based - * implementation currently doesn't. */ -#if defined(MBEDTLS_SSL_PROTO_TLS1_2) - if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + ret = mbedtls_cipher_setup_psa( &transform->cipher_ctx_enc, + cipher_info, transform->taglen ); + if( ret != 0 && ret != MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ) { - ret = mbedtls_cipher_setup_psa( &transform->cipher_ctx_enc, - cipher_info, transform->taglen ); - if( ret != 0 && ret != MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setup_psa", ret ); - goto end; - } + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setup_psa", ret ); + goto end; + } - if( ret == 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 3, ( "Successfully setup PSA-based encryption cipher context" ) ); - psa_fallthrough = 0; - } - else - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "Failed to setup PSA-based cipher context for record encryption - fall through to default setup." ) ); - psa_fallthrough = 1; - } + if( ret == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "Successfully setup PSA-based encryption cipher context" ) ); + psa_fallthrough = 0; } else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Failed to setup PSA-based cipher context for record encryption - fall through to default setup." ) ); psa_fallthrough = 1; -#else - psa_fallthrough = 1; -#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + } if( psa_fallthrough == 1 ) #endif /* MBEDTLS_USE_PSA_CRYPTO */ @@ -1017,38 +1002,24 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, } #if defined(MBEDTLS_USE_PSA_CRYPTO) - /* Only use PSA-based ciphers for TLS-1.2. - * That's relevant at least for TLS-1.0, where - * we assume that mbedtls_cipher_crypt() updates - * the structure field for the IV, which the PSA-based - * implementation currently doesn't. */ -#if defined(MBEDTLS_SSL_PROTO_TLS1_2) - if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + ret = mbedtls_cipher_setup_psa( &transform->cipher_ctx_dec, + cipher_info, transform->taglen ); + if( ret != 0 && ret != MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ) { - ret = mbedtls_cipher_setup_psa( &transform->cipher_ctx_dec, - cipher_info, transform->taglen ); - if( ret != 0 && ret != MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setup_psa", ret ); - goto end; - } + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_setup_psa", ret ); + goto end; + } - if( ret == 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 3, ( "Successfully setup PSA-based decryption cipher context" ) ); - psa_fallthrough = 0; - } - else - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "Failed to setup PSA-based cipher context for record decryption - fall through to default setup." ) ); - psa_fallthrough = 1; - } + if( ret == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "Successfully setup PSA-based decryption cipher context" ) ); + psa_fallthrough = 0; } else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Failed to setup PSA-based cipher context for record decryption - fall through to default setup." ) ); psa_fallthrough = 1; -#else - psa_fallthrough = 1; -#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + } if( psa_fallthrough == 1 ) #endif /* MBEDTLS_USE_PSA_CRYPTO */ From 3785c907c71af0eaeb4772586688f40eaf1a2681 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 20 Sep 2021 09:05:36 +0200 Subject: [PATCH 541/966] Define TLS 1.3 MVP and document coding rules Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 242 ++++++++++++++++++++++++ 1 file changed, 242 insertions(+) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 0009c68180..e6f9065801 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -66,3 +66,245 @@ together with their level of testing: as part of `MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL`: - Reader ([`library/mps_reader.h`](../../library/mps_reader.h)) + + +MVP definition +-------------- + +The TLS 1.3 MVP implements only the client side of the protocol. +The TLS 1.3 MVP does not support the handling of server HelloRetryRequest and +CertificateRequest messages. If it receives one of those messages, it aborts +the handshake with an handshake_failure closure alert. + +- Supported cipher suites: depends on the library configuration. Potentially + all of them: + TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, + TLS_AES_128_CCM_SHA256 and TLS_AES_128_CCM_8_SHA256. + +- Supported ClientHello extensions: + + MVP Prototype + (for comparison) + + server_name no YES + max_fragment_length no YES + status_request no no + supported_groups YES YES + signature_algorithms YES YES + use_srtp no no + heartbeat no no + apln no YES + signed_certificate_timestamp no no + client_certificate_type no no + server_certificate_type no no + padding no no + key_share YES YES + pre_shared_key no YES + psk_key_exchange_modes no YES + early_data no YES + cookie no YES + supported_versions YES YES + certificate_authorities no no + post_handshake_auth no no + signature_algorithms_cert no no + +- Supported groups: depends on the library configuration. + Potentially all ECDHE groups: + secp256r1, secp384r1, secp521r1(0x0019), x25519, x448. + +- Supported signature algorithms: depends on the library configuration. + Potentially: + ecdsa_secp256r1_sha256, ecdsa_secp384r1_sha384, ecdsa_secp521r1_sha512, + rsa_pss_rsae_sha256. + +- Supported versions: only TLS 1.3 + +- Support of Mbed TLS SSL/TLS related (not DTLS) features: + + The TLS 1.3 MVP is compatible with all TLS 1.2 configuration options in the + sense that when enabling the TLS 1.3 MVP in the library there is no need to + modify the configuration for TLS 1.2. Mbed TLS SSL/TLS related features are + not supported or not applicable to the TLS 1.3 MVP: + + Supported Comment + MBEDTLS_SSL_ALL_ALERT_MESSAGES no + MBEDTLS_SSL_ASYNC_PRIVATE no + MBEDTLS_SSL_CONTEXT_SERIALIZATION no + MBEDTLS_SSL_DEBUG_ALL no + MBEDTLS_SSL_ENCRYPT_THEN_MAC n/a + MBEDTLS_SSL_EXTENDED_MASTER_SECRET n/a + MBEDTLS_SSL_KEEP_PEER_CERTIFICATE no + MBEDTLS_SSL_RENEGOTIATION n/a Not TLS 1.2 dependent + MBEDTLS_SSL_MAX_FRAGMENT_LENGTH no + MBEDTLS_SSL_ALPN no + + MBEDTLS_SSL_SESSION_TICKETS no + MBEDTLS_SSL_EXPORT_KEYS no Incomplete support + MBEDTLS_SSL_SERVER_NAME_INDICATION no + MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH no + + MBEDTLS_ECP_RESTARTABLE no + MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED no + + MBEDTLS_KEY_EXCHANGE_PSK_ENABLED n/a Make sense in TLS 1.3 + MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED n/a context but their current + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED n/a definition is TLS 1.2 only. + MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED n/a + MBEDTLS_KEY_EXCHANGE_RSA_ENABLED n/a + MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED n/a + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED n/a + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED n/a + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED n/a + MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED n/a + MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED n/a + + MBEDTLS_USE_PSA_CRYPTO no + +Not in the plan yet but probably necessary for a viable client: +- server_name extension +- support for HelloRetryRequest +- fallback to TLS 1.2 + +Coding rules checklist for TLS 1.3 +---------------------------------- + +The following coding rules are aimed to be a checklist for TLS 1.3 upstreaming +work to reduce review rounds and the number of comments in each round. They +come along (do NOT replace) the project coding rules +(https://tls.mbed.org/kb/development/mbedtls-coding-standards). They have been +established and discussed following the review of #4882 that was the +PR upstreaming the first part of TLS 1.3 ClientHello writing code. + +TLS 1.3 specific coding rules: + + - TLS 1.3 specific C modules, headers, static functions names are prefixed + with `ssl_tls1_3_`. The same applies to structures and types that are + internal to C modules. + + - TLS 1.3 specific exported functions, macros, structures and types are + prefixed with `mbedtls_ssl_tls1_3_`. + + - The names of macros and variables related to a field or structure in the + TLS 1.3 specification should contain as far as possible the field name as + it is in the specification. If the field name is `too long` and we prefer + to introduce some kind of abbreviation of it, use the same abbreviation + everywhere in the code. + + Example 1: #define CLIENT_HELLO_RANDOM_LEN 32, macro for the length of the + `random` field of the ClientHello message. + + Example 2 (consistent abbreviation): mbedtls_ssl_tls1_3_write_sig_alg_ext() + and MBEDTLS_TLS_EXT_SIG_ALG, `sig_alg` standing for + `signature_algorithms`. + + - Regarding vectors that are represented by a length followed by their value + in the data exchanged between servers and clients: + + - Use `_len` for the name of a variable used to compute the + length in bytes of the vector, where is the name of the + vector as defined in the TLS 1.3 specification. + + - Use `_len_ptr` for the name of a variable intended to hold + the address of the first byte of the vector length. + + - Use `_ptr` for the name of a variable intended to hold the + address of the first byte of the vector value. + + - Use `_end_ptr` for the name of a variable intended to hold + the address of the first byte past the vector value. + + Those two last idioms should lower the risk of mis-using one of the address + in place of the other one which could potentially lead to some nasty + issues. + + Example: `cipher_suites` vector of ClientHello in + ssl_tls1_3_write_client_hello_cipher_suites() + + size_t cipher_suites_len; + unsigned char *cipher_suites_len_ptr; + unsigned char *cipher_suites_ptr; + + - Use of MBEDTLS_BYTE_xyz, MBEDTLS_PUT/GET_xyz, MBEDTLS_SSL_CHK_BUF_PTR + MBEDTLS_SSL_CHK_BUF_READ_PTR macros where applicable. + + These macros were introduced after the prototype was written thus are + likely not to be used in prototype where we now would use them in + development. + + The two first types, MBEDTLS_BYTE_xyz and MBEDTLS_PUT/GET_xyz, improve + the readability of the code and reduce the risk of writing or reading + bytes in the wrong order: we should probably have only MBEDTLS_GET/PUT_*_BE + (BE stands for Big-Endian) macros in the TLS 1.3 code. + + The two last types, MBEDTLS_SSL_CHK_BUF_PTR and + MBEDTLS_SSL_CHK_BUF_READ_PTR, improve the readability of the code and + reduce the risk of error in the non-completely-trivial arithmetic to + check that we do not write or read past the end of a data buffer. The + usage of those macros combined with the following rule mitigate the risk + to read/write past the end of a data buffer. + + Examples: hs_hdr[1] = MBEDTLS_BYTE_2( total_hs_len ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 ); + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); + + - To mitigate what happened here + (https://github.com/ARMmbed/mbedtls/pull/4882#discussion_r701704527) from + happening again, use always a local variable named `p` for the reading + pointer in functions parsing TLS 1.3 data, and for the writing pointer in + functions writing data into an output buffer. The name `p` has been + chosen as it was already widely used in TLS code. + + - When an TLS 1.3 structure is written or read by a function or as part of + a function, provide as documentation the definition of the structure as + it is in the TLS 1.3 specification. + +General coding rules: + + - We prefer grouping `related statement lines` by not adding blank lines + between them. + + Example 1: + + ret = ssl_tls13_write_client_hello_cipher_suites( ssl, buf, end, &output_len ); + if( ret != 0 ) + return( ret ); + buf += output_len; + + Example 2: + + MBEDTLS_SSL_CHK_BUF_PTR( cipher_suites_iter, end, 2 ); + MBEDTLS_PUT_UINT16_BE( cipher_suite, cipher_suites_iter, 0 ); + cipher_suites_iter += 2; + + - Use macros for constants that are used in different functions, different + places in the code. When a constant is used only locally in a function + (like the length in bytes of the vector lengths in functions reading and + writing TLS handshake message) there is no need to define a macro for it. + + Example: #define CLIENT_HELLO_RANDOM_LEN 32 + + - When declaring a pointer the dereferencing operator should be prepended to + the pointer name not appended to the pointer type: + + Example: mbedtls_ssl_context *ssl; + + - Maximum line length is 80 characters. + + Exceptions: + + - string literals can extend beyond 80 characters as we do not want to + split them to ease their search in the code base. + + - A line can be more than 80 characters by a few characters if just looking + at the 80 first characters is enough to fully understand the line. For + example it is generally fine if some closure characters like ";" or ")" + are beyond the 80 characters limit. + + - When in successive lines, functions and macros parameters should be aligned + vertically. + + Example: + int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char **buf, + size_t *buf_len ); From 1e07869381a0a66d08094919090f6f5dbcf4ecfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 22 Sep 2021 10:11:53 +0200 Subject: [PATCH 542/966] Fix inaccuracy in key exchange summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- docs/use-psa-crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/use-psa-crypto.md b/docs/use-psa-crypto.md index c8f89d0c24..6300bf02e2 100644 --- a/docs/use-psa-crypto.md +++ b/docs/use-psa-crypto.md @@ -160,7 +160,7 @@ TLS: key exchanges / asymmetric crypto - ECDHE computation client-side - ECDSA verification both sides - ECDSA signature (if using `mbedtls_pk_setup_opaque()`) -- PSK: client-side PSA-held using `mbedtls_ssl_conf_psk_opaque()` +- PSK: PSA-held keys using `mbedtls_ssl_conf_psk_opaque()` - DHE-PSK: not covered - RSA-PSK: not covered - ECDHE-PSK: not covered From 76e31ec169e09cc3afd93ad3ff63e5a043804e30 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 22 Sep 2021 21:16:27 +0800 Subject: [PATCH 543/966] Add gnutls version test for client hello Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 9170136038..39499d441c 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8668,13 +8668,22 @@ run_test "TLS1.3: handshake dispatch test: tls1_3 only" \ requires_openssl_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL -run_test "TLS1.3: Test client hello msg work" \ +run_test "TLS1.3: Test client hello msg work - openssl" \ "$O_NEXT_SRV -tls1_3 -msg" \ "$P_CLI min_version=tls1_3 max_version=tls1_3" \ 1 \ -c "SSL - The requested feature is not available" \ -s "ServerHello" +requires_gnutls_tls1_3 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +run_test "TLS1.3: Test client hello msg work - gnutls" \ + "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3 --debug=4" \ + "$P_CLI min_version=tls1_3 max_version=tls1_3" \ + 1 \ + -c "SSL - The requested feature is not available" \ + -s "SERVER HELLO was queued" + # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C From 11c81df707da138461e5c44be801f25155f00851 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 22 Sep 2021 18:15:51 +0100 Subject: [PATCH 544/966] Fix aarch64 assembly for bignum multiplication Add memory constraints to the aarch64 inline assembly in MULADDC_STOP. This fixes an issue where Clang 12 and 13 were generating non-functional code on aarch64 platforms. See #4962, #4943 for further details. Signed-off-by: David Horstmann --- ChangeLog.d/muladdc-aarch64-memory.txt | 4 ++++ library/bn_mul.h | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 ChangeLog.d/muladdc-aarch64-memory.txt diff --git a/ChangeLog.d/muladdc-aarch64-memory.txt b/ChangeLog.d/muladdc-aarch64-memory.txt new file mode 100644 index 0000000000..70addd253c --- /dev/null +++ b/ChangeLog.d/muladdc-aarch64-memory.txt @@ -0,0 +1,4 @@ +Bugfix + * Add missing memory constraints in aarch64 inline assembly for + bignum multiplication. + Fixes #4962. diff --git a/library/bn_mul.h b/library/bn_mul.h index 328e765008..b71ddd881a 100644 --- a/library/bn_mul.h +++ b/library/bn_mul.h @@ -224,7 +224,7 @@ "adcq %%rdx, %%rcx\n" \ "addq $8, %%rdi\n" -#define MULADDC_STOP \ +#define MULADDC_STOP \ : "+c" (c), "+D" (d), "+S" (s), "+m" (*(uint64_t (*)[16]) d) \ : "b" (b), "m" (*(const uint64_t (*)[16]) s) \ : "rax", "rdx", "r8" \ @@ -240,18 +240,18 @@ #define MULADDC_CORE \ "ldr x4, [%2], #8 \n\t" \ "ldr x5, [%1] \n\t" \ - "mul x6, x4, %3 \n\t" \ - "umulh x7, x4, %3 \n\t" \ + "mul x6, x4, %4 \n\t" \ + "umulh x7, x4, %4 \n\t" \ "adds x5, x5, x6 \n\t" \ "adc x7, x7, xzr \n\t" \ "adds x5, x5, %0 \n\t" \ "adc %0, x7, xzr \n\t" \ "str x5, [%1], #8 \n\t" -#define MULADDC_STOP \ - : "+r" (c), "+r" (d), "+r" (s) \ - : "r" (b) \ - : "x4", "x5", "x6", "x7", "cc" \ +#define MULADDC_STOP \ + : "+r" (c), "+r" (d), "+r" (s), "+m" (*(uint64_t (*)[16]) d) \ + : "r" (b), "m" (*(const uint64_t (*)[16]) s) \ + : "x4", "x5", "x6", "x7", "cc" \ ); #endif /* Aarch64 */ From 3ecdb3e308e8207a4c40798cf749a01a8d453256 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 21 Sep 2021 17:23:34 +0100 Subject: [PATCH 545/966] Change test dependencys to PSA_WANT Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 09ebcf08f3..63a5979458 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2679,11 +2679,11 @@ depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_finish_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:0:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL PSA AEAD setup: invalid algorithm (CTR) -depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C +depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES aead_multipart_setup:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:PSA_ERROR_INVALID_ARGUMENT PSA AEAD setup: invalid algorithm (ChaCha20) -depends_on:MBEDTLS_CHACHA20_C +depends_on:PSA_WANT_ALG_STREAM_CIPHER:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_setup:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:PSA_ERROR_INVALID_ARGUMENT PSA Multipart State Checks, AES - GCM From bdc2c68d97d25abfd4ffe93a48cb420c0bd41d6a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 21 Sep 2021 18:37:10 +0100 Subject: [PATCH 546/966] Add missing not setting nonce tests Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index c91f744b89..e9ca8d268a 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4402,6 +4402,36 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); + /* ------------------------------------------------------- */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_finish( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, tag_length, + &tag_size ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + + /* ------------------------------------------------------- */ + + operation = psa_aead_operation_init( ); + + PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); + + TEST_EQUAL( psa_aead_verify( &operation, final_data, + finish_output_size, + &output_part_length, + tag_buffer, + tag_length ), + PSA_ERROR_BAD_STATE ); + + psa_aead_abort( &operation ); + /* Test for double setting nonce. */ operation = psa_aead_operation_init( ); From bb979e774820b897fe3564a74d1e5d5c49db850d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 12:54:42 +0100 Subject: [PATCH 547/966] Rename enum types Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index e9ca8d268a..482063a1d4 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -269,13 +269,13 @@ typedef enum DO_NOT_SET_LENGTHS = 0, SET_LENGTHS_BEFORE_NONCE = 1, SET_LENGTHS_AFTER_NONCE = 2 -} setlengths_method; +} set_lengths_method_t; typedef enum { USE_NULL_TAG = 0, USE_GIVEN_TAG = 1, -} tagusage_method; +} tag_usage_method_t; /*! * \brief Internal Function for AEAD multipart tests. @@ -291,7 +291,7 @@ typedef enum * \param data_part_len_arg If not -1, the length of chunks to feed * the data in to be encrypted / decrypted. If * -1, no chunking - * \param set_lengths_method A member of the setlengths_method enum is + * \param set_lengths_method A member of the set_lengths_method_t enum is * expected here, this controls whether or not * to set lengths, and in what order with * respect to set nonce. @@ -308,7 +308,7 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, int ad_part_len_arg, data_t *input_data, int data_part_len_arg, - setlengths_method set_lengths_method, + set_lengths_method_t set_lengths_method, data_t *expected_output, int is_encrypt, int do_zero_parts ) @@ -3478,7 +3478,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, { size_t ad_part_len = 0; size_t data_part_len = 0; - setlengths_method set_lengths_method = DO_NOT_SET_LENGTHS; + set_lengths_method_t set_lengths_method = DO_NOT_SET_LENGTHS; /* Ensure that either one part of the test or the other is done, i.e this * test does something. */ @@ -3586,7 +3586,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, { size_t ad_part_len = 0; size_t data_part_len = 0; - setlengths_method set_lengths_method = DO_NOT_SET_LENGTHS; + set_lengths_method_t set_lengths_method = DO_NOT_SET_LENGTHS; /* Ensure that either one part of the test or the other is done, i.e this * test does something. */ @@ -4088,7 +4088,7 @@ void aead_multipart_verify( int key_type_arg, data_t *key_data, size_t plaintext_size = 0; size_t plaintext_length = 0; size_t verify_plaintext_size = 0; - tagusage_method tag_usage = tag_usage_arg; + tag_usage_method_t tag_usage = tag_usage_arg; unsigned char *tag_buffer = NULL; size_t tag_size = 0; From a2a09b096c413d40894ab9bdbd0c41b1dbb794b1 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 14:56:40 +0100 Subject: [PATCH 548/966] Remove double initialisation of AEAD operation Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 68 +-------------------- 1 file changed, 2 insertions(+), 66 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 482063a1d4..7c988067ad 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4191,8 +4191,6 @@ void aead_multipart_setup( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); - operation = psa_aead_operation_init( ); - mbedtls_test_set_step( 1 ); status = psa_aead_decrypt_setup( &operation, key, alg ); @@ -4267,8 +4265,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); - operation = psa_aead_operation_init( ); - TEST_EQUAL( psa_aead_generate_nonce( &operation, nonce_buffer, PSA_AEAD_NONCE_MAX_SIZE, &nonce_length ), @@ -4278,8 +4274,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len, input_data->len ), PSA_ERROR_BAD_STATE ); @@ -4288,8 +4282,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - TEST_EQUAL( psa_aead_update_ad( &operation, additional_data->x, additional_data->len ), PSA_ERROR_BAD_STATE ); @@ -4298,8 +4290,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - TEST_EQUAL( psa_aead_update( &operation, input_data->x, input_data->len, output_data, output_size, &output_length ), @@ -4309,8 +4299,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - TEST_EQUAL( psa_aead_finish( &operation, final_data, finish_output_size, &output_part_length, @@ -4322,8 +4310,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - TEST_EQUAL( psa_aead_verify( &operation, final_data, finish_output_size, &output_part_length, @@ -4335,8 +4321,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for double setups. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_encrypt_setup( &operation, key, alg ), @@ -4346,8 +4330,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_decrypt_setup( &operation, key, alg ), @@ -4357,8 +4339,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_decrypt_setup( &operation, key, alg ), @@ -4368,8 +4348,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_encrypt_setup( &operation, key, alg ), @@ -4379,8 +4357,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for not setting a nonce. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_update_ad( &operation, additional_data->x, @@ -4391,8 +4367,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_update( &operation, input_data->x, @@ -4404,8 +4378,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_finish( &operation, final_data, @@ -4419,8 +4391,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_verify( &operation, final_data, @@ -4434,8 +4404,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for double setting nonce. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4447,8 +4415,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for double generating nonce. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, @@ -4465,8 +4431,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for generate nonce then set and vice versa */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, @@ -4480,8 +4444,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4495,8 +4457,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for generating nonce in decrypt setup. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); TEST_EQUAL( psa_aead_generate_nonce( &operation, nonce_buffer, @@ -4508,8 +4468,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for setting lengths twice. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4525,8 +4483,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for setting lengths after already starting data. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4542,8 +4498,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* ------------------------------------------------------- */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4561,8 +4515,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for not sending any additional data or data after setting non zero * lengths for them. (encrypt) */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4582,8 +4534,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for not sending any additional data or data after setting non-zero * lengths for them. (decrypt) */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4603,8 +4553,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for not sending any additional data after setting a non-zero length * for it. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4621,8 +4569,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for not sending any data after setting a non-zero length for it.*/ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4644,8 +4590,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for sending too much additional data after setting lengths. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4659,7 +4603,7 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); - operation = psa_aead_operation_init( ); + /* ------------------------------------------------------- */ PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); @@ -4679,8 +4623,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test for sending too much data after setting lengths. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4694,7 +4636,7 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, psa_aead_abort( &operation ); - operation = psa_aead_operation_init( ); + /* ------------------------------------------------------- */ PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); @@ -4719,8 +4661,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test sending additional data after data. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4737,8 +4677,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test calling finish on decryption. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); @@ -4754,8 +4692,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test calling verify on encryption. */ - operation = psa_aead_operation_init( ); - PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) ); PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) ); From fbb4c6d9a249ebce03e89509676d92f589502d8d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 16:44:21 +0100 Subject: [PATCH 549/966] Replace AEAD operation init func with macro Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 33 +++++---------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 7c988067ad..406509091a 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -316,7 +316,7 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; unsigned char *output_data = NULL; unsigned char *part_data = NULL; unsigned char *final_data = NULL; @@ -391,9 +391,6 @@ static int aead_multipart_internal_func( int key_type_arg, data_t *key_data, ASSERT_ALLOC( final_data, final_output_size ); - operation = psa_aead_operation_init( ); - - if( is_encrypt ) status = psa_aead_encrypt_setup( &operation, key, alg ); else @@ -3693,7 +3690,7 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; uint8_t nonce_buffer[PSA_AEAD_NONCE_MAX_SIZE]; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; @@ -3729,8 +3726,6 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, ASSERT_ALLOC( ciphertext, ciphertext_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -3792,7 +3787,7 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; uint8_t *nonce_buffer = NULL; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; @@ -3828,8 +3823,6 @@ void aead_multipart_set_nonce( int key_type_arg, data_t *key_data, ASSERT_ALLOC( ciphertext, ciphertext_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -3908,7 +3901,7 @@ void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; @@ -3937,8 +3930,6 @@ void aead_multipart_update_buffer_test( int key_type_arg, data_t *key_data, ASSERT_ALLOC( ciphertext, ciphertext_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -3993,7 +3984,7 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; @@ -4025,8 +4016,6 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data, ASSERT_ALLOC( tag_buffer, tag_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_encrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -4079,7 +4068,7 @@ void aead_multipart_verify( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; @@ -4112,8 +4101,6 @@ void aead_multipart_verify( int key_type_arg, data_t *key_data, ASSERT_ALLOC( finish_plaintext, verify_plaintext_size ); - operation = psa_aead_operation_init( ); - status = psa_aead_decrypt_setup( &operation, key, alg ); /* If the operation is not supported, just skip and not fail in case the @@ -4166,7 +4153,7 @@ void aead_multipart_setup( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t expected_status = expected_status_arg; @@ -4181,8 +4168,6 @@ void aead_multipart_setup( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, &key ) ); - operation = psa_aead_operation_init( ); - mbedtls_test_set_step( 0 ); status = psa_aead_encrypt_setup( &operation, key, alg ); @@ -4214,7 +4199,7 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; - psa_aead_operation_t operation; + psa_aead_operation_t operation = PSA_AEAD_OPERATION_INIT; unsigned char *output_data = NULL; unsigned char *final_data = NULL; size_t output_size = 0; @@ -4258,8 +4243,6 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, /* Test all operations error without calling setup first. */ - operation = psa_aead_operation_init( ); - TEST_EQUAL( psa_aead_set_nonce( &operation, nonce->x, nonce->len ), PSA_ERROR_BAD_STATE ); From 2c363a802a35a3a07499a8e603b2d10e3f666d33 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 17:07:54 +0100 Subject: [PATCH 550/966] Add NULL / 0 buffer tests for update test Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 63a5979458..fd78335d1e 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2646,10 +2646,18 @@ PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 0 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL + PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 129 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:129:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL +PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 0 +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:0:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":PSA_ERROR_BUFFER_TOO_SMALL + PSA AEAD finish buffer test: AES - GCM, BUF = 8, TAG = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):8:16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL From 70618b22a9b3819c6bb6db86975fd7a0436004f9 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 17:12:16 +0100 Subject: [PATCH 551/966] Change sizeof to variable rather than struct Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 664b8aecce..415dab8b2b 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3822,7 +3822,7 @@ psa_status_t psa_aead_abort( psa_aead_operation_t *operation ) status = psa_driver_wrapper_aead_abort( operation ); - memset( operation, 0, sizeof( psa_aead_operation_t ) ); + memset( operation, 0, sizeof( *operation ) ); return( status ); } From 90fdc117dd583b9df6119c2a15aee123581a9c9e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 17:15:48 +0100 Subject: [PATCH 552/966] Make NULL tag check more explicit Signed-off-by: Paul Elliott --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 415dab8b2b..a954d86c67 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3760,7 +3760,7 @@ exit: * Even if the operation succeeds, make sure we clear the rest of the * buffer to prevent potential leakage of anything previously placed in * the same buffer.*/ - if( tag ) + if( tag != NULL ) { if( status != PSA_SUCCESS ) memset( tag, '!', tag_size ); From 88ecbe176da8600c982e008b90b7135a9b0f4722 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 17:23:03 +0100 Subject: [PATCH 553/966] Test generated nonce test generates expected sizes (But only in the positive test cases) Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 406509091a..cd97c50630 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3747,6 +3747,10 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data, TEST_EQUAL( actual_nonce_length, expected_nonce_length ); + if( expected_status == PSA_SUCCESS ) + TEST_EQUAL( actual_nonce_length, PSA_AEAD_NONCE_LENGTH( key_type, + alg ) ); + TEST_ASSERT( actual_nonce_length < PSA_AEAD_NONCE_MAX_SIZE ); if( expected_status == PSA_SUCCESS ) From 3db0b70263f142425c7f2a9bdcc8e99449fa2741 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 22 Sep 2021 17:27:58 +0100 Subject: [PATCH 554/966] Remove unnecessary test steps Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.function | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index cd97c50630..5455fc656e 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -4172,16 +4172,12 @@ void aead_multipart_setup( int key_type_arg, data_t *key_data, PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, &key ) ); - mbedtls_test_set_step( 0 ); - status = psa_aead_encrypt_setup( &operation, key, alg ); TEST_EQUAL( status, expected_status ); psa_aead_abort( &operation ); - mbedtls_test_set_step( 1 ); - status = psa_aead_decrypt_setup( &operation, key, alg ); TEST_EQUAL(status, expected_status ); From 6113af68c536fd34b379de06fa11a4b3e29627d4 Mon Sep 17 00:00:00 2001 From: joseph Date: Thu, 23 Sep 2021 20:58:45 +0900 Subject: [PATCH 555/966] Fix test code to can be built on alpine Signed-off-by: joseph --- ChangeLog.d/do-not-use-obsolete-header.txt | 5 +++++ tests/suites/test_suite_net.function | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 ChangeLog.d/do-not-use-obsolete-header.txt diff --git a/ChangeLog.d/do-not-use-obsolete-header.txt b/ChangeLog.d/do-not-use-obsolete-header.txt new file mode 100644 index 0000000000..9a57ef16b2 --- /dev/null +++ b/ChangeLog.d/do-not-use-obsolete-header.txt @@ -0,0 +1,5 @@ +Bugfix + * Don't use the obsolete header path sys/fcntl.h in unit tests. + These header files cause compilation errors in musl. + Fixes #4969. + diff --git a/tests/suites/test_suite_net.function b/tests/suites/test_suite_net.function index f429fc9221..513b72364b 100644 --- a/tests/suites/test_suite_net.function +++ b/tests/suites/test_suite_net.function @@ -9,11 +9,11 @@ #endif #if defined(MBEDTLS_PLATFORM_IS_UNIXLIKE) -#include #include #include #include #include +#include #include #endif From d3ac4a9a8abeba0232c43a7cf38b2905c0fe5862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 24 Sep 2021 10:06:04 +0200 Subject: [PATCH 556/966] Clarify wording of "not covered" section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The section is about things that are not covered, but some lists are about things that are covered, which was very confusing. Signed-off-by: Manuel Pégourié-Gonnard --- docs/use-psa-crypto.md | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/docs/use-psa-crypto.md b/docs/use-psa-crypto.md index 6300bf02e2..4292aa6b94 100644 --- a/docs/use-psa-crypto.md +++ b/docs/use-psa-crypto.md @@ -153,27 +153,33 @@ This is only a high-level overview, grouped by theme TLS: key exchanges / asymmetric crypto -------------------------------------- -- RSA: not covered -- DHE-RSA: not covered -- ECDHE-RSA: ECDHE computation client-side only -- ECDHE-ECDSA: - - ECDHE computation client-side - - ECDSA verification both sides - - ECDSA signature (if using `mbedtls_pk_setup_opaque()`) -- PSK: PSA-held keys using `mbedtls_ssl_conf_psk_opaque()` -- DHE-PSK: not covered -- RSA-PSK: not covered -- ECDHE-PSK: not covered -- ECDH-RSA: not covered -- ECDH-ECDSA: not covered -- ECJPAKE: not covered +The following key exchanges are not covered at all: + +- RSA +- DHE-RSA +- DHE-PSK +- RSA-PSK +- ECDHE-PSK +- ECDH-RSA +- ECDH-ECDSA +- ECJPAKE + +The following key exchanges are only partially covered: + +- ECDHE-RSA: RSA operations are not covered and, server-side, the ECDHE + operation isn't either +- ECDHE-ECDSA: server-side, the ECDHE operation isn't covered. (ECDSA + signature generation is only covered if using `mbedtls_pk_setup_opaque()`.) + +PSK if covered when the application uses `mbedtls_ssl_conf_psk_opaque()` or +`mbedtls_ssl_set_hs_psk_opaque()`. TLS: symmetric crypto --------------------- - some ciphers not supported via PSA yet: ARIA, Camellia, ChachaPoly (silent fallback to the legacy APIs) -- the HMAC part of the CBC and NULL ciphersuites is not covered +- the HMAC part of the CBC and NULL ciphersuites - the HMAC computation in `ssl_cookie.c` X.509 @@ -181,6 +187,6 @@ X.509 - most hash operations are still done via the legacy API, except the few that are documented above as using PSA -- RSA PKCS#1 v1.5 signature generation (from PSA-held keys): not covered -- RSA PKCS#1 v1.5 signature verification: not covered -- RSA-PSS signature verification: not covered +- RSA PKCS#1 v1.5 signature generation (from PSA-held keys) +- RSA PKCS#1 v1.5 signature verification +- RSA-PSS signature verification From ca9101739aca97117d1889489515c2262f8846bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 24 Sep 2021 10:14:32 +0200 Subject: [PATCH 557/966] Improve wording and fix some typos. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- docs/use-psa-crypto.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/use-psa-crypto.md b/docs/use-psa-crypto.md index 4292aa6b94..cdae3a8273 100644 --- a/docs/use-psa-crypto.md +++ b/docs/use-psa-crypto.md @@ -37,15 +37,18 @@ X.509) layers to pick up the improvements. ### PSA-held (opaque) keys in the PK layer -Add `mbedtls_pk_setup_opaque()` to wrap a PSA keypair into a PK context. The key -can be used for private-key operations and its public part can be written out. +There is a new API function `mbedtls_pk_setup_opaque()` that can be used to +wrap a PSA keypair into a PK context. The key can be used for private-key +operations and its public part can be exported. Benefits: isolation of long-term secrets, use of PSA Crypto drivers. Limitations: only for private keys, only ECC. (That is, only ECDSA signature -generation.) The following operations are not supported with a context set -this way, while they would be available with a normal `ECKEY` context: -`mbedtls_pk_verify()`, `mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`. +generation. Note: currently this will use randomized ECDSA while Mbed TLS uses +deterministic ECDSA by default.) The following operations are not supported +with a context set this way, while they would be available with a normal +`ECKEY` context: `mbedtls_pk_verify()`, `mbedtls_pk_check_pair()`, +`mbedtls_pk_debug()`. Use in X.509 and TLS: opt-in. The application needs to construct the PK context using the new API in order to get the benefits; it can then pass the @@ -56,14 +59,15 @@ resulting context to the following existing APIs: - `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature request). -In the TLS and X.509 API, there's two other function which accept a key or +In the TLS and X.509 API, there are two other functions which accept a key or keypair as a PK context: `mbedtls_x509write_crt_set_subject_key()` and `mbedtls_x509write_crt_set_issuer_key()`. Use of opaque contexts here probably works but is so far untested. ### PSA-held (opaque) keys for TLS 1.2 pre-shared keys (PSK) -Add `mbedtls_ssl_conf_psk_opaque()` and `mbedtls_ssl_set_hs_psk_opaque()` to +There are two new API functions `mbedtls_ssl_conf_psk_opaque()` and +`mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to register a PSA key for use with a PSK key exchange. Benefits: isolation of long-term secrets. @@ -81,8 +85,8 @@ APIs to get the benefits. ### PSA-based operations in the Cipher layer -Add `mbedtls_cipher_setup_psa()` to set up a context that will call PSA to -store the key and perform the operations. +There is a new API function `mbedtls_cipher_setup_psa()` to set up a context +that will call PSA to store the key and perform the operations. Benefits: use of PSA Crypto drivers; partial isolation of short-term secrets (still generated outside of PSA, but then held by PSA). From 9155b0e396b0cc90642d452916b4a4264025d42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 24 Sep 2021 10:17:07 +0200 Subject: [PATCH 558/966] Clarify that 1.3 is excluded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't mention "TLS 1.2 only" for PSK, as that could give the impression that the other things about TLS are supported beyond 1.2, which isn't the case currently. Signed-off-by: Manuel Pégourié-Gonnard --- docs/use-psa-crypto.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/use-psa-crypto.md b/docs/use-psa-crypto.md index cdae3a8273..af485ce8e7 100644 --- a/docs/use-psa-crypto.md +++ b/docs/use-psa-crypto.md @@ -64,7 +64,7 @@ keypair as a PK context: `mbedtls_x509write_crt_set_subject_key()` and `mbedtls_x509write_crt_set_issuer_key()`. Use of opaque contexts here probably works but is so far untested. -### PSA-held (opaque) keys for TLS 1.2 pre-shared keys (PSK) +### PSA-held (opaque) keys for TLS pre-shared keys (PSK) There are two new API functions `mbedtls_ssl_conf_psk_opaque()` and `mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to @@ -72,7 +72,7 @@ register a PSA key for use with a PSK key exchange. Benefits: isolation of long-term secrets. -Limitations: the key can only be used with with TLS 1.2, and only with "pure" +Limitations: the key can only be used with "pure" PSK key exchanges (ciphersuites starting with `TLS_PSK_WITH_`), to the exclusion of RSA-PSK, DHE-PSK and ECDHE-PSK key exchanges. It is the responsibility of the user to make sure that when provisioning an opaque pre-shared key, the @@ -154,6 +154,11 @@ Parts that are not covered yet This is only a high-level overview, grouped by theme +TLS: 1.3 experimental support +----------------------------- + +No part of the experimental support for TLS 1.3 is covered at the moment. + TLS: key exchanges / asymmetric crypto -------------------------------------- From 13841cb719d4d2af13de8c5ac0fbd4e4afd79664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 24 Sep 2021 11:43:14 +0200 Subject: [PATCH 559/966] Mention areas that are not (well) tested. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- docs/use-psa-crypto.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/use-psa-crypto.md b/docs/use-psa-crypto.md index af485ce8e7..6ec2dcaa1b 100644 --- a/docs/use-psa-crypto.md +++ b/docs/use-psa-crypto.md @@ -55,7 +55,8 @@ using the new API in order to get the benefits; it can then pass the resulting context to the following existing APIs: - `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the - key together with a certificate for ECDSA-based key exchanges; + key together with a certificate for ECDSA-based key exchanges (note: while +this is supported on both sides, it's currently only tested client-side); - `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature request). @@ -95,7 +96,9 @@ Limitations: the key is still passed in the clear by the application. The multi-part APIs are not supported, only the one-shot APIs. The only modes supported are ECB, CBC without padding, GCM and CCM (this excludes stream ciphers and ChachaPoly); the only cipher supported is AES (this excludes Aria, -Camellia, and ChachaPoly). +Camellia, and ChachaPoly). (Note: ECB is currently not tested.) (Note: it is +possible to perform multiple one-shot operations with the same context; +however this is not unit-tested, only tested via usage in TLS.) Use in TLS: automatic. Used when the cipher and mode is supported (with gracious fallback to the legacy API otherwise) in all places where a cipher is From 5977bc9e395daa1556688f2004ff596f811a7906 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 23 Sep 2021 17:35:08 +0100 Subject: [PATCH 560/966] Add MBEDTLS_PRIVATE to new structs Signed-off-by: Paul Elliott --- include/psa/crypto_builtin_composites.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/psa/crypto_builtin_composites.h b/include/psa/crypto_builtin_composites.h index cdecb2844c..8075caf660 100644 --- a/include/psa/crypto_builtin_composites.h +++ b/include/psa/crypto_builtin_composites.h @@ -86,24 +86,24 @@ typedef struct /* Context structure for the Mbed TLS AEAD implementation. */ typedef struct { - psa_algorithm_t alg; - psa_key_type_t key_type; + psa_algorithm_t MBEDTLS_PRIVATE(alg); + psa_key_type_t MBEDTLS_PRIVATE(key_type); - unsigned int is_encrypt : 1; + unsigned int MBEDTLS_PRIVATE(is_encrypt) : 1; - uint8_t tag_length; + uint8_t MBEDTLS_PRIVATE(tag_length); union { unsigned dummy; /* Enable easier initializing of the union. */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - mbedtls_ccm_context ccm; + mbedtls_ccm_context MBEDTLS_PRIVATE(ccm); #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - mbedtls_gcm_context gcm; + mbedtls_gcm_context MBEDTLS_PRIVATE(gcm); #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - mbedtls_chachapoly_context chachapoly; + mbedtls_chachapoly_context MBEDTLS_PRIVATE(chachapoly); #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ } ctx; From 32f46ba16a6adea6a74828906909642c32204265 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 23 Sep 2021 18:24:36 +0100 Subject: [PATCH 561/966] Remove ability to turn off chunked ad/data tests This is no longer required, as both PolyChaCha and GCM now support both chunked body data and additional data. Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 216 +++++++-------- tests/suites/test_suite_psa_crypto.function | 281 +++++++++----------- 2 files changed, 232 insertions(+), 265 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index c17d527475..e48bd976f5 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2748,435 +2748,435 @@ aead_encrypt_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f9091 PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1:0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #2 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1:1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013":1:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" PSA Multipart AEAD encrypt, AES-GCM, 128 bytes #1, T=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826":1:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":0:"":1:0:"f149e2b5f0adaa9842ca5f45b768a8fc" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":"":0:"f149e2b5f0adaa9842ca5f45b768a8fc" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=0, TAG=16, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":0:"":1:1:"f149e2b5f0adaa9842ca5f45b768a8fc" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"ab2265b4c168955561f04315":"":"":1:"f149e2b5f0adaa9842ca5f45b768a8fc" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=16, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":0:"":1:0:"204bdb1bd62154bf08922aaa54eed705" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":"":0:"204bdb1bd62154bf08922aaa54eed705" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=16, TAG=16, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":0:"":1:1:"204bdb1bd62154bf08922aaa54eed705" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"41c5da8667ef725220ffe39ae0ac590ac9fca729ab60ada0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"05ad13a5e2c2ab667e1a6fbc":"8b5c124bef6e2f0fe4d8c95cd5fa4cf1":"":1:"204bdb1bd62154bf08922aaa54eed705" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=20, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":0:"":1:0:"1b2d2764573e20ae640bf29d48e5fe05" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":"":0:"1b2d2764573e20ae640bf29d48e5fe05" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=20, TAG=16, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":0:"":1:1:"1b2d2764573e20ae640bf29d48e5fe05" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"093ef7551ebbff8eb0c0a8a4a62b198f0c2e838de10eeeee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"e656e93930ed5210ba3f0322":"3da22dacfd11b21b0a713157f60aec0cd22f1add":"":1:"1b2d2764573e20ae640bf29d48e5fe05" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":0:"":1:0:"77e5682a49243d5b9016eb1adafa2d" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":"":0:"77e5682a49243d5b9016eb1adafa2d" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=0, AAD=48, TAG=15, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":0:"":1:1:"77e5682a49243d5b9016eb1adafa2d" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"31389612d244c9792a510eca3f9c94f9f48c97ed67ae965a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"df6b54ec8b58114df5b09279":"0863bec42ee93385efbec665adfc46dafcd793f29e859e3b531c15b168f1888dd13e905cd7d5bc03f9f1f6495717df62":"":1:"77e5682a49243d5b9016eb1adafa2d" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":0:"d2ae38c4375954835d75b8e4c2f9bbb4":1:0:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":0:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=16, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":0:"d2ae38c4375954835d75b8e4c2f9bbb4":1:1:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":1:"69482957e6be5c54882d00314e0259cf191e9f29bef63a26860c1e020a21137e" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=8, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":0:"d3f3f57033df30c22860231334b099cb":1:0:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":"d3f3f57033df30c22860231334b099cb":0:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=0, TAG=8, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":0:"d3f3f57033df30c22860231334b099cb":1:1:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c50ac59e50556e47b834380018c0dc0380af9df3bf6714e6":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"f303bf4b6cfbba7104cd9436":"":"d3f3f57033df30c22860231334b099cb":1:"2269c72d77f2b6f9d57da1820ec5a5d3d62d4491e3e4e9e7" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=14, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":0:"e7fb0631eebf9bdba87045b33650c4ce":1:0:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":0:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=14, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":0:"e7fb0631eebf9bdba87045b33650c4ce":1:1:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"8ef391e4b7a2fe05b959be27823357080f963ed2f64b9e59":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0080052a2a5bb0e95222a419":"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":1:"88d674044031414af7ba9da8b89dd68e69897d99d8e1706f38c613896c18" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=4, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":0:"636871d4c0aae3da7b55abd8b5f21297":1:0:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":"636871d4c0aae3da7b55abd8b5f21297":0:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=16, TAG=4, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":0:"636871d4c0aae3da7b55abd8b5f21297":1:1:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"1cb5a0db778d3eb430b2816ceef9e455f519a8977b074183":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"c1df5e9e2e3165c54242a306":"7134e5ddc396c2a8a7da23906c8f7b40":"636871d4c0aae3da7b55abd8b5f21297":1:"14eb02562aa1d963d0033626cdc8a5c8972f4bdf" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=20, TAG=13, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":0:"3d952be11deb421b56e0ce9d7ce99553":1:0:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":"3d952be11deb421b56e0ce9d7ce99553":0:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=20, TAG=13, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":0:"3d952be11deb421b56e0ce9d7ce99553":1:1:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"45148f42669f8ab8fad689d9b9180e39d7ea8fc95696297e":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"5afcb134acc78b4eb9d11e79":"aec409e5fd82e50b824ebc1f45e75188d80615c6":"3d952be11deb421b56e0ce9d7ce99553":1:"077c0d53869869e191df116fd7baa8a293d2b577a29b0953c91b5d3b9d" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":0:"fdd8a462c86d4365c8bfee0e25fc8a62":1:0:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":"fdd8a462c86d4365c8bfee0e25fc8a62":0:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=24, IV=12, IN=16, AAD=48, TAG=15, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":0:"fdd8a462c86d4365c8bfee0e25fc8a62":1:1:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5255428457fe75e64447971ec5af0d13c5b60a07ee2d07b0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"40cb6ebafc202f82223db097":"b2da2bd05ab1f3e39613efc8d80c5d0f240ee08f6abad5791649e9c1d0f48fa3dc59c1e535d1db1a4d3fa2263f5a1117":"fdd8a462c86d4365c8bfee0e25fc8a62":1:"9ca4a6d08267038f6f7999c84105bb5eaf8f7b3b9310ec688e033088a03482" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":0:"":1:0:"bdc1ac884d332457a1d2664f168c76f0" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":"":0:"bdc1ac884d332457a1d2664f168c76f0" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=16, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":0:"":1:1:"bdc1ac884d332457a1d2664f168c76f0" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b52c505a37d78eda5dd34f20c22540ea1b58963cf8e5bf8ffa85f9f2492505b4":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"516c33929df5a3284ff463d7":"":"":1:"bdc1ac884d332457a1d2664f168c76f0" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=12, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":0:"":1:0:"2fb9c3e41fff24ef07437c47" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":"":0:"2fb9c3e41fff24ef07437c47" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=0, TAG=12, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":0:"":1:1:"2fb9c3e41fff24ef07437c47" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"98ebf7a58db8b8371d9069171190063cc1fdc1927e49a3385f890d41a838619c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"3e6db953bd4e641de644e50a":"":"":1:"2fb9c3e41fff24ef07437c47" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=16, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":0:"":1:0:"f6d47505ec96c98a42dc3ae719877b87" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":"":0:"f6d47505ec96c98a42dc3ae719877b87" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=16, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":0:"":1:1:"f6d47505ec96c98a42dc3ae719877b87" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"886cff5f3e6b8d0e1ad0a38fcdb26de97e8acbe79f6bed66959a598fa5047d65":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"3a8efa1cd74bbab5448f9945":"519fee519d25c7a304d6c6aa1897ee1eb8c59655":"":1:"f6d47505ec96c98a42dc3ae719877b87" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=13, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":0:"":1:0:"5233f95bdcf5d666fb957acdcb" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":"":0:"5233f95bdcf5d666fb957acdcb" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=20, TAG=13, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":0:"":1:1:"5233f95bdcf5d666fb957acdcb" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"a7c928738b89c3258b910ac31bc465338b2e133b143fd52d9c9859eb1d01f2a0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"a483a7e94fbb2d694d3c4a8d":"bdb613cd3c2f0edd37b3ed43041bacb949ee51fa":"":1:"5233f95bdcf5d666fb957acdcb" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":0:"":1:0:"d57e27914ecb4a764359d3c0f8d4d6" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":"":0:"d57e27914ecb4a764359d3c0f8d4d6" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=15, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":0:"":1:1:"d57e27914ecb4a764359d3c0f8d4d6" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"16a5b58a1dbb273a8fc6a4af722d46dbb898dd86ab128cb93d8388a8647a80a3":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"59e0c40d6675923cf5e004d5":"5b4b4ffc9c66bd394abeed3f03b695b949b3b69a42198cc3bfad971174915df913b967ccf36ee1f001f54efbcd117b68":"":1:"d57e27914ecb4a764359d3c0f8d4d6" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=4, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":0:"":1:0:"72901467" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":"":0:"72901467" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=0, AAD=48, TAG=4, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":0:"":1:1:"72901467" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"5dd13092dd695b90ab835ed6343031c4cdb710d32f4d3804d72b46d921fcfa18":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"1de4bd816c8ec6bffc1e6453":"1b63d6278702abacf8b6c2faf542a808659fd5da03cdc1061a8593ea8ce9fc8ff54ffef6ebf3e15f7a832b4ae750a6ce":"":1:"72901467" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":0:"722ee47da4b77424733546c2d400c4e5":1:0:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":"722ee47da4b77424733546c2d400c4e5":0:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=15, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":0:"722ee47da4b77424733546c2d400c4e5":1:1:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"ef9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"b6ac8e4963f49207ffd6374c":"":"722ee47da4b77424733546c2d400c4e5":1:"1224dfefb72a20d49e09256908874979882eafea22adf8dbed06a2265f907b" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=12, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":0:"bcf48ddcfe9d011a1003973d68d2d78a":1:0:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":"bcf48ddcfe9d011a1003973d68d2d78a":0:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=0, TAG=12, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":0:"bcf48ddcfe9d011a1003973d68d2d78a":1:1:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"b33b0e4c5b9f7ef77cec1a29ed5844bda3853238bdf7766e7645029931f169f0":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"f226d65e8654fdf5193ed721":"":"bcf48ddcfe9d011a1003973d68d2d78a":1:"d2eb20898a301b5d8e69e9926272021393af01abb6a970047a7fc010" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=16, TAG=14, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":0:"c37aada3d4408e880d47e41df77da9b9":1:0:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":"c37aada3d4408e880d47e41df77da9b9":0:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=16, TAG=14, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":0:"c37aada3d4408e880d47e41df77da9b9":1:1:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"c6e126a65faec77ab62318e30d8a50c39a664670039a66ae5a6874201bc68f9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"0ba5193b2d3a8378d67163ce":"5844b289dc74327f9fd93f7aae1c3d39":"c37aada3d4408e880d47e41df77da9b9":1:"b5cd7563989b460a2fe187e90c41fc3179c73d0d1e3a4484909969de93b0" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=48, TAG=15, depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":0:"e5f410fe939e79b7ad33fbd3aaf5856f":1:0:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":"e5f410fe939e79b7ad33fbd3aaf5856f":0:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" PSA Multipart AEAD encrypt, AES-GCM, CAVS 14.0, KEY=32, IV=12, IN=16, AAD=48, TAG=15, (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":0:"e5f410fe939e79b7ad33fbd3aaf5856f":1:1:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" +aead_multipart_encrypt:PSA_KEY_TYPE_AES:"2e6942d537f1a98444c2f9dbdb5d8db42a503a00a17b57d516399569e044a703":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"7eb67721581ed52cfcfc2c4d":"a96cc73451502c7278b467ac85d5fc14fc1a2f51bc685645b173f0cd9af02d383095de063e6eaa50374ce9bc951e9e61":"e5f410fe939e79b7ad33fbd3aaf5856f":1:"727f5e19a5582e5782bbbe73517f0c04c492319abf12b03b380724ff1483a3" PSA Multipart AEAD decrypt, AES - GCM, 144 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES - GCM, 144 bytes #1 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES - GCM, 144 bytes #2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":0:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013" PSA Multipart AEAD decrypt, AES - GCM, 144 bytes #2 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":0:"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"fe96eab10ff48c7942025422583d0377":PSA_ALG_GCM:"97ce3f848276783599c6875de324361e":"127628b6dcbce6fc8a8ef60798eb67b2088415635119697d20bb878c24d9c6f9c29e148521cb5e0feff892c7855d4f1c0bfb32ad33420976714dce87a0bbc18e4378bd1ef35197d0ca73051148f1199010f63caf122df5f71ad8d9c71df3eb2fbe3b2529d0ba657570358d3776f687bdb9c96d5e0e9e00c4b42d5d7a268d6a08":"12495120056ca3cac70d583603a476821bac6c57c9733b81cfb83538dc9e850f8bdf46065069591c23ebcbc6d1e2523375fb7efc80c09507fa25477ed07cee54fc4eb90168b3ef988f651fc40652474a644b1b311decf899660aef2347bb081af48950f06ebf799911e37120de94c55c20e5f0a77119be06e2b6e557f872fa0f6bac793bdc2190a195122c98544ccf56":1:"194c8bbbfae4a671386b8cd38f390f46f9df6b8661b470c310921a1c858a938045834bb10380037fbf5f5e00688554537be0fcafe8270b9b59068fa056ab1268fc166c2d729243a06650a171c929c7845c85330c04568d62977eedf3b1ba9dca13bdb8f9522817c8cb99e635e37465ec1c9f6f148d51437aa9f994a62e1bd013" PSA Multipart AEAD decrypt, AES - GCM, 144 bytes, T = 4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,4):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,4):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES - GCM, 144 bytes, T = 4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,4):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,4):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847f":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES - GCM, 144 bytes, T = 15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES - GCM, 144 bytes, T = 15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,15):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":0:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, AES-GCM, 144 bytes, T=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":0:"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"00e440846db73a490573deaf3728c94f":"a3cfcb832e935eb5bc3812583b3a1b2e82920c07fda3668a35d939d8f11379bb606d39e6416b2ef336fffb15aec3f47a71e191f4ff6c56ff15913562619765b26ae094713d60bab6ab82bfc36edaaf8c7ce2cf5906554dcc5933acdb9cb42c1d24718efdc4a09256020b024b224cfe602772bd688c6c8f1041a46f7ec7d51208":"3b6de52f6e582d317f904ee768895bd4d0790912efcf27b58651d0eb7eb0b2f07222c6ffe9f7e127d98ccb132025b098a67dc0ec0083235e9f83af1ae1297df4319547cbcb745cebed36abc1f32a059a05ede6c00e0da097521ead901ad6a73be20018bda4c323faa135169e21581e5106ac20853642e9d6b17f1dd925c872814365847fe0b7b7fbed325953df344a96":1:"5431d93278c35cfcd7ffa9ce2de5c6b922edffd5055a9eaa5b54cae088db007cf2d28efaf9edd1569341889073e87c0a88462d77016744be62132fd14a243ed6e30e12cd2f7d08a8daeec161691f3b27d4996df8745d74402ee208e4055615a8cb069d495cf5146226490ac615d7b17ab39fb4fdd098e4e7ee294d34c1312826" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:0:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":"db1a74ffb5f7de26f5742e0942b1b9cb":0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":0:"db1a74ffb5f7de26f5742e0942b1b9cb":1:1:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"0e5d6e68f82f32bea3f0b69498c1a31ef6d955cd3d27a2a8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"caf72ee1e62e1001e8cfbc63":"":"db1a74ffb5f7de26f5742e0942b1b9cb":1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:0:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":"434ff68f2436f48418fd69f52158":0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=0, AAD=48, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":0:"434ff68f2436f48418fd69f52158":1:1:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e79fb7defce4f650402e6b521170686d3eb2a0b9514f3a64":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"40e0d2d836c0519e7042419b":"41c5b5d971c0723bc1b63a259fe7e06c2961de1241bc34c13965f43636e4da3da8c75ed5956abe3a42f3039af005925a":"434ff68f2436f48418fd69f52158":1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:0:"b03c2c20f758a93a8d1220232ad87098" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":0:"b03c2c20f758a93a8d1220232ad87098" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=0, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":0:"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:1:"b03c2c20f758a93a8d1220232ad87098" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e41d1f533d5b342ffe434b94b1372683bfd5d9d8cb79f9ee":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"5fe11a596dfcd3a305c1d711":"":"1847f64fff986476d1d2f758692f856da4a0ff98c0c1101694c84fd86680c9":1:"b03c2c20f758a93a8d1220232ad87098" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:0:"b22b2dcdcc18adc30d16297b84b459d8" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":0:"b22b2dcdcc18adc30d16297b84b459d8" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":0:"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:1:"b22b2dcdcc18adc30d16297b84b459d8" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"8e7da473c057a2a4669a0d22bf9b7c9913fba48930ca0c9b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"f9ff8ef80d76c50f9ca0e9ff":"f141bae18a1b54f065554fd34aa02c91c90f505c":"5deb093b6e7c766a64bb9d5170af1ff8bf130b64eebdce06a9bdb2cf1da15a":1:"b22b2dcdcc18adc30d16297b84b459d8" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:0:"7e5fd8b595ddc4753676107951d900e2" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":0:"7e5fd8b595ddc4753676107951d900e2" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=12 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":0:"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:1:"7e5fd8b595ddc4753676107951d900e2" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"01bf150add51bb11623e3bfbebd62a7ea81c5b192b8eb6de":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"dfacbc6791b785d324c646b7":"e35412a625324257bef35399a7eacca34fec2d2d24166e6bb3e94d96f5c57599ded45e2a74503f07116caa1692398a07":"77579db3c6da769e17731faac4732d7cce65d960a49f94f6b583e54a":1:"7e5fd8b595ddc4753676107951d900e2" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:0:"37245449db8f72b1ecdb420f629d3d80" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":0:"37245449db8f72b1ecdb420f629d3d80" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=16, AAD=48, TAG=8 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":0:"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:1:"37245449db8f72b1ecdb420f629d3d80" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"551266c4ed166fe1c43761927801ed50cb9c0b3864fc97df":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"e711afbeccd567f866340abb":"562d1697237ebc563941076d459727dfa094eb9ac00d30ed5836825d163dd27517c7660a01056b2d868c7fc5d0343830":"2b54cc27f6ee71882e8b1ead207d2b042d262e87eac97b58":1:"37245449db8f72b1ecdb420f629d3d80" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:0:"496909523f574b205d757659c5" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":0:"496909523f574b205d757659c5" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=0, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":0:"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:1:"496909523f574b205d757659c5" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"78fa4a2a5b5b1b1d9580ea527f2e1653e9336e15cc5462f5":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"98b774f7110e0bea624b487f":"":"a642aabed8b99e15e297ee705a40c3e2e506cb889727b327b7e044a8":1:"496909523f574b205d757659c5" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:0:"b6e056de521a27266dffbc0d96" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":0:"b6e056de521a27266dffbc0d96" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=16, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":0:"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:1:"b6e056de521a27266dffbc0d96" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"61f4c2e55d729c4657e503dfe2b604e2853675dbdeb0982a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"0c4d5548aa2d8d54964e1e63":"5affdf8886dabb14790aff3dbfcbdd80":"0d4eacc3db304f46cb7a9eba6ec105bf86d9dc0639b7cebbd5260f47":1:"b6e056de521a27266dffbc0d96" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:0:"f6d56f8c86f27d957fa63aea22" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":0:"f6d56f8c86f27d957fa63aea22" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=20, TAG=13 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":0:"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:1:"f6d56f8c86f27d957fa63aea22" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"73245c4f115a74fe71d6fefb9094c57c75f28033a3c7372b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 13 ):"536a82485999b93b0bb7ef24":"64dcad870a42eeec0730fd7a7e4154638a85d739":"29333e87bfe65d0e37da2936f695824d4e3f37fab3b8e2b868f6":1:"f6d56f8c86f27d957fa63aea22" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:0:"bd94b34511bc65ae47684805cb" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":0:"bd94b34511bc65ae47684805cb" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=24, IV=12, IN=13, AAD=48, TAG=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":0:"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:1:"bd94b34511bc65ae47684805cb" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"9002e74638e09dd1f091439518e1460cdd5905bd9e1a37ae":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"76c81a95d24be5c8bac63b50":"aa3ae4531aaac8f3eb07f748712c55a680bc8df5cf845edc66d09049500b41688b8023f5746879b45bdd586af29c4ede":"31bf37acbc53ca3fdbc9e5eaaebbb85a7f":1:"bd94b34511bc65ae47684805cb" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:0:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":"15e051a5e4a5f5da6cea92e2ebee5bac":0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":0:"15e051a5e4a5f5da6cea92e2ebee5bac":1:1:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f5a2b27c74355872eb3ef6c5feafaa740e6ae990d9d48c3bd9bb8235e589f010":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"58d2240f580a31c1d24948e9":"":"15e051a5e4a5f5da6cea92e2ebee5bac":1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:0:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":"84c8beff4b0d160ee68ac613097f51":0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=16, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":0:"84c8beff4b0d160ee68ac613097f51":1:1:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"3395a1485315c5b5e6353acb05ae9499c440a2e9f5c57494662f827235ea314c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"3b7e632571602456b49880f0":"f283f80226dacb69c8af089ec6b59e81":"84c8beff4b0d160ee68ac613097f51":1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:0:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":"8d6351f18d873242204c20144e2b83":0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":0:"8d6351f18d873242204c20144e2b83":1:1:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4dc46ca55c1c1fcb4720c274c0e675c2ac5bf93d8dd5e951ca9f6b61f884edc9":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"6473ab77dc885127422f5594":"e2cf8172ab4cf77eba45cd2c8ff939b938080a90":"8d6351f18d873242204c20144e2b83":1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:0:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":"3bfd3d99fe2063e8ef8255519fe0":0:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=0, AAD=48, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":0:"3bfd3d99fe2063e8ef8255519fe0":1:1:"" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"a7f95798434f9a0fe6fd8acd30b8bad96dbdcfacee4594f01cbf26479be7d154":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"9ef5a77b02137b46e8461d09":"5595a16fa12d4dcdba6b128480dce2d39c1211c3fb6068cde6013f6a80dfcda5eb92af8879e40ee9c177fd0e446fc8ca":"3bfd3d99fe2063e8ef8255519fe0":1:"" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:0:"7789b41cb3ee548814ca0b388c10b343" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":0:"7789b41cb3ee548814ca0b388c10b343" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=16 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":0:"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:1:"7789b41cb3ee548814ca0b388c10b343" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"4c8ebfe1444ec1b2d503c6986659af2c94fafe945f72c1e8486a5acfedb8a0f8":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 16 ):"473360e0ad24889959858995":"":"d2c78110ac7e8f107c0df0570bd7c90cc26a379b6d98ef2852ead8ce83a833a7":1:"7789b41cb3ee548814ca0b388c10b343" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:0:"4860116a6d2deb9bf794bfd6ac5bbbd6" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":"58375442ab1c0e6a8952c83d128d9fc5f45bb315":0:"4860116a6d2deb9bf794bfd6ac5bbbd6" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=0, TAG=4 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":0:"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:1:"4860116a6d2deb9bf794bfd6ac5bbbd6" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"57805f98aae1b8b64bb49756529ab8181b3ada674a90c55422e9eb26c48bcd7b":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 4 ):"9735945d8ca161777206632a":"":"58375442ab1c0e6a8952c83d128d9fc5f45bb315":1:"4860116a6d2deb9bf794bfd6ac5bbbd6" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:0:"ff426dd751190ff826e8b4a0792d746e" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":0:"ff426dd751190ff826e8b4a0792d746e" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=16, TAG=8 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":0:"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:1:"ff426dd751190ff826e8b4a0792d746e" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"f913bb823a1d0c10b0b72d56866907b893f2266f15de1abc17f93600824db55a":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 8 ):"d4fe686a14592b6ca1bd6b42":"e35d880c1c53688eb83869de9dd8a473":"35af9b502ea6b56269f896bf98affdd59c2aa418b38bc7fd":1:"ff426dd751190ff826e8b4a0792d746e" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:0:"0a0b284515694188b6b6c15bc8a09036" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":0:"0a0b284515694188b6b6c15bc8a09036" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=16, AAD=20, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":0:"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:1:"0a0b284515694188b6b6c15bc8a09036" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"74e9d9d7cd0728cea94e169af485f21f9d2447e022f16008f803dcf5c4f7cc0c":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"ecba39edc96667da726122c0":"ae9ab021f86f5b81bb2e0fcbd4b855e1501e9f82":"e5745ce0e02dbba05363b548c3ac7047eacca7e61db6f72fc9b9e5bdb2bb":1:"0a0b284515694188b6b6c15bc8a09036" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:0:"f386b28e7eb4c2fb8eb5dc66a2" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":0:"f386b28e7eb4c2fb8eb5dc66a2" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=0, TAG=14 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":0:"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:1:"f386b28e7eb4c2fb8eb5dc66a2" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"60667fce64b8c7169ddf45f335e46951248f69abc4e0f4f292d0ffe3dfd5219f":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 14 ):"1057322a39f08ef761c3c8fc":"":"501b033c841acb430c52d88fe9cb44c751f2f1641d1e801a534ac8":1:"f386b28e7eb4c2fb8eb5dc66a2" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:0:"da1c61fbfcdb73445ad4c7d889" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":0:"da1c61fbfcdb73445ad4c7d889" PSA Multipart AEAD decrypt, CAVS14.0, AES-GCM, KEY=32, IV=12, IN=13, AAD=20, TAG=15 (lengths set) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":0:"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:1:"da1c61fbfcdb73445ad4c7d889" +aead_multipart_decrypt:PSA_KEY_TYPE_AES:"e67590da399cbcdcddcc56110562ade8665b50287a8ab38e8b9ee7520531b560":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 15 ):"2c36ab6b686a66fba1805196":"823493d42f4f60b2d1433ad75eccaafd7e7c7d12":"cff6b6f03c67152f3ce1030653d9bd9a6559f5b04b48d77c2a1fc364":1:"da1c61fbfcdb73445ad4c7d889" PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:0:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":0:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (RFC7539) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691" PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"":1:0:"a0784d7a4716f3feb4f64e7f4b39bf04" +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":"":0:"a0784d7a4716f3feb4f64e7f4b39bf04" PSA Multipart AEAD encrypt: ChaCha20-Poly1305 (zero-length input) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"":1:1:"a0784d7a4716f3feb4f64e7f4b39bf04" +aead_multipart_encrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04" PSA Multipart AEAD decrypt: ChaCha20 - Poly1305 (RFC7539, good tag) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":0:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" PSA Multipart AEAD decrypt: ChaCha20 - Poly1305 (RFC7539, good tag) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":1:"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b61161ae10b594f09e26a7e902ecbd0600691":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" PSA Multipart AEAD decrypt: ChaCha20 - Poly1305 (good tag, zero - length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:0:"" +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":"a0784d7a4716f3feb4f64e7f4b39bf04":0:"" PSA Multipart AEAD decrypt: ChaCha20 - Poly1305 (good tag, zero - length input) (lengths set) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":1:"a0784d7a4716f3feb4f64e7f4b39bf04":1:1:"" +aead_multipart_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":"a0784d7a4716f3feb4f64e7f4b39bf04":1:"" PSA Multipart AEAD verify, AES - GCM, invalid signature depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 81bd246718..591c2960de 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -3788,9 +3788,7 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, int alg_arg, data_t *nonce, data_t *additional_data, - int do_test_ad_chunked, data_t *input_data, - int do_test_data_chunked, int do_set_lengths, data_t *expected_output ) { @@ -3798,92 +3796,77 @@ void aead_multipart_encrypt( int key_type_arg, data_t *key_data, size_t data_part_len = 0; set_lengths_method_t set_lengths_method = DO_NOT_SET_LENGTHS; - /* Ensure that either one part of the test or the other is done, i.e this - * test does something. */ - TEST_ASSERT( do_test_ad_chunked || do_test_data_chunked ); - - /* Temporary whilst we have algorithms that cannot support chunking */ - if( do_test_ad_chunked == 1 ) + for( ad_part_len = 1; ad_part_len <= additional_data->len; ad_part_len++ ) { - for( ad_part_len = 1; ad_part_len <= additional_data->len; - ad_part_len++ ) + mbedtls_test_set_step( ad_part_len ); + + if( do_set_lengths ) { - mbedtls_test_set_step( ad_part_len ); - - if( do_set_lengths ) - { - if( ad_part_len & 0x01 ) - set_lengths_method = SET_LENGTHS_AFTER_NONCE; - else - set_lengths_method = SET_LENGTHS_BEFORE_NONCE; - } - - /* Split ad into length(ad_part_len) parts. */ - if( !aead_multipart_internal_func( key_type_arg, key_data, - alg_arg, nonce, - additional_data, - ad_part_len, - input_data, -1, - set_lengths_method, - expected_output, - 1, 0 ) ) - break; - - /* length(0) part, length(ad_part_len) part, length(0) part... */ - mbedtls_test_set_step( 1000 + ad_part_len ); - - if( !aead_multipart_internal_func( key_type_arg, key_data, - alg_arg, nonce, - additional_data, - ad_part_len, - input_data, -1, - set_lengths_method, - expected_output, - 1, 1 ) ) - break; + if( ad_part_len & 0x01 ) + set_lengths_method = SET_LENGTHS_AFTER_NONCE; + else + set_lengths_method = SET_LENGTHS_BEFORE_NONCE; } + + /* Split ad into length(ad_part_len) parts. */ + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + set_lengths_method, + expected_output, + 1, 0 ) ) + break; + + /* length(0) part, length(ad_part_len) part, length(0) part... */ + mbedtls_test_set_step( 1000 + ad_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + set_lengths_method, + expected_output, + 1, 1 ) ) + break; } - /* Temporary whilst we have algorithms that cannot support chunking */ - if( do_test_data_chunked == 1 ) + for( data_part_len = 1; data_part_len <= input_data->len; data_part_len++ ) { - for( data_part_len = 1; data_part_len <= input_data->len; - data_part_len++ ) + /* Split data into length(data_part_len) parts. */ + mbedtls_test_set_step( 2000 + data_part_len ); + + if( do_set_lengths ) { - /* Split data into length(data_part_len) parts. */ - mbedtls_test_set_step( 2000 + data_part_len ); - - if( do_set_lengths ) - { - if( data_part_len & 0x01 ) - set_lengths_method = SET_LENGTHS_AFTER_NONCE; - else - set_lengths_method = SET_LENGTHS_BEFORE_NONCE; - } - - if( !aead_multipart_internal_func( key_type_arg, key_data, - alg_arg, nonce, - additional_data, -1, - input_data, data_part_len, - set_lengths_method, - expected_output, - 1, 0 ) ) - break; - - /* length(0) part, length(data_part_len) part, length(0) part... */ - mbedtls_test_set_step( 3000 + data_part_len ); - - if( !aead_multipart_internal_func( key_type_arg, key_data, - alg_arg, nonce, - additional_data, -1, - input_data, data_part_len, - set_lengths_method, - expected_output, - 1, 1 ) ) - break; + if( data_part_len & 0x01 ) + set_lengths_method = SET_LENGTHS_AFTER_NONCE; + else + set_lengths_method = SET_LENGTHS_BEFORE_NONCE; } - } + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + set_lengths_method, + expected_output, + 1, 0 ) ) + break; + + /* length(0) part, length(data_part_len) part, length(0) part... */ + mbedtls_test_set_step( 3000 + data_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + set_lengths_method, + expected_output, + 1, 1 ) ) + break; + } /* Goto is required to silence warnings about unused labels, as we * don't actually do any test assertions in this function. */ @@ -3896,9 +3879,7 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, int alg_arg, data_t *nonce, data_t *additional_data, - int do_test_ad_chunked, data_t *input_data, - int do_test_data_chunked, int do_set_lengths, data_t *expected_output ) { @@ -3906,90 +3887,76 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data, size_t data_part_len = 0; set_lengths_method_t set_lengths_method = DO_NOT_SET_LENGTHS; - /* Ensure that either one part of the test or the other is done, i.e this - * test does something. */ - TEST_ASSERT( do_test_ad_chunked || do_test_data_chunked ); - - /* Temporary whilst we have algorithms that cannot support chunking */ - if( do_test_ad_chunked == 1 ) + for( ad_part_len = 1; ad_part_len <= additional_data->len; ad_part_len++ ) { - for( ad_part_len = 1; ad_part_len <= additional_data->len; - ad_part_len++ ) + /* Split ad into length(ad_part_len) parts. */ + mbedtls_test_set_step( ad_part_len ); + + if( do_set_lengths ) { - /* Split ad into length(ad_part_len) parts. */ - mbedtls_test_set_step( ad_part_len ); - - if( do_set_lengths ) - { - if( ad_part_len & 0x01 ) - set_lengths_method = SET_LENGTHS_AFTER_NONCE; - else - set_lengths_method = SET_LENGTHS_BEFORE_NONCE; - } - - if( !aead_multipart_internal_func( key_type_arg, key_data, - alg_arg, nonce, - additional_data, - ad_part_len, - input_data, -1, - set_lengths_method, - expected_output, - 0, 0 ) ) - break; - - /* length(0) part, length(ad_part_len) part, length(0) part... */ - mbedtls_test_set_step( 1000 + ad_part_len ); - - if( !aead_multipart_internal_func( key_type_arg, key_data, - alg_arg, nonce, - additional_data, - ad_part_len, - input_data, -1, - set_lengths_method, - expected_output, - 0, 1 ) ) - break; + if( ad_part_len & 0x01 ) + set_lengths_method = SET_LENGTHS_AFTER_NONCE; + else + set_lengths_method = SET_LENGTHS_BEFORE_NONCE; } + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + set_lengths_method, + expected_output, + 0, 0 ) ) + break; + + /* length(0) part, length(ad_part_len) part, length(0) part... */ + mbedtls_test_set_step( 1000 + ad_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, + ad_part_len, + input_data, -1, + set_lengths_method, + expected_output, + 0, 1 ) ) + break; } - /* Temporary whilst we have algorithms that cannot support chunking */ - if( do_test_data_chunked == 1 ) + for( data_part_len = 1; data_part_len <= input_data->len; data_part_len++ ) { - for( data_part_len = 1; data_part_len <= input_data->len; - data_part_len++ ) + /* Split data into length(data_part_len) parts. */ + mbedtls_test_set_step( 2000 + data_part_len ); + + if( do_set_lengths ) { - /* Split data into length(data_part_len) parts. */ - mbedtls_test_set_step( 2000 + data_part_len ); - - if( do_set_lengths ) - { - if( data_part_len & 0x01 ) - set_lengths_method = SET_LENGTHS_AFTER_NONCE; - else - set_lengths_method = SET_LENGTHS_BEFORE_NONCE; - } - - if( !aead_multipart_internal_func( key_type_arg, key_data, - alg_arg, nonce, - additional_data, -1, - input_data, data_part_len, - set_lengths_method, - expected_output, - 0, 0 ) ) - break; - - /* length(0) part, length(data_part_len) part, length(0) part... */ - mbedtls_test_set_step( 3000 + data_part_len ); - - if( !aead_multipart_internal_func( key_type_arg, key_data, - alg_arg, nonce, - additional_data, -1, - input_data, data_part_len, - set_lengths_method, - expected_output, - 0, 1 ) ) - break; + if( data_part_len & 0x01 ) + set_lengths_method = SET_LENGTHS_AFTER_NONCE; + else + set_lengths_method = SET_LENGTHS_BEFORE_NONCE; } + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + set_lengths_method, + expected_output, + 0, 0 ) ) + break; + + /* length(0) part, length(data_part_len) part, length(0) part... */ + mbedtls_test_set_step( 3000 + data_part_len ); + + if( !aead_multipart_internal_func( key_type_arg, key_data, + alg_arg, nonce, + additional_data, -1, + input_data, data_part_len, + set_lengths_method, + expected_output, + 0, 1 ) ) + break; } /* Goto is required to silence warnings about unused labels, as we From 7500a0e1eaf68e6c70a95304732a75b737f710bf Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Fri, 24 Sep 2021 15:18:44 +0100 Subject: [PATCH 562/966] Combine changelog entries for muladdc assembly fix Combine the changelog entries for the memory constraints fix on aarch64 and amd64, since these are essentially fixing the same issue. Signed-off-by: David Horstmann --- ChangeLog.d/muladdc-aarch64-memory.txt | 4 ---- ChangeLog.d/muladdc-amd64-memory.txt | 4 ---- ChangeLog.d/muladdc-memory.txt | 5 +++++ 3 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 ChangeLog.d/muladdc-aarch64-memory.txt delete mode 100644 ChangeLog.d/muladdc-amd64-memory.txt create mode 100644 ChangeLog.d/muladdc-memory.txt diff --git a/ChangeLog.d/muladdc-aarch64-memory.txt b/ChangeLog.d/muladdc-aarch64-memory.txt deleted file mode 100644 index 70addd253c..0000000000 --- a/ChangeLog.d/muladdc-aarch64-memory.txt +++ /dev/null @@ -1,4 +0,0 @@ -Bugfix - * Add missing memory constraints in aarch64 inline assembly for - bignum multiplication. - Fixes #4962. diff --git a/ChangeLog.d/muladdc-amd64-memory.txt b/ChangeLog.d/muladdc-amd64-memory.txt deleted file mode 100644 index b834331671..0000000000 --- a/ChangeLog.d/muladdc-amd64-memory.txt +++ /dev/null @@ -1,4 +0,0 @@ -Bugfix - * Fix missing constraints on x86_64 assembly code for bignum multiplication - that broke some bignum operations with (at least) Clang 12. - Fixes #4116, #4786, #4917. diff --git a/ChangeLog.d/muladdc-memory.txt b/ChangeLog.d/muladdc-memory.txt new file mode 100644 index 0000000000..218be5a605 --- /dev/null +++ b/ChangeLog.d/muladdc-memory.txt @@ -0,0 +1,5 @@ +Bugfix + * Fix missing constraints on x86_64 and aarch64 assembly code + for bignum multiplication that broke some bignum operations with + (at least) Clang 12. + Fixes #4116, #4786, #4917, #4962. From c7e7fe5c05880ebe2293671d42e7198bdfeadb47 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 27 Sep 2021 09:23:40 +0100 Subject: [PATCH 563/966] Add missing MBEDTLS_PRIVATE Signed-off-by: Paul Elliott --- include/psa/crypto_struct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index 4b1195d8bb..26894156c5 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -157,7 +157,7 @@ struct psa_aead_operation_s * ID values are auto-generated in psa_crypto_driver_wrappers.h * ID value zero means the context is not valid or not assigned to * any driver (i.e. none of the driver contexts are active). */ - unsigned int id; + unsigned int MBEDTLS_PRIVATE(id); psa_algorithm_t MBEDTLS_PRIVATE(alg); psa_key_type_t MBEDTLS_PRIVATE(key_type); From 687101b2e60536a006a925542239ab692e3855ae Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 14 Sep 2021 16:03:56 +0800 Subject: [PATCH 564/966] tls13: add dummy state machine handler Signed-off-by: Jerry Yu --- include/mbedtls/debug.h | 7 ++ include/mbedtls/ssl.h | 1 + library/ssl_tls13_client.c | 155 ++++++++++++++++++++++++++++++++++++- library/ssl_tls13_server.c | 2 + 4 files changed, 162 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/debug.h b/include/mbedtls/debug.h index 0aed59619c..1f82ce6640 100644 --- a/include/mbedtls/debug.h +++ b/include/mbedtls/debug.h @@ -108,6 +108,13 @@ #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) #endif +/* MSVC support __func__ from visual studio 2015( 1900 ) + Use MSVC predefine macro to avoid name check fail. + */ +#if (defined(_MSC_VER) && ( _MSC_VER <= 1900 )) +#define __func__ __FUNCTION__ +#endif + /** * \def MBEDTLS_PRINTF_SIZET * diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 725b156d5d..0abcb75fc5 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -623,6 +623,7 @@ typedef enum MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT, #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) MBEDTLS_SSL_ENCRYPTED_EXTENSIONS, + MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY, #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ } mbedtls_ssl_states; diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 13e932c453..4ccb5b33b0 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -701,6 +701,7 @@ static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) /* * Write ClientHello handshake message. + * Handler for MBEDTLS_SSL_CLIENT_HELLO */ static int ssl_tls13_write_client_hello( mbedtls_ssl_context *ssl ) { @@ -736,6 +737,116 @@ cleanup: return ret; } +/* + * Handler for MBEDTLS_SSL_SERVER_HELLO + */ +static int ssl_tls1_3_read_server_hello( mbedtls_ssl_context *ssl ) +{ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_ENCRYPTED_EXTENSIONS + */ +static int ssl_tls1_3_read_encrypted_extensions( mbedtls_ssl_context *ssl ) +{ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_REQUEST ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_CERTIFICATE_REQUEST + */ +static int ssl_tls1_3_read_certificate_request( mbedtls_ssl_context *ssl ) +{ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_CERTIFICATE ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_SERVER_CERTIFICATE + */ +static int ssl_tls1_3_read_server_certificate( mbedtls_ssl_context *ssl ) +{ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_VERIFY ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_CERTIFICATE_VERIFY + */ +static int ssl_tls1_3_read_certificate_verify( mbedtls_ssl_context *ssl ) +{ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_FINISHED ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_SERVER_FINISHED + */ +static int ssl_tls1_3_read_server_finished( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_CLIENT_CERTIFICATE + */ +static int ssl_tls1_3_write_client_certificate( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY + */ +static int ssl_tls1_3_write_client_certificate_verify( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_FINISHED ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_CLIENT_FINISHED + */ +static int ssl_tls1_3_write_client_finished( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_FLUSH_BUFFERS + */ +static int ssl_tls1_3_flush_buffers( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_HANDSHAKE_WRAPUP ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + return( 0 ); +} + +/* + * Handler for MBEDTLS_SSL_HANDSHAKE_WRAPUP + */ +static int ssl_tls1_3_handshake_wrapup( mbedtls_ssl_context *ssl ) +{ + ((void) ssl); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) { int ret = 0; @@ -754,9 +865,47 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) break; case MBEDTLS_SSL_SERVER_HELLO: - // Stop here : we haven't finished whole flow - ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); + ret = ssl_tls1_3_read_server_hello( ssl ); + break; + + case MBEDTLS_SSL_ENCRYPTED_EXTENSIONS: + ret = ssl_tls1_3_read_encrypted_extensions( ssl ); + break; + + case MBEDTLS_SSL_CERTIFICATE_REQUEST: + ret = ssl_tls1_3_read_certificate_request( ssl ); + break; + + case MBEDTLS_SSL_SERVER_CERTIFICATE: + ret = ssl_tls1_3_read_server_certificate( ssl ); + break; + + case MBEDTLS_SSL_CERTIFICATE_VERIFY: + ret = ssl_tls1_3_read_certificate_verify( ssl ); + break; + + case MBEDTLS_SSL_SERVER_FINISHED: + ret = ssl_tls1_3_read_server_finished( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_CERTIFICATE: + ret = ssl_tls1_3_write_client_certificate( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY: + ret = ssl_tls1_3_write_client_certificate_verify( ssl ); + break; + + case MBEDTLS_SSL_CLIENT_FINISHED: + ret = ssl_tls1_3_write_client_finished( ssl ); + break; + + case MBEDTLS_SSL_FLUSH_BUFFERS: + ret = ssl_tls1_3_flush_buffers( ssl ); + break; + + case MBEDTLS_SSL_HANDSHAKE_WRAPUP: + ret = ssl_tls1_3_handshake_wrapup( ssl ); break; default: diff --git a/library/ssl_tls13_server.c b/library/ssl_tls13_server.c index 0dcd7ed602..437e836e84 100644 --- a/library/ssl_tls13_server.c +++ b/library/ssl_tls13_server.c @@ -23,6 +23,8 @@ #if defined(MBEDTLS_SSL_SRV_C) +#include "mbedtls/debug.h" + #include "ssl_misc.h" int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl ) From 3523a3bee77061dcb1a75081b2b42d9978162881 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 14 Sep 2021 16:29:49 +0800 Subject: [PATCH 565/966] Improve dispatch tests Test base on return value is not good enough. Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 39499d441c..41e714ec22 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8660,11 +8660,11 @@ run_test "TLS1.3: Not supported version check: tls1_2 and tls1_3" \ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS1.3: handshake dispatch test: tls1_3 only" \ - "$P_SRV min_version=tls1_3 max_version=tls1_3" \ - "$P_CLI min_version=tls1_3 max_version=tls1_3" \ + "$P_SRV debug_level=2 min_version=tls1_3 max_version=tls1_3" \ + "$P_CLI debug_level=2 min_version=tls1_3 max_version=tls1_3" \ 1 \ - -s "SSL - The requested feature is not available" \ - -c "SSL - The requested feature is not available" + -s "tls13 server state: MBEDTLS_SSL_HELLO_REQUEST" \ + -c "tls13 client state: MBEDTLS_SSL_HELLO_REQUEST" requires_openssl_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL From 6c983524a8e367289d554a093dbd8bcfb2fe54cc Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 24 Sep 2021 12:45:36 +0800 Subject: [PATCH 566/966] Move msvc compatible fix to `common.h` Signed-off-by: Jerry Yu --- include/mbedtls/debug.h | 7 ------- library/common.h | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/mbedtls/debug.h b/include/mbedtls/debug.h index 1f82ce6640..0aed59619c 100644 --- a/include/mbedtls/debug.h +++ b/include/mbedtls/debug.h @@ -108,13 +108,6 @@ #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) #endif -/* MSVC support __func__ from visual studio 2015( 1900 ) - Use MSVC predefine macro to avoid name check fail. - */ -#if (defined(_MSC_VER) && ( _MSC_VER <= 1900 )) -#define __func__ __FUNCTION__ -#endif - /** * \def MBEDTLS_PRINTF_SIZET * diff --git a/library/common.h b/library/common.h index 780ce378de..ba8237acf6 100644 --- a/library/common.h +++ b/library/common.h @@ -318,4 +318,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c } #endif +/* Fix MSVC C99 compatible issue + * MSVC support __func__ from visual studio 2015( 1900 ) + * Use MSVC predefine macro to avoid name check fail. + */ +#if (defined(_MSC_VER) && ( _MSC_VER <= 1900 )) +#define __func__ __FUNCTION__ +#endif + #endif /* MBEDTLS_LIBRARY_COMMON_H */ From 435756ffc0eb5a7dd747a16e8bff913a5094c957 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 24 Sep 2021 13:44:29 +0800 Subject: [PATCH 567/966] Keep consistent order in dummy functions Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 4ccb5b33b0..2eb9a73905 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -792,8 +792,8 @@ static int ssl_tls1_3_read_certificate_verify( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_read_server_finished( mbedtls_ssl_context *ssl ) { - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE ); return( 0 ); } From 6e81b27003e24cb15d45b010f1b0713c9beb3de9 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 27 Sep 2021 11:16:17 +0800 Subject: [PATCH 568/966] Add client state number check It is temporary check. If any change on `mbedtls_ssl_states`, please double check those tests Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 2 +- library/ssl_tls13_server.c | 3 ++- tests/ssl-opt.sh | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 2eb9a73905..aa6c0854e0 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -851,7 +851,7 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) { int ret = 0; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "client state: %d", ssl->state ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "tls1_3 client state: %d", ssl->state ) ); switch( ssl->state ) { diff --git a/library/ssl_tls13_server.c b/library/ssl_tls13_server.c index 437e836e84..5238f044eb 100644 --- a/library/ssl_tls13_server.c +++ b/library/ssl_tls13_server.c @@ -29,7 +29,8 @@ int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl ) { - ((void) ssl); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "tls1_3 server state: %d", ssl->state ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); } diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 41e714ec22..66c648573b 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8663,26 +8663,50 @@ run_test "TLS1.3: handshake dispatch test: tls1_3 only" \ "$P_SRV debug_level=2 min_version=tls1_3 max_version=tls1_3" \ "$P_CLI debug_level=2 min_version=tls1_3 max_version=tls1_3" \ 1 \ - -s "tls13 server state: MBEDTLS_SSL_HELLO_REQUEST" \ - -c "tls13 client state: MBEDTLS_SSL_HELLO_REQUEST" + -s "tls1_3 server state: 0" \ + -c "tls1_3 client state: 0" requires_openssl_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS1.3: Test client hello msg work - openssl" \ "$O_NEXT_SRV -tls1_3 -msg" \ - "$P_CLI min_version=tls1_3 max_version=tls1_3" \ + "$P_CLI debug_level=2 min_version=tls1_3 max_version=tls1_3" \ 1 \ -c "SSL - The requested feature is not available" \ - -s "ServerHello" + -s "ServerHello" \ + -c "tls1_3 client state: 0" \ + -c "tls1_3 client state: 2" \ + -c "tls1_3 client state: 19" \ + -c "tls1_3 client state: 5" \ + -c "tls1_3 client state: 3" \ + -c "tls1_3 client state: 9" \ + -c "tls1_3 client state: 13" \ + -c "tls1_3 client state: 7" \ + -c "tls1_3 client state: 20" \ + -c "tls1_3 client state: 11" \ + -c "tls1_3 client state: 14" \ + -c "tls1_3 client state: 15" requires_gnutls_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS1.3: Test client hello msg work - gnutls" \ "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3 --debug=4" \ - "$P_CLI min_version=tls1_3 max_version=tls1_3" \ + "$P_CLI debug_level=2 min_version=tls1_3 max_version=tls1_3" \ 1 \ -c "SSL - The requested feature is not available" \ - -s "SERVER HELLO was queued" + -s "SERVER HELLO was queued" \ + -c "tls1_3 client state: 0" \ + -c "tls1_3 client state: 2" \ + -c "tls1_3 client state: 19" \ + -c "tls1_3 client state: 5" \ + -c "tls1_3 client state: 3" \ + -c "tls1_3 client state: 9" \ + -c "tls1_3 client state: 13" \ + -c "tls1_3 client state: 7" \ + -c "tls1_3 client state: 20" \ + -c "tls1_3 client state: 11" \ + -c "tls1_3 client state: 14" \ + -c "tls1_3 client state: 15" # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From 860b4ee42ec080deabe4b1e8f699af2a17183601 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 27 Sep 2021 13:16:13 +0800 Subject: [PATCH 569/966] Rename `*_read_*` to `*_process_*` Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index aa6c0854e0..ab48ec03b3 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -740,7 +740,7 @@ cleanup: /* * Handler for MBEDTLS_SSL_SERVER_HELLO */ -static int ssl_tls1_3_read_server_hello( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_process_server_hello( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); @@ -750,7 +750,7 @@ static int ssl_tls1_3_read_server_hello( mbedtls_ssl_context *ssl ) /* * Handler for MBEDTLS_SSL_ENCRYPTED_EXTENSIONS */ -static int ssl_tls1_3_read_encrypted_extensions( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_REQUEST ); @@ -760,7 +760,7 @@ static int ssl_tls1_3_read_encrypted_extensions( mbedtls_ssl_context *ssl ) /* * Handler for MBEDTLS_SSL_CERTIFICATE_REQUEST */ -static int ssl_tls1_3_read_certificate_request( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_process_certificate_request( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_CERTIFICATE ); @@ -770,7 +770,7 @@ static int ssl_tls1_3_read_certificate_request( mbedtls_ssl_context *ssl ) /* * Handler for MBEDTLS_SSL_SERVER_CERTIFICATE */ -static int ssl_tls1_3_read_server_certificate( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_process_server_certificate( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_VERIFY ); @@ -780,7 +780,7 @@ static int ssl_tls1_3_read_server_certificate( mbedtls_ssl_context *ssl ) /* * Handler for MBEDTLS_SSL_CERTIFICATE_VERIFY */ -static int ssl_tls1_3_read_certificate_verify( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_process_certificate_verify( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_FINISHED ); @@ -790,7 +790,7 @@ static int ssl_tls1_3_read_certificate_verify( mbedtls_ssl_context *ssl ) /* * Handler for MBEDTLS_SSL_SERVER_FINISHED */ -static int ssl_tls1_3_read_server_finished( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE ); @@ -865,27 +865,27 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) break; case MBEDTLS_SSL_SERVER_HELLO: - ret = ssl_tls1_3_read_server_hello( ssl ); + ret = ssl_tls1_3_process_server_hello( ssl ); break; case MBEDTLS_SSL_ENCRYPTED_EXTENSIONS: - ret = ssl_tls1_3_read_encrypted_extensions( ssl ); + ret = ssl_tls1_3_process_encrypted_extensions( ssl ); break; case MBEDTLS_SSL_CERTIFICATE_REQUEST: - ret = ssl_tls1_3_read_certificate_request( ssl ); + ret = ssl_tls1_3_process_certificate_request( ssl ); break; case MBEDTLS_SSL_SERVER_CERTIFICATE: - ret = ssl_tls1_3_read_server_certificate( ssl ); + ret = ssl_tls1_3_process_server_certificate( ssl ); break; case MBEDTLS_SSL_CERTIFICATE_VERIFY: - ret = ssl_tls1_3_read_certificate_verify( ssl ); + ret = ssl_tls1_3_process_certificate_verify( ssl ); break; case MBEDTLS_SSL_SERVER_FINISHED: - ret = ssl_tls1_3_read_server_finished( ssl ); + ret = ssl_tls1_3_process_server_finished( ssl ); break; case MBEDTLS_SSL_CLIENT_CERTIFICATE: From e86cd6575472dedd67c45938c41dcc50404e78ef Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 27 Sep 2021 14:38:20 +0800 Subject: [PATCH 570/966] fix unused-variable fail without MBEDTLS_DEBUG_C Signed-off-by: Jerry Yu --- library/ssl_tls13_server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/library/ssl_tls13_server.c b/library/ssl_tls13_server.c index 5238f044eb..86f44cb65f 100644 --- a/library/ssl_tls13_server.c +++ b/library/ssl_tls13_server.c @@ -29,6 +29,7 @@ int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl ) { + ((void) ssl); MBEDTLS_SSL_DEBUG_MSG( 2, ( "tls1_3 server state: %d", ssl->state ) ); return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); From e7047819eef8d27285acfdbbd66d2855ab4e18f5 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 13 Sep 2021 19:26:39 +0800 Subject: [PATCH 571/966] add pend fatal alert Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 25 +++++++++++++++++++++++++ library/ssl_misc.h | 5 +++++ library/ssl_msg.c | 22 ++++++++++++++++++++++ library/ssl_tls.c | 16 ++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 725b156d5d..58cc113b7f 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1526,6 +1526,23 @@ struct mbedtls_ssl_context int MBEDTLS_PRIVATE(keep_current_message); /*!< drop or reuse current message on next call to record layer? */ + /* The following three variables indicate if and, if yes, + * what kind of alert or warning is pending to be sent. + * They should not be set manually but through the macro + * MBEDTLS_SSL_PEND_FATAL_ALERT( type, user_return_value ) + * defined below. + */ + unsigned char MBEDTLS_PRIVATE(send_alert); /*!< Determines if either a fatal error + or a warning should be sent. Values: + - \c 0 if no alert is to be sent. + - #MBEDTLS_SSL_ALERT_LEVEL_FATAL + if a fatal alert is to be sent + - #MBEDTLS_SSL_ALERT_LEVEL_WARNING + if a non-fatal alert is to be sent. */ + unsigned char MBEDTLS_PRIVATE(alert_type); /*!< Type of alert if send_alert != 0 */ + int MBEDTLS_PRIVATE(alert_reason); /*!< The error code to be returned to the + * user once the fatal alert has been sent. */ + #if defined(MBEDTLS_SSL_PROTO_DTLS) uint8_t MBEDTLS_PRIVATE(disable_datagram_packing); /*!< Disable packing multiple records * within a single datagram. */ @@ -1624,6 +1641,14 @@ struct mbedtls_ssl_context #endif }; +#define MBEDTLS_SSL_PEND_FATAL_ALERT( type, user_return_value ) \ + do \ + { \ + ssl->send_alert = 1; \ + ssl->alert_reason = (user_return_value); \ + ssl->alert_type = (type); \ + } while( 0 ) + /** * \brief Return the name of the ciphersuite associated with the * given ID diff --git a/library/ssl_misc.h b/library/ssl_misc.h index c338d79eec..8b26983556 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1342,6 +1342,11 @@ void mbedtls_ssl_update_in_pointers( mbedtls_ssl_context *ssl ); int mbedtls_ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ); +/* + * Send pending fatal alerts or warnings. + */ +int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl ); + #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) void mbedtls_ssl_dtls_replay_reset( mbedtls_ssl_context *ssl ); #endif diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 2fe801a283..3144d9818c 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -5639,4 +5639,26 @@ void mbedtls_ssl_read_version( int *major, int *minor, int transport, } } +/* + * Send pending fatal alerts or warnings. + */ +int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl ) +{ + int ret; + + /* Send alert if requested */ + if( ssl->send_alert != 0 ) + { + ret = mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_FATAL, + ssl->alert_type ); + if( ret != 0 ) + return( ret ); + } + + ssl->send_alert = 0; + ssl->alert_type = 0; + return( 0 ); +} + #endif /* MBEDTLS_SSL_TLS_C */ diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 360419240f..7bb5f9fd7e 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5170,6 +5170,10 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) if( ret != 0 ) return( ret ); + ret = mbedtls_ssl_handle_pending_alert( ssl ); + if( ret != 0 ) + goto cleanup; + #if defined(MBEDTLS_SSL_CLI_C) if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { @@ -5199,6 +5203,18 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) } #endif + if( ret != 0 ) + { + int alert_ret; + alert_ret = mbedtls_ssl_handle_pending_alert( ssl ); + if( alert_ret != 0 ) + { + ret = alert_ret; + goto cleanup; + } + } + +cleanup: return( ret ); } From 33cedca8aa9d6fb8dc0c0107de38911f3cfd21c8 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 14 Sep 2021 19:55:49 +0800 Subject: [PATCH 572/966] fix comments issue Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 58cc113b7f..18142a8617 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1532,16 +1532,15 @@ struct mbedtls_ssl_context * MBEDTLS_SSL_PEND_FATAL_ALERT( type, user_return_value ) * defined below. */ - unsigned char MBEDTLS_PRIVATE(send_alert); /*!< Determines if either a fatal error - or a warning should be sent. Values: - - \c 0 if no alert is to be sent. - - #MBEDTLS_SSL_ALERT_LEVEL_FATAL - if a fatal alert is to be sent - - #MBEDTLS_SSL_ALERT_LEVEL_WARNING - if a non-fatal alert is to be sent. */ - unsigned char MBEDTLS_PRIVATE(alert_type); /*!< Type of alert if send_alert != 0 */ - int MBEDTLS_PRIVATE(alert_reason); /*!< The error code to be returned to the - * user once the fatal alert has been sent. */ + unsigned char MBEDTLS_PRIVATE(send_alert); /*!< Determines if a fatal alert + should be sent. Values: + - \c 0 , no alert is to be sent. + - \c 1 , alert is to be sent. */ + unsigned char MBEDTLS_PRIVATE(alert_type); /*!< Type of alert if send_alert + != 0 */ + int MBEDTLS_PRIVATE(alert_reason); /*!< The error code to be returned + to the user once the fatal alert + has been sent. */ #if defined(MBEDTLS_SSL_PROTO_DTLS) uint8_t MBEDTLS_PRIVATE(disable_datagram_packing); /*!< Disable packing multiple records From 394ece6cdd71d06e2186024769170588bb342ac8 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 14 Sep 2021 22:17:21 +0800 Subject: [PATCH 573/966] Add function for set pending alert flag Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 13 +------------ library/ssl_misc.h | 14 +++++++++++++- library/ssl_msg.c | 18 +++++++++++++++--- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 18142a8617..822205ee48 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1527,10 +1527,7 @@ struct mbedtls_ssl_context on next call to record layer? */ /* The following three variables indicate if and, if yes, - * what kind of alert or warning is pending to be sent. - * They should not be set manually but through the macro - * MBEDTLS_SSL_PEND_FATAL_ALERT( type, user_return_value ) - * defined below. + * what kind of alert is pending to be sent. */ unsigned char MBEDTLS_PRIVATE(send_alert); /*!< Determines if a fatal alert should be sent. Values: @@ -1640,14 +1637,6 @@ struct mbedtls_ssl_context #endif }; -#define MBEDTLS_SSL_PEND_FATAL_ALERT( type, user_return_value ) \ - do \ - { \ - ssl->send_alert = 1; \ - ssl->alert_reason = (user_return_value); \ - ssl->alert_type = (type); \ - } while( 0 ) - /** * \brief Return the name of the ciphersuite associated with the * given ID diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 8b26983556..5be5b03ac2 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1343,10 +1343,22 @@ void mbedtls_ssl_update_in_pointers( mbedtls_ssl_context *ssl ); int mbedtls_ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ); /* - * Send pending fatal alerts or warnings. + * Send pending alert */ int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl ); +/* + * Set pending fatal alert flag. + */ +void mbedtls_ssl_pend_fatal_alert( mbedtls_ssl_context *ssl, + unsigned char alert_type, + int alert_reason ); + +/* Alias of mbedtls_ssl_pend_fatal_alert */ +#define MBEDTLS_SSL_PEND_FATAL_ALERT( type, user_return_value ) \ + mbedtls_ssl_pend_fatal_alert( ssl, type, user_return_value ) + + #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) void mbedtls_ssl_dtls_replay_reset( mbedtls_ssl_context *ssl ); #endif diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 3144d9818c..9230bcd82a 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -5649,16 +5649,28 @@ int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl ) /* Send alert if requested */ if( ssl->send_alert != 0 ) { + /* Clear send_alert to avoid infinite loop */ + ssl->send_alert = 0; + ret = mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, ssl->alert_type ); if( ret != 0 ) return( ret ); } - - ssl->send_alert = 0; - ssl->alert_type = 0; return( 0 ); } +/* + * Set pending fatal alert flag. + */ +void mbedtls_ssl_pend_fatal_alert( mbedtls_ssl_context *ssl, + unsigned char alert_type, + int alert_reason ) +{ + ssl->send_alert = 1; + ssl->alert_type = alert_type; + ssl->alert_reason = alert_reason; +} + #endif /* MBEDTLS_SSL_TLS_C */ From bbd5a3fded73092349306d084b75de0b6a9b2c1f Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sat, 18 Sep 2021 20:50:22 +0800 Subject: [PATCH 574/966] fix pending_alert issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 1 - library/ssl_msg.c | 35 ++++++++++++++++++++++++----------- library/ssl_tls.c | 5 +++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 5be5b03ac2..a1128eda00 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1358,7 +1358,6 @@ void mbedtls_ssl_pend_fatal_alert( mbedtls_ssl_context *ssl, #define MBEDTLS_SSL_PEND_FATAL_ALERT( type, user_return_value ) \ mbedtls_ssl_pend_fatal_alert( ssl, type, user_return_value ) - #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) void mbedtls_ssl_dtls_replay_reset( mbedtls_ssl_context *ssl ); #endif diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 9230bcd82a..1ea5e89909 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -5641,24 +5641,37 @@ void mbedtls_ssl_read_version( int *major, int *minor, int transport, /* * Send pending fatal alerts or warnings. + * 0, No alert message. + * !0, error from send_alert_message or handshake_step return */ int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl ) { int ret; - /* Send alert if requested */ - if( ssl->send_alert != 0 ) - { - /* Clear send_alert to avoid infinite loop */ - ssl->send_alert = 0; + /* No pending alert, return success*/ + if( ssl->send_alert == 0 ) + return( 0 ); - ret = mbedtls_ssl_send_alert_message( ssl, - MBEDTLS_SSL_ALERT_LEVEL_FATAL, - ssl->alert_type ); - if( ret != 0 ) - return( ret ); + ret = mbedtls_ssl_send_alert_message( ssl, + MBEDTLS_SSL_ALERT_LEVEL_FATAL, + ssl->alert_type ); + + /* Success or send message fail, clear send_alert flag + * except WANT_WRITE. WANT_WRITE means need re-send message. + */ + if( ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + { + ssl->send_alert = 0; } - return( 0 ); + + if( ret != 0 ) + { + /* some errors on send alert message */ + return( ret ); + } + + /* Assume alert_reason == handshake_step return */ + return( ssl->alert_reason ); } /* diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 7bb5f9fd7e..c11810df84 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5205,10 +5205,15 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) if( ret != 0 ) { + /* handshake_step return error. And it is same + * with alert_reason. + */ int alert_ret; alert_ret = mbedtls_ssl_handle_pending_alert( ssl ); if( alert_ret != 0 ) { + /* If success send, ret == alert_ret. + */ ret = alert_ret; goto cleanup; } From 3bf1f97a0e471dd7ab427aaeca11b2a924b4c7f3 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 22 Sep 2021 21:37:18 +0800 Subject: [PATCH 575/966] fix various issue on pending send alert Signed-off-by: Jerry Yu --- library/ssl_msg.c | 15 ++++++--------- library/ssl_tls.c | 8 ++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 1ea5e89909..3bf4a603db 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -5640,9 +5640,10 @@ void mbedtls_ssl_read_version( int *major, int *minor, int transport, } /* - * Send pending fatal alerts or warnings. - * 0, No alert message. - * !0, error from send_alert_message or handshake_step return + * Send pending fatal alert. + * 0, No alert message. + * !0, if mbedtls_ssl_send_alert_message() returned in error, the error code it + * returned, ssl->alert_reason otherwise. */ int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl ) { @@ -5656,8 +5657,8 @@ int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_ALERT_LEVEL_FATAL, ssl->alert_type ); - /* Success or send message fail, clear send_alert flag - * except WANT_WRITE. WANT_WRITE means need re-send message. + /* If mbedtls_ssl_send_alert_message() returned with MBEDTLS_ERR_SSL_WANT_WRITE, + * do not clear the alert to be able to send it later. */ if( ret != MBEDTLS_ERR_SSL_WANT_WRITE ) { @@ -5665,12 +5666,8 @@ int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl ) } if( ret != 0 ) - { - /* some errors on send alert message */ return( ret ); - } - /* Assume alert_reason == handshake_step return */ return( ssl->alert_reason ); } diff --git a/library/ssl_tls.c b/library/ssl_tls.c index c11810df84..21a058dd57 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5208,13 +5208,9 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) /* handshake_step return error. And it is same * with alert_reason. */ - int alert_ret; - alert_ret = mbedtls_ssl_handle_pending_alert( ssl ); - if( alert_ret != 0 ) + if( ssl->send_alert ) { - /* If success send, ret == alert_ret. - */ - ret = alert_ret; + ret = mbedtls_ssl_handle_pending_alert( ssl ); goto cleanup; } } From 24c0ec31f99500c8ce557b693f0eb988e5aa5ee8 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 14:21:07 +0800 Subject: [PATCH 576/966] tls13: add get_handshake_transcript Signed-off-by: Jerry Yu --- library/ssl_misc.h | 7 +++ library/ssl_tls.c | 143 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index c338d79eec..604976f5fc 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1493,6 +1493,13 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, size_t total_hs_len ); +/* Get handshake transcript */ +int mbedtls_ssl_tls13_get_handshake_transcript( mbedtls_ssl_context *ssl, + const mbedtls_md_type_t md, + unsigned char *dst, + size_t dst_len, + size_t *olen ); + #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* * Write TLS 1.3 Signature Algorithm extension diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 360419240f..dc7b1e85c6 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6978,4 +6978,147 @@ exit: #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +#if defined(MBEDTLS_SHA384_C) +static int ssl_tls13_get_handshake_transcript_sha384( mbedtls_ssl_context *ssl, + unsigned char *dst, + size_t dst_len, + size_t *olen ) +{ +#if defined(MBEDTLS_USE_PSA_CRYPTO) + psa_status_t status; + psa_hash_operation_t sha384_psa = psa_hash_operation_init(); + + if( dst_len < 48 ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> PSA calc verify sha256" ) ); + status = psa_hash_clone( &ssl->handshake->fin_sha384_psa, &sha384_psa ); + if( status != PSA_SUCCESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "PSA hash clone failed" ) ); + return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); + } + + status = psa_hash_finish( &sha384_psa, dst, dst_len, olen ); + if( status != PSA_SUCCESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "PSA hash finish failed" ) ); + return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); + } + + *olen = 48; + MBEDTLS_SSL_DEBUG_BUF( 3, "PSA calculated verify result", dst, *olen ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= PSA calc verify" ) ); + return( 0 ); +#else /* MBEDTLS_USE_PSA_CRYPTO */ + int ret; + mbedtls_sha512_context sha512; + + if( dst_len < 48 ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + mbedtls_sha512_init( &sha512 ); + mbedtls_sha512_clone( &sha512, &ssl->handshake->fin_sha512 ); + + if( ( ret = mbedtls_sha512_finish( &sha512, dst ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha512_finish", ret ); + goto exit; + } + + *olen = 48; + +exit: + + mbedtls_sha512_free( &sha512 ); + return( ret ); +#endif /* !MBEDTLS_USE_PSA_CRYPTO */ +} +#endif /* MBEDTLS_SHA384_C */ + +#if defined(MBEDTLS_SHA256_C) +static int ssl_tls13_get_handshake_transcript_sha256( mbedtls_ssl_context *ssl, + unsigned char *dst, + size_t dst_len, + size_t *olen ) +{ +#if defined(MBEDTLS_USE_PSA_CRYPTO) + psa_status_t status; + psa_hash_operation_t sha256_psa = psa_hash_operation_init(); + + if( dst_len < 32 ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> PSA calc verify sha256" ) ); + status = psa_hash_clone( &ssl->handshake->fin_sha256_psa, &sha256_psa ); + if( status != PSA_SUCCESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "PSA hash clone failed" ) ); + return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); + } + + status = psa_hash_finish( &sha256_psa, dst, dst_len, olen ); + if( status != PSA_SUCCESS ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "PSA hash finish failed" ) ); + return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); + } + + *olen = 32; + MBEDTLS_SSL_DEBUG_BUF( 3, "PSA calculated verify result", dst, *olen ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= PSA calc verify" ) ); + return( 0 ); +#else /* MBEDTLS_USE_PSA_CRYPTO */ + int ret; + mbedtls_sha256_context sha256; + + if( dst_len < 32 ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + mbedtls_sha256_init( &sha256 ); + mbedtls_sha256_clone( &sha256, &ssl->handshake->fin_sha256 ); + + if( ( ret = mbedtls_sha256_finish( &sha256, dst ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha256_finish", ret ); + goto exit; + } + + *olen = 32; + +exit: + + mbedtls_sha256_free( &sha256 ); + return( ret ); +#endif /* !MBEDTLS_USE_PSA_CRYPTO */ +} +#endif /* MBEDTLS_SHA256_C */ + +int mbedtls_ssl_tls13_get_handshake_transcript( mbedtls_ssl_context *ssl, + const mbedtls_md_type_t md, + unsigned char *dst, + size_t dst_len, + size_t *olen ) +{ +#if defined(MBEDTLS_SHA384_C) + if( md == MBEDTLS_MD_SHA384 ) + { + return( ssl_tls13_get_handshake_transcript_sha384( ssl, dst, dst_len, olen ) ); + } + else +#endif /* MBEDTLS_SHA512_C */ +#if defined(MBEDTLS_SHA256_C) + if( md == MBEDTLS_MD_SHA256 ) + { + return( ssl_tls13_get_handshake_transcript_sha256( ssl, dst, dst_len, olen ) ); + } + else +#endif /* MBEDTLS_SHA256_C */ + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} + +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #endif /* MBEDTLS_SSL_TLS_C */ From 89ea321d96e8727b00bbf6ea632a40586b88a502 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 14:31:24 +0800 Subject: [PATCH 577/966] tls13: add key_schedule_stage_early_data Signed-off-by: Jerry Yu --- library/ssl_misc.h | 7 +++++++ library/ssl_tls13_keys.c | 27 +++++++++++++++++++++++++++ library/ssl_tls13_keys.h | 25 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 604976f5fc..5afdc4c5f8 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -675,6 +675,13 @@ struct mbedtls_ssl_handshake_params int extensions_present; /*!< extension presence; Each bitfield represents an extension and defined as \c MBEDTLS_SSL_EXT_XXX */ + + union + { + unsigned char early [MBEDTLS_MD_MAX_SIZE]; + unsigned char handshake[MBEDTLS_MD_MAX_SIZE]; + unsigned char app [MBEDTLS_MD_MAX_SIZE]; + } tls13_master_secrets; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 7aec21dffe..b7beb125ca 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -820,4 +820,31 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, return( 0 ); } +int mbedtls_ssl_tls13_key_schedule_stage_early_data( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + + if( ssl->handshake->ciphersuite_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "cipher suite info not found" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + mbedtls_md_type_t const md_type = ssl->handshake->ciphersuite_info->mac; + const unsigned char *input = NULL; + size_t input_len = 0; +#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) + input = ssl->handshake->psk; + input_len = ssl->handshake->psk_len; +#endif + ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, NULL, input, input_len, + ssl->handshake->tls13_master_secrets.early ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_evolve_secret", ret ); + return( ret ); + } + + return( 0 ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index ca892b1665..592ba12a0f 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -531,4 +531,29 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, mbedtls_ssl_key_set const *traffic_keys, mbedtls_ssl_context *ssl ); +/* + * TLS 1.3 key schedule evolutions + * + * Early Data -> Handshake -> Application + * + * Small wrappers around mbedtls_ssl_tls1_3_evolve_secret(). + */ + +/** + * \brief Begin TLS 1.3 key schedule by calculating early secret + * from chosen PSK. + * + * The TLS 1.3 key schedule can be viewed as a simple state machine + * with states Initial -> Early -> Handshake -> Application, and + * this function represents the Initial -> Early transition. + * + * In the early stage, mbedtls_ssl_tls1_3_generate_early_data_keys() + * can be used to derive the 0-RTT traffic keys. + * + * \param ssl The SSL context to operate on. + * + * \returns \c 0 on success. + * \returns A negative error code on failure. + */ +int mbedtls_ssl_tls13_key_schedule_stage_early_data( mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From 4925ef5da19db0f3482b59466bc15f80aab861f2 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 14:42:55 +0800 Subject: [PATCH 578/966] tls13: add generate handshake keys Signed-off-by: Jerry Yu --- library/ssl_misc.h | 23 ++++++++ library/ssl_tls13_keys.c | 116 +++++++++++++++++++++++++++++++++++++++ library/ssl_tls13_keys.h | 37 ++++++------- 3 files changed, 155 insertions(+), 21 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 5afdc4c5f8..d9759af6c6 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -478,6 +478,27 @@ struct mbedtls_ssl_key_set }; typedef struct mbedtls_ssl_key_set mbedtls_ssl_key_set; +typedef struct +{ + unsigned char binder_key [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char client_early_traffic_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char early_exporter_master_secret[ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_early_secrets; + +typedef struct +{ + unsigned char client_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char server_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_handshake_secrets; + +typedef struct +{ + unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_application_secrets; + /* * This structure contains the parameters only needed during handshake. */ @@ -682,6 +703,8 @@ struct mbedtls_ssl_handshake_params unsigned char handshake[MBEDTLS_MD_MAX_SIZE]; unsigned char app [MBEDTLS_MD_MAX_SIZE]; } tls13_master_secrets; + + mbedtls_ssl_tls1_3_handshake_secrets tls13_hs_secrets; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index b7beb125ca..5435a25a4c 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -847,4 +847,120 @@ int mbedtls_ssl_tls13_key_schedule_stage_early_data( mbedtls_ssl_context *ssl ) return( 0 ); } +/* mbedtls_ssl_tls13_generate_handshake_keys() generates keys necessary for + * protecting the handshake messages, as described in Section 7 of TLS 1.3. */ +int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, + mbedtls_ssl_key_set *traffic_keys ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + mbedtls_md_type_t md_type; + mbedtls_md_info_t const *md_info; + size_t md_size; + + unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; + size_t transcript_len; + + mbedtls_cipher_info_t const *cipher_info; + size_t keylen, ivlen; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls13_generate_handshake_keys" ) ); + + cipher_info = mbedtls_cipher_info_from_type( + ssl->handshake->ciphersuite_info->cipher ); + keylen = cipher_info->key_bitlen >> 3; + ivlen = cipher_info->iv_size; + + md_type = ssl->handshake->ciphersuite_info->mac; + md_info = mbedtls_md_info_from_type( md_type ); + md_size = mbedtls_md_get_size( md_info ); + + ret = mbedtls_ssl_tls13_get_handshake_transcript( ssl, md_type, + transcript, + sizeof( transcript ), + &transcript_len ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, + "mbedtls_ssl_tls13_get_handshake_transcript", + ret ); + return( ret ); + } + + ret = mbedtls_ssl_tls1_3_derive_handshake_secrets( md_type, + ssl->handshake->tls13_master_secrets.handshake, + transcript, transcript_len, + &ssl->handshake->tls13_hs_secrets ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_early_secrets", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "Client handshake traffic secret", + ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, + md_size ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "Server handshake traffic secret", + ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, + md_size ); + + /* + * Export client handshake traffic secret + */ +#if defined(MBEDTLS_SSL_EXPORT_KEYS) + if( ssl->f_export_keys != NULL ) + { + ssl->f_export_keys( ssl->p_export_keys, + MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_HANDSHAKE_TRAFFIC_SECRET, + ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, + md_size, + ssl->handshake->randbytes + 32, + ssl->handshake->randbytes, + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + + ssl->f_export_keys( ssl->p_export_keys, + MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_HANDSHAKE_TRAFFIC_SECRET, + ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, + md_size, + ssl->handshake->randbytes + 32, + ssl->handshake->randbytes, + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + } +#endif /* MBEDTLS_SSL_EXPORT_KEYS */ + + ret = mbedtls_ssl_tls1_3_make_traffic_keys( md_type, + ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, + ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, + md_size, + keylen, ivlen, traffic_keys ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_make_traffic_keys", ret ); + goto exit; + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "client_handshake write_key", + traffic_keys->client_write_key, + traffic_keys->key_len); + + MBEDTLS_SSL_DEBUG_BUF( 4, "server_handshake write_key", + traffic_keys->server_write_key, + traffic_keys->key_len); + + MBEDTLS_SSL_DEBUG_BUF( 4, "client_handshake write_iv", + traffic_keys->client_write_iv, + traffic_keys->iv_len); + + MBEDTLS_SSL_DEBUG_BUF( 4, "server_handshake write_iv", + traffic_keys->server_write_iv, + traffic_keys->iv_len); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls13_generate_handshake_keys" ) ); + +exit: + + return( ret ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 592ba12a0f..7176dee0a2 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -70,27 +70,6 @@ extern const struct mbedtls_ssl_tls1_3_labels_struct mbedtls_ssl_tls1_3_labels; #define MBEDTLS_SSL_TLS1_3_KEY_SCHEDULE_MAX_CONTEXT_LEN \ MBEDTLS_MD_MAX_SIZE -typedef struct -{ - unsigned char binder_key [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char client_early_traffic_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char early_exporter_master_secret[ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_early_secrets; - -typedef struct -{ - unsigned char client_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_handshake_secrets; - -typedef struct -{ - unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_application_secrets; - /* Maximum desired length for expanded key material generated * by HKDF-Expand-Label. * @@ -556,4 +535,20 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, * \returns A negative error code on failure. */ int mbedtls_ssl_tls13_key_schedule_stage_early_data( mbedtls_ssl_context *ssl ); + +/** + * \brief Compute TLS 1.3 handshake traffic keys. + * + * \param ssl The SSL context to operate on. This must be in + * key schedule stage \c Handshake, see + * mbedtls_ssl_tls13_key_schedule_stage_handshake(). + * \param traffic_keys The address at which to store the handshake traffic key + * keys. This must be writable but may be uninitialized. + * + * \returns \c 0 on success. + * \returns A negative error code on failure. + */ +int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, + mbedtls_ssl_key_set *traffic_keys ); + #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From 7bea4bac96227cd288ab79d744c7d0a12e0a9d77 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 15:06:18 +0800 Subject: [PATCH 579/966] tls13: add checksum of handshake message Signed-off-by: Jerry Yu --- library/ssl_misc.h | 8 ++++++++ library/ssl_tls13_generic.c | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index d9759af6c6..4ccfbc52d5 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1523,6 +1523,14 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, size_t total_hs_len ); +/* + * Update checksum of handshake message + */ +void mbedtls_ssl_tls13_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char const *msg, + size_t msg_len ); + /* Get handshake transcript */ int mbedtls_ssl_tls13_get_handshake_transcript( mbedtls_ssl_context *ssl, const mbedtls_md_type_t md, diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 5c20f29283..bac11787d8 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -66,6 +66,15 @@ cleanup: return( ret ); } +void mbedtls_ssl_tls13_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char const *msg, + size_t msg_len ) +{ + mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, hs_type, msg_len ); + ssl->handshake->update_checksum( ssl, msg, msg_len ); +} + void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, size_t total_hs_len ) From d3f73349a7b54507bc4becf960bea9ffc2132a3b Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 15:42:32 +0800 Subject: [PATCH 580/966] tls13: add ecdh_read_public Signed-off-by: Jerry Yu --- library/ecdh.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ library/ecp.c | 34 +++++++++++++++++++++++++++++++ library/ssl_misc.h | 18 +++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/library/ecdh.c b/library/ecdh.c index b72bd1fe08..b1d7c2a3b3 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -31,6 +31,7 @@ #include "mbedtls/ecdh.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" +#include "ssl_misc.h" #include "ecdh_misc.h" @@ -690,6 +691,55 @@ static int ecdh_calc_secret_internal( mbedtls_ecdh_context_mbed *ctx, return mbedtls_mpi_write_binary( &ctx->z, buf, *olen ); } +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +static int ecdh_read_tls13_public_internal( mbedtls_ecdh_context_mbed *ctx, + const unsigned char *buf, + size_t blen ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + const unsigned char *p = buf; + + if( ( ret = mbedtls_ecp_tls13_read_point( &ctx->grp, &ctx->Qp, &p, + blen ) ) != 0 ) + return( ret ); + + if( (size_t)( p - buf ) != blen ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + return( 0 ); +} + +/* + * Parse and import the client's TLS 1.3 public value + */ +int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, size_t blen ) +{ + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( buf != NULL ); + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_read_tls13_public_internal( ctx, buf, blen ) ); +#else + switch( ctx->var ) + { +#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) + case MBEDTLS_ECDH_VARIANT_EVEREST: + return( mbedtls_everest_read_public( &ctx->ctx.everest_ecdh, + buf, blen ) ); +#endif + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_read_tls13_public_internal( &ctx->ctx.mbed_ecdh, + buf, blen ) ); + default: + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } +#endif +} + +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* * Derive and export the shared secret */ diff --git a/library/ecp.c b/library/ecp.c index 0212069c83..a49cc457bc 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -79,6 +79,7 @@ #include "bn_mul.h" #include "ecp_invasive.h" +#include "ssl_misc.h" #include @@ -1051,6 +1052,39 @@ cleanup: return( ret ); } +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +int mbedtls_ecp_tls13_read_point( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *pt, + const unsigned char **buf, size_t buf_len ) +{ + unsigned char data_len; + const unsigned char *buf_start; + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( pt != NULL ); + ECP_VALIDATE_RET( buf != NULL ); + ECP_VALIDATE_RET( *buf != NULL ); + + if( buf_len < 3 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + data_len = ( *( *buf ) << 8 ) | *( *buf+1 ); + *buf += 2; + + if( data_len < 1 || data_len > buf_len - 2 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * Save buffer start for read_binary and update buf + */ + buf_start = *buf; + *buf += data_len; + + return( mbedtls_ecp_point_read_binary( grp, pt, buf_start, data_len ) ); +} + +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* * Fast mod-p functions expect their argument to be in the 0..p^2 range. * diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 4ccfbc52d5..6206c6f5b1 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1538,6 +1538,24 @@ int mbedtls_ssl_tls13_get_handshake_transcript( mbedtls_ssl_context *ssl, size_t dst_len, size_t *olen ); +#if defined(MBEDTLS_ECDH_C) +/* + * TLS 1.3 version of mbedtls_ecdh_read_public in ecdh.h + */ +int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, + size_t blen ); +#endif /* MBEDTLS_ECDH_C */ + +#if defined(MBEDTLS_ECP_C) +/* + * TLS 1.3 version of mbedtls_ecp_tls_read_point in ecp.h + */ +int mbedtls_ecp_tls13_read_point( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *pt, + const unsigned char **buf, size_t len ); +#endif /* MBEDTLS_ECP_C */ + #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* * Write TLS 1.3 Signature Algorithm extension From c7875b5f11d400f00f4ee6f8ccc83ffd4756dd08 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sun, 5 Sep 2021 21:05:50 +0800 Subject: [PATCH 581/966] add set in/out transform utils Signed-off-by: Jerry Yu --- library/ssl_misc.h | 8 ++++++++ library/ssl_msg.c | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 6206c6f5b1..8b2d50d2f0 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -986,6 +986,14 @@ void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform ); */ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ); +/* set inbound transform of ssl context */ +void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, + mbedtls_ssl_transform *transform ); + +/* set outbound transform of ssl context */ +void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, + mbedtls_ssl_transform *transform ); + int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 2fe801a283..fcdd0249bc 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -5551,6 +5551,23 @@ void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform ) mbedtls_platform_zeroize( transform, sizeof( mbedtls_ssl_transform ) ); } +void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, + mbedtls_ssl_transform *transform ) +{ + if( ssl->transform_in == transform ) + return; + + ssl->transform_in = transform; + mbedtls_platform_zeroize( ssl->in_ctr, 8 ); +} + +void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, + mbedtls_ssl_transform *transform ) +{ + ssl->transform_out = transform; + mbedtls_platform_zeroize( ssl->cur_out_ctr, 8 ); +} + #if defined(MBEDTLS_SSL_PROTO_DTLS) void mbedtls_ssl_buffering_free( mbedtls_ssl_context *ssl ) From 000f9760707bfc866e47d7a078b0b776bd7211d4 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 14 Sep 2021 11:12:51 +0800 Subject: [PATCH 582/966] Rename get_handshake_transcript - Remove tls13 prefix - Remove TLS1_3 macro wrap Signed-off-by: Jerry Yu --- library/ssl_misc.h | 14 +++++++------- library/ssl_tls.c | 34 +++++++++++++++------------------- library/ssl_tls13_keys.c | 4 ++-- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 8b2d50d2f0..44bfcb0062 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1539,13 +1539,6 @@ void mbedtls_ssl_tls13_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, unsigned char const *msg, size_t msg_len ); -/* Get handshake transcript */ -int mbedtls_ssl_tls13_get_handshake_transcript( mbedtls_ssl_context *ssl, - const mbedtls_md_type_t md, - unsigned char *dst, - size_t dst_len, - size_t *olen ); - #if defined(MBEDTLS_ECDH_C) /* * TLS 1.3 version of mbedtls_ecdh_read_public in ecdh.h @@ -1577,4 +1570,11 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ +/* Get handshake transcript */ +int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl, + const mbedtls_md_type_t md, + unsigned char *dst, + size_t dst_len, + size_t *olen ); + #endif /* ssl_misc.h */ diff --git a/library/ssl_tls.c b/library/ssl_tls.c index dc7b1e85c6..ae5a5b8026 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6978,13 +6978,11 @@ exit: #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - #if defined(MBEDTLS_SHA384_C) -static int ssl_tls13_get_handshake_transcript_sha384( mbedtls_ssl_context *ssl, - unsigned char *dst, - size_t dst_len, - size_t *olen ) +static int ssl_get_handshake_transcript_sha384( mbedtls_ssl_context *ssl, + unsigned char *dst, + size_t dst_len, + size_t *olen ) { #if defined(MBEDTLS_USE_PSA_CRYPTO) psa_status_t status; @@ -7039,10 +7037,10 @@ exit: #endif /* MBEDTLS_SHA384_C */ #if defined(MBEDTLS_SHA256_C) -static int ssl_tls13_get_handshake_transcript_sha256( mbedtls_ssl_context *ssl, - unsigned char *dst, - size_t dst_len, - size_t *olen ) +static int ssl_get_handshake_transcript_sha256( mbedtls_ssl_context *ssl, + unsigned char *dst, + size_t dst_len, + size_t *olen ) { #if defined(MBEDTLS_USE_PSA_CRYPTO) psa_status_t status; @@ -7096,29 +7094,27 @@ exit: } #endif /* MBEDTLS_SHA256_C */ -int mbedtls_ssl_tls13_get_handshake_transcript( mbedtls_ssl_context *ssl, - const mbedtls_md_type_t md, - unsigned char *dst, - size_t dst_len, - size_t *olen ) +int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl, + const mbedtls_md_type_t md, + unsigned char *dst, + size_t dst_len, + size_t *olen ) { #if defined(MBEDTLS_SHA384_C) if( md == MBEDTLS_MD_SHA384 ) { - return( ssl_tls13_get_handshake_transcript_sha384( ssl, dst, dst_len, olen ) ); + return( ssl_get_handshake_transcript_sha384( ssl, dst, dst_len, olen ) ); } else #endif /* MBEDTLS_SHA512_C */ #if defined(MBEDTLS_SHA256_C) if( md == MBEDTLS_MD_SHA256 ) { - return( ssl_tls13_get_handshake_transcript_sha256( ssl, dst, dst_len, olen ) ); + return( ssl_get_handshake_transcript_sha256( ssl, dst, dst_len, olen ) ); } else #endif /* MBEDTLS_SHA256_C */ return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ - #endif /* MBEDTLS_SSL_TLS_C */ diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 5435a25a4c..7e65268196 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -875,14 +875,14 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, md_info = mbedtls_md_info_from_type( md_type ); md_size = mbedtls_md_get_size( md_info ); - ret = mbedtls_ssl_tls13_get_handshake_transcript( ssl, md_type, + ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type, transcript, sizeof( transcript ), &transcript_len ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, - "mbedtls_ssl_tls13_get_handshake_transcript", + "mbedtls_ssl_get_handshake_transcript", ret ); return( ret ); } From a63de352dc1b847c45fb618fe0c56c7ba8ebd20c Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 15:42:32 +0800 Subject: [PATCH 583/966] Revert "tls13: add ecdh_read_public" This reverts commit 6a9d2ee4df88028e352e50d4f48687ce5b0f26ac. Signed-off-by: Jerry Yu --- library/ecdh.c | 50 ---------------------------------------------- library/ecp.c | 34 ------------------------------- library/ssl_misc.h | 18 ----------------- 3 files changed, 102 deletions(-) diff --git a/library/ecdh.c b/library/ecdh.c index b1d7c2a3b3..b72bd1fe08 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -31,7 +31,6 @@ #include "mbedtls/ecdh.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" -#include "ssl_misc.h" #include "ecdh_misc.h" @@ -691,55 +690,6 @@ static int ecdh_calc_secret_internal( mbedtls_ecdh_context_mbed *ctx, return mbedtls_mpi_write_binary( &ctx->z, buf, *olen ); } -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - -static int ecdh_read_tls13_public_internal( mbedtls_ecdh_context_mbed *ctx, - const unsigned char *buf, - size_t blen ) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - const unsigned char *p = buf; - - if( ( ret = mbedtls_ecp_tls13_read_point( &ctx->grp, &ctx->Qp, &p, - blen ) ) != 0 ) - return( ret ); - - if( (size_t)( p - buf ) != blen ) - return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - - return( 0 ); -} - -/* - * Parse and import the client's TLS 1.3 public value - */ -int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, - const unsigned char *buf, size_t blen ) -{ - ECDH_VALIDATE_RET( ctx != NULL ); - ECDH_VALIDATE_RET( buf != NULL ); - -#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) - return( ecdh_read_tls13_public_internal( ctx, buf, blen ) ); -#else - switch( ctx->var ) - { -#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) - case MBEDTLS_ECDH_VARIANT_EVEREST: - return( mbedtls_everest_read_public( &ctx->ctx.everest_ecdh, - buf, blen ) ); -#endif - case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: - return( ecdh_read_tls13_public_internal( &ctx->ctx.mbed_ecdh, - buf, blen ) ); - default: - return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; - } -#endif -} - -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ - /* * Derive and export the shared secret */ diff --git a/library/ecp.c b/library/ecp.c index a49cc457bc..0212069c83 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -79,7 +79,6 @@ #include "bn_mul.h" #include "ecp_invasive.h" -#include "ssl_misc.h" #include @@ -1052,39 +1051,6 @@ cleanup: return( ret ); } -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - -int mbedtls_ecp_tls13_read_point( const mbedtls_ecp_group *grp, - mbedtls_ecp_point *pt, - const unsigned char **buf, size_t buf_len ) -{ - unsigned char data_len; - const unsigned char *buf_start; - ECP_VALIDATE_RET( grp != NULL ); - ECP_VALIDATE_RET( pt != NULL ); - ECP_VALIDATE_RET( buf != NULL ); - ECP_VALIDATE_RET( *buf != NULL ); - - if( buf_len < 3 ) - return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - - data_len = ( *( *buf ) << 8 ) | *( *buf+1 ); - *buf += 2; - - if( data_len < 1 || data_len > buf_len - 2 ) - return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - - /* - * Save buffer start for read_binary and update buf - */ - buf_start = *buf; - *buf += data_len; - - return( mbedtls_ecp_point_read_binary( grp, pt, buf_start, data_len ) ); -} - -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ - /* * Fast mod-p functions expect their argument to be in the 0..p^2 range. * diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 44bfcb0062..8c5a32d67a 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1539,24 +1539,6 @@ void mbedtls_ssl_tls13_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, unsigned char const *msg, size_t msg_len ); -#if defined(MBEDTLS_ECDH_C) -/* - * TLS 1.3 version of mbedtls_ecdh_read_public in ecdh.h - */ -int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, - const unsigned char *buf, - size_t blen ); -#endif /* MBEDTLS_ECDH_C */ - -#if defined(MBEDTLS_ECP_C) -/* - * TLS 1.3 version of mbedtls_ecp_tls_read_point in ecp.h - */ -int mbedtls_ecp_tls13_read_point( const mbedtls_ecp_group *grp, - mbedtls_ecp_point *pt, - const unsigned char **buf, size_t len ); -#endif /* MBEDTLS_ECP_C */ - #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* * Write TLS 1.3 Signature Algorithm extension From e3131ef7f34055748d11e1e252124cf6c561a899 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 16 Sep 2021 13:14:15 +0800 Subject: [PATCH 584/966] fix various issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 2 +- library/ssl_msg.c | 2 +- library/ssl_tls13_keys.c | 36 ++++++++++++++++++++---------------- library/ssl_tls13_keys.h | 2 +- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 8c5a32d67a..1b5861c635 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1532,7 +1532,7 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, size_t total_hs_len ); /* - * Update checksum of handshake message + * Update checksum of handshake messages. */ void mbedtls_ssl_tls13_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, diff --git a/library/ssl_msg.c b/library/ssl_msg.c index fcdd0249bc..ea1d535a06 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -5565,7 +5565,7 @@ void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, mbedtls_ssl_transform *transform ) { ssl->transform_out = transform; - mbedtls_platform_zeroize( ssl->cur_out_ctr, 8 ); + mbedtls_platform_zeroize( ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); } #if defined(MBEDTLS_SSL_PROTO_DTLS) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 7e65268196..bfc3103fcb 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -21,14 +21,16 @@ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -#include "mbedtls/hkdf.h" -#include "ssl_misc.h" -#include "ssl_tls13_keys.h" -#include "mbedtls/debug.h" - #include #include +#include "mbedtls/hkdf.h" +#include "mbedtls/debug.h" +#include "mbedtls/error.h" + +#include "ssl_misc.h" +#include "ssl_tls13_keys.h" + #define MBEDTLS_SSL_TLS1_3_LABEL( name, string ) \ .name = string, @@ -820,24 +822,25 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, return( 0 ); } -int mbedtls_ssl_tls13_key_schedule_stage_early_data( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls13_key_schedule_stage_early( mbedtls_ssl_context *ssl ) { - int ret = 0; - + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + mbedtls_md_type_t md_type; + const unsigned char *input = NULL; + size_t input_len = 0; if( ssl->handshake->ciphersuite_info == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "cipher suite info not found" ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } - mbedtls_md_type_t const md_type = ssl->handshake->ciphersuite_info->mac; - const unsigned char *input = NULL; - size_t input_len = 0; + + md_type = ssl->handshake->ciphersuite_info->mac; #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) input = ssl->handshake->psk; input_len = ssl->handshake->psk_len; #endif ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, NULL, input, input_len, - ssl->handshake->tls13_master_secrets.early ); + ssl->handshake->tls13_master_secrets.early ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_evolve_secret", ret ); @@ -876,9 +879,9 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, md_size = mbedtls_md_get_size( md_info ); ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type, - transcript, - sizeof( transcript ), - &transcript_len ); + transcript, + sizeof( transcript ), + &transcript_len ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, @@ -893,7 +896,8 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, &ssl->handshake->tls13_hs_secrets ); if( ret != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_early_secrets", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_handshake_secrets", + ret ); return( ret ); } diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 7176dee0a2..407b5d613d 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -534,7 +534,7 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls13_key_schedule_stage_early_data( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_key_schedule_stage_early( mbedtls_ssl_context *ssl ); /** * \brief Compute TLS 1.3 handshake traffic keys. From 524314247686801c7fda1574ea2f00e6163e6e29 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 16 Sep 2021 13:25:04 +0800 Subject: [PATCH 585/966] Add macro for length of input counter Signed-off-by: Jerry Yu --- library/ssl_msg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index ea1d535a06..36a3e202ff 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -54,6 +54,8 @@ #include "mbedtls/oid.h" #endif +#define MBEDTLS_SSL_IN_CTR_LEN 8 + static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context const *ssl ); /* @@ -4791,7 +4793,7 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - memset( ssl->in_ctr, 0, 8 ); + mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_IN_CTR_LEN ); mbedtls_ssl_update_in_pointers( ssl ); @@ -5558,7 +5560,7 @@ void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, return; ssl->transform_in = transform; - mbedtls_platform_zeroize( ssl->in_ctr, 8 ); + mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_IN_CTR_LEN ); } void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, From b65eb2f3cf6f170c838ac0f7d9acf9da0450f033 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 16 Sep 2021 13:43:28 +0800 Subject: [PATCH 586/966] Revert "tls13: add generate handshake keys" This reverts commit f02ca4158674b974ae103849c43e0c92efc40e8c. Signed-off-by: Jerry Yu --- library/ssl_misc.h | 23 -------- library/ssl_tls13_keys.c | 117 --------------------------------------- library/ssl_tls13_keys.h | 36 +++++++----- 3 files changed, 21 insertions(+), 155 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 1b5861c635..fb261a0d6d 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -478,27 +478,6 @@ struct mbedtls_ssl_key_set }; typedef struct mbedtls_ssl_key_set mbedtls_ssl_key_set; -typedef struct -{ - unsigned char binder_key [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char client_early_traffic_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char early_exporter_master_secret[ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_early_secrets; - -typedef struct -{ - unsigned char client_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_handshake_secrets; - -typedef struct -{ - unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_application_secrets; - /* * This structure contains the parameters only needed during handshake. */ @@ -703,8 +682,6 @@ struct mbedtls_ssl_handshake_params unsigned char handshake[MBEDTLS_MD_MAX_SIZE]; unsigned char app [MBEDTLS_MD_MAX_SIZE]; } tls13_master_secrets; - - mbedtls_ssl_tls1_3_handshake_secrets tls13_hs_secrets; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index bfc3103fcb..32b68666be 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -850,121 +850,4 @@ int mbedtls_ssl_tls13_key_schedule_stage_early( mbedtls_ssl_context *ssl ) return( 0 ); } -/* mbedtls_ssl_tls13_generate_handshake_keys() generates keys necessary for - * protecting the handshake messages, as described in Section 7 of TLS 1.3. */ -int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, - mbedtls_ssl_key_set *traffic_keys ) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - - mbedtls_md_type_t md_type; - mbedtls_md_info_t const *md_info; - size_t md_size; - - unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; - size_t transcript_len; - - mbedtls_cipher_info_t const *cipher_info; - size_t keylen, ivlen; - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls13_generate_handshake_keys" ) ); - - cipher_info = mbedtls_cipher_info_from_type( - ssl->handshake->ciphersuite_info->cipher ); - keylen = cipher_info->key_bitlen >> 3; - ivlen = cipher_info->iv_size; - - md_type = ssl->handshake->ciphersuite_info->mac; - md_info = mbedtls_md_info_from_type( md_type ); - md_size = mbedtls_md_get_size( md_info ); - - ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type, - transcript, - sizeof( transcript ), - &transcript_len ); - if( ret != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, - "mbedtls_ssl_get_handshake_transcript", - ret ); - return( ret ); - } - - ret = mbedtls_ssl_tls1_3_derive_handshake_secrets( md_type, - ssl->handshake->tls13_master_secrets.handshake, - transcript, transcript_len, - &ssl->handshake->tls13_hs_secrets ); - if( ret != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_handshake_secrets", - ret ); - return( ret ); - } - - MBEDTLS_SSL_DEBUG_BUF( 4, "Client handshake traffic secret", - ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, - md_size ); - - MBEDTLS_SSL_DEBUG_BUF( 4, "Server handshake traffic secret", - ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, - md_size ); - - /* - * Export client handshake traffic secret - */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) - if( ssl->f_export_keys != NULL ) - { - ssl->f_export_keys( ssl->p_export_keys, - MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_HANDSHAKE_TRAFFIC_SECRET, - ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, - md_size, - ssl->handshake->randbytes + 32, - ssl->handshake->randbytes, - MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); - - ssl->f_export_keys( ssl->p_export_keys, - MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_HANDSHAKE_TRAFFIC_SECRET, - ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, - md_size, - ssl->handshake->randbytes + 32, - ssl->handshake->randbytes, - MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); - } -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ - - ret = mbedtls_ssl_tls1_3_make_traffic_keys( md_type, - ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, - ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, - md_size, - keylen, ivlen, traffic_keys ); - if( ret != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_make_traffic_keys", ret ); - goto exit; - } - - MBEDTLS_SSL_DEBUG_BUF( 4, "client_handshake write_key", - traffic_keys->client_write_key, - traffic_keys->key_len); - - MBEDTLS_SSL_DEBUG_BUF( 4, "server_handshake write_key", - traffic_keys->server_write_key, - traffic_keys->key_len); - - MBEDTLS_SSL_DEBUG_BUF( 4, "client_handshake write_iv", - traffic_keys->client_write_iv, - traffic_keys->iv_len); - - MBEDTLS_SSL_DEBUG_BUF( 4, "server_handshake write_iv", - traffic_keys->server_write_iv, - traffic_keys->iv_len); - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls13_generate_handshake_keys" ) ); - -exit: - - return( ret ); -} - #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 407b5d613d..7a41db13dd 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -70,6 +70,27 @@ extern const struct mbedtls_ssl_tls1_3_labels_struct mbedtls_ssl_tls1_3_labels; #define MBEDTLS_SSL_TLS1_3_KEY_SCHEDULE_MAX_CONTEXT_LEN \ MBEDTLS_MD_MAX_SIZE +typedef struct +{ + unsigned char binder_key [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char client_early_traffic_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char early_exporter_master_secret[ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_early_secrets; + +typedef struct +{ + unsigned char client_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char server_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_handshake_secrets; + +typedef struct +{ + unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_application_secrets; + /* Maximum desired length for expanded key material generated * by HKDF-Expand-Label. * @@ -536,19 +557,4 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, */ int mbedtls_ssl_tls13_key_schedule_stage_early( mbedtls_ssl_context *ssl ); -/** - * \brief Compute TLS 1.3 handshake traffic keys. - * - * \param ssl The SSL context to operate on. This must be in - * key schedule stage \c Handshake, see - * mbedtls_ssl_tls13_key_schedule_stage_handshake(). - * \param traffic_keys The address at which to store the handshake traffic key - * keys. This must be writable but may be uninitialized. - * - * \returns \c 0 on success. - * \returns A negative error code on failure. - */ -int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, - mbedtls_ssl_key_set *traffic_keys ); - #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From 92c1ca221f535dcfda4edd23f116836a3799743f Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 16 Sep 2021 18:56:10 +0800 Subject: [PATCH 587/966] fix likely typos error Signed-off-by: Jerry Yu --- library/ssl_msg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 36a3e202ff..b749d93173 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -54,7 +54,7 @@ #include "mbedtls/oid.h" #endif -#define MBEDTLS_SSL_IN_CTR_LEN 8 +#define SSL_CONTEXT_INPUT_COUNTER_LEN 8 static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context const *ssl ); @@ -4793,7 +4793,7 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_IN_CTR_LEN ); + mbedtls_platform_zeroize( ssl->in_ctr, SSL_CONTEXT_INPUT_COUNTER_LEN ); mbedtls_ssl_update_in_pointers( ssl ); @@ -5560,7 +5560,7 @@ void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, return; ssl->transform_in = transform; - mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_IN_CTR_LEN ); + mbedtls_platform_zeroize( ssl->in_ctr, SSL_CONTEXT_INPUT_COUNTER_LEN ); } void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, From 4836952f9d3805c10d8bc01fd3c659aa858e152a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sat, 18 Sep 2021 16:09:01 +0800 Subject: [PATCH 588/966] fix tls1_3 prefix issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 10 +++++----- library/ssl_tls13_generic.c | 8 ++++---- library/ssl_tls13_keys.c | 4 ++-- library/ssl_tls13_keys.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index fb261a0d6d..ea891f44a5 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -681,7 +681,7 @@ struct mbedtls_ssl_handshake_params unsigned char early [MBEDTLS_MD_MAX_SIZE]; unsigned char handshake[MBEDTLS_MD_MAX_SIZE]; unsigned char app [MBEDTLS_MD_MAX_SIZE]; - } tls13_master_secrets; + } tls1_3_master_secrets; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) @@ -1511,10 +1511,10 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, /* * Update checksum of handshake messages. */ -void mbedtls_ssl_tls13_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, - unsigned hs_type, - unsigned char const *msg, - size_t msg_len ); +void mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char const *msg, + size_t msg_len ); #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index bac11787d8..c8f6dc797c 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -66,10 +66,10 @@ cleanup: return( ret ); } -void mbedtls_ssl_tls13_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, - unsigned hs_type, - unsigned char const *msg, - size_t msg_len ) +void mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char const *msg, + size_t msg_len ) { mbedtls_ssl_tls13_add_hs_hdr_to_checksum( ssl, hs_type, msg_len ); ssl->handshake->update_checksum( ssl, msg, msg_len ); diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 32b68666be..2d504f0685 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -822,7 +822,7 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, return( 0 ); } -int mbedtls_ssl_tls13_key_schedule_stage_early( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; mbedtls_md_type_t md_type; @@ -840,7 +840,7 @@ int mbedtls_ssl_tls13_key_schedule_stage_early( mbedtls_ssl_context *ssl ) input_len = ssl->handshake->psk_len; #endif ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, NULL, input, input_len, - ssl->handshake->tls13_master_secrets.early ); + ssl->handshake->tls1_3_master_secrets.early ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_evolve_secret", ret ); diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 7a41db13dd..45b0fdfa4c 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -555,6 +555,6 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls13_key_schedule_stage_early( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From e06f4532efffe9f0c7b717fdc23ff1752fce8ebd Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 23 Sep 2021 18:35:07 +0800 Subject: [PATCH 589/966] remove useless code Signed-off-by: Jerry Yu --- library/ssl_tls13_keys.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 2d504f0685..cc94984063 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -835,10 +835,7 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ) } md_type = ssl->handshake->ciphersuite_info->mac; -#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) - input = ssl->handshake->psk; - input_len = ssl->handshake->psk_len; -#endif + ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, NULL, input, input_len, ssl->handshake->tls1_3_master_secrets.early ); if( ret != 0 ) From 957f0fa1f726b28ecd6715dede67bd586e1b1c3d Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 24 Sep 2021 10:27:07 +0800 Subject: [PATCH 590/966] Add length macro for in_ctr Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 3 +++ library/ssl_msg.c | 14 ++++++-------- library/ssl_srv.c | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 725b156d5d..3f627139c8 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -593,6 +593,9 @@ union mbedtls_ssl_premaster_secret #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret ) +/* Length of in_ctr buffer in mbedtls_ssl_session */ +#define MBEDTLS_SSL_IN_CTR_LEN 8 + #ifdef __cplusplus extern "C" { #endif diff --git a/library/ssl_msg.c b/library/ssl_msg.c index b749d93173..518cfeeef4 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -54,8 +54,6 @@ #include "mbedtls/oid.h" #endif -#define SSL_CONTEXT_INPUT_COUNTER_LEN 8 - static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context const *ssl ); /* @@ -3651,7 +3649,7 @@ static int ssl_prepare_record_content( mbedtls_ssl_context *ssl, #endif { unsigned i; - for( i = 8; i > mbedtls_ssl_ep_len( ssl ); i-- ) + for( i = MBEDTLS_SSL_IN_CTR_LEN; i > mbedtls_ssl_ep_len( ssl ); i-- ) if( ++ssl->in_ctr[i - 1] != 0 ) break; @@ -4793,7 +4791,7 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - mbedtls_platform_zeroize( ssl->in_ctr, SSL_CONTEXT_INPUT_COUNTER_LEN ); + mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_IN_CTR_LEN ); mbedtls_ssl_update_in_pointers( ssl ); @@ -4883,17 +4881,17 @@ void mbedtls_ssl_update_in_pointers( mbedtls_ssl_context *ssl ) * ssl_parse_record_header(). */ ssl->in_ctr = ssl->in_hdr + 3; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) - ssl->in_cid = ssl->in_ctr + 8; + ssl->in_cid = ssl->in_ctr + MBEDTLS_SSL_IN_CTR_LEN; ssl->in_len = ssl->in_cid; /* Default: no CID */ #else /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ - ssl->in_len = ssl->in_ctr + 8; + ssl->in_len = ssl->in_ctr + MBEDTLS_SSL_IN_CTR_LEN; #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ ssl->in_iv = ssl->in_len + 2; } else #endif { - ssl->in_ctr = ssl->in_hdr - 8; + ssl->in_ctr = ssl->in_hdr - MBEDTLS_SSL_IN_CTR_LEN; ssl->in_len = ssl->in_hdr + 3; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) ssl->in_cid = ssl->in_len; @@ -5560,7 +5558,7 @@ void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, return; ssl->transform_in = transform; - mbedtls_platform_zeroize( ssl->in_ctr, SSL_CONTEXT_INPUT_COUNTER_LEN ); + mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_IN_CTR_LEN ); } void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, diff --git a/library/ssl_srv.c b/library/ssl_srv.c index b8c4314846..147bb785de 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1220,7 +1220,7 @@ read_record_header: return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } - memcpy( ssl->cur_out_ctr + 2, ssl->in_ctr + 2, 6 ); + memcpy( ssl->cur_out_ctr + 2, ssl->in_ctr + 2, MBEDTLS_SSL_IN_CTR_LEN - 2 ); #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) if( mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) From 148165cc6f78086d72983a5d925bc2945e834d94 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 24 Sep 2021 23:20:59 +0800 Subject: [PATCH 591/966] Remove psa version of get_handshake_transcript Signed-off-by: Jerry Yu --- library/ssl_tls.c | 73 +++++++++++------------------------------------ 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index ae5a5b8026..ab36f5d89f 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6978,39 +6978,28 @@ exit: #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +#if defined(MBEDTLS_USE_PSA_CRYPTO) +int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl, + const mbedtls_md_type_t md, + unsigned char *dst, + size_t dst_len, + size_t *olen ) +{ + ((void) ssl); + ((void) md); + ((void) dst); + ((void) dst_len); + *olen = 0; + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE); +} +#else /* MBEDTLS_USE_PSA_CRYPTO */ + #if defined(MBEDTLS_SHA384_C) static int ssl_get_handshake_transcript_sha384( mbedtls_ssl_context *ssl, unsigned char *dst, size_t dst_len, size_t *olen ) { -#if defined(MBEDTLS_USE_PSA_CRYPTO) - psa_status_t status; - psa_hash_operation_t sha384_psa = psa_hash_operation_init(); - - if( dst_len < 48 ) - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> PSA calc verify sha256" ) ); - status = psa_hash_clone( &ssl->handshake->fin_sha384_psa, &sha384_psa ); - if( status != PSA_SUCCESS ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "PSA hash clone failed" ) ); - return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); - } - - status = psa_hash_finish( &sha384_psa, dst, dst_len, olen ); - if( status != PSA_SUCCESS ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "PSA hash finish failed" ) ); - return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); - } - - *olen = 48; - MBEDTLS_SSL_DEBUG_BUF( 3, "PSA calculated verify result", dst, *olen ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= PSA calc verify" ) ); - return( 0 ); -#else /* MBEDTLS_USE_PSA_CRYPTO */ int ret; mbedtls_sha512_context sha512; @@ -7032,7 +7021,6 @@ exit: mbedtls_sha512_free( &sha512 ); return( ret ); -#endif /* !MBEDTLS_USE_PSA_CRYPTO */ } #endif /* MBEDTLS_SHA384_C */ @@ -7042,33 +7030,6 @@ static int ssl_get_handshake_transcript_sha256( mbedtls_ssl_context *ssl, size_t dst_len, size_t *olen ) { -#if defined(MBEDTLS_USE_PSA_CRYPTO) - psa_status_t status; - psa_hash_operation_t sha256_psa = psa_hash_operation_init(); - - if( dst_len < 32 ) - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> PSA calc verify sha256" ) ); - status = psa_hash_clone( &ssl->handshake->fin_sha256_psa, &sha256_psa ); - if( status != PSA_SUCCESS ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "PSA hash clone failed" ) ); - return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); - } - - status = psa_hash_finish( &sha256_psa, dst, dst_len, olen ); - if( status != PSA_SUCCESS ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "PSA hash finish failed" ) ); - return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); - } - - *olen = 32; - MBEDTLS_SSL_DEBUG_BUF( 3, "PSA calculated verify result", dst, *olen ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= PSA calc verify" ) ); - return( 0 ); -#else /* MBEDTLS_USE_PSA_CRYPTO */ int ret; mbedtls_sha256_context sha256; @@ -7090,7 +7051,6 @@ exit: mbedtls_sha256_free( &sha256 ); return( ret ); -#endif /* !MBEDTLS_USE_PSA_CRYPTO */ } #endif /* MBEDTLS_SHA256_C */ @@ -7116,5 +7076,6 @@ int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_SHA256_C */ return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } +#endif /* !MBEDTLS_USE_PSA_CRYPTO */ #endif /* MBEDTLS_SSL_TLS_C */ From def52c36e53ff2d0d3e235fc3f5ef6fc7eed5ff5 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 12:03:55 +0200 Subject: [PATCH 592/966] Remove obscure comment about TLS 1.3 renegotiation config option Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index e6f9065801..96f844cdb1 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -134,7 +134,7 @@ the handshake with an handshake_failure closure alert. MBEDTLS_SSL_ENCRYPT_THEN_MAC n/a MBEDTLS_SSL_EXTENDED_MASTER_SECRET n/a MBEDTLS_SSL_KEEP_PEER_CERTIFICATE no - MBEDTLS_SSL_RENEGOTIATION n/a Not TLS 1.2 dependent + MBEDTLS_SSL_RENEGOTIATION n/a MBEDTLS_SSL_MAX_FRAGMENT_LENGTH no MBEDTLS_SSL_ALPN no From 023987feefa805c03ff71f5b9d99b162ba0fda79 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 11:59:25 +0200 Subject: [PATCH 593/966] Use GitHub table format Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 115 ++++++++++++------------ 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 96f844cdb1..1eef961a80 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -83,30 +83,32 @@ the handshake with an handshake_failure closure alert. - Supported ClientHello extensions: - MVP Prototype - (for comparison) + | Extension | MVP | Prototype (1) | + | ---------------------------- | ------- | ------------- | + | server_name | no | YES | + | max_fragment_length | no | YES | + | status_request | no | no | + | supported_groups | YES | YES | + | signature_algorithms | YES | YES | + | use_srtp | no | no | + | heartbeat | no | no | + | apln | no | YES | + | signed_certificate_timestamp | no | no | + | client_certificate_type | no | no | + | server_certificate_type | no | no | + | padding | no | no | + | key_share | YES | YES | + | pre_shared_key | no | YES | + | psk_key_exchange_modes | no | YES | + | early_data | no | YES | + | cookie | no | YES | + | supported_versions | YES | YES | + | certificate_authorities | no | no | + | post_handshake_auth | no | no | + | signature_algorithms_cert | no | no | + + (1) This is just for comparison. - server_name no YES - max_fragment_length no YES - status_request no no - supported_groups YES YES - signature_algorithms YES YES - use_srtp no no - heartbeat no no - apln no YES - signed_certificate_timestamp no no - client_certificate_type no no - server_certificate_type no no - padding no no - key_share YES YES - pre_shared_key no YES - psk_key_exchange_modes no YES - early_data no YES - cookie no YES - supported_versions YES YES - certificate_authorities no no - post_handshake_auth no no - signature_algorithms_cert no no - Supported groups: depends on the library configuration. Potentially all ECDHE groups: @@ -126,39 +128,42 @@ the handshake with an handshake_failure closure alert. modify the configuration for TLS 1.2. Mbed TLS SSL/TLS related features are not supported or not applicable to the TLS 1.3 MVP: - Supported Comment - MBEDTLS_SSL_ALL_ALERT_MESSAGES no - MBEDTLS_SSL_ASYNC_PRIVATE no - MBEDTLS_SSL_CONTEXT_SERIALIZATION no - MBEDTLS_SSL_DEBUG_ALL no - MBEDTLS_SSL_ENCRYPT_THEN_MAC n/a - MBEDTLS_SSL_EXTENDED_MASTER_SECRET n/a - MBEDTLS_SSL_KEEP_PEER_CERTIFICATE no - MBEDTLS_SSL_RENEGOTIATION n/a - MBEDTLS_SSL_MAX_FRAGMENT_LENGTH no - MBEDTLS_SSL_ALPN no + | Mbed TLS configuration option | Support | + | ---------------------------------------- | ------- | + | MBEDTLS_SSL_ALL_ALERT_MESSAGES | no | + | MBEDTLS_SSL_ASYNC_PRIVATE | no | + | MBEDTLS_SSL_CONTEXT_SERIALIZATION | no | + | MBEDTLS_SSL_DEBUG_ALL | no | + | MBEDTLS_SSL_ENCRYPT_THEN_MAC | n/a | + | MBEDTLS_SSL_EXTENDED_MASTER_SECRET | n/a | + | MBEDTLS_SSL_KEEP_PEER_CERTIFICATE | no | + | MBEDTLS_SSL_RENEGOTIATION | n/a | + | MBEDTLS_SSL_MAX_FRAGMENT_LENGTH | no | + | | | + | MBEDTLS_SSL_SESSION_TICKETS | no | + | MBEDTLS_SSL_EXPORT_KEYS | no (1) | + | MBEDTLS_SSL_SERVER_NAME_INDICATION | no | + | MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH | no | + | | | + | MBEDTLS_ECP_RESTARTABLE | no | + | MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED | no | + | | | + | MBEDTLS_KEY_EXCHANGE_PSK_ENABLED | n/a (2) | + | MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_RSA_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED | n/a | + | MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED | n/a | + | | | + | MBEDTLS_USE_PSA_CRYPTO | no | - MBEDTLS_SSL_SESSION_TICKETS no - MBEDTLS_SSL_EXPORT_KEYS no Incomplete support - MBEDTLS_SSL_SERVER_NAME_INDICATION no - MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH no - - MBEDTLS_ECP_RESTARTABLE no - MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED no - - MBEDTLS_KEY_EXCHANGE_PSK_ENABLED n/a Make sense in TLS 1.3 - MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED n/a context but their current - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED n/a definition is TLS 1.2 only. - MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED n/a - MBEDTLS_KEY_EXCHANGE_RSA_ENABLED n/a - MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED n/a - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED n/a - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED n/a - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED n/a - MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED n/a - MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED n/a - - MBEDTLS_USE_PSA_CRYPTO no + (1) Some support has already been upstreamed but it is incomplete. + (2) Make sense in TLS 1.3 context but their current definition is TLS 1.2 only. Not in the plan yet but probably necessary for a viable client: - server_name extension From 1fa5088c0b6c82dca3438584a0bc33ecccf7a233 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 12:06:52 +0200 Subject: [PATCH 594/966] Improve comment about PSK TLS 1.3 configuration options Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 1eef961a80..ee4e5fb592 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -163,7 +163,10 @@ the handshake with an handshake_failure closure alert. | MBEDTLS_USE_PSA_CRYPTO | no | (1) Some support has already been upstreamed but it is incomplete. - (2) Make sense in TLS 1.3 context but their current definition is TLS 1.2 only. + (2) Key exchange configuration options for TLS 1.3 will likely to be + organized around the notion of key exchange mode along the line + of the MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_NONE/PSK/PSK_EPHEMERAL/EPHEMERAL + runtime configuration macros. Not in the plan yet but probably necessary for a viable client: - server_name extension From 004df8ad5f8ffb724493d88be8e987efcdf8fb59 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 12:12:00 +0200 Subject: [PATCH 595/966] Improve comment about handshake failure with HRR and CertificateRequest Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index ee4e5fb592..9f6d0e48c5 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -74,7 +74,9 @@ MVP definition The TLS 1.3 MVP implements only the client side of the protocol. The TLS 1.3 MVP does not support the handling of server HelloRetryRequest and CertificateRequest messages. If it receives one of those messages, it aborts -the handshake with an handshake_failure closure alert. +the handshake with an handshake_failure closure alert and the +`mbedtls_ssl_handshake()` returns in error with the +`MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE` error code. - Supported cipher suites: depends on the library configuration. Potentially all of them: From 85e51083d8b6b4a6968235d57713b9af98a150ea Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 12:13:16 +0200 Subject: [PATCH 596/966] Add support for server_name extension Section 9.2 of the specification defines server_name extension as mandatory if not specified otherwise by an application profile. Thus add its support to the MVP scope. Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 9f6d0e48c5..29cda88dc2 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -87,7 +87,7 @@ the handshake with an handshake_failure closure alert and the | Extension | MVP | Prototype (1) | | ---------------------------- | ------- | ------------- | - | server_name | no | YES | + | server_name | YES | YES | | max_fragment_length | no | YES | | status_request | no | no | | supported_groups | YES | YES | From 3160d700498bd88f29444ba621e103b7784547e0 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 13:27:21 +0200 Subject: [PATCH 597/966] Add comments about key_share and supported_versions support Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 29cda88dc2..dce999fb45 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -99,18 +99,31 @@ the handshake with an handshake_failure closure alert and the | client_certificate_type | no | no | | server_certificate_type | no | no | | padding | no | no | - | key_share | YES | YES | + | key_share | YES (2) | YES | | pre_shared_key | no | YES | | psk_key_exchange_modes | no | YES | | early_data | no | YES | | cookie | no | YES | - | supported_versions | YES | YES | + | supported_versions | YES (3) | YES | | certificate_authorities | no | no | | post_handshake_auth | no | no | | signature_algorithms_cert | no | no | (1) This is just for comparison. + (2) The MVP sends one shared secret corresponding to the configured preferred + group. The preferred group is the group of the first curve in the list of + allowed curves as defined by the configuration. By default, it is the + mandatory group as defined by section 9.1 of the specification, + `secp256r1`. The list of allowed curves can be set through the + `mbedtls_ssl_conf_curves()` API. + + (3) The MVP proposes only TLS 1.3 and does not support version negociation. + Out-of-protocol fallback is supported though if the Mbed TLS library + has been built to support both TLS 1.3 and TLS 1.2: just set the + maximum of the minor version of the SSL configuration to + MBEDTLS_SSL_MINOR_VERSION_3 (`mbedtls_ssl_conf_min_version()` API) and + re-initiate a server handshake. - Supported groups: depends on the library configuration. Potentially all ECDHE groups: @@ -121,8 +134,6 @@ the handshake with an handshake_failure closure alert and the ecdsa_secp256r1_sha256, ecdsa_secp384r1_sha384, ecdsa_secp521r1_sha512, rsa_pss_rsae_sha256. -- Supported versions: only TLS 1.3 - - Support of Mbed TLS SSL/TLS related (not DTLS) features: The TLS 1.3 MVP is compatible with all TLS 1.2 configuration options in the From c3b510f096a3d88137ffdb8ab38a1ad8bcd3ad49 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 13:36:33 +0200 Subject: [PATCH 598/966] Amend supported groups and signatures based on spec 9.1 section Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index dce999fb45..ed2b38f4fe 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -126,13 +126,22 @@ the handshake with an handshake_failure closure alert and the re-initiate a server handshake. - Supported groups: depends on the library configuration. - Potentially all ECDHE groups: - secp256r1, secp384r1, secp521r1(0x0019), x25519, x448. + Minimally (as defined in section 9.1 of the TLS 1.3 specification): + secp256r1 and x25519. -- Supported signature algorithms: depends on the library configuration. - Potentially: - ecdsa_secp256r1_sha256, ecdsa_secp384r1_sha384, ecdsa_secp521r1_sha512, - rsa_pss_rsae_sha256. + Furthermore, depending on the library configuration, potentially: + secp384r1 and secp521r1. + + Finite field groups (DHE) are not supported. + +- Supported signature algorithms(both for certificates and CertificateVerify): + Minimally (as defined in section 9.1 of the TLS 1.3 specification): + rsa_pkcs1_sha256, rsa_pss_rsae_sha256 and ecdsa_secp256r1_sha256 + + Furthermore, depending on the library configuration, potentially: + ecdsa_secp384r1_sha384 and ecdsa_secp521r1_sha512 + +- Supported versions: only TLS 1.3, version negotiation is not supported. - Support of Mbed TLS SSL/TLS related (not DTLS) features: From 7a7032a4bacb38f772e7b153c77d1f636d9ef8b3 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 13:38:46 +0200 Subject: [PATCH 599/966] Remove out of MVP scope items Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index ed2b38f4fe..c3c181e0a8 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -190,11 +190,6 @@ the handshake with an handshake_failure closure alert and the of the MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_NONE/PSK/PSK_EPHEMERAL/EPHEMERAL runtime configuration macros. -Not in the plan yet but probably necessary for a viable client: -- server_name extension -- support for HelloRetryRequest -- fallback to TLS 1.2 - Coding rules checklist for TLS 1.3 ---------------------------------- From 660c723b098090b69a050795d6c60c87df35e860 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 13:40:53 +0200 Subject: [PATCH 600/966] Add paragraph about expected quality Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index c3c181e0a8..f7e3043f4f 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -190,6 +190,17 @@ the handshake with an handshake_failure closure alert and the of the MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_NONE/PSK/PSK_EPHEMERAL/EPHEMERAL runtime configuration macros. +- Quality considerations + - Standard Mbed TLS review bar + - Interoperability testing with OpenSSL and GnuTLS. Test with all the + cipher suites supported by OpenSSL/GnuTLS server with and without + certificate base authentication. + - Negative testing against OpenSSL/GnuTLS servers with which the + handshake fails due to imcompatibility with the capabilities of the + MVP: TLS 1.2 or 1.1 server, server sending an HelloRetryRequest message in + response to the MVP ClientHello, server sending a CertificateRequest + message ... + Coding rules checklist for TLS 1.3 ---------------------------------- From 72064b30cf714ba9e1c3dcabea13554b4b49f221 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 13:54:28 +0200 Subject: [PATCH 601/966] Fix usage of backticks Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 44 +++++++++++++++---------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index f7e3043f4f..e63fbbc0ac 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -222,15 +222,15 @@ TLS 1.3 specific coding rules: - The names of macros and variables related to a field or structure in the TLS 1.3 specification should contain as far as possible the field name as - it is in the specification. If the field name is `too long` and we prefer + it is in the specification. If the field name is "too long" and we prefer to introduce some kind of abbreviation of it, use the same abbreviation everywhere in the code. Example 1: #define CLIENT_HELLO_RANDOM_LEN 32, macro for the length of the `random` field of the ClientHello message. - Example 2 (consistent abbreviation): mbedtls_ssl_tls1_3_write_sig_alg_ext() - and MBEDTLS_TLS_EXT_SIG_ALG, `sig_alg` standing for + Example 2 (consistent abbreviation): `mbedtls_ssl_tls1_3_write_sig_alg_ext()` + and `MBEDTLS_TLS_EXT_SIG_ALG`, `sig_alg` standing for `signature_algorithms`. - Regarding vectors that are represented by a length followed by their value @@ -254,11 +254,12 @@ TLS 1.3 specific coding rules: issues. Example: `cipher_suites` vector of ClientHello in - ssl_tls1_3_write_client_hello_cipher_suites() - - size_t cipher_suites_len; - unsigned char *cipher_suites_len_ptr; - unsigned char *cipher_suites_ptr; + `ssl_tls1_3_write_client_hello_cipher_suites()` + ``` + size_t cipher_suites_len; + unsigned char *cipher_suites_len_ptr; + unsigned char *cipher_suites_ptr; + ``` - Use of MBEDTLS_BYTE_xyz, MBEDTLS_PUT/GET_xyz, MBEDTLS_SSL_CHK_BUF_PTR MBEDTLS_SSL_CHK_BUF_READ_PTR macros where applicable. @@ -272,16 +273,19 @@ TLS 1.3 specific coding rules: bytes in the wrong order: we should probably have only MBEDTLS_GET/PUT_*_BE (BE stands for Big-Endian) macros in the TLS 1.3 code. - The two last types, MBEDTLS_SSL_CHK_BUF_PTR and - MBEDTLS_SSL_CHK_BUF_READ_PTR, improve the readability of the code and + The two last types, `MBEDTLS_SSL_CHK_BUF_PTR` and + `MBEDTLS_SSL_CHK_BUF_READ_PTR`, improve the readability of the code and reduce the risk of error in the non-completely-trivial arithmetic to check that we do not write or read past the end of a data buffer. The usage of those macros combined with the following rule mitigate the risk to read/write past the end of a data buffer. - Examples: hs_hdr[1] = MBEDTLS_BYTE_2( total_hs_len ); - MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 ); - MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); + Examples: + ``` + hs_hdr[1] = MBEDTLS_BYTE_2( total_hs_len ); + MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 ); + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); + ``` - To mitigate what happened here (https://github.com/ARMmbed/mbedtls/pull/4882#discussion_r701704527) from @@ -296,33 +300,35 @@ TLS 1.3 specific coding rules: General coding rules: - - We prefer grouping `related statement lines` by not adding blank lines + - We prefer grouping "related statement lines" by not adding blank lines between them. Example 1: - + ``` ret = ssl_tls13_write_client_hello_cipher_suites( ssl, buf, end, &output_len ); if( ret != 0 ) return( ret ); buf += output_len; + ``` Example 2: - + ``` MBEDTLS_SSL_CHK_BUF_PTR( cipher_suites_iter, end, 2 ); MBEDTLS_PUT_UINT16_BE( cipher_suite, cipher_suites_iter, 0 ); cipher_suites_iter += 2; + ``` - Use macros for constants that are used in different functions, different places in the code. When a constant is used only locally in a function (like the length in bytes of the vector lengths in functions reading and writing TLS handshake message) there is no need to define a macro for it. - Example: #define CLIENT_HELLO_RANDOM_LEN 32 + Example: `#define CLIENT_HELLO_RANDOM_LEN 32` - When declaring a pointer the dereferencing operator should be prepended to the pointer name not appended to the pointer type: - Example: mbedtls_ssl_context *ssl; + Example: `mbedtls_ssl_context *ssl;` - Maximum line length is 80 characters. @@ -340,7 +346,9 @@ General coding rules: vertically. Example: + ``` int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, size_t *buf_len ); + ``` From b194466e99c9530359b8b64f28f999b4dcca03dd Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 13:56:46 +0200 Subject: [PATCH 602/966] Amend TLS 1.3 prefix Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index e63fbbc0ac..defba776a7 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -214,11 +214,13 @@ PR upstreaming the first part of TLS 1.3 ClientHello writing code. TLS 1.3 specific coding rules: - TLS 1.3 specific C modules, headers, static functions names are prefixed - with `ssl_tls1_3_`. The same applies to structures and types that are + with `ssl_tls13_`. The same applies to structures and types that are internal to C modules. - - TLS 1.3 specific exported functions, macros, structures and types are - prefixed with `mbedtls_ssl_tls1_3_`. + - TLS 1.3 specific exported functions, structures and types are + prefixed with `mbedtls_ssl_tls13_`. + + - Use TLS1_3 in TLS 1.3 specific macros. - The names of macros and variables related to a field or structure in the TLS 1.3 specification should contain as far as possible the field name as From 99733f05111f1fd59655e5c0d0933353d37c3c4e Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 13:58:21 +0200 Subject: [PATCH 603/966] Amend vector variables Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index defba776a7..ca97a251cf 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -242,25 +242,24 @@ TLS 1.3 specific coding rules: length in bytes of the vector, where is the name of the vector as defined in the TLS 1.3 specification. - - Use `_len_ptr` for the name of a variable intended to hold + - Use `p__len` for the name of a variable intended to hold the address of the first byte of the vector length. - - Use `_ptr` for the name of a variable intended to hold the + - Use `` for the name of a variable intended to hold the address of the first byte of the vector value. - - Use `_end_ptr` for the name of a variable intended to hold + - Use `_end` for the name of a variable intended to hold the address of the first byte past the vector value. - Those two last idioms should lower the risk of mis-using one of the address - in place of the other one which could potentially lead to some nasty - issues. + Those idioms should lower the risk of mis-using one of the address in place + of another one which could potentially lead to some nasty issues. Example: `cipher_suites` vector of ClientHello in `ssl_tls1_3_write_client_hello_cipher_suites()` ``` size_t cipher_suites_len; - unsigned char *cipher_suites_len_ptr; - unsigned char *cipher_suites_ptr; + unsigned char *p_cipher_suites_len; + unsigned char *cipher_suites; ``` - Use of MBEDTLS_BYTE_xyz, MBEDTLS_PUT/GET_xyz, MBEDTLS_SSL_CHK_BUF_PTR From fecda8ddb417f1479a88843ed934e6ad2f3ae696 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 13:59:38 +0200 Subject: [PATCH 604/966] Improve the description of common macros usage Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index ca97a251cf..1b6f5355b1 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -262,17 +262,24 @@ TLS 1.3 specific coding rules: unsigned char *cipher_suites; ``` - - Use of MBEDTLS_BYTE_xyz, MBEDTLS_PUT/GET_xyz, MBEDTLS_SSL_CHK_BUF_PTR - MBEDTLS_SSL_CHK_BUF_READ_PTR macros where applicable. + - Where applicable, use: + - the macros to extract a byte from a multi-byte integer MBEDTLS_BYTE_{0-8}. + - the macros to write in memory in big-endian order a multi-byte integer + MBEDTLS_PUT_UINT{8|16|32|64}_BE. + - the macros to read from memory a multi-byte integer in big-endian order + MBEDTLS_GET_UINT{8|16|32|64}_BE. + - the macro to check for space when writing into an output buffer + `MBEDTLS_SSL_CHK_BUF_PTR`. + - the macro to check for data when reading from an input buffer + `MBEDTLS_SSL_CHK_BUF_READ_PTR`. These macros were introduced after the prototype was written thus are likely not to be used in prototype where we now would use them in development. - The two first types, MBEDTLS_BYTE_xyz and MBEDTLS_PUT/GET_xyz, improve - the readability of the code and reduce the risk of writing or reading - bytes in the wrong order: we should probably have only MBEDTLS_GET/PUT_*_BE - (BE stands for Big-Endian) macros in the TLS 1.3 code. + The three first types, MBEDTLS_BYTE_{0-8}, MBEDTLS_PUT_UINT{8|16|32|64}_BE + and MBEDTLS_GET_UINT{8|16|32|64}_BE improve the readability of the code and + reduce the risk of writing or reading bytes in the wrong order. The two last types, `MBEDTLS_SSL_CHK_BUF_PTR` and `MBEDTLS_SSL_CHK_BUF_READ_PTR`, improve the readability of the code and From 3e7c4036b4dc9b51578a81d919885d0a866a038f Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 14:22:38 +0200 Subject: [PATCH 605/966] Miscellaneous improvements Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 1b6f5355b1..314928fe8d 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -143,7 +143,7 @@ the handshake with an handshake_failure closure alert and the - Supported versions: only TLS 1.3, version negotiation is not supported. -- Support of Mbed TLS SSL/TLS related (not DTLS) features: +- Compatibility with existing SSL/TLS build options: The TLS 1.3 MVP is compatible with all TLS 1.2 configuration options in the sense that when enabling the TLS 1.3 MVP in the library there is no need to @@ -299,8 +299,8 @@ TLS 1.3 specific coding rules: (https://github.com/ARMmbed/mbedtls/pull/4882#discussion_r701704527) from happening again, use always a local variable named `p` for the reading pointer in functions parsing TLS 1.3 data, and for the writing pointer in - functions writing data into an output buffer. The name `p` has been - chosen as it was already widely used in TLS code. + functions writing data into an output buffer and only that variable. The + name `p` has been chosen as it was already widely used in TLS code. - When an TLS 1.3 structure is written or read by a function or as part of a function, provide as documentation the definition of the structure as From 847c3580b8e2f25e724395e748914c8b024237b6 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 14:24:43 +0200 Subject: [PATCH 606/966] Expend coding rules Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 314928fe8d..481caef93b 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -350,6 +350,11 @@ General coding rules: example it is generally fine if some closure characters like ";" or ")" are beyond the 80 characters limit. + If a line becomes too long due to a refactoring (for example renaming a + function to a longer name, or indenting a block more), avoid rewrapping + lines in the same commit: it makes the review harder. Make one commit with + the longer lines and another commit with just the rewrapping. + - When in successive lines, functions and macros parameters should be aligned vertically. @@ -360,3 +365,19 @@ General coding rules: unsigned char **buf, size_t *buf_len ); ``` + + - When a function's parameters span several lines, group related parameters + together if possible. + + For example, prefer: + + ``` + mbedtls_ssl_tls13_start_handshake_msg( ssl, hs_type, + buf, buf_len ); + ``` + over + ``` + mbedtls_ssl_tls13_start_handshake_msg( ssl, hs_type, buf, + buf_len ); + ``` + even if it fits. From f164b6a7ff940ff0501ce06045a97f96146d3d55 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 27 Sep 2021 15:36:29 +0200 Subject: [PATCH 607/966] Add an overview section Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 34 ++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 481caef93b..5421492aee 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -71,12 +71,34 @@ together with their level of testing: MVP definition -------------- -The TLS 1.3 MVP implements only the client side of the protocol. -The TLS 1.3 MVP does not support the handling of server HelloRetryRequest and -CertificateRequest messages. If it receives one of those messages, it aborts -the handshake with an handshake_failure closure alert and the -`mbedtls_ssl_handshake()` returns in error with the -`MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE` error code. +- Overview + + - The TLS 1.3 MVP implements only the client side of the protocol. + + - The TLS 1.3 MVP supports ECDHE key establishment. + + - The TLS 1.3 MVP does not support DHE key establishment. + + - The TLS 1.3 MVP does not support pre-shared keys, including any form of + session resumption. This implies that it does not support sending early + data (0-RTT data). + + - The TLS 1.3 MVP supports the authentication of the server by the client + but does not support authentication of the client by the server. In terms + of TLS 1.3 authentication messages, this means that the TLS 1.3 MVP + supports the processing of the Certificate and CertificateVerify messages + but not of the CertificateRequest message. + + - The TLS 1.3 MVP does not support the handling of server HelloRetryRequest + message. In practice, this means that the handshake will fail if the MVP + does not provide in its ClientHello the shared secret associated to the + group selected by the server for key establishement. For more information, + see the comment associated to the `key_share` extension below. + + - If the TLS 1.3 MVP receives a HelloRetryRequest or a CertificateRequest + message, it aborts the handshake with an handshake_failure closure alert + and the `mbedtls_ssl_handshake()` returns in error with the + `MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE` error code. - Supported cipher suites: depends on the library configuration. Potentially all of them: From 4b627af36c67f1cecf740035b17abbf0d01f9990 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 7 Jul 2021 21:02:36 +0200 Subject: [PATCH 608/966] New macro MBEDTLS_CHECK_RETURN Put this macro before a function declaration to indicate that its result must be checked. This commit supports GCC-like compilers and MSVC >=2012. Signed-off-by: Gilles Peskine --- include/mbedtls/build_info.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/mbedtls/build_info.h b/include/mbedtls/build_info.h index 23f85ba01e..46717608be 100644 --- a/include/mbedtls/build_info.h +++ b/include/mbedtls/build_info.h @@ -53,6 +53,24 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #endif +/** \def MBEDTLS_CHECK_RETURN + * + * This macro appearing at the beginning of the declaration of a function + * indicates that its return value should be checked. + * + * This should appear before most functions returning an error code + * (as \c int in the \c mbedtls_xxx API or + * as ::psa_status_t in the \c psa_xxx API). + */ +#if defined(__GNUC__) +#define MBEDTLS_CHECK_RETURN __attribute__((warn_unused_result)) +#elif defined(_MSC_VER) && _MSC_VER >= 1700 +#include +#define MBEDTLS_CHECK_RETURN _Check_return_ +#else +#define MBEDTLS_CHECK_RETURN +#endif + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/mbedtls_config.h" #else From 7820a574f158deaa2110f8718704c99d295c0b12 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 7 Jul 2021 21:08:28 +0200 Subject: [PATCH 609/966] Catch failures of AES or DES operations Declare all AES and DES functions that return int as needing to have their result checked, and do check the result in our code. A DES or AES block operation can fail in alternative implementations of mbedtls_internal_aes_encrypt() (under MBEDTLS_AES_ENCRYPT_ALT), mbedtls_internal_aes_decrypt() (under MBEDTLS_AES_DECRYPT_ALT), mbedtls_des_crypt_ecb() (under MBEDTLS_DES_CRYPT_ECB_ALT), mbedtls_des3_crypt_ecb() (under MBEDTLS_DES3_CRYPT_ECB_ALT). A failure can happen if the accelerator peripheral is in a bad state. Several block modes were not catching the error. This commit does the following code changes, grouped together to avoid having an intermediate commit where the build fails: * Add MBEDTLS_CHECK_RETURN to all functions returning int in aes.h and des.h. * Fix all places where this causes a GCC warning, indicating that our code was not properly checking the result of an AES operation: * In library code: on failure, goto exit and return ret. * In pkey programs: goto exit. * In the benchmark program: exit (not ideal since there's no error message, but it's what the code currently does for failures). * In test code: TEST_ASSERT. * Changelog entry. Signed-off-by: Gilles Peskine --- check-return.txt | 12 +++++ include/mbedtls/aes.h | 14 ++++++ include/mbedtls/des.h | 13 +++++ library/aes.c | 48 ++++++++++++++---- library/des.c | 75 +++++++++++++++++++--------- programs/pkey/dh_client.c | 8 ++- programs/pkey/dh_server.c | 8 ++- programs/test/benchmark.c | 10 ++-- tests/suites/test_suite_aes.function | 12 ++--- tests/suites/test_suite_des.function | 24 ++++----- 10 files changed, 164 insertions(+), 60 deletions(-) create mode 100644 check-return.txt diff --git a/check-return.txt b/check-return.txt new file mode 100644 index 0000000000..e6371ec69b --- /dev/null +++ b/check-return.txt @@ -0,0 +1,12 @@ +Bugfix + * Failures of alternative implementations of AES or DES single-block + functions enabled with MBEDTLS_AES_ENCRYPT_ALT, MBEDTLS_AES_DECRYPT_ALT, + MBEDTLS_DES_CRYPT_ECB_ALT or MBEDTLS_DES3_CRYPT_ECB_ALT were ignored. + This does not concern the implementation provided with Mbed TLS, + where this function cannot fail, or full-module replacements with + MBEDTLS_AES_ALT or MBEDTLS_DES_ALT. Reported by Armelle Duboc in #1092. + +Changes + * Warn if errors from AES or DES functions are ignored. This is currently + supported on GCC-like compilers and on MSVC and can be configured by + setting MBEDTLS_CHECK_RETURN in mbedtls_config.h. diff --git a/include/mbedtls/aes.h b/include/mbedtls/aes.h index 879c3f2a14..eb75935c1f 100644 --- a/include/mbedtls/aes.h +++ b/include/mbedtls/aes.h @@ -163,6 +163,7 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ); * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -181,6 +182,7 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -201,6 +203,7 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -221,6 +224,7 @@ int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -249,6 +253,7 @@ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, * \return \c 0 on success. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, int mode, const unsigned char input[16], @@ -296,6 +301,7 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH * on failure. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, int mode, size_t length, @@ -340,6 +346,7 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, * smaller than an AES block in size (16 Bytes) or if \p * length is larger than 2^20 blocks (16 MiB). */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, int mode, size_t length, @@ -388,6 +395,7 @@ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, * * \return \c 0 on success. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, int mode, size_t length, @@ -432,6 +440,7 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, int mode, size_t length, @@ -486,6 +495,7 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, size_t length, size_t *iv_off, @@ -572,6 +582,7 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, size_t length, size_t *nc_off, @@ -592,6 +603,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ +MBEDTLS_CHECK_RETURN int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ); @@ -607,6 +619,7 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ +MBEDTLS_CHECK_RETURN int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ); @@ -618,6 +631,7 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, * \return \c 0 on success. * \return \c 1 on failure. */ +MBEDTLS_CHECK_RETURN int mbedtls_aes_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ diff --git a/include/mbedtls/des.h b/include/mbedtls/des.h index 63a8e00d1c..7bd618c276 100644 --- a/include/mbedtls/des.h +++ b/include/mbedtls/des.h @@ -139,6 +139,7 @@ void mbedtls_des_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] ); * security risk. We recommend considering stronger ciphers * instead. */ +MBEDTLS_CHECK_RETURN int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** @@ -152,6 +153,7 @@ int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SI * security risk. We recommend considering stronger ciphers * instead. */ +MBEDTLS_CHECK_RETURN int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** @@ -166,6 +168,7 @@ int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); * security risk. We recommend considering stronger ciphers * instead. */ +MBEDTLS_CHECK_RETURN int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** @@ -180,6 +183,7 @@ int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MB * security risk. We recommend considering stronger ciphers * instead. */ +MBEDTLS_CHECK_RETURN int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** @@ -190,6 +194,7 @@ int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MB * * \return 0 */ +MBEDTLS_CHECK_RETURN int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); @@ -201,6 +206,7 @@ int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx, * * \return 0 */ +MBEDTLS_CHECK_RETURN int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); @@ -212,6 +218,7 @@ int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx, * * \return 0 */ +MBEDTLS_CHECK_RETURN int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); @@ -223,6 +230,7 @@ int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx, * * \return 0 */ +MBEDTLS_CHECK_RETURN int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); @@ -239,6 +247,7 @@ int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx, * security risk. We recommend considering stronger ciphers * instead. */ +MBEDTLS_CHECK_RETURN int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, const unsigned char input[8], unsigned char output[8] ); @@ -266,6 +275,7 @@ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, * security risk. We recommend considering stronger ciphers * instead. */ +MBEDTLS_CHECK_RETURN int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, int mode, size_t length, @@ -283,6 +293,7 @@ int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, * * \return 0 if successful */ +MBEDTLS_CHECK_RETURN int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, const unsigned char input[8], unsigned char output[8] ); @@ -308,6 +319,7 @@ int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, * * \return 0 if successful, or MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH */ +MBEDTLS_CHECK_RETURN int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, int mode, size_t length, @@ -338,6 +350,7 @@ void mbedtls_des_setkey( uint32_t SK[32], * * \return 0 if successful, or 1 if the test failed */ +MBEDTLS_CHECK_RETURN int mbedtls_des_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ diff --git a/library/aes.c b/library/aes.c index 8e3358c494..4afc3c48ae 100644 --- a/library/aes.c +++ b/library/aes.c @@ -1011,6 +1011,7 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, unsigned char *output ) { int i; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char temp[16]; AES_VALIDATE_RET( ctx != NULL ); @@ -1040,7 +1041,9 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, while( length > 0 ) { memcpy( temp, input, 16 ); - mbedtls_aes_crypt_ecb( ctx, mode, input, output ); + ret = mbedtls_aes_crypt_ecb( ctx, mode, input, output ); + if( ret != 0 ) + goto exit; for( i = 0; i < 16; i++ ) output[i] = (unsigned char)( output[i] ^ iv[i] ); @@ -1059,7 +1062,9 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, for( i = 0; i < 16; i++ ) output[i] = (unsigned char)( input[i] ^ iv[i] ); - mbedtls_aes_crypt_ecb( ctx, mode, output, output ); + ret = mbedtls_aes_crypt_ecb( ctx, mode, output, output ); + if( ret != 0 ) + goto exit; memcpy( iv, output, 16 ); input += 16; @@ -1067,8 +1072,10 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, length -= 16; } } + ret = 0; - return( 0 ); +exit: + return( ret ); } #endif /* MBEDTLS_CIPHER_MODE_CBC */ @@ -1222,6 +1229,7 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, unsigned char *output ) { int c; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; size_t n; AES_VALIDATE_RET( ctx != NULL ); @@ -1242,7 +1250,11 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, while( length-- ) { if( n == 0 ) - mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + { + ret = mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + if( ret != 0 ) + goto exit; + } c = *input++; *output++ = (unsigned char)( c ^ iv[n] ); @@ -1256,7 +1268,11 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, while( length-- ) { if( n == 0 ) - mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + { + ret = mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + if( ret != 0 ) + goto exit; + } iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ ); @@ -1265,8 +1281,10 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, } *iv_off = n; + ret = 0; - return( 0 ); +exit: + return( ret ); } /* @@ -1279,6 +1297,7 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, const unsigned char *input, unsigned char *output ) { + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char c; unsigned char ov[17]; @@ -1291,7 +1310,9 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, while( length-- ) { memcpy( ov, iv, 16 ); - mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + ret = mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + if( ret != 0 ) + goto exit; if( mode == MBEDTLS_AES_DECRYPT ) ov[16] = *input; @@ -1303,8 +1324,10 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, memcpy( iv, ov + 1, 16 ); } + ret = 0; - return( 0 ); +exit: + return( ret ); } #endif /* MBEDTLS_CIPHER_MODE_CFB */ @@ -1366,6 +1389,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, unsigned char *output ) { int c, i; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; size_t n; AES_VALIDATE_RET( ctx != NULL ); @@ -1383,7 +1407,9 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, while( length-- ) { if( n == 0 ) { - mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, nonce_counter, stream_block ); + ret = mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, nonce_counter, stream_block ); + if( ret != 0 ) + goto exit; for( i = 16; i > 0; i-- ) if( ++nonce_counter[i - 1] != 0 ) @@ -1396,8 +1422,10 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, } *nc_off = n; + ret = 0; - return( 0 ); +exit: + return( ret ); } #endif /* MBEDTLS_CIPHER_MODE_CTR */ diff --git a/library/des.c b/library/des.c index 7f90faa044..91d22b5d90 100644 --- a/library/des.c +++ b/library/des.c @@ -28,6 +28,7 @@ #if defined(MBEDTLS_DES_C) #include "mbedtls/des.h" +#include "mbedtls/error.h" #include "mbedtls/platform_util.h" #include @@ -642,6 +643,7 @@ int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, unsigned char *output ) { int i; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char temp[8]; if( length % 8 ) @@ -654,7 +656,9 @@ int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( input[i] ^ iv[i] ); - mbedtls_des_crypt_ecb( ctx, output, output ); + ret = mbedtls_des_crypt_ecb( ctx, output, output ); + if( ret != 0 ) + goto exit; memcpy( iv, output, 8 ); input += 8; @@ -667,7 +671,9 @@ int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, while( length > 0 ) { memcpy( temp, input, 8 ); - mbedtls_des_crypt_ecb( ctx, input, output ); + ret = mbedtls_des_crypt_ecb( ctx, input, output ); + if( ret != 0 ) + goto exit; for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( output[i] ^ iv[i] ); @@ -679,8 +685,10 @@ int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, length -= 8; } } + ret = 0; - return( 0 ); +exit: + return( ret ); } #endif /* MBEDTLS_CIPHER_MODE_CBC */ @@ -741,6 +749,7 @@ int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, unsigned char *output ) { int i; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char temp[8]; if( length % 8 ) @@ -753,7 +762,9 @@ int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( input[i] ^ iv[i] ); - mbedtls_des3_crypt_ecb( ctx, output, output ); + ret = mbedtls_des3_crypt_ecb( ctx, output, output ); + if( ret != 0 ) + goto exit; memcpy( iv, output, 8 ); input += 8; @@ -766,7 +777,9 @@ int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, while( length > 0 ) { memcpy( temp, input, 8 ); - mbedtls_des3_crypt_ecb( ctx, input, output ); + ret = mbedtls_des3_crypt_ecb( ctx, input, output ); + if( ret != 0 ) + goto exit; for( i = 0; i < 8; i++ ) output[i] = (unsigned char)( output[i] ^ iv[i] ); @@ -778,8 +791,10 @@ int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, length -= 8; } } + ret = 0; - return( 0 ); +exit: + return( ret ); } #endif /* MBEDTLS_CIPHER_MODE_CBC */ @@ -872,39 +887,43 @@ int mbedtls_des_self_test( int verbose ) switch( i ) { case 0: - mbedtls_des_setkey_dec( &ctx, des3_test_keys ); + ret = mbedtls_des_setkey_dec( &ctx, des3_test_keys ); break; case 1: - mbedtls_des_setkey_enc( &ctx, des3_test_keys ); + ret = mbedtls_des_setkey_enc( &ctx, des3_test_keys ); break; case 2: - mbedtls_des3_set2key_dec( &ctx3, des3_test_keys ); + ret = mbedtls_des3_set2key_dec( &ctx3, des3_test_keys ); break; case 3: - mbedtls_des3_set2key_enc( &ctx3, des3_test_keys ); + ret = mbedtls_des3_set2key_enc( &ctx3, des3_test_keys ); break; case 4: - mbedtls_des3_set3key_dec( &ctx3, des3_test_keys ); + ret = mbedtls_des3_set3key_dec( &ctx3, des3_test_keys ); break; case 5: - mbedtls_des3_set3key_enc( &ctx3, des3_test_keys ); + ret = mbedtls_des3_set3key_enc( &ctx3, des3_test_keys ); break; default: return( 1 ); } + if( ret != 0 ) + goto exit; for( j = 0; j < 100; j++ ) { if( u == 0 ) - mbedtls_des_crypt_ecb( &ctx, buf, buf ); + ret = mbedtls_des_crypt_ecb( &ctx, buf, buf ); else - mbedtls_des3_crypt_ecb( &ctx3, buf, buf ); + ret = mbedtls_des3_crypt_ecb( &ctx3, buf, buf ); + if( ret != 0 ) + goto exit; } if( ( v == MBEDTLS_DES_DECRYPT && @@ -947,41 +966,45 @@ int mbedtls_des_self_test( int verbose ) switch( i ) { case 0: - mbedtls_des_setkey_dec( &ctx, des3_test_keys ); + ret = mbedtls_des_setkey_dec( &ctx, des3_test_keys ); break; case 1: - mbedtls_des_setkey_enc( &ctx, des3_test_keys ); + ret = mbedtls_des_setkey_enc( &ctx, des3_test_keys ); break; case 2: - mbedtls_des3_set2key_dec( &ctx3, des3_test_keys ); + ret = mbedtls_des3_set2key_dec( &ctx3, des3_test_keys ); break; case 3: - mbedtls_des3_set2key_enc( &ctx3, des3_test_keys ); + ret = mbedtls_des3_set2key_enc( &ctx3, des3_test_keys ); break; case 4: - mbedtls_des3_set3key_dec( &ctx3, des3_test_keys ); + ret = mbedtls_des3_set3key_dec( &ctx3, des3_test_keys ); break; case 5: - mbedtls_des3_set3key_enc( &ctx3, des3_test_keys ); + ret = mbedtls_des3_set3key_enc( &ctx3, des3_test_keys ); break; default: return( 1 ); } + if( ret != 0 ) + goto exit; if( v == MBEDTLS_DES_DECRYPT ) { for( j = 0; j < 100; j++ ) { if( u == 0 ) - mbedtls_des_crypt_cbc( &ctx, v, 8, iv, buf, buf ); + ret = mbedtls_des_crypt_cbc( &ctx, v, 8, iv, buf, buf ); else - mbedtls_des3_crypt_cbc( &ctx3, v, 8, iv, buf, buf ); + ret = mbedtls_des3_crypt_cbc( &ctx3, v, 8, iv, buf, buf ); + if( ret != 0 ) + goto exit; } } else @@ -991,9 +1014,11 @@ int mbedtls_des_self_test( int verbose ) unsigned char tmp[8]; if( u == 0 ) - mbedtls_des_crypt_cbc( &ctx, v, 8, iv, buf, buf ); + ret = mbedtls_des_crypt_cbc( &ctx, v, 8, iv, buf, buf ); else - mbedtls_des3_crypt_cbc( &ctx3, v, 8, iv, buf, buf ); + ret = mbedtls_des3_crypt_cbc( &ctx3, v, 8, iv, buf, buf ); + if( ret != 0 ) + goto exit; memcpy( tmp, prv, 8 ); memcpy( prv, buf, 8 ); @@ -1027,6 +1052,8 @@ exit: mbedtls_des_free( &ctx ); mbedtls_des3_free( &ctx3 ); + if( ret != 0 ) + ret = 1; return( ret ); } diff --git a/programs/pkey/dh_client.c b/programs/pkey/dh_client.c index eccb42ad83..d633e4d1b8 100644 --- a/programs/pkey/dh_client.c +++ b/programs/pkey/dh_client.c @@ -270,7 +270,9 @@ int main( void ) mbedtls_printf( "...\n . Receiving and decrypting the ciphertext" ); fflush( stdout ); - mbedtls_aes_setkey_dec( &aes, buf, 256 ); + ret = mbedtls_aes_setkey_dec( &aes, buf, 256 ); + if( ret != 0 ) + goto exit; memset( buf, 0, sizeof( buf ) ); @@ -280,7 +282,9 @@ int main( void ) goto exit; } - mbedtls_aes_crypt_ecb( &aes, MBEDTLS_AES_DECRYPT, buf, buf ); + ret = mbedtls_aes_crypt_ecb( &aes, MBEDTLS_AES_DECRYPT, buf, buf ); + if( ret != 0 ) + goto exit; buf[16] = '\0'; mbedtls_printf( "\n . Plaintext is \"%s\"\n\n", (char *) buf ); diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c index 0ddb85cf83..75713ff58d 100644 --- a/programs/pkey/dh_server.c +++ b/programs/pkey/dh_server.c @@ -290,9 +290,13 @@ int main( void ) mbedtls_printf( "...\n . Encrypting and sending the ciphertext" ); fflush( stdout ); - mbedtls_aes_setkey_enc( &aes, buf, 256 ); + ret = mbedtls_aes_setkey_enc( &aes, buf, 256 ); + if( ret != 0 ) + goto exit; memcpy( buf, PLAINTEXT, 16 ); - mbedtls_aes_crypt_ecb( &aes, MBEDTLS_AES_ENCRYPT, buf, buf ); + ret = mbedtls_aes_crypt_ecb( &aes, MBEDTLS_AES_ENCRYPT, buf, buf ); + if( ret != 0 ) + goto exit; if( ( ret = mbedtls_net_send( &client_fd, buf, 16 ) ) != 16 ) { diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c index 5985caf0bb..d3faad91ea 100644 --- a/programs/test/benchmark.c +++ b/programs/test/benchmark.c @@ -674,7 +674,8 @@ int main( int argc, char *argv[] ) { mbedtls_des3_context des3; mbedtls_des3_init( &des3 ); - mbedtls_des3_set3key_enc( &des3, tmp ); + if( mbedtls_des3_set3key_enc( &des3, tmp ) != 0 ) + mbedtls_exit( 1 ); TIME_AND_TSC( "3DES", mbedtls_des3_crypt_cbc( &des3, MBEDTLS_DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); mbedtls_des3_free( &des3 ); @@ -684,7 +685,8 @@ int main( int argc, char *argv[] ) { mbedtls_des_context des; mbedtls_des_init( &des ); - mbedtls_des_setkey_enc( &des, tmp ); + if( mbedtls_des_setkey_enc( &des, tmp ) != 0 ) + mbedtls_exit( 1 ); TIME_AND_TSC( "DES", mbedtls_des_crypt_cbc( &des, MBEDTLS_DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); mbedtls_des_free( &des ); @@ -722,7 +724,7 @@ int main( int argc, char *argv[] ) memset( buf, 0, sizeof( buf ) ); memset( tmp, 0, sizeof( tmp ) ); - mbedtls_aes_setkey_enc( &aes, tmp, keysize ); + CHECK_AND_CONTINUE( mbedtls_aes_setkey_enc( &aes, tmp, keysize ) ); TIME_AND_TSC( title, mbedtls_aes_crypt_cbc( &aes, MBEDTLS_AES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); @@ -743,7 +745,7 @@ int main( int argc, char *argv[] ) memset( buf, 0, sizeof( buf ) ); memset( tmp, 0, sizeof( tmp ) ); - mbedtls_aes_xts_setkey_enc( &ctx, tmp, keysize * 2 ); + CHECK_AND_CONTINUE( mbedtls_aes_xts_setkey_enc( &ctx, tmp, keysize * 2 ) ); TIME_AND_TSC( title, mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, BUFSIZE, diff --git a/tests/suites/test_suite_aes.function b/tests/suites/test_suite_aes.function index 1892c2595a..52af8e02f2 100644 --- a/tests/suites/test_suite_aes.function +++ b/tests/suites/test_suite_aes.function @@ -67,7 +67,7 @@ void aes_encrypt_cbc( data_t * key_str, data_t * iv_str, mbedtls_aes_init( &ctx ); - mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == 0 ); TEST_ASSERT( mbedtls_aes_crypt_cbc( &ctx, MBEDTLS_AES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { @@ -92,7 +92,7 @@ void aes_decrypt_cbc( data_t * key_str, data_t * iv_str, memset(output, 0x00, 100); mbedtls_aes_init( &ctx ); - mbedtls_aes_setkey_dec( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_setkey_dec( &ctx, key_str->x, key_str->len * 8 ) == 0 ); TEST_ASSERT( mbedtls_aes_crypt_cbc( &ctx, MBEDTLS_AES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0) { @@ -241,7 +241,7 @@ void aes_encrypt_cfb128( data_t * key_str, data_t * iv_str, mbedtls_aes_init( &ctx ); - mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == 0 ); TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 ); TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); @@ -263,7 +263,7 @@ void aes_decrypt_cfb128( data_t * key_str, data_t * iv_str, mbedtls_aes_init( &ctx ); - mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == 0 ); TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 ); TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 16, dst->len ) == 0 ); @@ -284,7 +284,7 @@ void aes_encrypt_cfb8( data_t * key_str, data_t * iv_str, mbedtls_aes_init( &ctx ); - mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == 0 ); TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 ); TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, @@ -306,7 +306,7 @@ void aes_decrypt_cfb8( data_t * key_str, data_t * iv_str, mbedtls_aes_init( &ctx ); - mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == 0 ); TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 ); TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, diff --git a/tests/suites/test_suite_des.function b/tests/suites/test_suite_des.function index 5b249355b6..7256fb5376 100644 --- a/tests/suites/test_suite_des.function +++ b/tests/suites/test_suite_des.function @@ -24,7 +24,7 @@ void des_encrypt_ecb( data_t * key_str, data_t * src_str, data_t * dst ) mbedtls_des_init( &ctx ); - mbedtls_des_setkey_enc( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des_setkey_enc( &ctx, key_str->x ) == 0 ); TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str->x, output ) == 0 ); TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); @@ -44,7 +44,7 @@ void des_decrypt_ecb( data_t * key_str, data_t * src_str, data_t * dst ) mbedtls_des_init( &ctx ); - mbedtls_des_setkey_dec( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des_setkey_dec( &ctx, key_str->x ) == 0 ); TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str->x, output ) == 0 ); TEST_ASSERT( mbedtls_test_hexcmp( output, dst->x, 8, dst->len ) == 0 ); @@ -65,7 +65,7 @@ void des_encrypt_cbc( data_t * key_str, data_t * iv_str, mbedtls_des_init( &ctx ); - mbedtls_des_setkey_enc( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des_setkey_enc( &ctx, key_str->x ) == 0 ); TEST_ASSERT( mbedtls_des_crypt_cbc( &ctx, MBEDTLS_DES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { @@ -91,7 +91,7 @@ void des_decrypt_cbc( data_t * key_str, data_t * iv_str, mbedtls_des_init( &ctx ); - mbedtls_des_setkey_dec( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des_setkey_dec( &ctx, key_str->x ) == 0 ); TEST_ASSERT( mbedtls_des_crypt_cbc( &ctx, MBEDTLS_DES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { @@ -117,9 +117,9 @@ void des3_encrypt_ecb( int key_count, data_t * key_str, if( key_count == 2 ) - mbedtls_des3_set2key_enc( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des3_set2key_enc( &ctx, key_str->x ) == 0 ); else if( key_count == 3 ) - mbedtls_des3_set3key_enc( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des3_set3key_enc( &ctx, key_str->x ) == 0 ); else TEST_ASSERT( 0 ); @@ -144,9 +144,9 @@ void des3_decrypt_ecb( int key_count, data_t * key_str, if( key_count == 2 ) - mbedtls_des3_set2key_dec( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des3_set2key_dec( &ctx, key_str->x ) == 0 ); else if( key_count == 3 ) - mbedtls_des3_set3key_dec( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des3_set3key_dec( &ctx, key_str->x ) == 0 ); else TEST_ASSERT( 0 ); @@ -172,9 +172,9 @@ void des3_encrypt_cbc( int key_count, data_t * key_str, if( key_count == 2 ) - mbedtls_des3_set2key_enc( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des3_set2key_enc( &ctx, key_str->x ) == 0 ); else if( key_count == 3 ) - mbedtls_des3_set3key_enc( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des3_set3key_enc( &ctx, key_str->x ) == 0 ); else TEST_ASSERT( 0 ); @@ -205,9 +205,9 @@ void des3_decrypt_cbc( int key_count, data_t * key_str, if( key_count == 2 ) - mbedtls_des3_set2key_dec( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des3_set2key_dec( &ctx, key_str->x ) == 0 ); else if( key_count == 3 ) - mbedtls_des3_set3key_dec( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des3_set3key_dec( &ctx, key_str->x ) == 0 ); else TEST_ASSERT( 0 ); From c78833abc70c9b641a5e626388d4c8445eac45f7 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 27 Sep 2021 16:00:40 +0100 Subject: [PATCH 610/966] Add reminder of assumption to documentation Key size is not verified by this function, but by the level above it. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index 9b6b798b66..e82e1cc098 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -169,6 +169,8 @@ psa_status_t mbedtls_psa_aead_decrypt( * operation. * \param[in] key_buffer The buffer containing the key context. * \param key_buffer_size Size of the \p key_buffer buffer in bytes. + It must be consistent with the size in bits + recorded in \p attributes. * \param alg The AEAD algorithm to compute * (\c PSA_ALG_XXX value such that * #PSA_ALG_IS_AEAD(\p alg) is true). @@ -210,6 +212,8 @@ psa_status_t mbedtls_psa_aead_encrypt_setup( * operation. * \param[in] key_buffer The buffer containing the key context. * \param key_buffer_size Size of the \p key_buffer buffer in bytes. + It must be consistent with the size in bits + recorded in \p attributes. * \param alg The AEAD algorithm to compute * (\c PSA_ALG_XXX value such that * #PSA_ALG_IS_AEAD(\p alg) is true). From e35f8f6a770f5f994e9ada6b95c5b474331bc6f9 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 4 Aug 2021 15:38:09 +0200 Subject: [PATCH 611/966] Move MBEDTLS_CHECK_RETURN to platform_util. Signed-off-by: Mateusz Starzyk --- include/mbedtls/aes.h | 1 + include/mbedtls/build_info.h | 18 ------------------ include/mbedtls/des.h | 1 + include/mbedtls/platform_util.h | 20 ++++++++++++++++++++ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/mbedtls/aes.h b/include/mbedtls/aes.h index eb75935c1f..5c07b912d9 100644 --- a/include/mbedtls/aes.h +++ b/include/mbedtls/aes.h @@ -42,6 +42,7 @@ #include "mbedtls/private_access.h" #include "mbedtls/build_info.h" +#include "mbedtls/platform_util.h" #include #include diff --git a/include/mbedtls/build_info.h b/include/mbedtls/build_info.h index 46717608be..23f85ba01e 100644 --- a/include/mbedtls/build_info.h +++ b/include/mbedtls/build_info.h @@ -53,24 +53,6 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #endif -/** \def MBEDTLS_CHECK_RETURN - * - * This macro appearing at the beginning of the declaration of a function - * indicates that its return value should be checked. - * - * This should appear before most functions returning an error code - * (as \c int in the \c mbedtls_xxx API or - * as ::psa_status_t in the \c psa_xxx API). - */ -#if defined(__GNUC__) -#define MBEDTLS_CHECK_RETURN __attribute__((warn_unused_result)) -#elif defined(_MSC_VER) && _MSC_VER >= 1700 -#include -#define MBEDTLS_CHECK_RETURN _Check_return_ -#else -#define MBEDTLS_CHECK_RETURN -#endif - #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/mbedtls_config.h" #else diff --git a/include/mbedtls/des.h b/include/mbedtls/des.h index 7bd618c276..d5289d3fc1 100644 --- a/include/mbedtls/des.h +++ b/include/mbedtls/des.h @@ -29,6 +29,7 @@ #include "mbedtls/private_access.h" #include "mbedtls/build_info.h" +#include "mbedtls/platform_util.h" #include #include diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 1a0a13513e..9c64cfd162 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -60,6 +60,26 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; #endif /* MBEDTLS_DEPRECATED_WARNING */ #endif /* MBEDTLS_DEPRECATED_REMOVED */ +/** \def MBEDTLS_CHECK_RETURN + * + * This macro appearing at the beginning of the declaration of a function + * indicates that its return value should be checked. + * + * This should appear before most functions returning an error code + * (as \c int in the \c mbedtls_xxx API or + * as ::psa_status_t in the \c psa_xxx API). + */ +#if !defined(MBEDTLS_CHECK_RETURN) +#if defined(__GNUC__) +#define MBEDTLS_CHECK_RETURN __attribute__((warn_unused_result)) +#elif defined(_MSC_VER) && _MSC_VER >= 1700 +#include +#define MBEDTLS_CHECK_RETURN _Check_return_ +#else +#define MBEDTLS_CHECK_RETURN +#endif +#endif + /** * \brief Securely zeroize a buffer * From 2a25804fd4332594ec27f80fc3bf4bdefe15dd8c Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Fri, 6 Aug 2021 13:56:54 +0200 Subject: [PATCH 612/966] Add MBEDTLS_CHECK_RETURN description to mbedtls_config. Signed-off-by: Mateusz Starzyk --- include/mbedtls/mbedtls_config.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index adc317dfef..0b4a3a6b5c 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -256,6 +256,18 @@ */ //#define MBEDTLS_DEPRECATED_REMOVED +/** \def MBEDTLS_CHECK_RETURN + * + * This macro appearing at the beginning of the declaration of a function + * indicates that its return value should be checked. + * + * Default implementation resides in platform_util.h. + * You can override default implementation by defining your own. + * Custom implementation can be empty, which will disable checking + * of functions' return values. + */ +//#define MBEDTLS_CHECK_RETURN + /* \} name SECTION: System support */ /** From ea59237370fcaf04b3e68501d899e4b33cc38b76 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 23 Sep 2021 17:08:26 +0200 Subject: [PATCH 613/966] Move changelog entry to the appropriate directory Signed-off-by: Gilles Peskine --- check-return.txt => ChangeLog.d/check-return.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename check-return.txt => ChangeLog.d/check-return.txt (100%) diff --git a/check-return.txt b/ChangeLog.d/check-return.txt similarity index 100% rename from check-return.txt rename to ChangeLog.d/check-return.txt From 463adf4536b4b04d85ac91eca2b66fe89a35307f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 23 Sep 2021 17:28:59 +0200 Subject: [PATCH 614/966] Define indirection macros MBEDTLS_CHECK_RETURN_xxx Define macros MBEDTLS_CHECK_RETURN_CRITICAL, MBEDTLS_CHECK_RETURN_TYPICAL and MBEDTLS_CHECK_RETURN_OPTIONAL so that we can indicate on a function-by-function basis whether checking the function's return value is almost always necessary (CRITICAL), typically necessary in portable applications but unnecessary in some reasonable cases (TYPICAL), or typically unnecessary (OPTIONAL). Update the documentation of MBEDTLS_CHECK_RETURN accordingly. This is split between the user documentation (Doxygen, in config.h) and the internal documentation (non-Doxygen, in platform_util.h, of minor importance since the macro isn't meant to be used directly). Signed-off-by: Gilles Peskine --- include/mbedtls/mbedtls_config.h | 15 +++++---- include/mbedtls/platform_util.h | 58 ++++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index 0b4a3a6b5c..a840c186a8 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -258,13 +258,16 @@ /** \def MBEDTLS_CHECK_RETURN * - * This macro appearing at the beginning of the declaration of a function - * indicates that its return value should be checked. + * This macro is used at the beginning of the declaration of a function + * to indicate that its return value should be checked. It should + * instruct the compiler to emit a warning or an error if the function + * is called without checking its return value. * - * Default implementation resides in platform_util.h. - * You can override default implementation by defining your own. - * Custom implementation can be empty, which will disable checking - * of functions' return values. + * There is a default implementation for popular compilers in platform_util.h. + * You can override the default implementation by defining your own here. + * + * If the implementation here is empty, this will effectively disable the + * checking of functions' return values. */ //#define MBEDTLS_CHECK_RETURN diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 9c64cfd162..3a28dac9ac 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -60,14 +60,12 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; #endif /* MBEDTLS_DEPRECATED_WARNING */ #endif /* MBEDTLS_DEPRECATED_REMOVED */ -/** \def MBEDTLS_CHECK_RETURN +/* Implementation of the check-return facility. + * See the user documentation in mbedtls_config.h. * - * This macro appearing at the beginning of the declaration of a function - * indicates that its return value should be checked. - * - * This should appear before most functions returning an error code - * (as \c int in the \c mbedtls_xxx API or - * as ::psa_status_t in the \c psa_xxx API). + * Do not use this macro directly to annotate function: instead, + * use one of MBEDTLS_CHECK_RETURN_CRITICAL or MBEDTLS_CHECK_RETURN_TYPICAL + * depending on how important it is to check the return value. */ #if !defined(MBEDTLS_CHECK_RETURN) #if defined(__GNUC__) @@ -80,6 +78,52 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; #endif #endif +/** Critical-failure function + * + * This macro appearing at the beginning of the declaration of a function + * indicates that its return value should be checked in all applications. + * Omitting the check is very likely to indicate a bug in the application + * and will result in a compile-time warning if #MBEDTLS_CHECK_RETURN + * is implemented for the compiler in use. + * + * \note The use of this macro is a work in progress. + * This macro may be added to more functions in the future. + * Such an extension is not considered an API break, provided that + * there are near-unavoidable circumstances under which the function + * can fail. For example, signature/MAC/AEAD verification functions, + * and functions that require a random generator, are considered + * return-check-critical. + */ +#define MBEDTLS_CHECK_RETURN_CRITICAL MBEDTLS_CHECK_RETURN + +/** Ordinary-failure function + * + * This macro appearing at the beginning of the declaration of a function + * indicates that its return value should be generally be checked in portable + * applications. Omitting the check will result in a compile-time warning if + * #MBEDTLS_CHECK_RETURN is implemented for the compiler in use. + * + * \note The use of this macro is a work in progress. + * This macro will be added to more functions in the future. + * Eventually this should appear before most functions returning + * an error code (as \c int in the \c mbedtls_xxx API or + * as ::psa_status_t in the \c psa_xxx API). + */ +#define MBEDTLS_CHECK_RETURN_TYPICAL MBEDTLS_CHECK_RETURN + +/** Benign-failure function + * + * This macro appearing at the beginning of the declaration of a function + * indicates that it is rarely useful to check its return value. + * + * This macro has an empty expansion. It exists for documentation purposes: + * a #MBEDTLS_CHECK_RETURN_OPTIONAL annotation indicates that the function + * has been analyzed for return-check usefuless, whereas the lack of + * an annotation indicates that the function has not been analyzed and its + * return-check usefulness is unknown. + */ +#define MBEDTLS_CHECK_RETURN_OPTIONAL + /** * \brief Securely zeroize a buffer * From e41803af9cba541de0aeb06d9e6e385649a5cb1c Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 23 Sep 2021 17:35:37 +0200 Subject: [PATCH 615/966] Change DES and AES functions to MBEDTLS_CHECK_RETURN_TYPICAL For all of these functions, the only possible failures are a hardware accelerator (not possible unless using an ALT implementation), an internal error or runtime corruption. Exception: the self-tests, which serve little purpose if their status isn't tested. Signed-off-by: Gilles Peskine --- include/mbedtls/aes.h | 28 ++++++++++++++-------------- include/mbedtls/des.h | 26 +++++++++++++------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/mbedtls/aes.h b/include/mbedtls/aes.h index 5c07b912d9..becbfae1d9 100644 --- a/include/mbedtls/aes.h +++ b/include/mbedtls/aes.h @@ -164,7 +164,7 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ); * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -183,7 +183,7 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -204,7 +204,7 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -225,7 +225,7 @@ int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, * \return \c 0 on success. * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -254,7 +254,7 @@ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, * \return \c 0 on success. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, int mode, const unsigned char input[16], @@ -302,7 +302,7 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH * on failure. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, int mode, size_t length, @@ -347,7 +347,7 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, * smaller than an AES block in size (16 Bytes) or if \p * length is larger than 2^20 blocks (16 MiB). */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, int mode, size_t length, @@ -396,7 +396,7 @@ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, * * \return \c 0 on success. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, int mode, size_t length, @@ -441,7 +441,7 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, int mode, size_t length, @@ -496,7 +496,7 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, size_t length, size_t *iv_off, @@ -583,7 +583,7 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, size_t length, size_t *nc_off, @@ -604,7 +604,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ); @@ -620,7 +620,7 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, * * \return \c 0 on success. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16] ); @@ -632,7 +632,7 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, * \return \c 0 on success. * \return \c 1 on failure. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_CRITICAL int mbedtls_aes_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ diff --git a/include/mbedtls/des.h b/include/mbedtls/des.h index d5289d3fc1..be74cb111e 100644 --- a/include/mbedtls/des.h +++ b/include/mbedtls/des.h @@ -140,7 +140,7 @@ void mbedtls_des_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] ); * security risk. We recommend considering stronger ciphers * instead. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** @@ -154,7 +154,7 @@ int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SI * security risk. We recommend considering stronger ciphers * instead. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** @@ -169,7 +169,7 @@ int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); * security risk. We recommend considering stronger ciphers * instead. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** @@ -184,7 +184,7 @@ int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MB * security risk. We recommend considering stronger ciphers * instead. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** @@ -195,7 +195,7 @@ int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MB * * \return 0 */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); @@ -207,7 +207,7 @@ int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx, * * \return 0 */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); @@ -219,7 +219,7 @@ int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx, * * \return 0 */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); @@ -231,7 +231,7 @@ int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx, * * \return 0 */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); @@ -248,7 +248,7 @@ int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx, * security risk. We recommend considering stronger ciphers * instead. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, const unsigned char input[8], unsigned char output[8] ); @@ -276,7 +276,7 @@ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, * security risk. We recommend considering stronger ciphers * instead. */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, int mode, size_t length, @@ -294,7 +294,7 @@ int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, * * \return 0 if successful */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, const unsigned char input[8], unsigned char output[8] ); @@ -320,7 +320,7 @@ int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, * * \return 0 if successful, or MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_TYPICAL int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, int mode, size_t length, @@ -351,7 +351,7 @@ void mbedtls_des_setkey( uint32_t SK[32], * * \return 0 if successful, or 1 if the test failed */ -MBEDTLS_CHECK_RETURN +MBEDTLS_CHECK_RETURN_CRITICAL int mbedtls_des_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ From 3f106f762dc0c65583da54c4ed3328ed18718570 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 23 Sep 2021 17:42:39 +0200 Subject: [PATCH 616/966] Move MBEDTLS_CHECK_RETURN to the correct section This is not a boolean macro: it's useful for what it expands to. Signed-off-by: Gilles Peskine --- include/mbedtls/mbedtls_config.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index a840c186a8..2110cc27b6 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -256,21 +256,6 @@ */ //#define MBEDTLS_DEPRECATED_REMOVED -/** \def MBEDTLS_CHECK_RETURN - * - * This macro is used at the beginning of the declaration of a function - * to indicate that its return value should be checked. It should - * instruct the compiler to emit a warning or an error if the function - * is called without checking its return value. - * - * There is a default implementation for popular compilers in platform_util.h. - * You can override the default implementation by defining your own here. - * - * If the implementation here is empty, this will effectively disable the - * checking of functions' return values. - */ -//#define MBEDTLS_CHECK_RETURN - /* \} name SECTION: System support */ /** @@ -3082,6 +3067,21 @@ //#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ //#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ +/** \def MBEDTLS_CHECK_RETURN + * + * This macro is used at the beginning of the declaration of a function + * to indicate that its return value should be checked. It should + * instruct the compiler to emit a warning or an error if the function + * is called without checking its return value. + * + * There is a default implementation for popular compilers in platform_util.h. + * You can override the default implementation by defining your own here. + * + * If the implementation here is empty, this will effectively disable the + * checking of functions' return values. + */ +//#define MBEDTLS_CHECK_RETURN + /* PSA options */ /** * Use HMAC_DRBG with the specified hash algorithm for HMAC_DRBG for the From 913fc5fff3831057f03b1de529c76ecd65e34b26 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 23 Sep 2021 17:43:46 +0200 Subject: [PATCH 617/966] Better default for MBEDTLS_CHECK_RETURN in config.h An empty expansion is possible, but as documented its effect is to disable the feature, so that isn't a good example. Instead, use the GCC implementation as the default: it's plausible that it could work even on compilers that don't advertise themselves as sufficiently GCC-like to define __GNUC__, and if not it gives users a concrete idea of what the macro is supposed to do. Signed-off-by: Gilles Peskine --- include/mbedtls/mbedtls_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index 2110cc27b6..13c86ed582 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -3080,7 +3080,7 @@ * If the implementation here is empty, this will effectively disable the * checking of functions' return values. */ -//#define MBEDTLS_CHECK_RETURN +//#define MBEDTLS_CHECK_RETURN __attribute__(__warn_unused_result__) /* PSA options */ /** From a33e6935bc061a897a62a5b4ef053693aaf754bd Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 23 Sep 2021 17:46:12 +0200 Subject: [PATCH 618/966] Use reserved identifier for warn_unused_result This is normally equivalent, but works even if some other header defines a macro called warn_unused_result. Signed-off-by: Gilles Peskine --- include/mbedtls/platform_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 3a28dac9ac..d8379deb31 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -69,7 +69,7 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; */ #if !defined(MBEDTLS_CHECK_RETURN) #if defined(__GNUC__) -#define MBEDTLS_CHECK_RETURN __attribute__((warn_unused_result)) +#define MBEDTLS_CHECK_RETURN __attribute__((__warn_unused_result__)) #elif defined(_MSC_VER) && _MSC_VER >= 1700 #include #define MBEDTLS_CHECK_RETURN _Check_return_ From 9a7d4c273470fdfb5a33566f8e2b9e36fc8b29d2 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 23 Sep 2021 18:07:36 +0200 Subject: [PATCH 619/966] New configuration option MBEDTLS_CHECK_RETURN_WARNING MBEDTLS_CHECK_RETURN_TYPICAL defaults off, but is enabled if MBEDTLS_CHECK_RETURN_WARNING is enabled at compile time. (MBEDTLS_CHECK_RETURN_CRITICAL is always enabled.) The default is off so that a plausible program that builds with one version of Mbed TLS in the default configuration will still build under the next version. Signed-off-by: Gilles Peskine --- ChangeLog.d/check-return.txt | 13 +++++++++---- include/mbedtls/mbedtls_config.h | 23 +++++++++++++++++++++++ include/mbedtls/platform_util.h | 4 ++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/ChangeLog.d/check-return.txt b/ChangeLog.d/check-return.txt index e6371ec69b..045b1805ec 100644 --- a/ChangeLog.d/check-return.txt +++ b/ChangeLog.d/check-return.txt @@ -6,7 +6,12 @@ Bugfix where this function cannot fail, or full-module replacements with MBEDTLS_AES_ALT or MBEDTLS_DES_ALT. Reported by Armelle Duboc in #1092. -Changes - * Warn if errors from AES or DES functions are ignored. This is currently - supported on GCC-like compilers and on MSVC and can be configured by - setting MBEDTLS_CHECK_RETURN in mbedtls_config.h. +Features + * Warn if errors from certain functions are ignored. This is currently + supported on GCC-like compilers and on MSVC and can be configured through + the macro MBEDTLS_CHECK_RETURN. The warnings are always enabled + (where supported) for critical functions where ignoring the return + value is almost always a bug. Enable the new configuration option + MBEDTLS_CHECK_RETURN_WARNING to get warnings for other functions. This + is currently implemented in the AES and DES modules, and will be extended + to other modules in the future. diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index 13c86ed582..c31a2cee52 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -520,6 +520,29 @@ */ //#define MBEDTLS_CAMELLIA_SMALL_MEMORY +/** + * \def MBEDTLS_CHECK_RETURN_WARNING + * + * If this macro is defined, emit a compile-time warning if application code + * calls a function without checking its return value, but the return value + * should generally be checked in portable applications. + * + * This is only supported on platforms where #MBEDTLS_CHECK_RETURN is + * implemented. Otherwise this option has no effect. + * + * Uncomment to get warnings on using fallible functions without checking + * their return value. + * + * \note This feature is a work in progress. + * Warnings will be added to more functions in the future. + * + * \note A few functions are considered critical, and ignoring the return + * value of these functions will trigger a warning even if this + * macro is not defined. To completely disable return value check + * warnings, define #MBEDTLS_CHECK_RETURN with an empty expansion. + */ +//#define MBEDTLS_CHECK_RETURN_WARNING + /** * \def MBEDTLS_CIPHER_MODE_CBC * diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index d8379deb31..ce0611da57 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -109,7 +109,11 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; * an error code (as \c int in the \c mbedtls_xxx API or * as ::psa_status_t in the \c psa_xxx API). */ +#if defined(MBEDTLS_CHECK_RETURN_WARNING) #define MBEDTLS_CHECK_RETURN_TYPICAL MBEDTLS_CHECK_RETURN +#else +#define MBEDTLS_CHECK_RETURN_TYPICAL +#endif /** Benign-failure function * From 409fbbe4a2128c961c28d8f885a08afe6b2bd2fe Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 27 Sep 2021 16:17:51 +0200 Subject: [PATCH 620/966] Minor documentation fix Signed-off-by: Gilles Peskine --- include/mbedtls/platform_util.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index ce0611da57..e1f063c34e 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -101,7 +101,8 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; * This macro appearing at the beginning of the declaration of a function * indicates that its return value should be generally be checked in portable * applications. Omitting the check will result in a compile-time warning if - * #MBEDTLS_CHECK_RETURN is implemented for the compiler in use. + * #MBEDTLS_CHECK_RETURN is implemented for the compiler in use and + * #MBEDTLS_CHECK_RETURN_WARNING is enabled in the compile-time configuration. * * \note The use of this macro is a work in progress. * This macro will be added to more functions in the future. From 89458d1420bd3ccefbc0c4a2a6e037e1a274ccea Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 27 Sep 2021 19:20:17 +0200 Subject: [PATCH 621/966] More robust handling of excluded files Don't try to enumerate excluded files. List included files, and remove names from the list if they match an excluded-file pattern. This resolves the problem that the script could get into an infinite loop due to the use of recursive globbing. Unfortunately, Python's recursive globs follows symbolic links to directories, which leads to an infinite loop if a symbolic link points to an ancestor of the directory that contains it. Signed-off-by: Gilles Peskine --- tests/scripts/check_names.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index a9aa118ea4..737b3df3d9 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -44,6 +44,7 @@ error. It must be run from Mbed TLS root. import abc import argparse +import fnmatch import glob import textwrap import os @@ -222,8 +223,9 @@ class CodeParser(): # Memo for storing "glob expression": set(filepaths) self.files = {} - # Globally excluded filenames - self.excluded_files = ["**/bn_mul", "**/compat-2.x.h"] + # Globally excluded filenames. + # Note that "*" can match directory separators in exclude lists. + self.excluded_files = ["*/bn_mul", "*/compat-2.x.h"] @staticmethod def check_repo_path(): @@ -302,6 +304,15 @@ class CodeParser(): "mbed_words": mbed_words } + def is_file_excluded(self, path, exclude_wildcards): + """Whether the give file path is excluded.""" + # exclude_wildcards may be None. Also, consider the global exclusions. + exclude_wildcards = (exclude_wildcards or []) + self.excluded_files + for pattern in exclude_wildcards: + if fnmatch.fnmatch(path, pattern): + return True + return False + def get_files(self, include_wildcards, exclude_wildcards): """ Get all files that match any of the UNIX-style wildcards. While the @@ -317,25 +328,11 @@ class CodeParser(): """ accumulator = set() - # exclude_wildcards may be None. Also, consider the global exclusions. - exclude_wildcards = (exclude_wildcards or []) + self.excluded_files - - # Internal function to hit the memoisation cache or add to it the result - # of a glob operation. Used both for inclusion and exclusion since the - # only difference between them is whether they perform set union or - # difference on the return value of this function. - def hit_cache(wildcard): - if wildcard not in self.files: - self.files[wildcard] = set(glob.glob(wildcard, recursive=True)) - return self.files[wildcard] - for include_wildcard in include_wildcards: - accumulator = accumulator.union(hit_cache(include_wildcard)) + accumulator = accumulator.union(glob.iglob(include_wildcard)) - for exclude_wildcard in exclude_wildcards: - accumulator = accumulator.difference(hit_cache(exclude_wildcard)) - - return list(accumulator) + return list(path for path in accumulator + if not self.is_file_excluded(path, exclude_wildcards)) def parse_macros(self, include, exclude=None): """ From 745f5f2724804623a43dc86bcace687923960fec Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 27 Sep 2021 17:38:08 +0100 Subject: [PATCH 622/966] Add test for PolyChaCha with shortened tag Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index e48bd976f5..f83f83b86b 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -3330,6 +3330,10 @@ PSA AEAD setup: invalid algorithm (ChaCha20) depends_on:PSA_WANT_ALG_STREAM_CIPHER:PSA_WANT_KEY_TYPE_CHACHA20 aead_multipart_setup:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_STREAM_CIPHER:PSA_ERROR_INVALID_ARGUMENT +PSA AEAD setup: invalid algorithm (ChaCha20 - Poly1305 with short tag) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_multipart_setup:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CHACHA20_POLY1305,12):PSA_ERROR_NOT_SUPPORTED + PSA Multipart State Checks, AES - GCM depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_state_test:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E" From 325d374e3d406f3862d2cfb6570a17087e2361d8 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 27 Sep 2021 17:56:28 +0100 Subject: [PATCH 623/966] Move set lengths checking to PSA Core Signed-off-by: Paul Elliott --- library/psa_crypto.c | 35 ++++++++++++++++++++ library/psa_crypto_aead.c | 49 ---------------------------- library/psa_crypto_aead.h | 41 ----------------------- library/psa_crypto_driver_wrappers.c | 6 ++-- tests/src/drivers/test_driver_aead.c | 5 ++- 5 files changed, 40 insertions(+), 96 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 83b45f097a..65dc5c7fe1 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3901,6 +3901,41 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, goto exit; } +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { + /* Lengths can only be too large for GCM if size_t is bigger than 32 + * bits. Without the guard this code will generate warnings on 32bit + * builds */ +#if SIZE_MAX > UINT32_MAX + if( (( uint64_t ) ad_length ) >> 61 != 0 || + (( uint64_t ) plaintext_length ) > 0xFFFFFFFE0ull ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } +#endif + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + if( ad_length > 0xFF00 ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + /* No length restrictions for ChaChaPoly. */ + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + status = psa_driver_wrapper_aead_set_lengths( operation, ad_length, plaintext_length ); diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 9000abf307..d7317bd1a0 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -477,55 +477,6 @@ psa_status_t mbedtls_psa_aead_set_nonce( return( status ); } - /* Declare the lengths of the message and additional data for AEAD. */ -psa_status_t mbedtls_psa_aead_set_lengths( - mbedtls_psa_aead_operation_t *operation, - size_t ad_length, - size_t plaintext_length ) -{ - -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation->alg == PSA_ALG_GCM ) - { - /* Lengths can only be too large for GCM if size_t is bigger than 32 - * bits. Without the guard this code will generate warnings on 32bit - * builds */ -#if SIZE_MAX > UINT32_MAX - if( ( (uint64_t) ad_length ) >> 61 != 0 || - ( (uint64_t) plaintext_length ) > 0xFFFFFFFE0ull ) - { - return ( PSA_ERROR_INVALID_ARGUMENT ); - } -#endif - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - if( ad_length > 0xFF00 ) - return ( PSA_ERROR_INVALID_ARGUMENT ); - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) - { - /* No length restrictions for ChaChaPoly. */ - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ - { - ( void ) operation; - ( void ) ad_length; - ( void ) plaintext_length; - - return ( PSA_ERROR_NOT_SUPPORTED ); - } - - return ( PSA_SUCCESS ); -} - /* Pass additional data to an active multipart AEAD operation. */ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t *operation, diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index e82e1cc098..f968c15c87 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -267,47 +267,6 @@ psa_status_t mbedtls_psa_aead_set_nonce( const uint8_t *nonce, size_t nonce_length ); -/** Declare the lengths of the message and additional data for AEAD. - * - * \note The signature of this function is that of a PSA driver aead_set_lengths - * entry point. This function behaves as an aead_set_lengths entry point - * as defined in the PSA driver interface specification for transparent - * drivers. - * - * The PSA core calls this function before calling mbedtls_psa_aead_update_ad() - * or mbedtls_psa_aead_update() if the algorithm for the operation requires it. - * If the algorithm does not require it, calling this function is optional, but - * if this function is called then the implementation must enforce the lengths. - * - * The PSA core may call this function before or after setting the nonce with - * mbedtls_psa_aead_set_nonce(). - * - * - For #PSA_ALG_CCM, calling this function is required. - * - For the other AEAD algorithms defined in this specification, calling - * this function is not required. - * - * If this function returns an error status, the PSA core calls - * mbedtls_psa_aead_abort(). - * - * \param[in,out] operation Active AEAD operation. - * \param ad_length Size of the non-encrypted additional - * authenticated data in bytes. - * \param plaintext_length Size of the plaintext to encrypt in bytes. - * - * \retval #PSA_SUCCESS - * Success. - * \retval #PSA_ERROR_INVALID_ARGUMENT - * At least one of the lengths is not acceptable for the chosen - * algorithm. - * \retval #PSA_ERROR_NOT_SUPPORTED - * Algorithm previously set is not supported in this configuration of - * the library. - */ -psa_status_t mbedtls_psa_aead_set_lengths( - mbedtls_psa_aead_operation_t *operation, - size_t ad_length, - size_t plaintext_length ); - /** Pass additional data to an active AEAD operation. * * \note The signature of this function is that of a PSA driver diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index cfc77fbb5b..4bbb61c3d4 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1706,9 +1706,9 @@ psa_status_t psa_driver_wrapper_aead_set_lengths( { #if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - return( mbedtls_psa_aead_set_lengths( &operation->ctx.mbedtls_ctx, - ad_length, - plaintext_length ) ); + /* No mbedtls_psa_aead_set_lengths, everything is done in PSA + * Core. */ + return( PSA_SUCCESS ); #endif /* MBEDTLS_PSA_BUILTIN_AEAD */ diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index 6befe7cc0f..d27ada294d 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -171,9 +171,8 @@ psa_status_t mbedtls_test_transparent_aead_set_lengths( } else { - mbedtls_test_driver_aead_hooks.driver_status = - mbedtls_psa_aead_set_lengths( operation, ad_length, - plaintext_length ); + /* No mbedtls_psa_aead_set_lengths, everything is done in PSA Core. */ + mbedtls_test_driver_aead_hooks.driver_status = PSA_SUCCESS; } return( mbedtls_test_driver_aead_hooks.driver_status ); From 4ed1ed18d2a5595164bbc2b08df7ef814235e289 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 27 Sep 2021 18:09:28 +0100 Subject: [PATCH 624/966] Move nonce size checking to PSA Core Signed-off-by: Paul Elliott --- library/psa_crypto.c | 42 ++++++++++++++++++++++++++++++++++----- library/psa_crypto_aead.c | 6 ------ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 65dc5c7fe1..fd2069b797 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3863,11 +3863,43 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, goto exit; } - /* Not checking nonce size here as GCM spec allows almost arbitrarily - * large nonces. Please note that we do not generally recommend the usage - * of nonces of greater length than PSA_AEAD_NONCE_MAX_SIZE, as large - * nonces are hashed to a shorter size, which can then lead to collisions - * if you encrypt a very large number of messages.*/ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( operation->alg == PSA_ALG_GCM ) + { + /* Not checking max nonce size here as GCM spec allows almost + * arbitrarily large nonces. Please note that we do not generally + * recommend the usage of nonces of greater length than + * PSA_AEAD_NONCE_MAX_SIZE, as large nonces are hashed to a shorter + * size, which can then lead to collisions if you encrypt a very + * large number of messages.*/ + if( nonce_length == 0 ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( operation->alg == PSA_ALG_CCM ) + { + if( nonce_length < 7 || nonce_length > 13 ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) + { + if( nonce_length != 12 ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ status = psa_driver_wrapper_aead_set_nonce( operation, nonce, nonce_length ); diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index d7317bd1a0..4f6e70809e 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -438,12 +438,6 @@ psa_status_t mbedtls_psa_aead_set_nonce( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( mbedtls_aead_check_nonce_length( operation, nonce_length ) - != PSA_SUCCESS ) - { - return( PSA_ERROR_INVALID_ARGUMENT ); - } - #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { From 8a8322407227becbf3247a8b24b4b1087ee5d1b3 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 28 Sep 2021 10:12:49 +0200 Subject: [PATCH 625/966] Fix typo Signed-off-by: Gilles Peskine --- tests/scripts/check_names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/check_names.py b/tests/scripts/check_names.py index 737b3df3d9..ac2490fc1e 100755 --- a/tests/scripts/check_names.py +++ b/tests/scripts/check_names.py @@ -305,7 +305,7 @@ class CodeParser(): } def is_file_excluded(self, path, exclude_wildcards): - """Whether the give file path is excluded.""" + """Whether the given file path is excluded.""" # exclude_wildcards may be None. Also, consider the global exclusions. exclude_wildcards = (exclude_wildcards or []) + self.excluded_files for pattern in exclude_wildcards: From d52398d31fa85665ea2e2690363cbfee32220ed7 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 28 Sep 2021 16:13:44 +0800 Subject: [PATCH 626/966] fix double underscore fail Signed-off-by: Jerry Yu --- library/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/common.h b/library/common.h index ba8237acf6..9b10ec8fbb 100644 --- a/library/common.h +++ b/library/common.h @@ -323,7 +323,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * Use MSVC predefine macro to avoid name check fail. */ #if (defined(_MSC_VER) && ( _MSC_VER <= 1900 )) -#define __func__ __FUNCTION__ +#define /*no-check-names*/ __func__ __FUNCTION__ #endif #endif /* MBEDTLS_LIBRARY_COMMON_H */ From ad8d0bad10e48827c32723ceab0ed5d4c786631a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 28 Sep 2021 17:58:26 +0800 Subject: [PATCH 627/966] Keep consistency order. Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index ab48ec03b3..633bb8da2e 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -802,8 +802,8 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_write_client_certificate( mbedtls_ssl_context *ssl ) { - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY ); return( 0 ); } @@ -812,8 +812,8 @@ static int ssl_tls1_3_write_client_certificate( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_write_client_certificate_verify( mbedtls_ssl_context *ssl ) { - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_FINISHED ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_FINISHED ); return( 0 ); } @@ -822,8 +822,8 @@ static int ssl_tls1_3_write_client_certificate_verify( mbedtls_ssl_context *ssl */ static int ssl_tls1_3_write_client_finished( mbedtls_ssl_context *ssl ) { - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); return( 0 ); } @@ -832,8 +832,8 @@ static int ssl_tls1_3_write_client_finished( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_flush_buffers( mbedtls_ssl_context *ssl ) { - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_HANDSHAKE_WRAPUP ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_HANDSHAKE_WRAPUP ); return( 0 ); } From dff6c5d963af83a0f0dfda501bdfabc289a51b37 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 28 Sep 2021 11:00:20 +0100 Subject: [PATCH 628/966] Restore internal driver for aead_set_lengths Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 23 ++++++++++++++++ library/psa_crypto_aead.h | 41 ++++++++++++++++++++++++++++ library/psa_crypto_driver_wrappers.c | 6 ++-- tests/src/drivers/test_driver_aead.c | 5 ++-- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 4f6e70809e..2c6e4435cc 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -471,6 +471,29 @@ psa_status_t mbedtls_psa_aead_set_nonce( return( status ); } + /* Declare the lengths of the message and additional data for AEAD. */ +psa_status_t mbedtls_psa_aead_set_lengths( + mbedtls_psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ) +{ + + ( void ) operation; + ( void ) ad_length; + ( void ) plaintext_length; + +#if !defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) && \ + !defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) && \ + !defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + { + return ( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* !MBEDTLS_PSA_BUILTIN_ALG_GCM && !MBEDTLS_PSA_BUILTIN_ALG_CCM && + !MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) */ + + return ( PSA_SUCCESS ); +} + /* Pass additional data to an active multipart AEAD operation. */ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t *operation, diff --git a/library/psa_crypto_aead.h b/library/psa_crypto_aead.h index f968c15c87..e82e1cc098 100644 --- a/library/psa_crypto_aead.h +++ b/library/psa_crypto_aead.h @@ -267,6 +267,47 @@ psa_status_t mbedtls_psa_aead_set_nonce( const uint8_t *nonce, size_t nonce_length ); +/** Declare the lengths of the message and additional data for AEAD. + * + * \note The signature of this function is that of a PSA driver aead_set_lengths + * entry point. This function behaves as an aead_set_lengths entry point + * as defined in the PSA driver interface specification for transparent + * drivers. + * + * The PSA core calls this function before calling mbedtls_psa_aead_update_ad() + * or mbedtls_psa_aead_update() if the algorithm for the operation requires it. + * If the algorithm does not require it, calling this function is optional, but + * if this function is called then the implementation must enforce the lengths. + * + * The PSA core may call this function before or after setting the nonce with + * mbedtls_psa_aead_set_nonce(). + * + * - For #PSA_ALG_CCM, calling this function is required. + * - For the other AEAD algorithms defined in this specification, calling + * this function is not required. + * + * If this function returns an error status, the PSA core calls + * mbedtls_psa_aead_abort(). + * + * \param[in,out] operation Active AEAD operation. + * \param ad_length Size of the non-encrypted additional + * authenticated data in bytes. + * \param plaintext_length Size of the plaintext to encrypt in bytes. + * + * \retval #PSA_SUCCESS + * Success. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * At least one of the lengths is not acceptable for the chosen + * algorithm. + * \retval #PSA_ERROR_NOT_SUPPORTED + * Algorithm previously set is not supported in this configuration of + * the library. + */ +psa_status_t mbedtls_psa_aead_set_lengths( + mbedtls_psa_aead_operation_t *operation, + size_t ad_length, + size_t plaintext_length ); + /** Pass additional data to an active AEAD operation. * * \note The signature of this function is that of a PSA driver diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 4bbb61c3d4..cfc77fbb5b 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1706,9 +1706,9 @@ psa_status_t psa_driver_wrapper_aead_set_lengths( { #if defined(MBEDTLS_PSA_BUILTIN_AEAD) case PSA_CRYPTO_MBED_TLS_DRIVER_ID: - /* No mbedtls_psa_aead_set_lengths, everything is done in PSA - * Core. */ - return( PSA_SUCCESS ); + return( mbedtls_psa_aead_set_lengths( &operation->ctx.mbedtls_ctx, + ad_length, + plaintext_length ) ); #endif /* MBEDTLS_PSA_BUILTIN_AEAD */ diff --git a/tests/src/drivers/test_driver_aead.c b/tests/src/drivers/test_driver_aead.c index d27ada294d..6befe7cc0f 100644 --- a/tests/src/drivers/test_driver_aead.c +++ b/tests/src/drivers/test_driver_aead.c @@ -171,8 +171,9 @@ psa_status_t mbedtls_test_transparent_aead_set_lengths( } else { - /* No mbedtls_psa_aead_set_lengths, everything is done in PSA Core. */ - mbedtls_test_driver_aead_hooks.driver_status = PSA_SUCCESS; + mbedtls_test_driver_aead_hooks.driver_status = + mbedtls_psa_aead_set_lengths( operation, ad_length, + plaintext_length ); } return( mbedtls_test_driver_aead_hooks.driver_status ); From bb0f9e1740bf1f6630c120abb4e13a31514dad3f Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 28 Sep 2021 11:14:27 +0100 Subject: [PATCH 629/966] Move all nonce length checks to PSA Core Remove duplicated code from oneshot API Signed-off-by: Paul Elliott --- library/psa_crypto.c | 86 +++++++++++++++++++++++---------------- library/psa_crypto_aead.c | 41 ------------------- 2 files changed, 51 insertions(+), 76 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index fd2069b797..42abdf5c46 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3609,6 +3609,42 @@ exit: /* AEAD */ /****************************************************************/ +/* Helper to perform common nonce length checks. */ +static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, + size_t nonce_length ) +{ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) + if( alg == PSA_ALG_GCM ) + { + /* Not checking max nonce size here as GCM spec allows almost + * arbitrarily large nonces. Please note that we do not generally + * recommend the usage of nonces of greater length than + * PSA_AEAD_NONCE_MAX_SIZE, as large nonces are hashed to a shorter + * size, which can then lead to collisions if you encrypt a very + * large number of messages.*/ + if( nonce_length == 0 ) + return( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) + if( alg == PSA_ALG_CCM ) + { + if( nonce_length < 7 || nonce_length > 13 ) + return( PSA_ERROR_NOT_SUPPORTED ); + } + else +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ +#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) + if( alg == PSA_ALG_CHACHA20_POLY1305 ) + { + if( nonce_length != 12 ) + return( PSA_ERROR_NOT_SUPPORTED ); + } +#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ + + return PSA_SUCCESS; +} + psa_status_t psa_aead_encrypt( mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *nonce, @@ -3638,6 +3674,10 @@ psa_status_t psa_aead_encrypt( mbedtls_svc_key_id_t key, .core = slot->attr }; + status = psa_aead_check_nonce_length( alg, nonce_length ); + if( status != PSA_SUCCESS ) + goto exit; + status = psa_driver_wrapper_aead_encrypt( &attributes, slot->key.data, slot->key.bytes, alg, @@ -3649,6 +3689,7 @@ psa_status_t psa_aead_encrypt( mbedtls_svc_key_id_t key, if( status != PSA_SUCCESS && ciphertext_size != 0 ) memset( ciphertext, 0, ciphertext_size ); +exit: psa_unlock_key_slot( slot ); return( status ); @@ -3683,6 +3724,10 @@ psa_status_t psa_aead_decrypt( mbedtls_svc_key_id_t key, .core = slot->attr }; + status = psa_aead_check_nonce_length( alg, nonce_length ); + if( status != PSA_SUCCESS ) + goto exit; + status = psa_driver_wrapper_aead_decrypt( &attributes, slot->key.data, slot->key.bytes, alg, @@ -3694,6 +3739,7 @@ psa_status_t psa_aead_decrypt( mbedtls_svc_key_id_t key, if( status != PSA_SUCCESS && plaintext_size != 0 ) memset( plaintext, 0, plaintext_size ); +exit: psa_unlock_key_slot( slot ); return( status ); @@ -3863,43 +3909,13 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, goto exit; } -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation->alg == PSA_ALG_GCM ) + status = psa_aead_check_nonce_length( operation->alg, nonce_length ); + + if( status != PSA_SUCCESS ) { - /* Not checking max nonce size here as GCM spec allows almost - * arbitrarily large nonces. Please note that we do not generally - * recommend the usage of nonces of greater length than - * PSA_AEAD_NONCE_MAX_SIZE, as large nonces are hashed to a shorter - * size, which can then lead to collisions if you encrypt a very - * large number of messages.*/ - if( nonce_length == 0 ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; } -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - if( nonce_length < 7 || nonce_length > 13 ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) - { - if( nonce_length != 12 ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } - } -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ status = psa_driver_wrapper_aead_set_nonce( operation, nonce, nonce_length ); diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 2c6e4435cc..5e36932e7c 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -136,37 +136,6 @@ static psa_status_t psa_aead_setup( return( PSA_SUCCESS ); } -/* Perform common nonce length checks */ -static psa_status_t mbedtls_aead_check_nonce_length( - mbedtls_psa_aead_operation_t *operation, - size_t nonce_length ) -{ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( operation->alg == PSA_ALG_GCM ) - { - if( nonce_length == 0 ) - return( PSA_ERROR_NOT_SUPPORTED ); - } -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - if( nonce_length < 7 || nonce_length > 13 ) - return( PSA_ERROR_NOT_SUPPORTED ); - } - else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) - { - if( nonce_length != 12 ) - return( PSA_ERROR_NOT_SUPPORTED ); - } -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ - - return PSA_SUCCESS; -} - psa_status_t mbedtls_psa_aead_encrypt( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, @@ -195,11 +164,6 @@ psa_status_t mbedtls_psa_aead_encrypt( } tag = ciphertext + plaintext_length; - status = mbedtls_aead_check_nonce_length( &operation, nonce_length ); - - if( status != PSA_SUCCESS ) - goto exit; - #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation.alg == PSA_ALG_CCM ) { @@ -308,11 +272,6 @@ psa_status_t mbedtls_psa_aead_decrypt( if( status != PSA_SUCCESS ) goto exit; - status = mbedtls_aead_check_nonce_length( &operation, nonce_length ); - - if( status != PSA_SUCCESS ) - goto exit; - #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation.alg == PSA_ALG_CCM ) { From 5b8618b44cc272e4f851612f1143c038c894a40d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 28 Sep 2021 12:34:53 +0200 Subject: [PATCH 630/966] fixup: Make the fields of mbedtls_ecp_curve_info public Remove more places where MBEDTLS_PRIVATE() was used on grp_id, which is now public. Signed-off-by: Gilles Peskine --- include/mbedtls/psa_util.h | 2 +- programs/pkey/ecdsa.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/psa_util.h b/include/mbedtls/psa_util.h index f6f2e58054..6f6354591b 100644 --- a/include/mbedtls/psa_util.h +++ b/include/mbedtls/psa_util.h @@ -369,7 +369,7 @@ static inline psa_key_type_t mbedtls_psa_parse_tls_ecc_group( if( curve_info == NULL ) return( 0 ); return( PSA_KEY_TYPE_ECC_KEY_PAIR( - mbedtls_ecc_group_to_psa( curve_info->MBEDTLS_PRIVATE(grp_id), bits ) ) ); + mbedtls_ecc_group_to_psa( curve_info->grp_id, bits ) ) ); } #endif /* MBEDTLS_ECP_C */ diff --git a/programs/pkey/ecdsa.c b/programs/pkey/ecdsa.c index 6b6e9517d4..550a230e8f 100644 --- a/programs/pkey/ecdsa.c +++ b/programs/pkey/ecdsa.c @@ -51,7 +51,7 @@ #define ECPARAMS MBEDTLS_ECP_DP_SECP192R1 #if !defined(ECPARAMS) -#define ECPARAMS mbedtls_ecp_curve_list()->MBEDTLS_PRIVATE(grp_id) +#define ECPARAMS mbedtls_ecp_curve_list()->grp_id #endif #if !defined(MBEDTLS_ECDSA_C) || !defined(MBEDTLS_SHA256_C) || \ From 6ca7c7fd6b346d90312bbf906522ce2aefa38240 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 28 Sep 2021 18:51:40 +0800 Subject: [PATCH 631/966] Remove useless variables Signed-off-by: Jerry Yu --- library/ssl_tls13_keys.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index cc94984063..b07c1c3b9e 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -826,8 +826,7 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; mbedtls_md_type_t md_type; - const unsigned char *input = NULL; - size_t input_len = 0; + if( ssl->handshake->ciphersuite_info == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "cipher suite info not found" ) ); @@ -836,7 +835,7 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ) md_type = ssl->handshake->ciphersuite_info->mac; - ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, NULL, input, input_len, + ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, NULL, NULL, 0, ssl->handshake->tls1_3_master_secrets.early ); if( ret != 0 ) { From d9a94fe3d096d488fb54688033c10fbcfd980001 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 28 Sep 2021 18:58:59 +0800 Subject: [PATCH 632/966] Add counter length macro Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 4 ++-- library/ssl_misc.h | 20 ++++++++++---------- library/ssl_msg.c | 34 ++++++++++++++++++---------------- library/ssl_srv.c | 3 ++- library/ssl_tls.c | 19 +++++++++++-------- 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 3f627139c8..d2f4361388 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -594,7 +594,7 @@ union mbedtls_ssl_premaster_secret #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret ) /* Length of in_ctr buffer in mbedtls_ssl_session */ -#define MBEDTLS_SSL_IN_CTR_LEN 8 +#define MBEDTLS_SSL_COUNTER_LEN 8 #ifdef __cplusplus extern "C" { @@ -1555,7 +1555,7 @@ struct mbedtls_ssl_context size_t MBEDTLS_PRIVATE(out_buf_len); /*!< length of output buffer */ #endif - unsigned char MBEDTLS_PRIVATE(cur_out_ctr)[8]; /*!< Outgoing record sequence number. */ + unsigned char MBEDTLS_PRIVATE(cur_out_ctr)[MBEDTLS_SSL_COUNTER_LEN]; /*!< Outgoing record sequence number. */ #if defined(MBEDTLS_SSL_PROTO_DTLS) uint16_t MBEDTLS_PRIVATE(mtu); /*!< path mtu, used to fragment outgoing messages */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index ea891f44a5..6f83fc3276 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -573,8 +573,8 @@ struct mbedtls_ssl_handshake_params flight being received */ mbedtls_ssl_transform *alt_transform_out; /*!< Alternative transform for resending messages */ - unsigned char alt_out_ctr[8]; /*!< Alternative record epoch/counter - for resending messages */ + unsigned char alt_out_ctr[MBEDTLS_SSL_COUNTER_LEN]; /*!< Alternative record epoch/counter + for resending messages */ #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) /* The state of CID configuration in this handshake. */ @@ -873,14 +873,14 @@ static inline int mbedtls_ssl_transform_uses_aead( typedef struct { - uint8_t ctr[8]; /* In TLS: The implicit record sequence number. - * In DTLS: The 2-byte epoch followed by - * the 6-byte sequence number. - * This is stored as a raw big endian byte array - * as opposed to a uint64_t because we rarely - * need to perform arithmetic on this, but do - * need it as a Byte array for the purpose of - * MAC computations. */ + uint8_t ctr[MBEDTLS_SSL_COUNTER_LEN]; /* In TLS: The implicit record sequence number. + * In DTLS: The 2-byte epoch followed by + * the 6-byte sequence number. + * This is stored as a raw big endian byte array + * as opposed to a uint64_t because we rarely + * need to perform arithmetic on this, but do + * need it as a Byte array for the purpose of + * MAC computations. */ uint8_t type; /* The record content type. */ uint8_t ver[2]; /* SSL/TLS version as present on the wire. * Convert to internal presentation of versions diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 518cfeeef4..25e3ca3ec2 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2117,9 +2117,9 @@ static int ssl_swap_epochs( mbedtls_ssl_context *ssl ) ssl->handshake->alt_transform_out = tmp_transform; /* Swap epoch + sequence_number */ - memcpy( tmp_out_ctr, ssl->cur_out_ctr, 8 ); - memcpy( ssl->cur_out_ctr, ssl->handshake->alt_out_ctr, 8 ); - memcpy( ssl->handshake->alt_out_ctr, tmp_out_ctr, 8 ); + memcpy( tmp_out_ctr, ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); + memcpy( ssl->cur_out_ctr, ssl->handshake->alt_out_ctr, sizeof( ssl->cur_out_ctr ) ); + memcpy( ssl->handshake->alt_out_ctr, tmp_out_ctr, sizeof( ssl->handshake->alt_out_ctr ) ); /* Adjust to the newly activated transform */ mbedtls_ssl_update_out_pointers( ssl, ssl->transform_out ); @@ -2562,7 +2562,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, ssl->conf->transport, ssl->out_hdr + 1 ); - memcpy( ssl->out_ctr, ssl->cur_out_ctr, 8 ); + memcpy( ssl->out_ctr, ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); MBEDTLS_PUT_UINT16_BE( len, ssl->out_len, 0); if( ssl->transform_out != NULL ) @@ -2574,7 +2574,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) rec.data_len = ssl->out_msglen; rec.data_offset = ssl->out_msg - rec.buf; - memcpy( &rec.ctr[0], ssl->out_ctr, 8 ); + memcpy( &rec.ctr[0], ssl->out_ctr, MBEDTLS_SSL_COUNTER_LEN ); mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, ssl->conf->transport, rec.ver ); rec.type = ssl->out_msgtype; @@ -3649,7 +3649,7 @@ static int ssl_prepare_record_content( mbedtls_ssl_context *ssl, #endif { unsigned i; - for( i = MBEDTLS_SSL_IN_CTR_LEN; i > mbedtls_ssl_ep_len( ssl ); i-- ) + for( i = MBEDTLS_SSL_COUNTER_LEN; i > mbedtls_ssl_ep_len( ssl ); i-- ) if( ++ssl->in_ctr[i - 1] != 0 ) break; @@ -4791,7 +4791,7 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_IN_CTR_LEN ); + mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_COUNTER_LEN ); mbedtls_ssl_update_in_pointers( ssl ); @@ -4827,12 +4827,12 @@ void mbedtls_ssl_update_out_pointers( mbedtls_ssl_context *ssl, { ssl->out_ctr = ssl->out_hdr + 3; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) - ssl->out_cid = ssl->out_ctr + 8; + ssl->out_cid = ssl->out_ctr + MBEDTLS_SSL_COUNTER_LEN; ssl->out_len = ssl->out_cid; if( transform != NULL ) ssl->out_len += transform->out_cid_len; #else /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ - ssl->out_len = ssl->out_ctr + 8; + ssl->out_len = ssl->out_ctr + MBEDTLS_SSL_COUNTER_LEN; #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ ssl->out_iv = ssl->out_len + 2; } @@ -4881,17 +4881,17 @@ void mbedtls_ssl_update_in_pointers( mbedtls_ssl_context *ssl ) * ssl_parse_record_header(). */ ssl->in_ctr = ssl->in_hdr + 3; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) - ssl->in_cid = ssl->in_ctr + MBEDTLS_SSL_IN_CTR_LEN; + ssl->in_cid = ssl->in_ctr + MBEDTLS_SSL_COUNTER_LEN; ssl->in_len = ssl->in_cid; /* Default: no CID */ #else /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ - ssl->in_len = ssl->in_ctr + MBEDTLS_SSL_IN_CTR_LEN; + ssl->in_len = ssl->in_ctr + MBEDTLS_SSL_COUNTER_LEN; #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ ssl->in_iv = ssl->in_len + 2; } else #endif { - ssl->in_ctr = ssl->in_hdr - MBEDTLS_SSL_IN_CTR_LEN; + ssl->in_ctr = ssl->in_hdr - MBEDTLS_SSL_COUNTER_LEN; ssl->in_len = ssl->in_hdr + 3; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) ssl->in_cid = ssl->in_len; @@ -5065,9 +5065,11 @@ static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl ) } in_ctr_cmp = memcmp( ssl->in_ctr + ep_len, - ssl->conf->renego_period + ep_len, 8 - ep_len ); - out_ctr_cmp = memcmp( ssl->cur_out_ctr + ep_len, - ssl->conf->renego_period + ep_len, 8 - ep_len ); + &ssl->conf->renego_period[ep_len], + MBEDTLS_SSL_COUNTER_LEN - ep_len ); + out_ctr_cmp = memcmp( &ssl->cur_out_ctr[ep_len], + &ssl->conf->renego_period[ep_len], + sizeof( ssl->cur_out_ctr ) - ep_len ); if( in_ctr_cmp <= 0 && out_ctr_cmp <= 0 ) { @@ -5558,7 +5560,7 @@ void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, return; ssl->transform_in = transform; - mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_IN_CTR_LEN ); + mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_COUNTER_LEN ); } void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 147bb785de..79c160ea4a 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1220,7 +1220,8 @@ read_record_header: return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } - memcpy( ssl->cur_out_ctr + 2, ssl->in_ctr + 2, MBEDTLS_SSL_IN_CTR_LEN - 2 ); + memcpy( &ssl->cur_out_ctr[2], ssl->in_ctr + 2, + MBEDTLS_SSL_COUNTER_LEN - 2 ); #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) if( mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index ab36f5d89f..b22db47b5b 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -2820,10 +2820,13 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) /* Remember current epoch settings for resending */ ssl->handshake->alt_transform_out = ssl->transform_out; - memcpy( ssl->handshake->alt_out_ctr, ssl->cur_out_ctr, 8 ); + memcpy( ssl->handshake->alt_out_ctr, ssl->cur_out_ctr, + sizeof( ssl->cur_out_ctr ) ); /* Set sequence_number to zero */ - memset( ssl->cur_out_ctr + 2, 0, 6 ); + mbedtls_platform_zeroize( &ssl->cur_out_ctr[2], + sizeof( ssl->cur_out_ctr ) - 2 ); + /* Increment epoch */ for( i = 2; i > 0; i-- ) @@ -2839,7 +2842,7 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - memset( ssl->cur_out_ctr, 0, 8 ); + mbedtls_platform_zeroize( ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); ssl->transform_out = ssl->transform_negotiate; ssl->session_out = ssl->session_negotiate; @@ -3324,7 +3327,7 @@ static void ssl_session_reset_msg_layer( mbedtls_ssl_context *ssl, ssl->out_msglen = 0; ssl->out_left = 0; memset( ssl->out_buf, 0, out_buf_len ); - memset( ssl->cur_out_ctr, 0, sizeof( ssl->cur_out_ctr ) ); + mbedtls_platform_zeroize( ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); ssl->transform_out = NULL; #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) @@ -5778,7 +5781,7 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, used += 8; if( used <= buf_len ) { - memcpy( p, ssl->cur_out_ctr, 8 ); + memcpy( p, ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); p += 8; } @@ -6035,11 +6038,11 @@ static int ssl_context_load( mbedtls_ssl_context *ssl, ssl->disable_datagram_packing = *p++; #endif /* MBEDTLS_SSL_PROTO_DTLS */ - if( (size_t)( end - p ) < 8 ) + if( (size_t)( end - p ) < sizeof( ssl->cur_out_ctr ) ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - memcpy( ssl->cur_out_ctr, p, 8 ); - p += 8; + memcpy( ssl->cur_out_ctr, p, sizeof( ssl->cur_out_ctr ) ); + p += sizeof( ssl->cur_out_ctr ); #if defined(MBEDTLS_SSL_PROTO_DTLS) if( (size_t)( end - p ) < 2 ) From 946c9204757da344755d3265a779270ef578c1cb Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 28 Sep 2021 14:32:55 +0100 Subject: [PATCH 633/966] Add safety for nonce length to internal driver Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 5e36932e7c..bc37a043e6 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -412,6 +412,16 @@ psa_status_t mbedtls_psa_aead_set_nonce( #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { + /* Note - ChaChaPoly allows an 8 byte nonce, but we would have to + * allocate a buffer in the operation, copy the nonce to it and pad + * it, so for now check the nonce is 12 bytes, as + * mbedtls_chachapoly_starts() assumes it can read 12 bytes from the + * passed in buffer. */ + if( nonce_length != 12 ) + { + return( PSA_ERROR_INVALID_ARGUMENT ); + } + status = mbedtls_to_psa_error( mbedtls_chachapoly_starts( &operation->ctx.chachapoly, nonce, From 814f0c5fb1e8c47aa7e27c8216e98a6393a8c56e Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 28 Sep 2021 14:41:22 +0100 Subject: [PATCH 634/966] Remove check for lack of supported ciphers Add comment explaining (currently) empty function. Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index bc37a043e6..a72865c04c 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -446,20 +446,12 @@ psa_status_t mbedtls_psa_aead_set_lengths( size_t ad_length, size_t plaintext_length ) { - + /* Nothing here yet, work is currently done in PSA Core, however support + * for CCM will require this function. */ ( void ) operation; ( void ) ad_length; ( void ) plaintext_length; -#if !defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) && \ - !defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) && \ - !defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - { - return ( PSA_ERROR_NOT_SUPPORTED ); - } -#endif /* !MBEDTLS_PSA_BUILTIN_ALG_GCM && !MBEDTLS_PSA_BUILTIN_ALG_CCM && - !MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) */ - return ( PSA_SUCCESS ); } From 8ee9ed6785e1f9ded44f1bd07401b0b70c524479 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 28 Sep 2021 14:46:43 +0200 Subject: [PATCH 635/966] Fix and improve the documentation of supported groups Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 5421492aee..b15d77ca61 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -135,9 +135,12 @@ MVP definition (2) The MVP sends one shared secret corresponding to the configured preferred group. The preferred group is the group of the first curve in the list of - allowed curves as defined by the configuration. By default, it is the - mandatory group as defined by section 9.1 of the specification, - `secp256r1`. The list of allowed curves can be set through the + allowed curves as defined by the configuration. The allowed curves are + by default ordered as follow: `secp256r1`, `x25519`, `secp384r1` + and finally `secp521r1`. This default order is aligned with the + list of mandatory-to-implement groups (in absence of an application + profile standard specifying otherwise) defined in section 9.1 of the + specification. The list of allowed curves can be changed through the `mbedtls_ssl_conf_curves()` API. (3) The MVP proposes only TLS 1.3 and does not support version negociation. @@ -148,11 +151,8 @@ MVP definition re-initiate a server handshake. - Supported groups: depends on the library configuration. - Minimally (as defined in section 9.1 of the TLS 1.3 specification): - secp256r1 and x25519. - - Furthermore, depending on the library configuration, potentially: - secp384r1 and secp521r1. + Potentially all ECDHE groups but x448: + secp256r1, x25519, secp384r1 and secp521r1. Finite field groups (DHE) are not supported. From fb877215b56152215622b44a48f0d8fe8e11e788 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 28 Sep 2021 15:49:39 +0200 Subject: [PATCH 636/966] Fix supported signature documentation Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index b15d77ca61..5a73715b0e 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -156,12 +156,15 @@ MVP definition Finite field groups (DHE) are not supported. -- Supported signature algorithms(both for certificates and CertificateVerify): - Minimally (as defined in section 9.1 of the TLS 1.3 specification): - rsa_pkcs1_sha256, rsa_pss_rsae_sha256 and ecdsa_secp256r1_sha256 +- Supported signature algorithms (both for certificates and CertificateVerify): + depends on the library configuration. + Potentially: + rsa_pkcs1_sha256, rsa_pss_rsae_sha256, ecdsa_secp256r1_sha256, + ecdsa_secp384r1_sha384 and ecdsa_secp521r1_sha512. - Furthermore, depending on the library configuration, potentially: - ecdsa_secp384r1_sha384 and ecdsa_secp521r1_sha512 + Note that in absence of an application profile standard specifying otherwise + the three first ones in the list above are mandatory (see section 9.1 of the + specification). - Supported versions: only TLS 1.3, version negotiation is not supported. From 7fc96c1a5731df5fa41bc4dca235e1f6ba62ffad Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Tue, 28 Sep 2021 15:54:57 +0200 Subject: [PATCH 637/966] Fix test description Signed-off-by: Ronald Cron --- docs/architecture/tls13-experimental.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 5a73715b0e..5d7c14f1bb 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -218,10 +218,9 @@ MVP definition - Quality considerations - Standard Mbed TLS review bar - Interoperability testing with OpenSSL and GnuTLS. Test with all the - cipher suites supported by OpenSSL/GnuTLS server with and without - certificate base authentication. + cipher suites and signature algorithms supported by OpenSSL/GnuTLS server. - Negative testing against OpenSSL/GnuTLS servers with which the - handshake fails due to imcompatibility with the capabilities of the + handshake fails due to incompatibility with the capabilities of the MVP: TLS 1.2 or 1.1 server, server sending an HelloRetryRequest message in response to the MVP ClientHello, server sending a CertificateRequest message ... From baff51c8b7d0e6d9e023fa4f0cea4410fc08f719 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 28 Sep 2021 17:44:45 +0100 Subject: [PATCH 638/966] Make sure nonce length checks use base algorithm Nonce length checks are now being used in the oneshot AEAD code as well, which passes variant algorithms, not the base version, so need to convert to base if necessary. Signed-off-by: Paul Elliott --- library/psa_crypto.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 42abdf5c46..395a697308 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3609,12 +3609,20 @@ exit: /* AEAD */ /****************************************************************/ -/* Helper to perform common nonce length checks. */ +/* Helper function to get the base algorithm from its variants. */ +static psa_algorithm_t psa_aead_get_base_algorithm( psa_algorithm_t alg ) +{ + return PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( alg ); +} + +/* Helper function to perform common nonce length checks. */ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, size_t nonce_length ) { + psa_algorithm_t base_alg = psa_aead_get_base_algorithm( alg ); + #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) - if( alg == PSA_ALG_GCM ) + if( base_alg == PSA_ALG_GCM ) { /* Not checking max nonce size here as GCM spec allows almost * arbitrarily large nonces. Please note that we do not generally @@ -3627,7 +3635,7 @@ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, } #endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) - if( alg == PSA_ALG_CCM ) + if( base_alg == PSA_ALG_CCM ) { if( nonce_length < 7 || nonce_length > 13 ) return( PSA_ERROR_NOT_SUPPORTED ); @@ -3635,11 +3643,11 @@ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) - if( alg == PSA_ALG_CHACHA20_POLY1305 ) - { - if( nonce_length != 12 ) - return( PSA_ERROR_NOT_SUPPORTED ); - } + if( base_alg == PSA_ALG_CHACHA20_POLY1305 ) + { + if( nonce_length != 12 ) + return( PSA_ERROR_NOT_SUPPORTED ); + } #endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ return PSA_SUCCESS; @@ -3745,12 +3753,6 @@ exit: return( status ); } -/* Helper function to get the base algorithm from its variants. */ -static psa_algorithm_t psa_aead_get_base_algorithm( psa_algorithm_t alg ) -{ - return PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( alg ); -} - /* Set the key for a multipart authenticated operation. */ static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, int is_encrypt, From d96a5c2d86ee01c61f3c8d8a16f16d351b72fc82 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 29 Sep 2021 17:46:51 +0800 Subject: [PATCH 639/966] Fix wrong usage of counter len macro Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 2 +- library/ssl_msg.c | 14 ++++++++------ library/ssl_srv.c | 2 +- library/ssl_tls.c | 9 ++++----- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index d2f4361388..2b75267e84 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -593,7 +593,7 @@ union mbedtls_ssl_premaster_secret #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret ) -/* Length of in_ctr buffer in mbedtls_ssl_session */ +/* Length in number of bytes of the TLS sequence number */ #define MBEDTLS_SSL_COUNTER_LEN 8 #ifdef __cplusplus diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 25e3ca3ec2..e636762c53 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2101,7 +2101,7 @@ void mbedtls_ssl_flight_free( mbedtls_ssl_flight_item *flight ) static int ssl_swap_epochs( mbedtls_ssl_context *ssl ) { mbedtls_ssl_transform *tmp_transform; - unsigned char tmp_out_ctr[8]; + unsigned char tmp_out_ctr[MBEDTLS_SSL_COUNTER_LEN]; if( ssl->transform_out == ssl->handshake->alt_transform_out ) { @@ -2117,9 +2117,11 @@ static int ssl_swap_epochs( mbedtls_ssl_context *ssl ) ssl->handshake->alt_transform_out = tmp_transform; /* Swap epoch + sequence_number */ - memcpy( tmp_out_ctr, ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); - memcpy( ssl->cur_out_ctr, ssl->handshake->alt_out_ctr, sizeof( ssl->cur_out_ctr ) ); - memcpy( ssl->handshake->alt_out_ctr, tmp_out_ctr, sizeof( ssl->handshake->alt_out_ctr ) ); + memcpy( tmp_out_ctr, ssl->cur_out_ctr, sizeof( tmp_out_ctr ) ); + memcpy( ssl->cur_out_ctr, ssl->handshake->alt_out_ctr, + sizeof( ssl->cur_out_ctr ) ); + memcpy( ssl->handshake->alt_out_ctr, tmp_out_ctr, + sizeof( ssl->handshake->alt_out_ctr ) ); /* Adjust to the newly activated transform */ mbedtls_ssl_update_out_pointers( ssl, ssl->transform_out ); @@ -2562,7 +2564,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, ssl->conf->transport, ssl->out_hdr + 1 ); - memcpy( ssl->out_ctr, ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); + memcpy( ssl->out_ctr, ssl->cur_out_ctr, MBEDTLS_SSL_COUNTER_LEN ); MBEDTLS_PUT_UINT16_BE( len, ssl->out_len, 0); if( ssl->transform_out != NULL ) @@ -2574,7 +2576,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) rec.data_len = ssl->out_msglen; rec.data_offset = ssl->out_msg - rec.buf; - memcpy( &rec.ctr[0], ssl->out_ctr, MBEDTLS_SSL_COUNTER_LEN ); + memcpy( &rec.ctr[0], ssl->out_ctr, sizeof( rec.ctr ) ); mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, ssl->conf->transport, rec.ver ); rec.type = ssl->out_msgtype; diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 79c160ea4a..e27fdff5e3 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1221,7 +1221,7 @@ read_record_header: } memcpy( &ssl->cur_out_ctr[2], ssl->in_ctr + 2, - MBEDTLS_SSL_COUNTER_LEN - 2 ); + sizeof( ssl->cur_out_ctr ) - 2 ); #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) if( mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index b22db47b5b..58b81ff26d 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -2821,7 +2821,7 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) /* Remember current epoch settings for resending */ ssl->handshake->alt_transform_out = ssl->transform_out; memcpy( ssl->handshake->alt_out_ctr, ssl->cur_out_ctr, - sizeof( ssl->cur_out_ctr ) ); + sizeof( ssl->handshake->alt_out_ctr ) ); /* Set sequence_number to zero */ mbedtls_platform_zeroize( &ssl->cur_out_ctr[2], @@ -5778,11 +5778,11 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, } #endif /* MBEDTLS_SSL_PROTO_DTLS */ - used += 8; + used += MBEDTLS_SSL_COUNTER_LEN; if( used <= buf_len ) { - memcpy( p, ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); - p += 8; + memcpy( p, ssl->cur_out_ctr, MBEDTLS_SSL_COUNTER_LEN ); + p += MBEDTLS_SSL_COUNTER_LEN; } #if defined(MBEDTLS_SSL_PROTO_DTLS) @@ -6040,7 +6040,6 @@ static int ssl_context_load( mbedtls_ssl_context *ssl, if( (size_t)( end - p ) < sizeof( ssl->cur_out_ctr ) ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - memcpy( ssl->cur_out_ctr, p, sizeof( ssl->cur_out_ctr ) ); p += sizeof( ssl->cur_out_ctr ); From 8c4eb88fe35d42c5f57868c34135e0cd8f45f1f2 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 29 Sep 2021 12:10:32 +0200 Subject: [PATCH 640/966] test_suite_cipher: add tests for mbedtls_cipher_setup_psa() with ECB Signed-off-by: Przemyslaw Stekiel --- tests/suites/test_suite_cipher.aes.data | 96 +++++++++++++++++++++++++ tests/suites/test_suite_cipher.function | 8 +++ 2 files changed, 104 insertions(+) diff --git a/tests/suites/test_suite_cipher.aes.data b/tests/suites/test_suite_cipher.aes.data index 4dbdd52529..4ad593a3a2 100644 --- a/tests/suites/test_suite_cipher.aes.data +++ b/tests/suites/test_suite_cipher.aes.data @@ -1798,6 +1798,102 @@ AES-256-CBC crypt Decrypt NIST KAT #4 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"5c9d844ed46f9885085e5d6a4f94c7d7":"014730f80ac625fe84f026c60bfd547d":0:1 +AES-128-ECB crypt Encrypt NIST KAT #1 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"3ad78e726c1ec02b7ebfe92b23d9ec34":0:1 + +AES-128-ECB crypt Encrypt NIST KAT #2 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"ffffffffffffffffffffffffffffe000":"00000000000000000000000000000000":"00000000000000000000000000000000":"323994cfb9da285a5d9642e1759b224a":0:1 + +AES-128-ECB crypt Encrypt NIST KAT #3 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"10a58869d74be5a374cf867cfb473859":"00000000000000000000000000000000":"00000000000000000000000000000000":"6d251e6944b051e04eaa6fb4dbf78465":0:1 + +AES-128-ECB crypt Encrypt NIST KAT #4 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"f34481ec3cc627bacd5dc3fb08f273e6":"0336763e966d92595a567cc9ce537f5e":0:1 + +AES-128-ECB crypt Decrypt NIST KAT #1 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"3ad78e726c1ec02b7ebfe92b23d9ec34":"80000000000000000000000000000000":0:1 + +AES-128-ECB crypt Decrypt NIST KAT #2 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"ffffc000000000000000000000000000":"00000000000000000000000000000000":"df556a33438db87bc41b1752c55e5e49":"00000000000000000000000000000000":0:1 + +AES-128-ECB crypt Decrypt NIST KAT #3 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"10a58869d74be5a374cf867cfb473859":"00000000000000000000000000000000":"6d251e6944b051e04eaa6fb4dbf78465":"00000000000000000000000000000000":0:1 + +AES-128-ECB crypt Decrypt NIST KAT #4 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"0336763e966d92595a567cc9ce537f5e":"f34481ec3cc627bacd5dc3fb08f273e6":0:1 + +AES-192-ECB crypt Encrypt NIST KAT #1 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"6cd02513e8d4dc986b4afe087a60bd0c":0:1 + +AES-192-ECB crypt Encrypt NIST KAT #2 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"ff0000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"833f71258d53036b02952c76c744f5a1":0:1 + +AES-192-ECB crypt Encrypt NIST KAT #3 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd":"00000000000000000000000000000000":"00000000000000000000000000000000":"0956259c9cd5cfd0181cca53380cde06":0:1 + +AES-192-ECB crypt Encrypt NIST KAT #4 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"1b077a6af4b7f98229de786d7516b639":"275cfc0413d8ccb70513c3859b1d0f72":0:1 + +AES-192-ECB crypt Decrypt NIST KAT #1 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"6cd02513e8d4dc986b4afe087a60bd0c":"80000000000000000000000000000000":0:1 + +AES-192-ECB crypt Decrypt NIST KAT #2 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"ffe000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"7ababc4b3f516c9aafb35f4140b548f9":"00000000000000000000000000000000":0:1 + +AES-192-ECB crypt Decrypt NIST KAT #3 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd":"00000000000000000000000000000000":"0956259c9cd5cfd0181cca53380cde06":"00000000000000000000000000000000":0:1 + +AES-192-ECB crypt Decrypt NIST KAT #4 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"275cfc0413d8ccb70513c3859b1d0f72":"1b077a6af4b7f98229de786d7516b639":0:1 + +AES-256-ECB crypt Encrypt NIST KAT #1 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"ddc6bf790c15760d8d9aeb6f9a75fd4e":0:1 + +AES-256-ECB crypt Encrypt NIST KAT #2 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"ff00000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"ec52a212f80a09df6317021bc2a9819e":0:1 + +AES-256-ECB crypt Encrypt NIST KAT #3 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558":"00000000000000000000000000000000":"00000000000000000000000000000000":"46f2fb342d6f0ab477476fc501242c5f":0:1 + +AES-256-ECB crypt Encrypt NIST KAT #4 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"014730f80ac625fe84f026c60bfd547d":"5c9d844ed46f9885085e5d6a4f94c7d7":0:1 + +AES-256-ECB crypt Decrypt NIST KAT #1 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ddc6bf790c15760d8d9aeb6f9a75fd4e":"80000000000000000000000000000000":0:1 + +AES-256-ECB crypt Decrypt NIST KAT #2 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"ffe0000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"d1ccb9b1337002cbac42c520b5d67722":"00000000000000000000000000000000":0:1 + +AES-256-ECB crypt Decrypt NIST KAT #3 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558":"00000000000000000000000000000000":"46f2fb342d6f0ab477476fc501242c5f":"00000000000000000000000000000000":0:1 + +AES-256-ECB crypt Decrypt NIST KAT #4 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"5c9d844ed46f9885085e5d6a4f94c7d7":"014730f80ac625fe84f026c60bfd547d":0:1 + Cipher Corner Case behaviours depends_on:MBEDTLS_AES_C cipher_special_behaviours: diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index 674349f764..20d48e2a1b 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -950,6 +950,14 @@ void test_vec_crypt( int cipher_id, int operation, data_t *key, if( use_psa == 1 ) { PSA_ASSERT( psa_crypto_init( ) ); + + if (cipher_id == MBEDTLS_CIPHER_AES_192_ECB || + cipher_id == MBEDTLS_CIPHER_AES_256_ECB) + { + TEST_ASSERT( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE == mbedtls_cipher_setup_psa( &ctx, + mbedtls_cipher_info_from_type( cipher_id ), 0 ) ); + goto exit; + } TEST_ASSERT( 0 == mbedtls_cipher_setup_psa( &ctx, mbedtls_cipher_info_from_type( cipher_id ), 0 ) ); } From 80c6a8e1a6301a0084954dc509515267770026a2 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 29 Sep 2021 12:13:11 +0200 Subject: [PATCH 641/966] Add PSA support for MBEDTLS_CIPHER_AES_128_ECB Signed-off-by: Przemyslaw Stekiel --- include/mbedtls/psa_util.h | 1 + library/cipher.c | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/psa_util.h b/include/mbedtls/psa_util.h index f6f2e58054..31a1254b9f 100644 --- a/include/mbedtls/psa_util.h +++ b/include/mbedtls/psa_util.h @@ -57,6 +57,7 @@ static inline psa_key_type_t mbedtls_psa_translate_cipher_type( case MBEDTLS_CIPHER_AES_128_CBC: case MBEDTLS_CIPHER_AES_192_CBC: case MBEDTLS_CIPHER_AES_256_CBC: + case MBEDTLS_CIPHER_AES_128_ECB: return( PSA_KEY_TYPE_AES ); /* ARIA not yet supported in PSA. */ diff --git a/library/cipher.c b/library/cipher.c index 546cace552..dc801894b7 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -1266,9 +1266,12 @@ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, if( status != PSA_SUCCESS ) return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED ); - status = psa_cipher_set_iv( &cipher_op, iv, iv_len ); - if( status != PSA_SUCCESS ) - return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED ); + if( ctx->cipher_info->mode != MBEDTLS_MODE_ECB ) + { + status = psa_cipher_set_iv( &cipher_op, iv, iv_len ); + if( status != PSA_SUCCESS ) + return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED ); + } status = psa_cipher_update( &cipher_op, input, ilen, From e716e6c00bcc81e54d233b430319b544b065cd75 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 29 Sep 2021 14:10:20 +0100 Subject: [PATCH 642/966] Switch cipher enabled macros Switch from using MBEDTLS_PSA_BUILTIN_ macros over to using PSA_WANT_ macros, as code was moved from the internal drivers to the PSA Core. Signed-off-by: Paul Elliott --- library/psa_crypto.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 395a697308..ea02f24d1d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3621,7 +3621,7 @@ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, { psa_algorithm_t base_alg = psa_aead_get_base_algorithm( alg ); -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) +#if defined(PSA_WANT_ALG_GCM) if( base_alg == PSA_ALG_GCM ) { /* Not checking max nonce size here as GCM spec allows almost @@ -3633,22 +3633,22 @@ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, if( nonce_length == 0 ) return( PSA_ERROR_NOT_SUPPORTED ); } -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) +#endif /* PSA_WANT_ALG_GCM */ +#if defined(PSA_WANT_ALG_CCM) if( base_alg == PSA_ALG_CCM ) { if( nonce_length < 7 || nonce_length > 13 ) return( PSA_ERROR_NOT_SUPPORTED ); } else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) +#endif /* PSA_WANT_ALG_CCM */ +#if defined(PSA_WANT_ALG_CHACHA20_POLY1305) if( base_alg == PSA_ALG_CHACHA20_POLY1305 ) { if( nonce_length != 12 ) return( PSA_ERROR_NOT_SUPPORTED ); } -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ +#endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */ return PSA_SUCCESS; } @@ -3951,7 +3951,7 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, goto exit; } -#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) +#if defined(PSA_WANT_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { /* Lengths can only be too large for GCM if size_t is bigger than 32 @@ -3967,8 +3967,8 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, #endif } else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) +#endif /* PSA_WANT_ALG_GCM */ +#if defined(PSA_WANT_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { if( ad_length > 0xFF00 ) @@ -3978,13 +3978,13 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, } } else -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ -#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) +#endif /* PSA_WANT_ALG_CCM */ +#if defined(PSA_WANT_ALG_CHACHA20_POLY1305) if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) { /* No length restrictions for ChaChaPoly. */ } -#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */ +#endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */ status = psa_driver_wrapper_aead_set_lengths( operation, ad_length, plaintext_length ); From 355f59edbe7ef021131f1dc378a10013eb668c5f Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 29 Sep 2021 14:16:19 +0100 Subject: [PATCH 643/966] Fix formatting issues Signed-off-by: Paul Elliott --- library/psa_crypto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ea02f24d1d..ee2eec59b5 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3912,7 +3912,6 @@ psa_status_t psa_aead_set_nonce( psa_aead_operation_t *operation, } status = psa_aead_check_nonce_length( operation->alg, nonce_length ); - if( status != PSA_SUCCESS ) { status = PSA_ERROR_INVALID_ARGUMENT; @@ -3955,8 +3954,8 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, if( operation->alg == PSA_ALG_GCM ) { /* Lengths can only be too large for GCM if size_t is bigger than 32 - * bits. Without the guard this code will generate warnings on 32bit - * builds */ + * bits. Without the guard this code will generate warnings on 32bit + * builds. */ #if SIZE_MAX > UINT32_MAX if( (( uint64_t ) ad_length ) >> 61 != 0 || (( uint64_t ) plaintext_length ) > 0xFFFFFFFE0ull ) From 60116aee9e86206caf8e16d8b2da7a4205d9735a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 29 Sep 2021 14:19:11 +0100 Subject: [PATCH 644/966] Invert logic on nonce length tests Signed-off-by: Paul Elliott --- library/psa_crypto.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ee2eec59b5..ece64b100d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3630,27 +3630,27 @@ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, * PSA_AEAD_NONCE_MAX_SIZE, as large nonces are hashed to a shorter * size, which can then lead to collisions if you encrypt a very * large number of messages.*/ - if( nonce_length == 0 ) - return( PSA_ERROR_NOT_SUPPORTED ); + if( nonce_length != 0 ) + return( PSA_SUCCESS ); } #endif /* PSA_WANT_ALG_GCM */ #if defined(PSA_WANT_ALG_CCM) if( base_alg == PSA_ALG_CCM ) { - if( nonce_length < 7 || nonce_length > 13 ) - return( PSA_ERROR_NOT_SUPPORTED ); + if( nonce_length >= 7 && nonce_length <= 13 ) + return( PSA_SUCCESS ); } else #endif /* PSA_WANT_ALG_CCM */ #if defined(PSA_WANT_ALG_CHACHA20_POLY1305) if( base_alg == PSA_ALG_CHACHA20_POLY1305 ) { - if( nonce_length != 12 ) - return( PSA_ERROR_NOT_SUPPORTED ); + if( nonce_length == 12 ) + return( PSA_SUCCESS ); } #endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */ - return PSA_SUCCESS; + return( PSA_ERROR_NOT_SUPPORTED ); } psa_status_t psa_aead_encrypt( mbedtls_svc_key_id_t key, From 4ef7bd8595a8264cad957dca868c317691ed11e7 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 28 Sep 2021 21:23:57 +0200 Subject: [PATCH 645/966] Simplify PSA_ALG_AEAD_WITH_SHORTENED_TAG with full-length tag Only use PSA_ALG_AEAD_WITH_SHORTENED_TAG with the default tag length when it's part of a series or when the tag length is a critical part of the test. Don't use it when the tag length is secondary, to make the test data easier to read. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto.data | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index f83f83b86b..7830968ce2 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -3212,19 +3212,19 @@ aead_multipart_verify:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909 PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 12 / Expect 12) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):12:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:12:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 11 / Expect 0) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):11:0:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:11:0:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 0 / Expect 0) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:0:0:"":"":PSA_ERROR_BUFFER_TOO_SMALL PSA Multipart Nonce Generation, AES - GCM, NONCE = (Req 16 / Expect 12) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_generate_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:16:12:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Nonce Generation: ChaCha20 - Poly1305, NONCE = (Req 12 / Expect 12) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 @@ -3244,19 +3244,20 @@ aead_multipart_generate_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8 PSA Multipart Set Nonce, AES - GCM, NONCE = 0 (NULL) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:0:"":"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce, AES - GCM, NONCE = 0 (Non-NULL) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):-1:"":"":PSA_ERROR_INVALID_ARGUMENT +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:-1:"":"":PSA_ERROR_INVALID_ARGUMENT PSA Multipart Set Nonce, AES - GCM, NONCE = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):16:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:16:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Set Nonce, AES - GCM, NONCE = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS + PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 11 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 @@ -3280,11 +3281,11 @@ aead_multipart_set_nonce:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_GCM:15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL PSA AEAD output buffer test: AES - GCM, IN = 16, BUF = 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):0:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_update_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_GCM:0:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL PSA AEAD output buffer test: ChaCha20 - Poly1305 IN = 130, BUF = 129 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 @@ -3296,19 +3297,19 @@ aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8 PSA AEAD finish buffer test: AES - GCM, BUF = 8, TAG = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):8:16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_GCM:8:16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL PSA AEAD finish buffer test: AES - GCM, BUF = 15, TAG = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:20:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_GCM:15:20:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS PSA AEAD finish buffer test: AES - GCM, BUF = 15, TAG = 15 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_GCM:15:15:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL PSA AEAD finish buffer test: AES - GCM, BUF = 15, TAG = 0 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,16):15:0:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_GCM:15:0:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL PSA AEAD finish buffer test: ChaCha20 - Poly1305, BUF = 0, TAG = 20 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 From 96b332ccaca1395057d45fdb8be24b883446fb3f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 28 Sep 2021 21:26:12 +0200 Subject: [PATCH 646/966] Test invalid nonce length for one-shot AEAD decryption Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto.data | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 7830968ce2..21f52b28b8 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2482,6 +2482,22 @@ PSA AEAD decrypt: AES-CCM, invalid tag length 18 depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT +PSA AEAD decrypt: AES-CCM, invalid nonce length 6 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c090693056":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_NOT_SUPPORTED + +PSA AEAD decrypt: AES-CCM, invalid nonce length 14 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd97200":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_NOT_SUPPORTED + +PSA AEAD decrypt: AES-CCM_8, invalid nonce length 6 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c090693056":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_NOT_SUPPORTED + +PSA AEAD decrypt: AES-CCM_8, invalid nonce length 14 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c0906930561e0ab0ef4cd97200":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_NOT_SUPPORTED + PSA AEAD encrypt/decrypt, AES-GCM, 19 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":PSA_ALG_GCM:"000102030405060708090A0B0C0D0E0F":"000102030405060708090A0B":"0C0D0E0F101112131415161718191A1B1C1D1E":PSA_SUCCESS @@ -2634,6 +2650,14 @@ PSA AEAD decrypt: AES-GCM, invalid tag length 2 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 2 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT +PSA AEAD decrypt: AES-GCM, nonce=0 (bad) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":PSA_ERROR_NOT_SUPPORTED + +PSA AEAD decrypt: AES-GCM, nonce=0 (bad), TAG=12 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":PSA_ERROR_NOT_SUPPORTED + PSA AEAD decrypt: AES-GCM, invalid tag length 18 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 18 ):"48c0906930561e0ab0ef4cd972":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT @@ -2738,6 +2762,18 @@ PSA AEAD decrypt: ChaCha20-Poly1305 (good tag, zero-length input) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344454647":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_SUCCESS +PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=8, not supported) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"0700000040414243":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED + +PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=11, too short) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED + +PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=13, too long) +depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 +aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"07000000404142434445464700":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED + PSA AEAD encrypt/decrypt: invalid algorithm (CTR) depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C aead_encrypt_decrypt:PSA_KEY_TYPE_AES:"D7828D13B2B0BDC325A76236DF93CC6B":PSA_ALG_CTR:"000102030405060708090A0B0C0D0E0F":"":"":PSA_ERROR_NOT_SUPPORTED From cc12395c7b1faa9ce35a5dcf4c34981871e71f6f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 28 Sep 2021 21:26:35 +0200 Subject: [PATCH 647/966] Test invalid nonce length for multipart AEAD with short tag Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto.data | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 21f52b28b8..5a91fcea28 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -3294,6 +3294,21 @@ PSA Multipart Set Nonce, AES - GCM, NONCE = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_GCM:20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS +PSA Multipart Set Nonce, AES - GCM_12, NONCE = 0 (NULL) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,12):0:"":"":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart Set Nonce, AES - GCM_12, NONCE = 0 (Non-NULL) +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,12):-1:"":"":PSA_ERROR_INVALID_ARGUMENT + +PSA Multipart Set Nonce, AES - GCM_12, NONCE = 16 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,12):16:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS + +PSA Multipart Set Nonce, AES - GCM_12, NONCE = 20 +depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES +aead_multipart_set_nonce:PSA_KEY_TYPE_AES:"aa740abfadcda779220d3b406c5d7ec09a77fe9d94104539":PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM,12):20:"290322092d57479e20f6281e331d95a9":"e7fb0631eebf9bdba87045b33650c4ce":PSA_SUCCESS PSA Multipart Set Nonce: ChaCha20 - Poly1305, NONCE = 11 depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 From 5902cd64e2aa1e3e6be6fde498fa5b3d01fbe4bf Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Tue, 28 Sep 2021 10:00:32 -0400 Subject: [PATCH 648/966] Remove MBEDTLS_SSL_EXPORT_KEYS, making it always on This option only gated an ability to set a callback, but was deemed unnecessary as it was yet another define to remember when writing tests, or test configurations. Fixes #4653. Signed-off-by: Andrzej Kurek --- ChangeLog.d/remove-ssl-export-keys.txt | 5 +++++ configs/config-thread.h | 1 - include/mbedtls/mbedtls_config.h | 10 ---------- include/mbedtls/ssl.h | 6 ------ library/ssl_tls.c | 16 +++++----------- programs/ssl/ssl_client2.c | 13 ------------- programs/ssl/ssl_server2.c | 13 ------------- programs/ssl/ssl_test_common_source.c | 3 --- programs/ssl/ssl_test_lib.h | 4 ---- tests/ssl-opt.sh | 1 - 10 files changed, 10 insertions(+), 62 deletions(-) create mode 100644 ChangeLog.d/remove-ssl-export-keys.txt diff --git a/ChangeLog.d/remove-ssl-export-keys.txt b/ChangeLog.d/remove-ssl-export-keys.txt new file mode 100644 index 0000000000..1a4b31dcaa --- /dev/null +++ b/ChangeLog.d/remove-ssl-export-keys.txt @@ -0,0 +1,5 @@ +Changes + * Remove MBEDTLS_SSL_EXPORT_KEYS, making it always on and increasing the + code size by about 80B on an M0 build. This option only gated an ability + to set a callback, but was deemed unnecessary as it was yet another define + to remember when writing tests, or test configurations. Fixes #4653. diff --git a/configs/config-thread.h b/configs/config-thread.h index be889a1874..36d8245106 100644 --- a/configs/config-thread.h +++ b/configs/config-thread.h @@ -45,7 +45,6 @@ #define MBEDTLS_SSL_PROTO_DTLS #define MBEDTLS_SSL_DTLS_ANTI_REPLAY #define MBEDTLS_SSL_DTLS_HELLO_VERIFY -#define MBEDTLS_SSL_EXPORT_KEYS /* mbed TLS modules */ #define MBEDTLS_AES_C diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index adc317dfef..fc42dfbd03 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -1598,16 +1598,6 @@ */ #define MBEDTLS_SSL_SESSION_TICKETS -/** - * \def MBEDTLS_SSL_EXPORT_KEYS - * - * Enable support for exporting key block and master secret. - * This is required for certain users of TLS, e.g. EAP-TLS. - * - * Comment this macro to disable support for key export - */ -#define MBEDTLS_SSL_EXPORT_KEYS - /** * \def MBEDTLS_SSL_SERVER_NAME_INDICATION * diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 725b156d5d..956afc6844 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1139,7 +1139,6 @@ typedef enum } mbedtls_tls_prf_types; -#if defined(MBEDTLS_SSL_EXPORT_KEYS) typedef enum { MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET = 0, @@ -1175,7 +1174,6 @@ typedef void mbedtls_ssl_export_keys_t( void *p_expkey, const unsigned char client_random[32], const unsigned char server_random[32], mbedtls_tls_prf_types tls_prf_type ); -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ /** * SSL/TLS configuration to be shared between mbedtls_ssl_context structures. @@ -1617,11 +1615,9 @@ struct mbedtls_ssl_context * and #MBEDTLS_SSL_CID_DISABLED. */ #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) /** Callback to export key block and master secret */ mbedtls_ssl_export_keys_t *MBEDTLS_PRIVATE(f_export_keys); void *MBEDTLS_PRIVATE(p_export_keys); /*!< context for key export callback */ -#endif }; /** @@ -2194,7 +2190,6 @@ void mbedtls_ssl_conf_session_tickets_cb( mbedtls_ssl_config *conf, void *p_ticket ); #endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) /** * \brief Configure a key export callback. * (Default: none.) @@ -2216,7 +2211,6 @@ void mbedtls_ssl_conf_session_tickets_cb( mbedtls_ssl_config *conf, void mbedtls_ssl_set_export_keys_cb( mbedtls_ssl_context *ssl, mbedtls_ssl_export_keys_t *f_export_keys, void *p_export_keys ); -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) /** diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 360419240f..f16157a528 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -587,7 +587,6 @@ static int ssl_use_opaque_psk( mbedtls_ssl_context const *ssl ) #endif /* MBEDTLS_USE_PSA_CRYPTO && MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) static mbedtls_tls_prf_types tls_prf_get_type( mbedtls_ssl_tls_prf_cb *tls_prf ) { #if defined(MBEDTLS_SSL_PROTO_TLS1_2) @@ -608,7 +607,6 @@ static mbedtls_tls_prf_types tls_prf_get_type( mbedtls_ssl_tls_prf_cb *tls_prf ) #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ return( MBEDTLS_SSL_TLS_PRF_NONE ); } -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ int mbedtls_ssl_tls_prf( const mbedtls_tls_prf_types prf, const unsigned char *secret, size_t slen, @@ -660,8 +658,9 @@ typedef int ssl_tls_prf_t(const unsigned char *, size_t, const char *, * - [in] randbytes: buffer holding ServerHello.random + ClientHello.random * - [in] minor_ver: SSL/TLS minor version * - [in] endpoint: client or server - * - [in] ssl: optionally used for: - * - MBEDTLS_SSL_EXPORT_KEYS: ssl->conf->{f,p}_export_keys + * - [in] ssl: used for: + * - ssl->conf->{f,p}_export_keys + * [in] optionally used for: * - MBEDTLS_DEBUG_C: ssl->conf->{f,p}_dbg */ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, @@ -694,9 +693,8 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, const mbedtls_cipher_info_t *cipher_info; const mbedtls_md_info_t *md_info; -#if !defined(MBEDTLS_SSL_EXPORT_KEYS) && \ - !defined(MBEDTLS_DEBUG_C) - ssl = NULL; /* make sure we don't use it except for those cases */ +#if !defined(MBEDTLS_DEBUG_C) + ssl = NULL; /* make sure we don't use it except for this case */ (void) ssl; #endif @@ -960,7 +958,6 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, ((void) mac_dec); ((void) mac_enc); -#if defined(MBEDTLS_SSL_EXPORT_KEYS) if( ssl->f_export_keys != NULL ) { ssl->f_export_keys( ssl->p_export_keys, @@ -970,7 +967,6 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, randbytes, tls_prf_get_type( tls_prf ) ); } -#endif #if defined(MBEDTLS_USE_PSA_CRYPTO) @@ -4229,7 +4225,6 @@ void mbedtls_ssl_conf_session_tickets_cb( mbedtls_ssl_config *conf, #endif #endif /* MBEDTLS_SSL_SESSION_TICKETS */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) void mbedtls_ssl_set_export_keys_cb( mbedtls_ssl_context *ssl, mbedtls_ssl_export_keys_t *f_export_keys, void *p_export_keys ) @@ -4237,7 +4232,6 @@ void mbedtls_ssl_set_export_keys_cb( mbedtls_ssl_context *ssl, ssl->f_export_keys = f_export_keys; ssl->p_export_keys = p_export_keys; } -#endif #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) void mbedtls_ssl_conf_async_private_cb( diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index a970503c87..a02d977ec9 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -207,7 +207,6 @@ int main( void ) #define USAGE_TICKETS "" #endif /* MBEDTLS_SSL_SESSION_TICKETS */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) #define USAGE_EAP_TLS \ " eap_tls=%%d default: 0 (disabled)\n" #define USAGE_NSS_KEYLOG \ @@ -230,12 +229,6 @@ int main( void ) #else /* MBEDTLS_SSL_DTLS_SRTP */ #define USAGE_SRTP "" #endif -#else /* MBEDTLS_SSL_EXPORT_KEYS */ -#define USAGE_EAP_TLS "" -#define USAGE_NSS_KEYLOG "" -#define USAGE_NSS_KEYLOG_FILE "" -#define USAGE_SRTP "" -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) #define USAGE_MAX_FRAG_LEN \ @@ -729,7 +722,6 @@ int main( int argc, char *argv[] ) unsigned char *context_buf = NULL; size_t context_buf_len; #endif -#if defined(MBEDTLS_SSL_EXPORT_KEYS) unsigned char eap_tls_keymaterial[16]; unsigned char eap_tls_iv[8]; const char* eap_tls_label = "client EAP encryption"; @@ -747,7 +739,6 @@ int main( int argc, char *argv[] ) MBEDTLS_TLS_SRTP_UNSET }; #endif /* MBEDTLS_SSL_DTLS_SRTP */ -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); @@ -1962,7 +1953,6 @@ int main( int argc, char *argv[] ) goto exit; } -#if defined(MBEDTLS_SSL_EXPORT_KEYS) if( opt.eap_tls != 0 ) { mbedtls_ssl_set_export_keys_cb( &ssl, eap_tls_key_derivation, @@ -1981,7 +1971,6 @@ int main( int argc, char *argv[] ) &dtls_srtp_keying ); } #endif /* MBEDTLS_SSL_DTLS_SRTP */ -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ #if defined(MBEDTLS_X509_CRT_PARSE_C) if( ( ret = mbedtls_ssl_set_hostname( &ssl, opt.server_name ) ) != 0 ) @@ -2169,7 +2158,6 @@ int main( int argc, char *argv[] ) } #endif -#if defined(MBEDTLS_SSL_EXPORT_KEYS) if( opt.eap_tls != 0 ) { size_t j = 0; @@ -2286,7 +2274,6 @@ int main( int argc, char *argv[] ) } } #endif /* MBEDTLS_SSL_DTLS_SRTP */ -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ if( opt.reconnect != 0 ) { mbedtls_printf(" . Saving session for reuse..." ); diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index e8e4ed8aea..40a6902294 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -278,7 +278,6 @@ int main( void ) #define USAGE_TICKETS "" #endif /* MBEDTLS_SSL_SESSION_TICKETS */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) #define USAGE_EAP_TLS \ " eap_tls=%%d default: 0 (disabled)\n" #define USAGE_NSS_KEYLOG \ @@ -299,12 +298,6 @@ int main( void ) #else /* MBEDTLS_SSL_DTLS_SRTP */ #define USAGE_SRTP "" #endif -#else /* MBEDTLS_SSL_EXPORT_KEYS */ -#define USAGE_EAP_TLS "" -#define USAGE_NSS_KEYLOG "" -#define USAGE_NSS_KEYLOG_FILE "" -#define USAGE_SRTP "" -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ #if defined(MBEDTLS_SSL_CACHE_C) #define USAGE_CACHE \ @@ -1365,7 +1358,6 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_USE_PSA_CRYPTO) psa_status_t status; #endif -#if defined(MBEDTLS_SSL_EXPORT_KEYS) unsigned char eap_tls_keymaterial[16]; unsigned char eap_tls_iv[8]; const char* eap_tls_label = "client EAP encryption"; @@ -1383,7 +1375,6 @@ int main( int argc, char *argv[] ) MBEDTLS_TLS_SRTP_UNSET }; #endif /* MBEDTLS_SSL_DTLS_SRTP */ -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); @@ -2966,7 +2957,6 @@ int main( int argc, char *argv[] ) goto exit; } -#if defined(MBEDTLS_SSL_EXPORT_KEYS) if( opt.eap_tls != 0 ) { mbedtls_ssl_set_export_keys_cb( &ssl, eap_tls_key_derivation, @@ -2985,7 +2975,6 @@ int main( int argc, char *argv[] ) &dtls_srtp_keying ); } #endif /* MBEDTLS_SSL_DTLS_SRTP */ -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ io_ctx.ssl = &ssl; io_ctx.net = &client_fd; @@ -3251,7 +3240,6 @@ handshake: #endif /* MBEDTLS_X509_REMOVE_INFO */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) if( opt.eap_tls != 0 ) { size_t j = 0; @@ -3369,7 +3357,6 @@ handshake: } } #endif /* MBEDTLS_SSL_DTLS_SRTP */ -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) ret = report_cid_usage( &ssl, "initial handshake" ); diff --git a/programs/ssl/ssl_test_common_source.c b/programs/ssl/ssl_test_common_source.c index 6ec4171a89..62cd35de8f 100644 --- a/programs/ssl/ssl_test_common_source.c +++ b/programs/ssl/ssl_test_common_source.c @@ -24,7 +24,6 @@ * limitations under the License. */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) void eap_tls_key_derivation( void *p_expkey, mbedtls_ssl_key_export_type secret_type, const unsigned char *secret, @@ -140,8 +139,6 @@ void dtls_srtp_key_derivation( void *p_expkey, } #endif /* MBEDTLS_SSL_DTLS_SRTP */ -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ - int ssl_check_record( mbedtls_ssl_context const *ssl, unsigned char const *buf, size_t len ) { diff --git a/programs/ssl/ssl_test_lib.h b/programs/ssl/ssl_test_lib.h index f9e031b587..6b9e7b8da7 100644 --- a/programs/ssl/ssl_test_lib.h +++ b/programs/ssl/ssl_test_lib.h @@ -95,8 +95,6 @@ #include "../test/query_config.h" -#if defined(MBEDTLS_SSL_EXPORT_KEYS) - typedef struct eap_tls_keys { unsigned char master_secret[48]; @@ -122,8 +120,6 @@ typedef struct dtls_srtp_keys #endif /* MBEDTLS_SSL_DTLS_SRTP */ -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ - typedef struct { mbedtls_ssl_context *ssl; diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 39499d441c..e641396aa3 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8613,7 +8613,6 @@ run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \ -s "Extra-header:" \ -c "Extra-header:" -requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS run_test "export keys functionality" \ "$P_SRV eap_tls=1 debug_level=3" \ "$P_CLI eap_tls=1 debug_level=3" \ From 324f72ec9c6e77ec4bd215f6d19cd7b7c6e57c58 Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Wed, 29 Sep 2021 04:21:21 -0400 Subject: [PATCH 649/966] Fix a bug where the ssl context is used after it's nullified When not using DEBUG_C, but using the DTLS CID feature - a null pointer was accessed in ssl_tls.c. Signed-off-by: Andrzej Kurek --- library/ssl_tls.c | 5 +++-- tests/scripts/all.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index f16157a528..821506ff77 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -693,8 +693,9 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, const mbedtls_cipher_info_t *cipher_info; const mbedtls_md_info_t *md_info; -#if !defined(MBEDTLS_DEBUG_C) - ssl = NULL; /* make sure we don't use it except for this case */ +#if !defined(MBEDTLS_DEBUG_C) && \ + !defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) + ssl = NULL; /* make sure we don't use it except for these cases */ (void) ssl; #endif diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f30795c226..00939a7386 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2083,6 +2083,18 @@ component_test_variable_ssl_in_out_buffer_len_CID () { tests/compat.sh } +component_test_CID_no_debug() { + msg "build: Connection ID enabled, debug disabled" + scripts/config.py unset MBEDTLS_DEBUG_C + scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID + + CC=gcc cmake . + make + + msg "test: Connection ID enabled, debug disabled" + make test +} + component_test_ssl_alloc_buffer_and_mfl () { msg "build: default config with memory buffer allocator and MFL extension" scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C From 8739f0fb8d92e8a5e73259ed74f98c03ca19af86 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 29 Sep 2021 16:16:47 +0100 Subject: [PATCH 650/966] Fix incorrect nonce length on oneshot test Signed-off-by: Paul Elliott --- tests/suites/test_suite_psa_crypto.data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 5a91fcea28..063629e599 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2768,7 +2768,7 @@ aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495 PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=11, too short) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"070000004041424344":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"0700000040414243444546":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=13, too long) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 From 86de1b76d8a10ed93ec8930af5a1db525cd1b94f Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 29 Sep 2021 19:43:40 +0200 Subject: [PATCH 651/966] Address review comments Signed-off-by: Przemyslaw Stekiel --- include/mbedtls/psa_util.h | 2 ++ tests/suites/test_suite_cipher.aes.data | 48 ++++++++++++------------- tests/suites/test_suite_cipher.function | 8 ----- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/include/mbedtls/psa_util.h b/include/mbedtls/psa_util.h index 31a1254b9f..fad2bb3489 100644 --- a/include/mbedtls/psa_util.h +++ b/include/mbedtls/psa_util.h @@ -58,6 +58,8 @@ static inline psa_key_type_t mbedtls_psa_translate_cipher_type( case MBEDTLS_CIPHER_AES_192_CBC: case MBEDTLS_CIPHER_AES_256_CBC: case MBEDTLS_CIPHER_AES_128_ECB: + case MBEDTLS_CIPHER_AES_192_ECB: + case MBEDTLS_CIPHER_AES_256_ECB: return( PSA_KEY_TYPE_AES ); /* ARIA not yet supported in PSA. */ diff --git a/tests/suites/test_suite_cipher.aes.data b/tests/suites/test_suite_cipher.aes.data index 4ad593a3a2..c8fbca290b 100644 --- a/tests/suites/test_suite_cipher.aes.data +++ b/tests/suites/test_suite_cipher.aes.data @@ -1800,99 +1800,99 @@ test_vec_crypt:MBEDTLS_CIPHER_AES_256_CBC:MBEDTLS_DECRYPT:"000000000000000000000 AES-128-ECB crypt Encrypt NIST KAT #1 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"3ad78e726c1ec02b7ebfe92b23d9ec34":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"":"80000000000000000000000000000000":"3ad78e726c1ec02b7ebfe92b23d9ec34":0:1 AES-128-ECB crypt Encrypt NIST KAT #2 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"ffffffffffffffffffffffffffffe000":"00000000000000000000000000000000":"00000000000000000000000000000000":"323994cfb9da285a5d9642e1759b224a":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"ffffffffffffffffffffffffffffe000":"":"00000000000000000000000000000000":"323994cfb9da285a5d9642e1759b224a":0:1 AES-128-ECB crypt Encrypt NIST KAT #3 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"10a58869d74be5a374cf867cfb473859":"00000000000000000000000000000000":"00000000000000000000000000000000":"6d251e6944b051e04eaa6fb4dbf78465":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"10a58869d74be5a374cf867cfb473859":"":"00000000000000000000000000000000":"6d251e6944b051e04eaa6fb4dbf78465":0:1 AES-128-ECB crypt Encrypt NIST KAT #4 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"f34481ec3cc627bacd5dc3fb08f273e6":"0336763e966d92595a567cc9ce537f5e":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"":"f34481ec3cc627bacd5dc3fb08f273e6":"0336763e966d92595a567cc9ce537f5e":0:1 AES-128-ECB crypt Decrypt NIST KAT #1 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"3ad78e726c1ec02b7ebfe92b23d9ec34":"80000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"":"3ad78e726c1ec02b7ebfe92b23d9ec34":"80000000000000000000000000000000":0:1 AES-128-ECB crypt Decrypt NIST KAT #2 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"ffffc000000000000000000000000000":"00000000000000000000000000000000":"df556a33438db87bc41b1752c55e5e49":"00000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"ffffc000000000000000000000000000":"":"df556a33438db87bc41b1752c55e5e49":"00000000000000000000000000000000":0:1 AES-128-ECB crypt Decrypt NIST KAT #3 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"10a58869d74be5a374cf867cfb473859":"00000000000000000000000000000000":"6d251e6944b051e04eaa6fb4dbf78465":"00000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"10a58869d74be5a374cf867cfb473859":"":"6d251e6944b051e04eaa6fb4dbf78465":"00000000000000000000000000000000":0:1 AES-128-ECB crypt Decrypt NIST KAT #4 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"00000000000000000000000000000000":"0336763e966d92595a567cc9ce537f5e":"f34481ec3cc627bacd5dc3fb08f273e6":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_DECRYPT:"00000000000000000000000000000000":"":"0336763e966d92595a567cc9ce537f5e":"f34481ec3cc627bacd5dc3fb08f273e6":0:1 AES-192-ECB crypt Encrypt NIST KAT #1 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"6cd02513e8d4dc986b4afe087a60bd0c":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"":"80000000000000000000000000000000":"6cd02513e8d4dc986b4afe087a60bd0c":0:1 AES-192-ECB crypt Encrypt NIST KAT #2 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"ff0000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"833f71258d53036b02952c76c744f5a1":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"ff0000000000000000000000000000000000000000000000":"":"00000000000000000000000000000000":"833f71258d53036b02952c76c744f5a1":0:1 AES-192-ECB crypt Encrypt NIST KAT #3 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd":"00000000000000000000000000000000":"00000000000000000000000000000000":"0956259c9cd5cfd0181cca53380cde06":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd":"":"00000000000000000000000000000000":"0956259c9cd5cfd0181cca53380cde06":0:1 AES-192-ECB crypt Encrypt NIST KAT #4 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"1b077a6af4b7f98229de786d7516b639":"275cfc0413d8ccb70513c3859b1d0f72":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_ENCRYPT:"000000000000000000000000000000000000000000000000":"":"1b077a6af4b7f98229de786d7516b639":"275cfc0413d8ccb70513c3859b1d0f72":0:1 AES-192-ECB crypt Decrypt NIST KAT #1 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"6cd02513e8d4dc986b4afe087a60bd0c":"80000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"":"6cd02513e8d4dc986b4afe087a60bd0c":"80000000000000000000000000000000":0:1 AES-192-ECB crypt Decrypt NIST KAT #2 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"ffe000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"7ababc4b3f516c9aafb35f4140b548f9":"00000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"ffe000000000000000000000000000000000000000000000":"":"7ababc4b3f516c9aafb35f4140b548f9":"00000000000000000000000000000000":0:1 AES-192-ECB crypt Decrypt NIST KAT #3 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd":"00000000000000000000000000000000":"0956259c9cd5cfd0181cca53380cde06":"00000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd":"":"0956259c9cd5cfd0181cca53380cde06":"00000000000000000000000000000000":0:1 AES-192-ECB crypt Decrypt NIST KAT #4 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"275cfc0413d8ccb70513c3859b1d0f72":"1b077a6af4b7f98229de786d7516b639":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_192_ECB:MBEDTLS_DECRYPT:"000000000000000000000000000000000000000000000000":"":"275cfc0413d8ccb70513c3859b1d0f72":"1b077a6af4b7f98229de786d7516b639":0:1 AES-256-ECB crypt Encrypt NIST KAT #1 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"80000000000000000000000000000000":"ddc6bf790c15760d8d9aeb6f9a75fd4e":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"80000000000000000000000000000000":"ddc6bf790c15760d8d9aeb6f9a75fd4e":0:1 AES-256-ECB crypt Encrypt NIST KAT #2 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"ff00000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000":"ec52a212f80a09df6317021bc2a9819e":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"ff00000000000000000000000000000000000000000000000000000000000000":"":"00000000000000000000000000000000":"ec52a212f80a09df6317021bc2a9819e":0:1 AES-256-ECB crypt Encrypt NIST KAT #3 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558":"00000000000000000000000000000000":"00000000000000000000000000000000":"46f2fb342d6f0ab477476fc501242c5f":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558":"":"00000000000000000000000000000000":"46f2fb342d6f0ab477476fc501242c5f":0:1 AES-256-ECB crypt Encrypt NIST KAT #4 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"014730f80ac625fe84f026c60bfd547d":"5c9d844ed46f9885085e5d6a4f94c7d7":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_ENCRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"014730f80ac625fe84f026c60bfd547d":"5c9d844ed46f9885085e5d6a4f94c7d7":0:1 AES-256-ECB crypt Decrypt NIST KAT #1 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ddc6bf790c15760d8d9aeb6f9a75fd4e":"80000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"ddc6bf790c15760d8d9aeb6f9a75fd4e":"80000000000000000000000000000000":0:1 AES-256-ECB crypt Decrypt NIST KAT #2 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"ffe0000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"d1ccb9b1337002cbac42c520b5d67722":"00000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"ffe0000000000000000000000000000000000000000000000000000000000000":"":"d1ccb9b1337002cbac42c520b5d67722":"00000000000000000000000000000000":0:1 AES-256-ECB crypt Decrypt NIST KAT #3 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558":"00000000000000000000000000000000":"46f2fb342d6f0ab477476fc501242c5f":"00000000000000000000000000000000":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558":"":"46f2fb342d6f0ab477476fc501242c5f":"00000000000000000000000000000000":0:1 AES-256-ECB crypt Decrypt NIST KAT #4 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C -test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"5c9d844ed46f9885085e5d6a4f94c7d7":"014730f80ac625fe84f026c60bfd547d":0:1 +test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"5c9d844ed46f9885085e5d6a4f94c7d7":"014730f80ac625fe84f026c60bfd547d":0:1 Cipher Corner Case behaviours depends_on:MBEDTLS_AES_C diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index 20d48e2a1b..674349f764 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -950,14 +950,6 @@ void test_vec_crypt( int cipher_id, int operation, data_t *key, if( use_psa == 1 ) { PSA_ASSERT( psa_crypto_init( ) ); - - if (cipher_id == MBEDTLS_CIPHER_AES_192_ECB || - cipher_id == MBEDTLS_CIPHER_AES_256_ECB) - { - TEST_ASSERT( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE == mbedtls_cipher_setup_psa( &ctx, - mbedtls_cipher_info_from_type( cipher_id ), 0 ) ); - goto exit; - } TEST_ASSERT( 0 == mbedtls_cipher_setup_psa( &ctx, mbedtls_cipher_info_from_type( cipher_id ), 0 ) ); } From 5c4ca32f936753bfe586649b28abea74b81d285f Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 5 Aug 2021 13:56:48 +0200 Subject: [PATCH 652/966] Silence warnings about unused return value This macro is not used inside the library yet, but may be used in deprecated functions in the future, if a function returning void has to change to returning an error. It may also be useful in user code, so it is in a public header. Signed-off-by: Mateusz Starzyk Signed-off-by: Gilles Peskine --- include/mbedtls/platform_util.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index e1f063c34e..0882dc68d2 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -129,6 +129,13 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; */ #define MBEDTLS_CHECK_RETURN_OPTIONAL +/** \def MBEDTLS_IGNORE_RETURN + * + * Silences warning about unused return value given by functions + * with \c MBEDTLS_CHECK_RETURN attribute. + */ +#define MBEDTLS_IGNORE_RETURN(result) if( result ) {} + /** * \brief Securely zeroize a buffer * From a72fe641cc44c320b1ed0e61f936f5161731411f Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Wed, 29 Sep 2021 15:57:30 -0400 Subject: [PATCH 653/966] Do not zeroize the ssl context if a key exporting function is set Signed-off-by: Andrzej Kurek --- library/ssl_tls.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 821506ff77..11ccf274c2 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -695,8 +695,11 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, #if !defined(MBEDTLS_DEBUG_C) && \ !defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) - ssl = NULL; /* make sure we don't use it except for these cases */ - (void) ssl; + if( ssl->f_export_keys == NULL ) + { + ssl = NULL; /* make sure we don't use it except for these cases */ + (void) ssl; + } #endif /* @@ -959,7 +962,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform, ((void) mac_dec); ((void) mac_enc); - if( ssl->f_export_keys != NULL ) + if( ssl != NULL && ssl->f_export_keys != NULL ) { ssl->f_export_keys( ssl->p_export_keys, MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET, From 6b226b0874e46b98feb7a46e83624f71cc757ee1 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Fri, 24 Sep 2021 07:51:16 +0000 Subject: [PATCH 654/966] Add fetch_hand_message in generic This function is one common function in generic file, get it from the encrypted extension and submit one patch independently. Signed-off-by: XiaokangQian --- library/ssl_misc.h | 8 ++++++++ library/ssl_tls13_generic.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index a1128eda00..fa777cc936 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1489,6 +1489,14 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl, ssl->state = ( int ) state; } +/* + * Fetch TLS 1.3 handshake message header + */ +int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char **buf, + size_t *buf_len ); + /* * Write TLS 1.3 handshake message header */ diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 5c20f29283..4aaafa5ea2 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -28,6 +28,38 @@ #include "ssl_misc.h" +int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char **buf, + size_t *buflen ) +{ + int ret; + + if( ( ret = mbedtls_ssl_read_record( ssl, 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + goto cleanup; + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE || + ssl->in_msg[0] != hs_type ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE, + MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + ret = MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE; + goto cleanup; + } + + *buf = ssl->in_msg + 4; + *buflen = ssl->in_hslen - 4; + + +cleanup: + + return( ret ); +} + int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, From 16c61aa7385da89712d345b68959ef62d26f1c69 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 27 Sep 2021 09:30:17 +0000 Subject: [PATCH 655/966] TLS1.3: Alignment coding styles based on comments Fix kinds of alignment issues in fetch handshake messages. Signed-off-by: XiaokangQian --- library/ssl_misc.h | 6 +++--- library/ssl_tls13_generic.c | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index fa777cc936..3f3f505031 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1493,9 +1493,9 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl, * Fetch TLS 1.3 handshake message header */ int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, - unsigned hs_type, - unsigned char **buf, - size_t *buf_len ); + unsigned hs_type, + unsigned char **buf, + size_t *buf_len ); /* * Write TLS 1.3 handshake message header diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 4aaafa5ea2..f7112332f2 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -29,9 +29,9 @@ #include "ssl_misc.h" int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, - unsigned hs_type, - unsigned char **buf, - size_t *buflen ) + unsigned hs_type, + unsigned char **buf, + size_t *buflen ) { int ret; @@ -41,10 +41,10 @@ int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, goto cleanup; } - if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE || + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE || ssl->in_msg[0] != hs_type ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Receive unexpected handshake message." ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE, MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); ret = MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE; @@ -54,7 +54,6 @@ int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, *buf = ssl->in_msg + 4; *buflen = ssl->in_hslen - 4; - cleanup: return( ret ); From 05420b120b5a529a246f301492434c139b6ae403 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 29 Sep 2021 08:46:37 +0000 Subject: [PATCH 656/966] TLS1.3: Add useful comments based on RFC8446 Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index f7112332f2..99ab2695d3 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -46,11 +46,18 @@ int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, { MBEDTLS_SSL_DEBUG_MSG( 1, ( "Receive unexpected handshake message." ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE, - MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); ret = MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE; goto cleanup; } + /* + * Jump handshake header (4 bytes, see Section 4 of RFC 8446). + * ... + * HandshakeType msg_type; + * uint24 length; + * ... + */ *buf = ssl->in_msg + 4; *buflen = ssl->in_hslen - 4; From 73142dfb989651da6b701cc874f104324fc91da9 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Thu, 30 Sep 2021 12:11:16 +0200 Subject: [PATCH 657/966] Add change-log: fix-mbedtls_cipher_crypt-aes-ecb.txt Signed-off-by: Przemyslaw Stekiel --- ChangeLog.d/fix-mbedtls_cipher_crypt-aes-ecb.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 ChangeLog.d/fix-mbedtls_cipher_crypt-aes-ecb.txt diff --git a/ChangeLog.d/fix-mbedtls_cipher_crypt-aes-ecb.txt b/ChangeLog.d/fix-mbedtls_cipher_crypt-aes-ecb.txt new file mode 100644 index 0000000000..6dc47244fe --- /dev/null +++ b/ChangeLog.d/fix-mbedtls_cipher_crypt-aes-ecb.txt @@ -0,0 +1,2 @@ +Bugfix + * Fix mbedtls_cipher_crypt: AES-ECB when MBEDTLS_USE_PSA_CRYPTO is enabled. From b6b15b26e9ff59fb55625d17e18ce303e47bdb62 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 30 Sep 2021 14:10:06 +0200 Subject: [PATCH 658/966] Add contact information directly on the home page This information was already present in SECURITY.md and SUPPORT.md, but that wasn't very apparent. Signed-off-by: Gilles Peskine --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b80ee115aa..dbe6a2325e 100644 --- a/README.md +++ b/README.md @@ -298,3 +298,10 @@ Contributing ------------ We gratefully accept bug reports and contributions from the community. Please see the [contributing guidelines](CONTRIBUTING.md) for details on how to do this. + +Contact +------- + +* To report a security vulnerability in Mbed TLS, please email . For more information, see [`SECURITY.md`](SECURITY.md). +* To report a bug or request a feature in Mbed TLS, please [file an issue on GitHub](https://github.com/ARMmbed/mbedtls/issues/new/choose). +* Please see [`SUPPORT.md`](SUPPORT.md) for other channels for discussion and support about Mbed TLS. From 050d2fc2014b2b65948aaa68e1930ba4eba943e5 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 30 Sep 2021 18:24:21 +0200 Subject: [PATCH 659/966] Limit make parallelism to the number of CPUs Don't default to unbridled -j, which causes a load spike and isn't really faster. "Number of CPUs" is implemented here as a reasonable compromise between portability, correctness and simplicity. This is just a default that can be overridden by setting MAKEFLAGS in the environment. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f30795c226..aeca888384 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -175,7 +175,7 @@ pre_initialize_variables () { # if MAKEFLAGS is not set add the -j option to speed up invocations of make if [ -z "${MAKEFLAGS+set}" ]; then - export MAKEFLAGS="-j" + export MAKEFLAGS="-j$(all_sh_nproc)" fi # Include more verbose output for failing tests run by CMake @@ -343,6 +343,18 @@ trap 'fatal_signal HUP' HUP trap 'fatal_signal INT' INT trap 'fatal_signal TERM' TERM +# Number of processors on this machine. Used as the default setting +# for parallel make. +all_sh_nproc () +{ + { + nproc || # Linux + sysctl -n hw.ncpuonline || # NetBSD, OpenBSD + sysctl -n hw.ncpu || # FreeBSD + echo 1 + } 2>/dev/null +} + msg() { if [ -n "${current_component:-}" ]; then From cd79dfc4bbfb8b89d4ba9d12024a7e1d90c01cef Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 30 Sep 2021 18:53:36 +0200 Subject: [PATCH 660/966] Fix mistake in the sample implementation of MBEDTLS_CHECK_RETURN Signed-off-by: Gilles Peskine --- include/mbedtls/mbedtls_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index c31a2cee52..f7d06d03a0 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -3103,7 +3103,7 @@ * If the implementation here is empty, this will effectively disable the * checking of functions' return values. */ -//#define MBEDTLS_CHECK_RETURN __attribute__(__warn_unused_result__) +//#define MBEDTLS_CHECK_RETURN __attribute__((__warn_unused_result__)) /* PSA options */ /** From 252b758dd6a990a6c69e3a8d3a99005977a50407 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 30 Sep 2021 18:54:51 +0200 Subject: [PATCH 661/966] Cleaner implementation of MBEDTLS_IGNORE_RETURN The previous implementation was misparsed in constructs like `if (condition) MBEDTLS_IGNORE_RETURN(...); else ...;`. Implement it as an expression, tested with GCC, Clang and MSVC. Signed-off-by: Gilles Peskine --- include/mbedtls/platform_util.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 0882dc68d2..d632eed4f8 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -133,8 +133,15 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; * * Silences warning about unused return value given by functions * with \c MBEDTLS_CHECK_RETURN attribute. +/* GCC doesn't silence the warning with just (void)(result). + * !(void)(result) is known to work up at least up to GCC 10, as well + * as with Clang and MSVC. + * + * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Non_002dbugs.html + * https://stackoverflow.com/questions/40576003/ignoring-warning-wunused-result + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34 */ -#define MBEDTLS_IGNORE_RETURN(result) if( result ) {} +#define MBEDTLS_IGNORE_RETURN(result) ( (void) !( result ) ) /** * \brief Securely zeroize a buffer From fcc93d797b9fdb99900bf274356d38795ffe915e Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 30 Sep 2021 18:56:17 +0200 Subject: [PATCH 662/966] Make MBEDTLS_IGNORE_RETURN configurable Signed-off-by: Gilles Peskine --- include/mbedtls/mbedtls_config.h | 8 ++++++++ include/mbedtls/platform_util.h | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index f7d06d03a0..4757aa66cf 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -3105,6 +3105,14 @@ */ //#define MBEDTLS_CHECK_RETURN __attribute__((__warn_unused_result__)) +/** \def MBEDTLS_IGNORE_RETURN + * + * This macro requires one argument, which should be a C function call. + * If that function call would cause a #MBEDTLS_CHECK_RETURN warning, this + * warning is suppressed. + */ +//#define MBEDTLS_IGNORE_RETURN( result ) ((void) !(result)) + /* PSA options */ /** * Use HMAC_DRBG with the specified hash algorithm for HMAC_DRBG for the diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index d632eed4f8..6f6b6967aa 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -104,6 +104,9 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; * #MBEDTLS_CHECK_RETURN is implemented for the compiler in use and * #MBEDTLS_CHECK_RETURN_WARNING is enabled in the compile-time configuration. * + * You can use #MBEDTLS_IGNORE_RETURN to explicitly ignore the return value + * of a function that is annotated with #MBEDTLS_CHECK_RETURN. + * * \note The use of this macro is a work in progress. * This macro will be added to more functions in the future. * Eventually this should appear before most functions returning @@ -131,8 +134,10 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; /** \def MBEDTLS_IGNORE_RETURN * - * Silences warning about unused return value given by functions - * with \c MBEDTLS_CHECK_RETURN attribute. + * Call this macro with one argument, a function call, to suppress a warning + * from #MBEDTLS_CHECK_RETURN due to that function call. + */ +#if !defined(MBEDTLS_IGNORE_RETURN) /* GCC doesn't silence the warning with just (void)(result). * !(void)(result) is known to work up at least up to GCC 10, as well * as with Clang and MSVC. @@ -142,6 +147,7 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34 */ #define MBEDTLS_IGNORE_RETURN(result) ( (void) !( result ) ) +#endif /** * \brief Securely zeroize a buffer From 2aefc9ef2e08157a848e8ce2200b0a7b8d0640d0 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 30 Sep 2021 20:34:29 +0200 Subject: [PATCH 663/966] Fix typo in comment Signed-off-by: Gilles Peskine --- include/mbedtls/platform_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 6f6b6967aa..36e3718e6c 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -139,7 +139,7 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; */ #if !defined(MBEDTLS_IGNORE_RETURN) /* GCC doesn't silence the warning with just (void)(result). - * !(void)(result) is known to work up at least up to GCC 10, as well + * (void)!(result) is known to work up at least up to GCC 10, as well * as with Clang and MSVC. * * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Non_002dbugs.html From eb009232c0233ebca6d6b706593a16684f1180d9 Mon Sep 17 00:00:00 2001 From: LuoPeng Date: Wed, 22 Sep 2021 23:51:19 +0800 Subject: [PATCH 664/966] Update library/gcm.c Co-authored-by: davidhorstmann-arm <70948878+davidhorstmann-arm@users.noreply.github.com> Signed-off-by: openluopworld --- library/gcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/gcm.c b/library/gcm.c index e1c1c7d518..0e402dd8ca 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -278,7 +278,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, else { memset( work_buf, 0x00, 16 ); - MBEDTLS_PUT_UINT64_BE( iv_len * 8, work_buf, 8 ); + MBEDTLS_PUT_UINT64_BE( iv_len * 8, work_buf, 8 ); p = iv; while( iv_len > 0 ) From eab65acca45c6287799877aaed0c30341687f330 Mon Sep 17 00:00:00 2001 From: openluopworld Date: Wed, 22 Sep 2021 23:59:42 +0800 Subject: [PATCH 665/966] bugfix: if the len of iv is not 96-bit, y0 can be calculated incorrectly. An initialization vector IV can have any number of bits between 1 and 2^64. So it should be filled to the lower 64-bit in the last step when computing ghash. Signed-off-by: openluopworld --- library/gcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/gcm.c b/library/gcm.c index 0e402dd8ca..4c0a44e413 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -254,6 +254,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, size_t i; const unsigned char *p; size_t use_len, olen = 0; + uint64_t iv_bits; GCM_VALIDATE_RET( ctx != NULL ); GCM_VALIDATE_RET( iv != NULL ); @@ -278,7 +279,8 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, else { memset( work_buf, 0x00, 16 ); - MBEDTLS_PUT_UINT64_BE( iv_len * 8, work_buf, 8 ); + iv_bits = (uint64_t)iv_len * 8; + MBEDTLS_PUT_UINT64_BE( iv_bits, work_buf, 8 ); p = iv; while( iv_len > 0 ) From 0483e3d65272a20ca13baf4e1f6e93b154d87892 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Mon, 4 Oct 2021 11:13:22 +0200 Subject: [PATCH 666/966] Add key_opaque option to ssl_server2.c + test Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_server2.c | 32 +++++++++++++++++++++++++++++++- tests/ssl-opt.sh | 15 +++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index e8e4ed8aea..abc9b5f5d4 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -80,6 +80,7 @@ int main( void ) #define DFL_CA_PATH "" #define DFL_CRT_FILE "" #define DFL_KEY_FILE "" +#define DFL_KEY_OPAQUE 0 #define DFL_KEY_PWD "" #define DFL_CRT_FILE2 "" #define DFL_KEY_FILE2 "" @@ -200,6 +201,13 @@ int main( void ) #else #define USAGE_IO "" #endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_X509_CRT_PARSE_C) +#define USAGE_KEY_OPAQUE \ + " key_opaque=%%d Handle your private key as if it were opaque\n" \ + " default: 0 (disabled)\n" +#else +#define USAGE_KEY_OPAQUE "" +#endif #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) #define USAGE_SSL_ASYNC \ @@ -483,6 +491,7 @@ int main( void ) " cert_req_ca_list=%%d default: 1 (send ca list)\n" \ " options: 1 (send ca list), 0 (don't send)\n" \ USAGE_IO \ + USAGE_KEY_OPAQUE \ "\n" \ USAGE_PSK \ USAGE_CA_CALLBACK \ @@ -567,6 +576,7 @@ struct options const char *ca_path; /* the path with the CA certificate(s) reside */ const char *crt_file; /* the file with the server certificate */ const char *key_file; /* the file with the server key */ + int key_opaque; /* handle private key as if it were opaque */ const char *key_pwd; /* the password for the server key */ const char *crt_file2; /* the file with the 2nd server certificate */ const char *key_file2; /* the file with the 2nd server key */ @@ -1315,6 +1325,9 @@ int main( int argc, char *argv[] ) mbedtls_pk_context pkey; mbedtls_x509_crt srvcert2; mbedtls_pk_context pkey2; +#if defined(MBEDTLS_USE_PSA_CRYPTO) + psa_key_id_t key_slot = 0; /* invalid key slot */ +#endif int key_cert_init = 0, key_cert_init2 = 0; #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) ssl_async_key_context_t ssl_async_keys; @@ -1491,6 +1504,7 @@ int main( int argc, char *argv[] ) opt.ca_path = DFL_CA_PATH; opt.crt_file = DFL_CRT_FILE; opt.key_file = DFL_KEY_FILE; + opt.key_opaque = DFL_KEY_OPAQUE; opt.key_pwd = DFL_KEY_PWD; opt.crt_file2 = DFL_CRT_FILE2; opt.key_file2 = DFL_KEY_FILE2; @@ -1622,6 +1636,10 @@ int main( int argc, char *argv[] ) opt.key_file = q; else if( strcmp( p, "key_pwd" ) == 0 ) opt.key_pwd = q; +#if defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_X509_CRT_PARSE_C) + else if( strcmp( p, "key_opaque" ) == 0 ) + opt.key_opaque = atoi( q ); +#endif else if( strcmp( p, "crt_file2" ) == 0 ) opt.crt_file2 = q; else if( strcmp( p, "key_file2" ) == 0 ) @@ -2473,11 +2491,23 @@ int main( int argc, char *argv[] ) (unsigned int) -ret ); goto exit; } +#if defined(MBEDTLS_USE_PSA_CRYPTO) + if( opt.key_opaque != 0 ) + { + if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey2, &key_slot, + PSA_ALG_SHA_256 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! " + "mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret ); + goto exit; + } + } +#endif /* MBEDTLS_USE_PSA_CRYPTO */ key_cert_init2 = 2; #endif /* MBEDTLS_ECDSA_C */ } - mbedtls_printf( " ok\n" ); + mbedtls_printf( " ok (key type: %s)\n", mbedtls_pk_get_name( &pkey2 ) ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 66c648573b..d6fef13013 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1444,6 +1444,21 @@ run_test "Opaque key for client authentication" \ -S "error" \ -C "error" +# Test using an opaque private key for server authentication +requires_config_enabled MBEDTLS_USE_PSA_CRYPTO +requires_config_enabled MBEDTLS_X509_CRT_PARSE_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SHA256_C +run_test "Opaque key for server authentication" \ + "$P_SRV auth_mode=required key_opaque=1" \ + "$P_CLI crt_file=data_files/server5.crt \ + key_file=data_files/server5.key" \ + 0 \ + -c "Verifying peer X.509 certificate... ok" \ + -s "key type: Opaque" \ + -S "error" \ + -C "error" + # Test ciphersuites which we expect to be fully supported by PSA Crypto # and check that we don't fall back to Mbed TLS' internal crypto primitives. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM From f28261fc14da5f52b460c903e027aff187f9cf5f Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 30 Sep 2021 16:39:07 +0200 Subject: [PATCH 667/966] Remove output buffer limitation for PSA with GCM. The requirement of minimum 15 bytes for output buffer in psa_aead_finish() and psa_aead_verify() does not apply to the built-in implementation of the GCM. Alternative implementations are expected to verify the length of the provided output buffers and to return the MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL in case the buffer length is too small. Signed-off-by: Mateusz Starzyk --- ChangeLog.d/psa_gcm_buffer_limitation.txt | 11 +++++++++++ include/mbedtls/gcm.h | 2 ++ library/psa_crypto.c | 2 ++ library/psa_crypto_aead.c | 3 --- tests/suites/test_suite_psa_crypto.data | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 ChangeLog.d/psa_gcm_buffer_limitation.txt diff --git a/ChangeLog.d/psa_gcm_buffer_limitation.txt b/ChangeLog.d/psa_gcm_buffer_limitation.txt new file mode 100644 index 0000000000..7259e50684 --- /dev/null +++ b/ChangeLog.d/psa_gcm_buffer_limitation.txt @@ -0,0 +1,11 @@ +Bugfix + * Remove PSA'a AEAD finish/verify output buffer limitation for GCM. + The requirement of minimum 15 bytes for output buffer in + psa_aead_finish() and psa_aead_verify() does not apply to the built-in + implementation of GCM. + +API changes + * New error code for GCM: MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL. + Alternative GCM implementations are expected to verify + the length of the provided output buffers and to return the + MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL in case the buffer length is too small. diff --git a/include/mbedtls/gcm.h b/include/mbedtls/gcm.h index 9d9155fc5b..a4de9191d8 100644 --- a/include/mbedtls/gcm.h +++ b/include/mbedtls/gcm.h @@ -45,6 +45,8 @@ #define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012 /** Bad input parameters to function. */ #define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014 +/** An output buffer is too small. */ +#define MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL -0x0018 #ifdef __cplusplus extern "C" { diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ece64b100d..5978b6ac5b 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -201,6 +201,8 @@ psa_status_t mbedtls_to_psa_error( int ret ) case MBEDTLS_ERR_GCM_AUTH_FAILED: return( PSA_ERROR_INVALID_SIGNATURE ); + case MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL: + return( PSA_ERROR_BUFFER_TOO_SMALL ); case MBEDTLS_ERR_GCM_BAD_INPUT: return( PSA_ERROR_INVALID_ARGUMENT ); diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index a72865c04c..673cdf3448 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -567,9 +567,6 @@ psa_status_t mbedtls_psa_aead_finish( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { - if( ciphertext_size < 15 ) - return( PSA_ERROR_BUFFER_TOO_SMALL ); - status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm, ciphertext, ciphertext_size, ciphertext_length, diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 063629e599..3a3e67821a 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -3348,7 +3348,7 @@ aead_multipart_update_buffer_test:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8 PSA AEAD finish buffer test: AES - GCM, BUF = 8, TAG = 16 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_GCM:8:16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_ERROR_BUFFER_TOO_SMALL +aead_multipart_finish_buffer_test:PSA_KEY_TYPE_AES:"fbc0b4c56a714c83217b2d1bcadd2ed2e9efb0dcac6cc19f":PSA_ALG_GCM:8:16:"5f4b43e811da9c470d6a9b01":"":"d2ae38c4375954835d75b8e4c2f9bbb4":PSA_SUCCESS PSA AEAD finish buffer test: AES - GCM, BUF = 15, TAG = 20 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES From c48f43b44de534af4a89aae26cefebdba0a14aca Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 4 Oct 2021 13:46:38 +0200 Subject: [PATCH 668/966] Fix PSA AEAD GCM's update output buffer length verification. Move GCM's update output buffer length verification from PSA AEAD to the built-in implementation of the GCM. Signed-off-by: Mateusz Starzyk --- ChangeLog.d/psa_gcm_buffer_limitation.txt | 5 +++++ library/gcm.c | 2 +- library/psa_crypto_aead.c | 3 --- tests/suites/test_suite_gcm.aes128_de.data | 4 ++++ tests/suites/test_suite_gcm.aes128_en.data | 3 +++ tests/suites/test_suite_gcm.function | 24 ++++++++++++++++++++++ 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/ChangeLog.d/psa_gcm_buffer_limitation.txt b/ChangeLog.d/psa_gcm_buffer_limitation.txt index 7259e50684..0c07e24154 100644 --- a/ChangeLog.d/psa_gcm_buffer_limitation.txt +++ b/ChangeLog.d/psa_gcm_buffer_limitation.txt @@ -3,6 +3,11 @@ Bugfix The requirement of minimum 15 bytes for output buffer in psa_aead_finish() and psa_aead_verify() does not apply to the built-in implementation of GCM. + * Move GCM's update output buffer length verification from PSA AEAD to + the built-in implementation of the GCM. + The requirement for output buffer size to be equal or greater then + input buffer size is valid only for the built-in implementation of GCM. + Alternative GCM implementations can process whole blocks only. API changes * New error code for GCM: MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL. diff --git a/library/gcm.c b/library/gcm.c index 910646b281..6d625642eb 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -431,7 +431,7 @@ int mbedtls_gcm_update( mbedtls_gcm_context *ctx, unsigned char ectr[16]; if( output_size < input_length ) - return( MBEDTLS_ERR_GCM_BAD_INPUT ); + return( MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL ); GCM_VALIDATE_RET( output_length != NULL ); *output_length = input_length; diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 673cdf3448..c7f7352fbd 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -510,9 +510,6 @@ psa_status_t mbedtls_psa_aead_update( #if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM) if( operation->alg == PSA_ALG_GCM ) { - if( output_size < input_length ) - return( PSA_ERROR_BUFFER_TOO_SMALL ); - status = mbedtls_to_psa_error( mbedtls_gcm_update( &operation->ctx.gcm, input, input_length, diff --git a/tests/suites/test_suite_gcm.aes128_de.data b/tests/suites/test_suite_gcm.aes128_de.data index 3df31e56bf..ede6f243c1 100644 --- a/tests/suites/test_suite_gcm.aes128_de.data +++ b/tests/suites/test_suite_gcm.aes128_de.data @@ -726,6 +726,10 @@ AES-GCM Bad IV (AES-128,128,0,0,32) #0 depends_on:MBEDTLS_AES_C gcm_bad_parameters:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_DECRYPT:"d0194b6ee68f0ed8adc4b22ed15dbf14":"":"":"":32:MBEDTLS_ERR_GCM_BAD_INPUT +AES-GCM, output buffer too small, NIST Validation (AES-128,128,1024,0,128) #0 +depends_on:MBEDTLS_AES_C +gcm_update_output_buffer_too_small:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_DECRYPT:"0dd358bc3f992f26e81e3a2f3aa2d517":"87cc4fd75788c9d5cc83bae5d764dd249d178ab23224049795d4288b5ed9ea3f317068a39a7574b300c8544226e87b08e008fbe241d094545c211d56ac44437d41491a438272738968c8d371aa7787b5f606c8549a9d868d8a71380e9657d3c0337979feb01de5991fc1470dfc59eb02511efbbff3fcb479a862ba3844a25aaa":"d8c750bb443ee1a169dfe97cfe4d855b" + AES-GCM Selftest depends_on:MBEDTLS_AES_C gcm_selftest: diff --git a/tests/suites/test_suite_gcm.aes128_en.data b/tests/suites/test_suite_gcm.aes128_en.data index d60c458bcd..273642cbd7 100644 --- a/tests/suites/test_suite_gcm.aes128_en.data +++ b/tests/suites/test_suite_gcm.aes128_en.data @@ -726,6 +726,9 @@ AES-GCM Bad IV (AES-128,128,0,0,32) #0 depends_on:MBEDTLS_AES_C gcm_bad_parameters:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_ENCRYPT:"d0194b6ee68f0ed8adc4b22ed15dbf14":"":"":"":32:MBEDTLS_ERR_GCM_BAD_INPUT +AES-GCM, output buffer too small, NIST Validation (AES-128,128,1024,0,128) #0 +gcm_update_output_buffer_too_small:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_ENCRYPT:"ce0f8cfe9d64c4f4c045d11b97c2d918":"dfff250d380f363880963b42d6913c1ba11e8edf7c4ab8b76d79ccbaac628f548ee542f48728a9a2620a0d69339c8291e8d398440d740e310908cdee7c273cc91275ce7271ba12f69237998b07b789b3993aaac8dc4ec1914432a30f5172f79ea0539bd1f70b36d437e5170bc63039a5280816c05e1e41760b58e35696cebd55":"ad4c3627a494fc628316dc03faf81db8" + AES-GCM Selftest depends_on:MBEDTLS_AES_C gcm_selftest: diff --git a/tests/suites/test_suite_gcm.function b/tests/suites/test_suite_gcm.function index c530e6b429..816ebc4ec5 100644 --- a/tests/suites/test_suite_gcm.function +++ b/tests/suites/test_suite_gcm.function @@ -431,6 +431,30 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void gcm_update_output_buffer_too_small( int cipher_id, int mode, + data_t * key_str, const data_t *input, + const data_t *iv ) +{ + mbedtls_gcm_context ctx; + uint8_t *output = NULL; + size_t olen; + size_t output_len = input->len - 1; + + mbedtls_gcm_init( &ctx ); + TEST_EQUAL( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_gcm_starts( &ctx, mode, iv->x, iv->len ) ); + + ASSERT_ALLOC( output, output_len ); + olen = 0xdeadbeef; + TEST_EQUAL( MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL, mbedtls_gcm_update( &ctx, input->x, input->len, output, output_len, &olen ) ); + +exit: + mbedtls_free( output ); + mbedtls_gcm_free( &ctx ); +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ void gcm_selftest( ) { From ff0aee0e7b542f325f1d25df8df91cfae501fd7e Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 5 Oct 2021 09:36:03 +0200 Subject: [PATCH 669/966] Build with -O2 when running ssl-opt SSL testing benefits from faster executables, so use -O2 rather than -O1. Some builds use -O1, but that's intended for jobs that only run unit tests, where the build takes longer than the tests. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 812b6b1c64..567fa936c4 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2275,7 +2275,7 @@ component_build_mbedtls_config_file () { } component_test_m32_o0 () { - # Build once with -O0, to compile out the i386 specific inline assembly + # Build without optimization, to not use the i386 specific inline assembly. msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s scripts/config.py full make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS" @@ -2290,16 +2290,17 @@ support_test_m32_o0 () { esac } -component_test_m32_o1 () { - # Build again with -O1, to compile in the i386 specific inline assembly - msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s +component_test_m32_o2 () { + # Build with optimization, to use the i386 specific inline assembly + # and go faster for tests. + msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s scripts/config.py full - make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS" + make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS" - msg "test: i386, make, gcc -O1 (ASan build)" + msg "test: i386, make, gcc -O2 (ASan build)" make test - msg "test ssl-opt.sh, i386, make, gcc-O1" + msg "test ssl-opt.sh, i386, make, gcc-O2" tests/ssl-opt.sh } support_test_m32_o1 () { @@ -2411,7 +2412,7 @@ component_test_no_x509_info () { scripts/config.pl full scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests scripts/config.pl set MBEDTLS_X509_REMOVE_INFO - make CFLAGS='-Werror -O1' + make CFLAGS='-Werror -O2' msg "test: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s make test From 8135cb9e072cb693727a786a871e3a1299e5a295 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 18:10:16 +0200 Subject: [PATCH 670/966] Break out algorithm_tester() as a separate method No intended behavior change. Signed-off-by: Gilles Peskine --- scripts/mbedtls_dev/macro_collector.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/scripts/mbedtls_dev/macro_collector.py b/scripts/mbedtls_dev/macro_collector.py index f9ef5f9150..bd2d296c01 100644 --- a/scripts/mbedtls_dev/macro_collector.py +++ b/scripts/mbedtls_dev/macro_collector.py @@ -233,6 +233,25 @@ class PSAMacroCollector(PSAMacroEnumerator): self.key_types_from_group = {} #type: Dict[str, str] self.algorithms_from_hash = {} #type: Dict[str, str] + @staticmethod + def algorithm_tester(name: str) -> str: + """The predicate for whether an algorithm is built from the given constructor. + + The given name must be the name of an algorithm constructor of the + form ``PSA_ALG_xxx`` which is used as ``PSA_ALG_xxx(yyy)`` to build + an algorithm value. Return the corresponding predicate macro which + is used as ``predicate(alg)`` to test whether ``alg`` can be built + as ``PSA_ALG_xxx(yyy)``. The predicate is usually called + ``PSA_ALG_IS_xxx``. + """ + prefix = 'PSA_ALG_' + assert name.startswith(prefix) + midfix = 'IS_' + suffix = name[len(prefix):] + if suffix in ['DSA', 'ECDSA']: + midfix += 'RANDOMIZED_' + return prefix + midfix + suffix + def record_algorithm_subtype(self, name: str, expansion: str) -> None: """Record the subtype of an algorithm constructor. @@ -308,12 +327,7 @@ class PSAMacroCollector(PSAMacroEnumerator): self.algorithms.add(name) self.record_algorithm_subtype(name, expansion) elif name.startswith('PSA_ALG_') and parameter == 'hash_alg': - if name in ['PSA_ALG_DSA', 'PSA_ALG_ECDSA']: - # A naming irregularity - tester = name[:8] + 'IS_RANDOMIZED_' + name[8:] - else: - tester = name[:8] + 'IS_' + name[8:] - self.algorithms_from_hash[name] = tester + self.algorithms_from_hash[name] = self.algorithm_tester(name) elif name.startswith('PSA_KEY_USAGE_') and not parameter: self.key_usage_flags.add(name) else: From acd2d0e92389a7e64a7d8d1b7d3e1d2077124dfb Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 18:10:38 +0200 Subject: [PATCH 671/966] New algorithm PSA_ALG_RSA_PSS_ANY_SALT This is a variant of PSA_ALG_RSA_PSS which currently has exactly the same behavior, but is intended to have a different behavior when verifying signatures. In a subsequent commit, PSA_ALG_RSA_PSS will change to requiring the salt length to be what it would produce when signing, as is currently documented, whereas PSA_ALG_RSA_PSS_ANY_SALT will retain the current behavior of allowing any salt length (including 0). Changes in this commit: * New algorithm constructor PSA_ALG_RSA_PSS_ANY_SALT. * New predicates PSA_ALG_IS_RSA_PSS_STANDARD_SALT (corresponding to PSA_ALG_RSA_PSS) and PSA_ALG_IS_RSA_PSS_ANY_SALT (corresponding to PSA_ALG_RSA_PSS_ANY_SALT). * Support for the new predicates in macro_collector.py (needed for generate_psa_constant_names). Signed-off-by: Gilles Peskine --- include/psa/crypto_values.h | 68 ++++++++++++++++++- scripts/mbedtls_dev/macro_collector.py | 2 + .../test_suite_psa_crypto_metadata.data | 8 +++ 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index daef9416cc..aa7d02ef39 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -886,7 +886,7 @@ * algorithm parametrized with any supported hash. * * That is, suppose that `PSA_xxx_SIGNATURE` is one of the following macros: - * - #PSA_ALG_RSA_PKCS1V15_SIGN, #PSA_ALG_RSA_PSS, + * - #PSA_ALG_RSA_PKCS1V15_SIGN, #PSA_ALG_RSA_PSS, #PSA_ALG_RSA_PSS_ANY_SALT, * - #PSA_ALG_ECDSA, #PSA_ALG_DETERMINISTIC_ECDSA. * Then you may create and use a key as follows: * - Set the key usage field using #PSA_ALG_ANY_HASH, for example: @@ -1341,6 +1341,7 @@ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PKCS1V15_SIGN_BASE) #define PSA_ALG_RSA_PSS_BASE ((psa_algorithm_t)0x06000300) +#define PSA_ALG_RSA_PSS_ANY_SALT_BASE ((psa_algorithm_t)0x06001300) /** RSA PSS signature with hashing. * * This is the signature scheme defined by RFC 8017 @@ -1361,9 +1362,72 @@ */ #define PSA_ALG_RSA_PSS(hash_alg) \ (PSA_ALG_RSA_PSS_BASE | ((hash_alg) & PSA_ALG_HASH_MASK)) -#define PSA_ALG_IS_RSA_PSS(alg) \ + +/** RSA PSS signature with hashing with relaxed verification. + * + * This algorithm has the same behavior as #PSA_ALG_RSA_PSS when signing, + * but allows an arbitrary salt length (including \c 0) when verifying a + * signature. + * + * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that + * #PSA_ALG_IS_HASH(\p hash_alg) is true). + * This includes #PSA_ALG_ANY_HASH + * when specifying the algorithm in a usage policy. + * + * \return The corresponding RSA PSS signature algorithm. + * \return Unspecified if \p hash_alg is not a supported + * hash algorithm. + */ +#define PSA_ALG_RSA_PSS_ANY_SALT(hash_alg) \ + (PSA_ALG_RSA_PSS_ANY_SALT_BASE | ((hash_alg) & PSA_ALG_HASH_MASK)) + +/** Whether the specified algorithm is RSA PSS with standard salt. + * + * \param alg An algorithm value or an algorithm policy wildcard. + * + * \return 1 if \p alg is of the form + * #PSA_ALG_RSA_PSS(\c hash_alg), + * where \c hash_alg is a hash algorithm or + * #PSA_ALG_ANY_HASH. 0 otherwise. + * This macro may return either 0 or 1 if \p alg is not + * a supported algorithm identifier or policy. + */ +#define PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) \ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_BASE) +/** Whether the specified algorithm is RSA PSS with any salt. + * + * \param alg An algorithm value or an algorithm policy wildcard. + * + * \return 1 if \p alg is of the form + * #PSA_ALG_RSA_PSS_ANY_SALT_BASE(\c hash_alg), + * where \c hash_alg is a hash algorithm or + * #PSA_ALG_ANY_HASH. 0 otherwise. + * This macro may return either 0 or 1 if \p alg is not + * a supported algorithm identifier or policy. + */ +#define PSA_ALG_IS_RSA_PSS_ANY_SALT(alg) \ + (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_ANY_SALT_BASE) + +/** Whether the specified algorithm is RSA PSS. + * + * This includes any of the RSA PSS algorithm variants, regardless of the + * constraints on salt length. + * + * \param alg An algorithm value or an algorithm policy wildcard. + * + * \return 1 if \p alg is of the form + * #PSA_ALG_RSA_PSS(\c hash_alg) or + * #PSA_ALG_RSA_PSS_ANY_SALT_BASE(\c hash_alg), + * where \c hash_alg is a hash algorithm or + * #PSA_ALG_ANY_HASH. 0 otherwise. + * This macro may return either 0 or 1 if \p alg is not + * a supported algorithm identifier or policy. + */ +#define PSA_ALG_IS_RSA_PSS(alg) \ + ((((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_BASE) || \ + (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_ANY_SALT_BASE)) + #define PSA_ALG_ECDSA_BASE ((psa_algorithm_t)0x06000600) /** ECDSA signature with hashing. * diff --git a/scripts/mbedtls_dev/macro_collector.py b/scripts/mbedtls_dev/macro_collector.py index bd2d296c01..bf82f13dc5 100644 --- a/scripts/mbedtls_dev/macro_collector.py +++ b/scripts/mbedtls_dev/macro_collector.py @@ -250,6 +250,8 @@ class PSAMacroCollector(PSAMacroEnumerator): suffix = name[len(prefix):] if suffix in ['DSA', 'ECDSA']: midfix += 'RANDOMIZED_' + elif suffix == 'RSA_PSS': + suffix += '_STANDARD_SALT' return prefix + midfix + suffix def record_algorithm_subtype(self, name: str, expansion: str) -> None: diff --git a/tests/suites/test_suite_psa_crypto_metadata.data b/tests/suites/test_suite_psa_crypto_metadata.data index a3668fcc94..f2b43741a6 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.data +++ b/tests/suites/test_suite_psa_crypto_metadata.data @@ -182,6 +182,10 @@ Asymmetric signature: RSA PSS SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256 asymmetric_signature_algorithm:PSA_ALG_RSA_PSS( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_HASH_AND_SIGN +Asymmetric signature: RSA PSS-any-salt SHA-256 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256 +asymmetric_signature_algorithm:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_HASH_AND_SIGN + Asymmetric signature: randomized ECDSA (no hashing) depends_on:PSA_WANT_ALG_ECDSA asymmetric_signature_algorithm:PSA_ALG_ECDSA_ANY:ALG_IS_ECDSA | ALG_IS_RANDOMIZED_ECDSA | ALG_IS_HASH_AND_SIGN @@ -214,6 +218,10 @@ Asymmetric signature: RSA PSS with wildcard hash depends_on:PSA_WANT_ALG_RSA_PSS asymmetric_signature_wildcard:PSA_ALG_RSA_PSS( PSA_ALG_ANY_HASH ):ALG_IS_RSA_PSS +Asymmetric signature: RSA PSS-any-salt with wildcard hash +depends_on:PSA_WANT_ALG_RSA_PSS +asymmetric_signature_wildcard:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_ANY_HASH ):ALG_IS_RSA_PSS + Asymmetric signature: randomized ECDSA with wildcard hash depends_on:PSA_WANT_ALG_ECDSA asymmetric_signature_wildcard:PSA_ALG_ECDSA( PSA_ALG_ANY_HASH ):ALG_IS_ECDSA | ALG_IS_RANDOMIZED_ECDSA From a4337d7b154cc2dd9eba9c261b5f4fb43c531c76 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 18:14:59 +0200 Subject: [PATCH 672/966] Update metadata tests with the new IS_ALG_RSA_PSS_xxx_SALT predicates Signed-off-by: Gilles Peskine --- .../test_suite_psa_crypto_metadata.data | 8 ++-- .../test_suite_psa_crypto_metadata.function | 40 ++++++++++--------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_metadata.data b/tests/suites/test_suite_psa_crypto_metadata.data index f2b43741a6..7eb1dc92cf 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.data +++ b/tests/suites/test_suite_psa_crypto_metadata.data @@ -180,11 +180,11 @@ asymmetric_signature_algorithm:PSA_ALG_RSA_PKCS1V15_SIGN( PSA_ALG_SHA_256 ):ALG_ Asymmetric signature: RSA PSS SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_RSA_PSS( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_RSA_PSS( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_STANDARD_SALT | ALG_IS_HASH_AND_SIGN Asymmetric signature: RSA PSS-any-salt SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_ANY_SALT | ALG_IS_HASH_AND_SIGN Asymmetric signature: randomized ECDSA (no hashing) depends_on:PSA_WANT_ALG_ECDSA @@ -216,11 +216,11 @@ asymmetric_signature_wildcard:PSA_ALG_RSA_PKCS1V15_SIGN( PSA_ALG_ANY_HASH ):ALG_ Asymmetric signature: RSA PSS with wildcard hash depends_on:PSA_WANT_ALG_RSA_PSS -asymmetric_signature_wildcard:PSA_ALG_RSA_PSS( PSA_ALG_ANY_HASH ):ALG_IS_RSA_PSS +asymmetric_signature_wildcard:PSA_ALG_RSA_PSS( PSA_ALG_ANY_HASH ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_STANDARD_SALT Asymmetric signature: RSA PSS-any-salt with wildcard hash depends_on:PSA_WANT_ALG_RSA_PSS -asymmetric_signature_wildcard:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_ANY_HASH ):ALG_IS_RSA_PSS +asymmetric_signature_wildcard:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_ANY_HASH ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_ANY_SALT Asymmetric signature: randomized ECDSA with wildcard hash depends_on:PSA_WANT_ALG_ECDSA diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index 9f4fc75495..ab9b2f879a 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -22,25 +22,27 @@ #define ALG_IS_STREAM_CIPHER ( 1u << 3 ) #define ALG_IS_RSA_PKCS1V15_SIGN ( 1u << 4 ) #define ALG_IS_RSA_PSS ( 1u << 5 ) -#define ALG_IS_DSA ( 1u << 6 ) -#define ALG_DSA_IS_DETERMINISTIC ( 1u << 7 ) -#define ALG_IS_DETERMINISTIC_DSA ( 1u << 8 ) -#define ALG_IS_RANDOMIZED_DSA ( 1u << 9 ) -#define ALG_IS_ECDSA ( 1u << 10 ) -#define ALG_ECDSA_IS_DETERMINISTIC ( 1u << 11 ) -#define ALG_IS_DETERMINISTIC_ECDSA ( 1u << 12 ) -#define ALG_IS_RANDOMIZED_ECDSA ( 1u << 13 ) -#define ALG_IS_HASH_EDDSA ( 1u << 14 ) -#define ALG_IS_HASH_AND_SIGN ( 1u << 15 ) -#define ALG_IS_RSA_OAEP ( 1u << 16 ) -#define ALG_IS_HKDF ( 1u << 17 ) -#define ALG_IS_FFDH ( 1u << 18 ) -#define ALG_IS_ECDH ( 1u << 19 ) -#define ALG_IS_WILDCARD ( 1u << 20 ) -#define ALG_IS_RAW_KEY_AGREEMENT ( 1u << 21 ) -#define ALG_IS_AEAD_ON_BLOCK_CIPHER ( 1u << 22 ) -#define ALG_IS_TLS12_PRF ( 1u << 23 ) -#define ALG_IS_TLS12_PSK_TO_MS ( 1u << 24 ) +#define ALG_IS_RSA_PSS_ANY_SALT ( 1u << 6 ) +#define ALG_IS_RSA_PSS_STANDARD_SALT ( 1u << 7 ) +#define ALG_IS_DSA ( 1u << 8 ) +#define ALG_DSA_IS_DETERMINISTIC ( 1u << 9 ) +#define ALG_IS_DETERMINISTIC_DSA ( 1u << 10 ) +#define ALG_IS_RANDOMIZED_DSA ( 1u << 11 ) +#define ALG_IS_ECDSA ( 1u << 12 ) +#define ALG_ECDSA_IS_DETERMINISTIC ( 1u << 13 ) +#define ALG_IS_DETERMINISTIC_ECDSA ( 1u << 14 ) +#define ALG_IS_RANDOMIZED_ECDSA ( 1u << 15 ) +#define ALG_IS_HASH_EDDSA ( 1u << 16 ) +#define ALG_IS_HASH_AND_SIGN ( 1u << 17 ) +#define ALG_IS_RSA_OAEP ( 1u << 18 ) +#define ALG_IS_HKDF ( 1u << 19 ) +#define ALG_IS_FFDH ( 1u << 20 ) +#define ALG_IS_ECDH ( 1u << 21 ) +#define ALG_IS_WILDCARD ( 1u << 22 ) +#define ALG_IS_RAW_KEY_AGREEMENT ( 1u << 23 ) +#define ALG_IS_AEAD_ON_BLOCK_CIPHER ( 1u << 24 ) +#define ALG_IS_TLS12_PRF ( 1u << 25 ) +#define ALG_IS_TLS12_PSK_TO_MS ( 1u << 26 ) /* Flags for key type classification macros. There is a flag for every * key type classification macro PSA_KEY_TYPE_IS_xxx except for some that From 454f31c9b9ac07714e98753f10cc41272cf5e018 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 18:30:27 +0200 Subject: [PATCH 673/966] Add test cases for PSA_ALG_RSA_PSS_ANY_SALT The test cases strictly replicate a subset of the test cases for PSA_ALG_RSA_PSS. The subset validates that PSA_ALG_RSA_PSS_ANY_SALT is recognized wherever PSA_ALG_RSA_PSS is. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto.data | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 063629e599..72df17a23d 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -3406,6 +3406,10 @@ PSA signature size: RSA keypair, 1024 bits, PSS depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR signature_size:PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_ALG_RSA_PSS( PSA_ALG_SHA_256 ):128 +PSA signature size: RSA keypair, 1024 bits, PSS-any-salt +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR +signature_size:PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ):128 + PSA signature size: RSA keypair, 1023 bits, PKCS#1 v1.5 raw depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR signature_size:PSA_KEY_TYPE_RSA_KEY_PAIR:1023:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:128 @@ -3422,6 +3426,10 @@ PSA import/exercise RSA keypair, PSS-SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C import_and_exercise_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_ALG_RSA_PSS(PSA_ALG_SHA_256) +PSA import/exercise RSA keypair, PSS-any-salt-SHA-256 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +import_and_exercise_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_ALG_RSA_PSS(PSA_ALG_SHA_256) + PSA import/exercise RSA public key, PKCS#1 v1.5 raw depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C import_and_exercise_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:1024:PSA_ALG_RSA_PKCS1V15_SIGN_RAW @@ -3430,6 +3438,10 @@ PSA import/exercise RSA public key, PSS-SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C import_and_exercise_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:1024:PSA_ALG_RSA_PSS(PSA_ALG_SHA_256) +PSA import/exercise RSA public key, PSS-any-salt-SHA-256 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +import_and_exercise_key:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_KEY_TYPE_RSA_PUBLIC_KEY:1024:PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256) + PSA import/exercise: ECP SECP256R1 keypair, ECDSA depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:PSA_WANT_ECC_SECP_R1_256 import_and_exercise_key:"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):256:PSA_ALG_ECDSA_ANY @@ -3490,10 +3502,18 @@ PSA sign hash: RSA PSS SHA-256, wrong hash length (0 bytes) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C sign_hash_fail:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"":127:PSA_ERROR_INVALID_ARGUMENT +PSA sign hash: RSA PSS-any-salt SHA-256, wrong hash length (0 bytes) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +sign_hash_fail:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"":127:PSA_ERROR_INVALID_ARGUMENT + PSA sign hash: RSA PSS SHA-256, wrong hash length (129 bytes) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C sign_hash_fail:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":127:PSA_ERROR_INVALID_ARGUMENT +PSA sign hash: RSA PSS-any-salt SHA-256, wrong hash length (129 bytes) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +sign_hash_fail:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":127:PSA_ERROR_INVALID_ARGUMENT + PSA sign hash: deterministic ECDSA SECP256R1 SHA-256, output buffer too small depends_on:PSA_WANT_ALG_DETERMINISTIC_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:PSA_WANT_ECC_SECP_R1_256 sign_hash_fail:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"ab45435712649cb30bbddac49197eebf2740ffc7f874d9244c3460f54f322d3a":PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 ):"9ac4335b469bbd791439248504dd0d49c71349a295fee5a1c68507f45a9e1c7b":63:PSA_ERROR_BUFFER_TOO_SMALL @@ -3538,6 +3558,10 @@ PSA sign/verify hash: RSA PSS SHA-256, 32 bytes (hash size) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C sign_verify_hash:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" +PSA sign/verify hash: RSA PSS-any-salt SHA-256, 32 bytes (hash size) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +sign_verify_hash:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" + PSA sign/verify hash: randomized ECDSA SECP256R1 SHA-256 depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:MBEDTLS_PK_PARSE_C:PSA_WANT_ECC_SECP_R1_256 sign_verify_hash:PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"ab45435712649cb30bbddac49197eebf2740ffc7f874d9244c3460f54f322d3a":PSA_ALG_ECDSA( PSA_ALG_SHA_256 ):"9ac4335b469bbd791439248504dd0d49c71349a295fee5a1c68507f45a9e1c7b" @@ -3598,14 +3622,26 @@ PSA verify hash: RSA PSS SHA-256, good signature, 32 bytes (hash size) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"1967ae568cc071dfebeeca76b11d40bd1ec5af241c50b3dcceff21f4536c0693a7179a8d5d163a7625fefd37c161127800edeebc24fa73ca772096827bd3f75e8ccf2c64f07b7171b5c99022a4d73b760f34a385ccff0bd5ed7997d2a29d2847acb0767f93a2a404bc046c97de66d95dc9f7646fdb216b627b2ea0de8afcefb7" +PSA verify hash: RSA PSS-any-salt SHA-256, good signature, 32 bytes (hash size) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"1967ae568cc071dfebeeca76b11d40bd1ec5af241c50b3dcceff21f4536c0693a7179a8d5d163a7625fefd37c161127800edeebc24fa73ca772096827bd3f75e8ccf2c64f07b7171b5c99022a4d73b760f34a385ccff0bd5ed7997d2a29d2847acb0767f93a2a404bc046c97de66d95dc9f7646fdb216b627b2ea0de8afcefb7" + PSA verify hash: RSA PSS SHA-256, wrong hash length (0 bytes) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"":"34c011b625c32d992f4ab8fcfa52b616ea66270b5b75a4fc71af712f9b8806bcdd374ce50eafcbb489562b93347885f93c2de1d404c45cacccefceb112ff6ffdfe4264f91d66320bbbe09304b851b8ad6280bbccc571eebcd49c7db5dfa399a6289e1978407904598751613d9870770cdd8507e3dc7b46851dbf05ae1df2988d":PSA_ERROR_INVALID_ARGUMENT +PSA verify hash: RSA PSS-any-salt SHA-256, wrong hash length (0 bytes) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"":"34c011b625c32d992f4ab8fcfa52b616ea66270b5b75a4fc71af712f9b8806bcdd374ce50eafcbb489562b93347885f93c2de1d404c45cacccefceb112ff6ffdfe4264f91d66320bbbe09304b851b8ad6280bbccc571eebcd49c7db5dfa399a6289e1978407904598751613d9870770cdd8507e3dc7b46851dbf05ae1df2988d":PSA_ERROR_INVALID_ARGUMENT + PSA verify hash: RSA PSS SHA-256, wrong hash length (129 bytes) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"1491cead330b4ad5b092f8351518141ac11d0888591572669c1e79d6e932c488acd62d44479b0e14cd91a048778bc02398a772ad6bdb4f7764780cf0afe70293d0cac86f2695a1dcb54568bb37d7086f9e86f95a6802d2ee5a4facaa762beff5261bb2816b62cb5af86404974c3f6b67985ac1fbfdf46d6de54f6e29d9274308":PSA_ERROR_INVALID_ARGUMENT +PSA verify hash: RSA PSS-any-salt SHA-256, wrong hash length (129 bytes) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"1491cead330b4ad5b092f8351518141ac11d0888591572669c1e79d6e932c488acd62d44479b0e14cd91a048778bc02398a772ad6bdb4f7764780cf0afe70293d0cac86f2695a1dcb54568bb37d7086f9e86f95a6802d2ee5a4facaa762beff5261bb2816b62cb5af86404974c3f6b67985ac1fbfdf46d6de54f6e29d9274308":PSA_ERROR_INVALID_ARGUMENT + PSA verify hash: ECDSA SECP256R1, good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:PSA_WANT_ECC_SECP_R1_256 verify_hash:PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):"04dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_ALG_ECDSA_ANY:"9ac4335b469bbd791439248504dd0d49c71349a295fee5a1c68507f45a9e1c7b":"6a3399f69421ffe1490377adf2ea1f117d81a63cf5bf22e918d51175eb259151ce95d7c26cc04e25503e2f7a1ec3573e3c2412534bb4a19b3a7811742f49f50f" @@ -3722,6 +3758,10 @@ PSA sign/verify message: RSA PSS SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C sign_verify_message:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"616263" +PSA sign/verify message: RSA PSS-any-salt SHA-256 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +sign_verify_message:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"616263" + PSA sign/verify message: RSA PSS SHA-256, 0 bytes depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C sign_verify_message:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"" @@ -3790,18 +3830,34 @@ PSA verify message: RSA PSS SHA-256, good signature, 0 bytes depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"":"50c06249deb97228e277b51d3e3542a6e5c140d6f6d1cb8a3dff53b5ce6e6fcb39d0767703174135208adf5d75399dd7525702b275153e7605ec38b65d33337bb9bbeb8c392ee22e3e9c0dafa43074a8205e17df2106bedd7bf6f1ada702aeb2ce04864c0ca9ec31964f9a957d8ebb9abc82454ad37c541e9b4d9842436c14a4" +PSA verify message: RSA PSS-any-salt SHA-256, good signature, 0 bytes +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"":"50c06249deb97228e277b51d3e3542a6e5c140d6f6d1cb8a3dff53b5ce6e6fcb39d0767703174135208adf5d75399dd7525702b275153e7605ec38b65d33337bb9bbeb8c392ee22e3e9c0dafa43074a8205e17df2106bedd7bf6f1ada702aeb2ce04864c0ca9ec31964f9a957d8ebb9abc82454ad37c541e9b4d9842436c14a4" + PSA verify message: RSA PSS SHA-256, good signature, 32 bytes (hash size) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"6b65e1fdc900dce8a2b82130ae8ccfac27b6d0eb5f2c0c1085b80f34ceaaf064c8ff237e74a24a3c6fb7a842f172e5146315616281bbbeeae90febaab139a212decf1c68923f2a48e242b1fd72105e3a3f2329c30d78abe8673335ad08c5ba1aa515360bb5660050f1994bb08d3dd17e3407a379403bafa4e229b3c851283f6d" +PSA verify message: RSA PSS-any-salt SHA-256, good signature, 32 bytes (hash size) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"6b65e1fdc900dce8a2b82130ae8ccfac27b6d0eb5f2c0c1085b80f34ceaaf064c8ff237e74a24a3c6fb7a842f172e5146315616281bbbeeae90febaab139a212decf1c68923f2a48e242b1fd72105e3a3f2329c30d78abe8673335ad08c5ba1aa515360bb5660050f1994bb08d3dd17e3407a379403bafa4e229b3c851283f6d" + PSA verify message: RSA PSS SHA-256, good signature, 128 bytes (signature size) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"29b65db0936b7fe408bda672077b0bc5e176177ba9a550fb548c292f7b4af1bb6475e0a979ba43dd644780801fabe5b62a1359cf7692918f30013e90c2362235765abc2078905d13b345dd689bf15e4e94ca51535d12f0675d5f13e9f254ba7696f0096d62deb023d106e9a96a5da3162bead6a745c8b9000868d2f9a447d5c5" +PSA verify message: RSA-any-salt PSS SHA-256, good signature, 128 bytes (signature size) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"29b65db0936b7fe408bda672077b0bc5e176177ba9a550fb548c292f7b4af1bb6475e0a979ba43dd644780801fabe5b62a1359cf7692918f30013e90c2362235765abc2078905d13b345dd689bf15e4e94ca51535d12f0675d5f13e9f254ba7696f0096d62deb023d106e9a96a5da3162bead6a745c8b9000868d2f9a447d5c5" + PSA verify message: RSA PSS SHA-256, good signature, 129 bytes depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"43286cc0fc599603fbb0cd1fd70c3a17b08d2adf4f90202dddfa4b9d74be8c720bbb1c714665466de6452d401ca061b68225785ff387c2615f03c81351cc3838cd3014a031a4f4c9f70bba06f504c6a9942ac2dbfed2329e590d526a9be26b4025a6d7c4151b4e795cfe756c9a8a5e8fa9228a6f5f6f427a5a070e5c0ea69830" +PSA verify message: RSA PSS-any-salt SHA-256, good signature, 129 bytes +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"43286cc0fc599603fbb0cd1fd70c3a17b08d2adf4f90202dddfa4b9d74be8c720bbb1c714665466de6452d401ca061b68225785ff387c2615f03c81351cc3838cd3014a031a4f4c9f70bba06f504c6a9942ac2dbfed2329e590d526a9be26b4025a6d7c4151b4e795cfe756c9a8a5e8fa9228a6f5f6f427a5a070e5c0ea69830" + PSA verify message: ECDSA SECP256R1 SHA-256, good depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:PSA_WANT_ALG_SHA_256:MBEDTLS_PK_PARSE_C:PSA_WANT_ECC_SECP_R1_256 verify_message:PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1):"04dea5e45d0ea37fc566232a508f4ad20ea13d47e4bf5fa4d54a57a0ba012042087097496efc583fed8b24a5b9be9a51de063f5a00a8b698a16fd7f29b5485f320":PSA_ALG_ECDSA(PSA_ALG_SHA_256):"616263":"0f8c19f5affea6d593a33e176aa52717bff8d5875165fc63e80a2d65580d295789db5ffb5397ba4c67834e2731ee268ea6f7e83846fbb02145b35442db18cf0b" @@ -4768,6 +4824,10 @@ PSA generate key: RSA, 1024 bits, good, sign (PSS SHA-256) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_GENPRIME:MBEDTLS_MD_C generate_key:PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):PSA_SUCCESS:0 +PSA generate key: RSA, 1024 bits, good, sign (PSS-any-salt SHA-256) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_GENPRIME:MBEDTLS_MD_C +generate_key:PSA_KEY_TYPE_RSA_KEY_PAIR:1024:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):PSA_SUCCESS:0 + PSA generate key: RSA, 512 bits, good, encrypt (PKCS#1 v1.5) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_CRYPT:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_GENPRIME generate_key:PSA_KEY_TYPE_RSA_KEY_PAIR:512:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_RSA_PKCS1V15_CRYPT:PSA_SUCCESS:0 From 44c96aa046102bfbee7738baae4324971f9ea231 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 18:33:56 +0200 Subject: [PATCH 674/966] Support PSA_ALG_RSA_PSS_ANY_SALT iff PSA_ALG_RSA_PSS is supported Signed-off-by: Gilles Peskine --- include/mbedtls/config_psa.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/mbedtls/config_psa.h b/include/mbedtls/config_psa.h index 3b01b78d29..60191f1491 100644 --- a/include/mbedtls/config_psa.h +++ b/include/mbedtls/config_psa.h @@ -56,6 +56,12 @@ extern "C" { #define PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW PSA_WANT_ALG_RSA_PKCS1V15_SIGN #endif +#if defined(PSA_WANT_ALG_RSA_PSS_ANY_SALT) && !defined(PSA_WANT_ALG_RSA_PSS) +#define PSA_WANT_ALG_RSA_PSS PSA_WANT_ALG_RSA_PSS_ANY_SALT +#elif !defined(PSA_WANT_ALG_RSA_PSS_ANY_SALT) && defined(PSA_WANT_ALG_RSA_PSS) +#define PSA_WANT_ALG_RSA_PSS_ANY_SALT PSA_WANT_ALG_RSA_PSS +#endif + /****************************************************************/ From f5322b32235c8df13357419dcb8700a389a2876e Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 18:39:58 +0200 Subject: [PATCH 675/966] Shorten some test descriptions Ensure the unique part fits in the 66 columns that the test runner displays. Leave room for an additional distinguisher on signature key policy negative test cases. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto.data | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 72df17a23d..d4a5209baa 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -912,11 +912,11 @@ PSA key policy: asymmetric signature, sign | verify, key usage extension depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_MD_C asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):32:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature, wrong algorithm family +PSA key policy: asymmetric signature, wrong alg family (RSA v15/PSS) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature, wildcard in policy, wrong algorithm family +PSA key policy: asymmetric signature, wildcard in policy, wrong alg family depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE @@ -952,39 +952,39 @@ PSA key policy: asymmetric signature, neither sign nor verify depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_MD_C asymmetric_signature_key_policy:0:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):32:0 -PSA key policy: asymmetric signature for message, sign | verify +PSA key policy: msg asymmetric signature, sign | verify depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):1:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature for message, wrong algorithm family +PSA key policy: msg asymmetric signature, wrong alg family (RSA v15/PSS) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature for message, wildcard in policy, wrong algorithm family +PSA key policy: msg asymmetric signature, wildcard in policy, wrong alg family depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature for message, wildcard in policy, ECDSA SHA-256 +PSA key policy: msg asymmetric signature, wildcard in policy, ECDSA SHA-256 depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_ECC_KEY_PAIR:PSA_WANT_ECC_SECP_R1_256 asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_ECDSA(PSA_ALG_ANY_HASH):PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1):"49c9a8c18c4b885638c431cf1df1c994131609b580d4fd43a0cab17db2f13eee":PSA_ALG_ECDSA(PSA_ALG_SHA_256):32:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature for message, wildcard in policy, PKCS#1v1.5 SHA-256 +PSA key policy: msg asymmetric signature, wildcard in policy, PKCS#1v1.5 SHA-256 depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):32:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature for message, wrong hash algorithm +PSA key policy: msg asymmetric signature, wrong hash algorithm depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_ALG_SHA_384:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_384):0:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature for message, alg=0 in policy +PSA key policy: msg asymmetric signature, alg=0 in policy depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:0:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE -PSA key policy: asymmetric signature for message, sign but not verify +PSA key policy: msg asymmetric signature, sign but not verify depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):1:PSA_KEY_USAGE_SIGN_MESSAGE -PSA key policy: asymmetric signature for message, verify but not sign +PSA key policy: msg asymmetric signature, verify but not sign depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):1:PSA_KEY_USAGE_VERIFY_MESSAGE From 033b178dce57a4a94e5c98131d6b6747948e4034 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 18:41:27 +0200 Subject: [PATCH 676/966] Test that a PSS policy doesn't allow PSS_ANY_SALT and vice versa Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto.data | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index d4a5209baa..741a9bebee 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -912,6 +912,14 @@ PSA key policy: asymmetric signature, sign | verify, key usage extension depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_MD_C asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):32:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE +PSA key policy: asymmetric signature, wrong alg family (PSS std/any salt) +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR +asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE + +PSA key policy: asymmetric signature, wrong alg family (PSS any/std salt) +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR +asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE + PSA key policy: asymmetric signature, wrong alg family (RSA v15/PSS) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH | PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE @@ -956,6 +964,14 @@ PSA key policy: msg asymmetric signature, sign | verify depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):1:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE +PSA key policy: msg asymmetric signature, wrong alg family (PSS std/any salt) +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR +asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE + +PSA key policy: msg asymmetric signature, wrong alg family (PSS any/std salt) +depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR +asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE + PSA key policy: msg asymmetric signature, wrong alg family (RSA v15/PSS) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR asymmetric_signature_key_policy:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE:PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):PSA_KEY_TYPE_RSA_KEY_PAIR:"3082013b020100024100ee2b131d6b1818a94ca8e91c42387eb15a7c271f57b89e7336b144d4535b16c83097ecdefbbb92d1b5313b5a37214d0e8f25922dca778b424b25295fc8a1a7070203010001024100978ac8eadb0dc6035347d6aba8671215ff21283385396f7897c04baf5e2a835f3b53ef80a82ed36ae687a925380b55a0c73eb85656e989dcf0ed7fb4887024e1022100fdad8e1c6853563f8b921d2d112462ae7d6b176082d2ba43e87e1a37fc1a8b33022100f0592cf4c55ba44307b18981bcdbda376c51e590ffa5345ba866f6962dca94dd02201995f1a967d44ff4a4cd1de837bc65bf97a2bf7eda730a9a62cea53254591105022027f96cf4b8ee68ff8d04062ec1ce7f18c0b74e4b3379b29f9bfea3fc8e592731022100cefa6d220496b43feb83194255d8fb930afcf46f36606e3aa0eb7a93ad88c10c":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):0:PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE From 25794d8946c524b0c1906cd0f6ab26473e1ec85b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 20:17:55 +0200 Subject: [PATCH 677/966] Test PSS verification with different salt lengths Test the following combinations: * 1024-bit key, SHA-256, salt=0 * 1024-bit key, SHA-256, salt=31 (1 byte shorter than standard) * 1024-bit key, SHA-256, salt=32 (standard length) * 1024-bit key, SHA-256, salt=94 (maximum possible length) * 1024-bit key, SHA-512, salt=61 (1 byte shorter than standard) * 1024-bit key, SHA-512, salt=62 (standard = maximum possible length) * 528-bit key, SHA-512, salt=0 (only possible length) Test psa_verify_hash() for both PSA_ALG_RSA_PSS and PSA_ALG_RSA_PSS_ANY_SALT with all of these combinations. For psa_verify_message(), just test once with the standard length and once with a different length. Note that as of this commit, both PSA_ALG_RSA_PSS and PSA_ALG_RSA_PSS_ANY_SALT accept any salt length during verification, hence all the new test cases are positive. The verify test cases were generated using the Python script below. ``` from Cryptodome import Hash from Cryptodome.Hash import SHA512 from Cryptodome import PublicKey from Cryptodome.PublicKey import RSA from Cryptodome.Signature import pss key = { 528: RSA.import_key(bytes.fromhex("30820145020100024300e31c246d46485984261fd174cab3d4357344602ecd793c47dbe54252d37bb350bc634359b19515542080e4724a4b672291be57c7648f51629eaef234e847d99cc65f0203010001024300b166322e09504a5c274b83592f5cf8ce2793a96de5a265abdbe060c641dbc65db0d11c782fe133a7e60aea686d21058d928cad3ef58924c4bb26b9206a03001d0241022200f85d72e463b406ffa282c34b5f0c2d6c2aacf210246af53d5bc7a0b7fa036e1cdb022200ea176c3d9a7fb355fb9fb7707e679b4acfb7bcb645b907e27cdf1764bc340971cd02212e13380342b3dd3083777abf7acc8988ad8a1406069b890f6efd63c57dae31394d022200c3602d3cf537e3cbbda93e072bd8f92965586aae8e5eb20ffc3c8e5fcb1c7b4d7902220098a04f18e48c689ad2f5b9bd404333def54cb2506cd0075c967a2968261e8b8f10")), 1024: RSA.import_key(bytes.fromhex("3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24")), } hash_module = { 256: Hash.SHA256, 512: Hash.SHA512, } def print_test_case(remark, pub, kbits, hbits, input, output): key_hex = pub.hex() input_hex = input.hex() output_hex = output.hex() print(f"""\ PSA verify hash: RSA-{kbits} PSS SHA-{hbits}, {remark} depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_{hbits}:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"{key_hex}":PSA_ALG_RSA_PSS(PSA_ALG_SHA_{hbits}):"{input_hex}":"{output_hex}" PSA verify hash: RSA-{kbits} PSS-any-salt SHA-{hbits}, {remark} depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_{hbits}:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"{key_hex}":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_{hbits}):"{input_hex}":"{output_hex}" """) def rand(n): return bytes(x & 0xff for x in range(n)) def test_case(kbits, hbits, slen): priv = key[kbits] pub_spki = priv.publickey().export_key('DER') pub_raw = PublicKey._expand_subject_public_key_info(pub_spki)[1] hash_op = hash_module[hbits].new(b'abc') digest = hash_op.copy().digest() output = pss.new(priv, salt_bytes=slen, rand_func=rand).sign(hash_op) print_test_case(f"slen={slen}", pub_raw, kbits, hbits, digest, output) test_case(1024, 256, 0) test_case(1024, 256, 31) test_case(1024, 256, 32) test_case(1024, 256, 94) test_case(1024, 512, 61) test_case(1024, 512, 62) test_case(528, 512, 0) ``` Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto.data | 72 ++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 741a9bebee..40bd5eaae5 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -3634,13 +3634,61 @@ PSA verify hash: RSA PKCS#1 v1.5 SHA-256, wrong signature (leading junk) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"21a73664d55b39c7ea6c1e5b5011724a11e1d7073d3a68f48c836fad153a1d91b6abdbc8f69da13b206cc96af6363b114458b026af14b24fab8929ed634c6a2acace0bcc62d9bb6a984afbcbfcd3a0608d32a2bae535b9cd1ecdf9dd281db1e0025c3bfb5512963ec3b98ddaa69e38bc3c84b1b61a04e5648640856aacc6fc7311":PSA_ERROR_INVALID_SIGNATURE -PSA verify hash: RSA PSS SHA-256, good signature, 32 bytes (hash size) +PSA verify hash: RSA-1024 PSS SHA-256, slen=0 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"1967ae568cc071dfebeeca76b11d40bd1ec5af241c50b3dcceff21f4536c0693a7179a8d5d163a7625fefd37c161127800edeebc24fa73ca772096827bd3f75e8ccf2c64f07b7171b5c99022a4d73b760f34a385ccff0bd5ed7997d2a29d2847acb0767f93a2a404bc046c97de66d95dc9f7646fdb216b627b2ea0de8afcefb7" +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b" -PSA verify hash: RSA PSS-any-salt SHA-256, good signature, 32 bytes (hash size) +PSA verify hash: RSA-1024 PSS-any-salt SHA-256, slen=0 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"1967ae568cc071dfebeeca76b11d40bd1ec5af241c50b3dcceff21f4536c0693a7179a8d5d163a7625fefd37c161127800edeebc24fa73ca772096827bd3f75e8ccf2c64f07b7171b5c99022a4d73b760f34a385ccff0bd5ed7997d2a29d2847acb0767f93a2a404bc046c97de66d95dc9f7646fdb216b627b2ea0de8afcefb7" +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b" + +PSA verify hash: RSA-1024 PSS SHA-256, slen=31 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"797914eadbbe8293a7b0fe29d2db9fb246b519128d46d3ec93142a1a08a2992ba5325ad9b5ce55344b37996dbb81eb89628263cae4e3fc0e947dec0b8b0c7b0ee94bca02dd287f9cc619e2d88fb2279fb2a8f8301271c58009bb1223f3cfa730cb852947685678cfdef2968c82a9b8bffd8c0d518476b1ea2a5ad6c100045d8e" + +PSA verify hash: RSA-1024 PSS-any-salt SHA-256, slen=31 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"797914eadbbe8293a7b0fe29d2db9fb246b519128d46d3ec93142a1a08a2992ba5325ad9b5ce55344b37996dbb81eb89628263cae4e3fc0e947dec0b8b0c7b0ee94bca02dd287f9cc619e2d88fb2279fb2a8f8301271c58009bb1223f3cfa730cb852947685678cfdef2968c82a9b8bffd8c0d518476b1ea2a5ad6c100045d8e" + +PSA verify hash: RSA-1024 PSS SHA-256, slen=32 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"6b201c50637962338d1b218c1d26f031205a0e3c47bc4c54856aa037e5a332d2981e80a51648e902e46046e5507a255c4c73f5ff40d5a54c0a11d2eca7804e1767b20ea12c945a23f5473181d379689c1ba634a2c47c0a8ec90c922ca6466ae9e9fb92871c9043b5858ae34828bceb4ead82db8f21a18ebe1d95b469bbdef1df" + +PSA verify hash: RSA-1024 PSS-any-salt SHA-256, slen=32 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"6b201c50637962338d1b218c1d26f031205a0e3c47bc4c54856aa037e5a332d2981e80a51648e902e46046e5507a255c4c73f5ff40d5a54c0a11d2eca7804e1767b20ea12c945a23f5473181d379689c1ba634a2c47c0a8ec90c922ca6466ae9e9fb92871c9043b5858ae34828bceb4ead82db8f21a18ebe1d95b469bbdef1df" + +PSA verify hash: RSA-1024 PSS SHA-256, slen=94 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"44a09fa66f1b2e790474960e90517e418747cfcd18423dff957516a598569d74f26ef1eae4a200d12d801e16fc6fde375330c79c0d8430825e0a7f69c664faefccfa25e7fbfc68af02af0f67fe4c49f68f6abc68c8f66d3fd77fc838961f4415827340c66e39c79ed7dae0738c08ce8272aebe50c72e31994b9b6db640b51800" + +PSA verify hash: RSA-1024 PSS-any-salt SHA-256, slen=94 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"44a09fa66f1b2e790474960e90517e418747cfcd18423dff957516a598569d74f26ef1eae4a200d12d801e16fc6fde375330c79c0d8430825e0a7f69c664faefccfa25e7fbfc68af02af0f67fe4c49f68f6abc68c8f66d3fd77fc838961f4415827340c66e39c79ed7dae0738c08ce8272aebe50c72e31994b9b6db640b51800" + +PSA verify hash: RSA-1024 PSS SHA-512, slen=61 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"23f5b30c8d612d8f31206c177ac2023c4f44754d03c7ff67daff99f24fa369b3e5f7c15b228a4417a1ff1c93fb8d645d619c2f4f559ac6c7f7bac20ba9df32353d19941265a4e74261adaf45d48682c0bc86cea6128f11ad172ff461fb1d97bded615861843996e2a98e7b8313b695519d001ae35305d6cbf3c0ee6c7ab06d1a" + +PSA verify hash: RSA-1024 PSS-any-salt SHA-512, slen=61 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"23f5b30c8d612d8f31206c177ac2023c4f44754d03c7ff67daff99f24fa369b3e5f7c15b228a4417a1ff1c93fb8d645d619c2f4f559ac6c7f7bac20ba9df32353d19941265a4e74261adaf45d48682c0bc86cea6128f11ad172ff461fb1d97bded615861843996e2a98e7b8313b695519d001ae35305d6cbf3c0ee6c7ab06d1a" + +PSA verify hash: RSA-1024 PSS SHA-512, slen=62 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"6b215d77cf88b2d08be53b4f3ac6e72ebfbf7e0dc6c1e77b238cfb661c247a011b8746709fbefe4bc05d37343391683e9489d720ecbb7df37f4e36967918958996939461703465c2014a4c12faf875f8def70070e55b765b165c7e9c6f2eb05c98351b1e82219c31a2fb3ddce05f8988f552ff92f0b3471f63c0e53824c550a4" + +PSA verify hash: RSA-1024 PSS-any-salt SHA-512, slen=62 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"6b215d77cf88b2d08be53b4f3ac6e72ebfbf7e0dc6c1e77b238cfb661c247a011b8746709fbefe4bc05d37343391683e9489d720ecbb7df37f4e36967918958996939461703465c2014a4c12faf875f8def70070e55b765b165c7e9c6f2eb05c98351b1e82219c31a2fb3ddce05f8988f552ff92f0b3471f63c0e53824c550a4" + +PSA verify hash: RSA-528 PSS SHA-512, slen=0 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"304a024300e31c246d46485984261fd174cab3d4357344602ecd793c47dbe54252d37bb350bc634359b19515542080e4724a4b672291be57c7648f51629eaef234e847d99cc65f0203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"a14ad0fef77d36c28658a66129ee632e40e1032003eefe7fcda8e52b06675a051c80b2ca1cb99ed0762e90c9a48c434cd1063638eed7895a9c770e5435af750a1955" + +PSA verify hash: RSA-528 PSS-any-salt SHA-512, slen=0 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"304a024300e31c246d46485984261fd174cab3d4357344602ecd793c47dbe54252d37bb350bc634359b19515542080e4724a4b672291be57c7648f51629eaef234e847d99cc65f0203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"a14ad0fef77d36c28658a66129ee632e40e1032003eefe7fcda8e52b06675a051c80b2ca1cb99ed0762e90c9a48c434cd1063638eed7895a9c770e5435af750a1955" PSA verify hash: RSA PSS SHA-256, wrong hash length (0 bytes) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C @@ -3842,13 +3890,21 @@ PSA verify message with keypair: RSA PKCS#1 v1.5 SHA-256, good signature depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_message:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):"616263":"a73664d55b39c7ea6c1e5b5011724a11e1d7073d3a68f48c836fad153a1d91b6abdbc8f69da13b206cc96af6363b114458b026af14b24fab8929ed634c6a2acace0bcc62d9bb6a984afbcbfcd3a0608d32a2bae535b9cd1ecdf9dd281db1e0025c3bfb5512963ec3b98ddaa69e38bc3c84b1b61a04e5648640856aacc6fc7311" -PSA verify message: RSA PSS SHA-256, good signature, 0 bytes +PSA verify message: RSA-1024 PSS SHA-256, slen=0 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"":"50c06249deb97228e277b51d3e3542a6e5c140d6f6d1cb8a3dff53b5ce6e6fcb39d0767703174135208adf5d75399dd7525702b275153e7605ec38b65d33337bb9bbeb8c392ee22e3e9c0dafa43074a8205e17df2106bedd7bf6f1ada702aeb2ce04864c0ca9ec31964f9a957d8ebb9abc82454ad37c541e9b4d9842436c14a4" +verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"616263":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b" -PSA verify message: RSA PSS-any-salt SHA-256, good signature, 0 bytes +PSA verify message: RSA-1024 PSS-any-salt SHA-256, slen=0 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"":"50c06249deb97228e277b51d3e3542a6e5c140d6f6d1cb8a3dff53b5ce6e6fcb39d0767703174135208adf5d75399dd7525702b275153e7605ec38b65d33337bb9bbeb8c392ee22e3e9c0dafa43074a8205e17df2106bedd7bf6f1ada702aeb2ce04864c0ca9ec31964f9a957d8ebb9abc82454ad37c541e9b4d9842436c14a4" +verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"616263":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b" + +PSA verify message: RSA-1024 PSS SHA-256, slen=32 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"616263":"6b201c50637962338d1b218c1d26f031205a0e3c47bc4c54856aa037e5a332d2981e80a51648e902e46046e5507a255c4c73f5ff40d5a54c0a11d2eca7804e1767b20ea12c945a23f5473181d379689c1ba634a2c47c0a8ec90c922ca6466ae9e9fb92871c9043b5858ae34828bceb4ead82db8f21a18ebe1d95b469bbdef1df" + +PSA verify message: RSA-1024 PSS-any-salt SHA-256, slen=32 +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"616263":"6b201c50637962338d1b218c1d26f031205a0e3c47bc4c54856aa037e5a332d2981e80a51648e902e46046e5507a255c4c73f5ff40d5a54c0a11d2eca7804e1767b20ea12c945a23f5473181d379689c1ba634a2c47c0a8ec90c922ca6466ae9e9fb92871c9043b5858ae34828bceb4ead82db8f21a18ebe1d95b469bbdef1df" PSA verify message: RSA PSS SHA-256, good signature, 32 bytes (hash size) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C From b9b817e9777b30ab913fb1a3c0cad7f9c3d7a476 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 4 Oct 2021 22:15:05 +0200 Subject: [PATCH 678/966] Fix PSA_ALG_RSA_PSS verification accepting an arbitrary salt length PSA_ALG_RSA_PSS algorithm now accepts only the same salt length for verification that it produces when signing, as documented. Fixes #4946. Signed-off-by: Gilles Peskine --- ChangeLog.d/psa_alg_rsa_pss.txt | 5 ++++ library/psa_crypto_rsa.c | 34 +++++++++++++++++++++---- tests/suites/test_suite_psa_crypto.data | 28 ++++++++++++-------- 3 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 ChangeLog.d/psa_alg_rsa_pss.txt diff --git a/ChangeLog.d/psa_alg_rsa_pss.txt b/ChangeLog.d/psa_alg_rsa_pss.txt new file mode 100644 index 0000000000..5c6048fe6c --- /dev/null +++ b/ChangeLog.d/psa_alg_rsa_pss.txt @@ -0,0 +1,5 @@ +Bugfix + * Fix PSA_ALG_RSA_PSS verification accepting an arbitrary salt length. + This algorithm now accepts only the same salt length for verification + that it produces when signing, as documented. Use the new algorithm + PSA_ALG_RSA_PSS_ANY_SALT to accept any salt length. Fixes #4946. diff --git a/library/psa_crypto_rsa.c b/library/psa_crypto_rsa.c index 2c357c91ce..7ee15ea077 100644 --- a/library/psa_crypto_rsa.c +++ b/library/psa_crypto_rsa.c @@ -453,6 +453,27 @@ exit: return( status ); } +#if defined(BUILTIN_ALG_RSA_PSS) +static int rsa_pss_expected_salt_len( psa_algorithm_t alg, + const mbedtls_rsa_context *rsa, + size_t hash_length ) +{ + if( PSA_ALG_IS_RSA_PSS_ANY_SALT( alg ) ) + return( MBEDTLS_RSA_SALT_LEN_ANY ); + /* Otherwise: standard salt length, i.e. largest possible salt length + * up to the hash length. */ + int klen = (int) (int) mbedtls_rsa_get_len( rsa ); // known to fit + int hlen = (int) hash_length; // known to fit + int room = klen - 2 - hlen; + if( room < 0 ) + return( 0 ); // there is no valid signature in this case anyway + else if( room > hlen ) + return( hlen ); + else + return( room ); +} +#endif + static psa_status_t rsa_verify_hash( const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, @@ -503,11 +524,14 @@ static psa_status_t rsa_verify_hash( ret = mbedtls_rsa_set_padding( rsa, MBEDTLS_RSA_PKCS_V21, md_alg ); if( ret == 0 ) { - ret = mbedtls_rsa_rsassa_pss_verify( rsa, - md_alg, - (unsigned int) hash_length, - hash, - signature ); + int slen = rsa_pss_expected_salt_len( alg, rsa, hash_length ); + ret = mbedtls_rsa_rsassa_pss_verify_ext( rsa, + md_alg, + (unsigned) hash_length, + hash, + md_alg, + slen, + signature ); } } else diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 40bd5eaae5..e189d0f4fa 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -3634,17 +3634,17 @@ PSA verify hash: RSA PKCS#1 v1.5 SHA-256, wrong signature (leading junk) depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"21a73664d55b39c7ea6c1e5b5011724a11e1d7073d3a68f48c836fad153a1d91b6abdbc8f69da13b206cc96af6363b114458b026af14b24fab8929ed634c6a2acace0bcc62d9bb6a984afbcbfcd3a0608d32a2bae535b9cd1ecdf9dd281db1e0025c3bfb5512963ec3b98ddaa69e38bc3c84b1b61a04e5648640856aacc6fc7311":PSA_ERROR_INVALID_SIGNATURE -PSA verify hash: RSA-1024 PSS SHA-256, slen=0 +PSA verify hash: RSA-1024 PSS SHA-256, slen=0 (bad) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b" +verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b":PSA_ERROR_INVALID_SIGNATURE PSA verify hash: RSA-1024 PSS-any-salt SHA-256, slen=0 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b" -PSA verify hash: RSA-1024 PSS SHA-256, slen=31 +PSA verify hash: RSA-1024 PSS SHA-256, slen=31 (bad) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"797914eadbbe8293a7b0fe29d2db9fb246b519128d46d3ec93142a1a08a2992ba5325ad9b5ce55344b37996dbb81eb89628263cae4e3fc0e947dec0b8b0c7b0ee94bca02dd287f9cc619e2d88fb2279fb2a8f8301271c58009bb1223f3cfa730cb852947685678cfdef2968c82a9b8bffd8c0d518476b1ea2a5ad6c100045d8e" +verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"797914eadbbe8293a7b0fe29d2db9fb246b519128d46d3ec93142a1a08a2992ba5325ad9b5ce55344b37996dbb81eb89628263cae4e3fc0e947dec0b8b0c7b0ee94bca02dd287f9cc619e2d88fb2279fb2a8f8301271c58009bb1223f3cfa730cb852947685678cfdef2968c82a9b8bffd8c0d518476b1ea2a5ad6c100045d8e":PSA_ERROR_INVALID_SIGNATURE PSA verify hash: RSA-1024 PSS-any-salt SHA-256, slen=31 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C @@ -3658,17 +3658,17 @@ PSA verify hash: RSA-1024 PSS-any-salt SHA-256, slen=32 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"6b201c50637962338d1b218c1d26f031205a0e3c47bc4c54856aa037e5a332d2981e80a51648e902e46046e5507a255c4c73f5ff40d5a54c0a11d2eca7804e1767b20ea12c945a23f5473181d379689c1ba634a2c47c0a8ec90c922ca6466ae9e9fb92871c9043b5858ae34828bceb4ead82db8f21a18ebe1d95b469bbdef1df" -PSA verify hash: RSA-1024 PSS SHA-256, slen=94 +PSA verify hash: RSA-1024 PSS SHA-256, slen=94 (bad) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"44a09fa66f1b2e790474960e90517e418747cfcd18423dff957516a598569d74f26ef1eae4a200d12d801e16fc6fde375330c79c0d8430825e0a7f69c664faefccfa25e7fbfc68af02af0f67fe4c49f68f6abc68c8f66d3fd77fc838961f4415827340c66e39c79ed7dae0738c08ce8272aebe50c72e31994b9b6db640b51800" +verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"44a09fa66f1b2e790474960e90517e418747cfcd18423dff957516a598569d74f26ef1eae4a200d12d801e16fc6fde375330c79c0d8430825e0a7f69c664faefccfa25e7fbfc68af02af0f67fe4c49f68f6abc68c8f66d3fd77fc838961f4415827340c66e39c79ed7dae0738c08ce8272aebe50c72e31994b9b6db640b51800":PSA_ERROR_INVALID_SIGNATURE PSA verify hash: RSA-1024 PSS-any-salt SHA-256, slen=94 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_256):"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad":"44a09fa66f1b2e790474960e90517e418747cfcd18423dff957516a598569d74f26ef1eae4a200d12d801e16fc6fde375330c79c0d8430825e0a7f69c664faefccfa25e7fbfc68af02af0f67fe4c49f68f6abc68c8f66d3fd77fc838961f4415827340c66e39c79ed7dae0738c08ce8272aebe50c72e31994b9b6db640b51800" -PSA verify hash: RSA-1024 PSS SHA-512, slen=61 +PSA verify hash: RSA-1024 PSS SHA-512, slen=61 (bad) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"23f5b30c8d612d8f31206c177ac2023c4f44754d03c7ff67daff99f24fa369b3e5f7c15b228a4417a1ff1c93fb8d645d619c2f4f559ac6c7f7bac20ba9df32353d19941265a4e74261adaf45d48682c0bc86cea6128f11ad172ff461fb1d97bded615861843996e2a98e7b8313b695519d001ae35305d6cbf3c0ee6c7ab06d1a" +verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"23f5b30c8d612d8f31206c177ac2023c4f44754d03c7ff67daff99f24fa369b3e5f7c15b228a4417a1ff1c93fb8d645d619c2f4f559ac6c7f7bac20ba9df32353d19941265a4e74261adaf45d48682c0bc86cea6128f11ad172ff461fb1d97bded615861843996e2a98e7b8313b695519d001ae35305d6cbf3c0ee6c7ab06d1a":PSA_ERROR_INVALID_SIGNATURE PSA verify hash: RSA-1024 PSS-any-salt SHA-512, slen=61 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C @@ -3690,6 +3690,14 @@ PSA verify hash: RSA-528 PSS-any-salt SHA-512, slen=0 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"304a024300e31c246d46485984261fd174cab3d4357344602ecd793c47dbe54252d37bb350bc634359b19515542080e4724a4b672291be57c7648f51629eaef234e847d99cc65f0203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"a14ad0fef77d36c28658a66129ee632e40e1032003eefe7fcda8e52b06675a051c80b2ca1cb99ed0762e90c9a48c434cd1063638eed7895a9c770e5435af750a1955" +PSA verify hash: RSA-520 PSS SHA-512 (hash too large) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"3049024200d5a06f86e5b9d87428540165ca966fa8893a62e2a59d0bfd7617780bb039f9165a373a8e119d0766f8de556710f33f67019153bad8223775e797d451d48206f3bf0203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead42":PSA_ERROR_INVALID_ARGUMENT + +PSA verify hash: RSA-520 PSS-any-salt SHA-512 (hash too large) +depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_512:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C +verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"3049024200d5a06f86e5b9d87428540165ca966fa8893a62e2a59d0bfd7617780bb039f9165a373a8e119d0766f8de556710f33f67019153bad8223775e797d451d48206f3bf0203010001":PSA_ALG_RSA_PSS_ANY_SALT(PSA_ALG_SHA_512):"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f":"deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead42":PSA_ERROR_INVALID_ARGUMENT + PSA verify hash: RSA PSS SHA-256, wrong hash length (0 bytes) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_hash_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"":"34c011b625c32d992f4ab8fcfa52b616ea66270b5b75a4fc71af712f9b8806bcdd374ce50eafcbb489562b93347885f93c2de1d404c45cacccefceb112ff6ffdfe4264f91d66320bbbe09304b851b8ad6280bbccc571eebcd49c7db5dfa399a6289e1978407904598751613d9870770cdd8507e3dc7b46851dbf05ae1df2988d":PSA_ERROR_INVALID_ARGUMENT @@ -3890,9 +3898,9 @@ PSA verify message with keypair: RSA PKCS#1 v1.5 SHA-256, good signature depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_KEY_PAIR:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C verify_message:PSA_KEY_TYPE_RSA_KEY_PAIR:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc3020301000102818100874bf0ffc2f2a71d14671ddd0171c954d7fdbf50281e4f6d99ea0e1ebcf82faa58e7b595ffb293d1abe17f110b37c48cc0f36c37e84d876621d327f64bbe08457d3ec4098ba2fa0a319fba411c2841ed7be83196a8cdf9daa5d00694bc335fc4c32217fe0488bce9cb7202e59468b1ead119000477db2ca797fac19eda3f58c1024100e2ab760841bb9d30a81d222de1eb7381d82214407f1b975cbbfe4e1a9467fd98adbd78f607836ca5be1928b9d160d97fd45c12d6b52e2c9871a174c66b488113024100c5ab27602159ae7d6f20c3c2ee851e46dc112e689e28d5fcbbf990a99ef8a90b8bb44fd36467e7fc1789ceb663abda338652c3c73f111774902e840565927091024100b6cdbd354f7df579a63b48b3643e353b84898777b48b15f94e0bfc0567a6ae5911d57ad6409cf7647bf96264e9bd87eb95e263b7110b9a1f9f94acced0fafa4d024071195eec37e8d257decfc672b07ae639f10cbb9b0c739d0c809968d644a94e3fd6ed9287077a14583f379058f76a8aecd43c62dc8c0f41766650d725275ac4a1024100bb32d133edc2e048d463388b7be9cb4be29f4b6250be603e70e3647501c97ddde20a4e71be95fd5e71784e25aca4baf25be5738aae59bbfe1c997781447a2b24":PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256):"616263":"a73664d55b39c7ea6c1e5b5011724a11e1d7073d3a68f48c836fad153a1d91b6abdbc8f69da13b206cc96af6363b114458b026af14b24fab8929ed634c6a2acace0bcc62d9bb6a984afbcbfcd3a0608d32a2bae535b9cd1ecdf9dd281db1e0025c3bfb5512963ec3b98ddaa69e38bc3c84b1b61a04e5648640856aacc6fc7311" -PSA verify message: RSA-1024 PSS SHA-256, slen=0 +PSA verify message: RSA-1024 PSS SHA-256, slen=0 (bad) depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C -verify_message:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"616263":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b" +verify_message_fail:PSA_KEY_TYPE_RSA_PUBLIC_KEY:"30818902818100af057d396ee84fb75fdbb5c2b13c7fe5a654aa8aa2470b541ee1feb0b12d25c79711531249e1129628042dbbb6c120d1443524ef4c0e6e1d8956eeb2077af12349ddeee54483bc06c2c61948cd02b202e796aebd94d3a7cbf859c2c1819c324cb82b9cd34ede263a2abffe4733f077869e8660f7d6834da53d690ef7985f6bc30203010001":PSA_ALG_RSA_PSS(PSA_ALG_SHA_256):"616263":"abc4b612c6b71e13fa5965b2e25ee6adec5b1f211b2db158e9f3c4547d6cbef909a73dfb474b8caaf6c8fcafa10ec0bbadfd1883289ce33ad08ad533c61ea004fef4d9b76a1efc267efd066ae8918cb8e994faad30ff5e340e14c941926ba7ca9422b86e8055df1c1b90a5959a59cc7a5fc15cbd0d848cd40f7857b7629b668b":PSA_ERROR_INVALID_SIGNATURE PSA verify message: RSA-1024 PSS-any-salt SHA-256, slen=0 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_MD_C From 575f23c3d5bad874a03b3def02fa68a5458cdc9b Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 6 Oct 2021 11:31:49 +0200 Subject: [PATCH 679/966] add client/server opaque test Signed-off-by: Przemyslaw Stekiel --- tests/ssl-opt.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index d6fef13013..7d0b31381f 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1459,6 +1459,23 @@ run_test "Opaque key for server authentication" \ -S "error" \ -C "error" +# Test using an opaque private key for client/server authentication +requires_config_enabled MBEDTLS_USE_PSA_CRYPTO +requires_config_enabled MBEDTLS_X509_CRT_PARSE_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SHA256_C +run_test "Opaque key for client/server authentication" \ + "$P_SRV auth_mode=required key_opaque=1" \ + "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \ + key_file=data_files/server5.key" \ + 0 \ + -c "key type: Opaque" \ + -c "Verifying peer X.509 certificate... ok" \ + -s "key type: Opaque" \ + -s "Verifying peer X.509 certificate... ok" \ + -S "error" \ + -C "error" + # Test ciphersuites which we expect to be fully supported by PSA Crypto # and check that we don't fall back to Mbed TLS' internal crypto primitives. run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM From c0fe820dc9f79050189b1d02fbe0922dd5875b86 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Thu, 7 Oct 2021 11:08:56 +0200 Subject: [PATCH 680/966] psa_generate_key(): return PSA_ERROR_INVALID_ARGUMENT for public key Signed-off-by: Przemyslaw Stekiel --- library/psa_crypto.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ece64b100d..59c267827a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -5703,6 +5703,10 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes, if( psa_get_key_bits( attributes ) == 0 ) return( PSA_ERROR_INVALID_ARGUMENT ); + /* Reject any attempt to create a public key. */ + if( PSA_KEY_TYPE_IS_PUBLIC_KEY(attributes->core.type) ) + return( PSA_ERROR_INVALID_ARGUMENT ); + status = psa_start_key_creation( PSA_KEY_CREATION_GENERATE, attributes, &slot, &driver ); if( status != PSA_SUCCESS ) From 770153e83665426606a19ed8a4b8755211dfda74 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Thu, 7 Oct 2021 11:12:41 +0200 Subject: [PATCH 681/966] Add change-log entry Signed-off-by: Przemyslaw Stekiel --- ChangeLog.d/fix-psa_gen_key-status.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 ChangeLog.d/fix-psa_gen_key-status.txt diff --git a/ChangeLog.d/fix-psa_gen_key-status.txt b/ChangeLog.d/fix-psa_gen_key-status.txt new file mode 100644 index 0000000000..c46bd6f01f --- /dev/null +++ b/ChangeLog.d/fix-psa_gen_key-status.txt @@ -0,0 +1,2 @@ +Bugfix + * Fix status ret by psa_generate_key() for public key. Fixes #4551. From db0ed7c57999ddc2f50c841a6df94ef242599876 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Thu, 7 Oct 2021 15:11:32 +0200 Subject: [PATCH 682/966] ssl_server2.c: fix build err (key_slot - unused variable) Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_server2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index abc9b5f5d4..68e92b7121 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1325,7 +1325,7 @@ int main( int argc, char *argv[] ) mbedtls_pk_context pkey; mbedtls_x509_crt srvcert2; mbedtls_pk_context pkey2; -#if defined(MBEDTLS_USE_PSA_CRYPTO) +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_USE_PSA_CRYPTO) psa_key_id_t key_slot = 0; /* invalid key slot */ #endif int key_cert_init = 0, key_cert_init2 = 0; From 4086159910dfc1cf95fab62d9b3d94906d87982c Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 7 Oct 2021 19:12:44 +0200 Subject: [PATCH 683/966] Remove obsolete specification draft See https://armmbed.github.io/mbed-crypto/psa/#hardware-abstraction-layer instead. Signed-off-by: Gilles Peskine --- docs/.gitignore | 1 - docs/PSACryptoDriverModelSpec.pdf | Bin 565092 -> 0 bytes 2 files changed, 1 deletion(-) delete mode 100644 docs/PSACryptoDriverModelSpec.pdf diff --git a/docs/.gitignore b/docs/.gitignore index 33ae5acf64..23f832b734 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -1,3 +1,2 @@ *.html *.pdf -!PSACryptoDriverModelSpec.pdf diff --git a/docs/PSACryptoDriverModelSpec.pdf b/docs/PSACryptoDriverModelSpec.pdf deleted file mode 100644 index cf11380e840184071cdf3b55ae11d7f67b389e8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 565092 zcmeFYWppL6vMy$3W@ct)W@ct)W@e9>Va&|T%*-A$Gc(&`d$yf9_ucz)lXF(yN&Y1( zTK%J1t-V{SmOj;2r6N}nlb~m2V22_9wLH2G!$QPF!9|mJGWJD2Hpk>S}e!XaNtd=$`n_4+M;ynHAs+ylw?C@q|yWA zNz-z6lg+wJs)<6^)L?obqp=YzZ^RuK3dy4!-cR4h=M$=}YCa5DSuW)23R5=JK z);b_Gc$E>Pa4={UFom(Qbrmk%=qw+mR5}&T9x17vGa+atkYq(*q##P_RG?cp?$G0b zAl4035nhGge95RvDZneVT%dLWqv7mw3?P;4LYXy>Xh57HP@sGeGrCp>8%8iodBPD> z$K+S=4ZP|QSzd&~DOD(TT0xfEM9N6;0b1CI$E+l}OmG?vh0%4sT2N?oV2w&t6B_A} z*Rdo}LIHYO$0EE+Xg1zE@@a>y=wHEWcz zMAc{$430{v0sBFzDJZK#eU2>Rk?E<%aGy+e(TRvw1zUI(n;%d)g*6)Z=7_0q1kLjv z4+o(5`HK(r?fDKDzr%Lv>*wzXG~Og%`ThTNczIGV?^EVso7Ny$j$!wHl@04eK;qxJ zcdQ(!L`dSNo4=OL)a?o4CcTk9E=BgYhy9j~Q1>|#@*Iwlheq(~U2^{pIL`X{tlXe}xUnjtB`(B2Nx;ou_ zq~aXaUY-Cnre;3?l$Ay*xD>5{uecKezkVo zvwlM#8~+o#>l$6iw8+4k%H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Y#WxxY*f&Xtx%?ydr=Q+x^ zBixGuiJK^kp0}cYm%K+s$DfEI9Lf6!7S)};DXaQG zJnmqj<^r_Kuch1N+je%o>AICW9iWX$yQDqkXWD^+R?28SqZ-rw15~bX)j_r4N%I9` zFEHKi_i0w_#!lGgzq9mHV~-%;VcbMb+$l_OF0?jLHK5v4V5?0{tWMOcKDGTmi9i(e zQ@DE$jkBzAcLTzY| zxhaHs){~}2J~g{noMSD@)|9#)Q(G&XN9~d(HKtD-e+{TNwX1jcEo1jSW1M-dt~)A! zBCd^BB`jNh%1ENbq1e&gVUru<*+-VUuwk2$kH{YD%l88!sxNScMECXoJs#ocWa!}J X1`MOYad0w!XXS>Ypb%G(fct*{i^jr} From cf522226945d464847bd2477fde9af4d24be0723 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 7 Oct 2021 19:25:29 +0200 Subject: [PATCH 684/966] Correct support function name Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 567fa936c4..721c82d34b 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2303,7 +2303,7 @@ component_test_m32_o2 () { msg "test ssl-opt.sh, i386, make, gcc-O2" tests/ssl-opt.sh } -support_test_m32_o1 () { +support_test_m32_o2 () { support_test_m32_o0 "$@" } From 77f0535a9352053a98988bb592c90e521522347f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 7 Oct 2021 19:27:16 +0200 Subject: [PATCH 685/966] Clarify a comment Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 721c82d34b..5bc9a3d276 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2275,7 +2275,8 @@ component_build_mbedtls_config_file () { } component_test_m32_o0 () { - # Build without optimization, to not use the i386 specific inline assembly. + # Build without optimization, so as to use portable C code (in a 32-bit + # build) and not the i386-specific inline assembly. msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s scripts/config.py full make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS" From dbf7b7eeb5712df6651c7e360a55b82633bd7d14 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 7 Oct 2021 19:34:57 +0200 Subject: [PATCH 686/966] Switch cmake -O2 builds around to where we test a lot Use Release mode (-O2) for component_test_full_cmake_clang which runs SSL tests. To have some coverage with Check mode (which enables more compiler warnings but compiles with -Os), change a few other builds that only run unit tests at most to Check mode. Don't add any new builds, to keep the total build volume down. We don't need extensive coverage of all combinations, just a reasonable set. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 5bc9a3d276..646055d63b 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1283,7 +1283,7 @@ component_test_psa_collect_statuses () { component_test_full_cmake_clang () { msg "build: cmake, full config, clang" # ~ 50s scripts/config.py full - CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . + CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release -D ENABLE_TESTING=On . make msg "test: main suites (full config, clang)" # ~ 5s @@ -1926,7 +1926,8 @@ component_build_no_std_function () { scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT - make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check + make } component_build_no_ssl_srv () { @@ -2094,7 +2095,7 @@ component_test_when_no_ciphersuites_have_mac () { component_test_no_date_time () { msg "build: default config without MBEDTLS_HAVE_TIME_DATE" scripts/config.py unset MBEDTLS_HAVE_TIME_DATE - CC=gcc cmake + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check make msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites" @@ -2633,7 +2634,7 @@ component_test_cmake_out_of_source () { MBEDTLS_ROOT_DIR="$PWD" mkdir "$OUT_OF_SOURCE_DIR" cd "$OUT_OF_SOURCE_DIR" - cmake "$MBEDTLS_ROOT_DIR" + cmake -D CMAKE_BUILD_TYPE:String=Check "$MBEDTLS_ROOT_DIR" make msg "test: cmake 'out-of-source' build" From 34da3727d6feef7322bd15e238bcef6317cf5edc Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sun, 19 Sep 2021 18:05:08 +0800 Subject: [PATCH 687/966] Add check read ptr macro Signed-off-by: Jerry Yu --- library/ssl_misc.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 3f3f505031..4cbefdbfd4 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -409,6 +409,29 @@ static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur, } \ } while( 0 ) +/** + * \brief This macro checks if the remaining size in a input buffer is + * greater or equal than a needed space. If it is not the case, + * it returns an SSL_DECODE_ERROR error and sends DECODE_ERROR + * alert message. + * + * \param cur Pointer to the current position in the buffer. + * \param end Pointer to one past the end of the buffer. + * \param need Needed space in bytes. + * + */ +#define MBEDTLS_SSL_CHK_BUF_READ_PTR( cur, end, need ) \ + do { \ + if( mbedtls_ssl_chk_buf_ptr( ( cur ), ( end ), ( need ) ) != 0 ) \ + { \ + MBEDTLS_SSL_DEBUG_MSG( 1, \ + ( "missing input data in %s", __func__ ) ); \ + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_ERR_SSL_DECODE_ERROR ); \ + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); \ + } \ + } while( 0 ) + #ifdef __cplusplus extern "C" { #endif From 1b7c4a464c385421f2a2f33ec3d22de7c6530007 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 17:09:12 +0800 Subject: [PATCH 688/966] tls13: add key exchange modes in handshake params Signed-off-by: Jerry Yu --- library/ssl_misc.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 4cbefdbfd4..9f9192fc07 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -509,6 +509,9 @@ struct mbedtls_ssl_handshake_params /* * Handshake specific crypto variables */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + int tls1_3_kex_modes; /*!< key exchange modes for TLS 1.3 */ +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) @@ -1438,6 +1441,43 @@ static inline int mbedtls_ssl_conf_tls13_some_psk_enabled( mbedtls_ssl_context * MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); } +static inline unsigned mbedtls_ssl_tls1_3_check_kex_modes( mbedtls_ssl_context *ssl, + int kex_mode_mask ) +{ + return( ( ssl->handshake->tls1_3_kex_modes & kex_mode_mask ) != 0 ); +} + +static inline int mbedtls_ssl_tls1_3_psk_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ) ); +} + +static inline int mbedtls_ssl_tls1_3_psk_ephemeral_enabled( + mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) ); +} + +static inline int mbedtls_ssl_tls1_3_ephemeral_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) ); +} + +static inline int mbedtls_ssl_tls1_3_some_ephemeral_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL ) ); +} + +static inline int mbedtls_ssl_tls1_3_some_psk_enabled( mbedtls_ssl_context *ssl ) +{ + return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ /** From e15e665cfb9de25232ef69cb6893fbd010c63d21 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 28 Sep 2021 21:06:07 +0800 Subject: [PATCH 689/966] fix comments and check return issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 9f9192fc07..8074a3aeeb 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -410,14 +410,14 @@ static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur, } while( 0 ) /** - * \brief This macro checks if the remaining size in a input buffer is - * greater or equal than a needed space. If it is not the case, - * it returns an SSL_DECODE_ERROR error and sends DECODE_ERROR - * alert message. + * \brief This macro checks if the remaining length in an input buffer is + * greater or equal than a needed length. If it is not the case, it + * returns an SSL_DECODE_ERROR error and pends DECODE_ERROR alert + * message. * * \param cur Pointer to the current position in the buffer. * \param end Pointer to one past the end of the buffer. - * \param need Needed space in bytes. + * \param need Needed length in bytes. * */ #define MBEDTLS_SSL_CHK_BUF_READ_PTR( cur, end, need ) \ @@ -1442,9 +1442,9 @@ static inline int mbedtls_ssl_conf_tls13_some_psk_enabled( mbedtls_ssl_context * } static inline unsigned mbedtls_ssl_tls1_3_check_kex_modes( mbedtls_ssl_context *ssl, - int kex_mode_mask ) + int kex_modes_mask ) { - return( ( ssl->handshake->tls1_3_kex_modes & kex_mode_mask ) != 0 ); + return( ( ssl->handshake->tls1_3_kex_modes & kex_modes_mask ) == 0 ); } static inline int mbedtls_ssl_tls1_3_psk_enabled( mbedtls_ssl_context *ssl ) From adf861aad4c12c7328282ac2a14da6e716b7b674 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 29 Sep 2021 21:22:08 +0800 Subject: [PATCH 690/966] Address kex_modes check function Signed-off-by: Jerry Yu --- library/ssl_misc.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 8074a3aeeb..d269e6f858 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1441,6 +1441,16 @@ static inline int mbedtls_ssl_conf_tls13_some_psk_enabled( mbedtls_ssl_context * MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); } +/** + * Given a list of key exchange modes, check if at least one of them is + * supported. + * + * \param[in] ssl SSL context + * \param key_modes_mask Mask of the key exchange modes to check + * + * \return 0 if at least one of the key exchange modes is supported, + * <>0 otherwise. + */ static inline unsigned mbedtls_ssl_tls1_3_check_kex_modes( mbedtls_ssl_context *ssl, int kex_modes_mask ) { @@ -1449,32 +1459,32 @@ static inline unsigned mbedtls_ssl_tls1_3_check_kex_modes( mbedtls_ssl_context * static inline int mbedtls_ssl_tls1_3_psk_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ) ); } static inline int mbedtls_ssl_tls1_3_psk_ephemeral_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) ); } static inline int mbedtls_ssl_tls1_3_ephemeral_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) ); } static inline int mbedtls_ssl_tls1_3_some_ephemeral_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL ) ); } static inline int mbedtls_ssl_tls1_3_some_psk_enabled( mbedtls_ssl_context *ssl ) { - return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, + return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl, MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); } From 0cabad375b67892005cc22947accb0ffbcbf3f7f Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 30 Sep 2021 09:52:35 +0800 Subject: [PATCH 691/966] fix doxygen parameter wrong Signed-off-by: Jerry Yu --- library/ssl_misc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index d269e6f858..85c7779705 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1446,7 +1446,7 @@ static inline int mbedtls_ssl_conf_tls13_some_psk_enabled( mbedtls_ssl_context * * supported. * * \param[in] ssl SSL context - * \param key_modes_mask Mask of the key exchange modes to check + * \param kex_modes_mask Mask of the key exchange modes to check * * \return 0 if at least one of the key exchange modes is supported, * <>0 otherwise. From dca3d5ddf9d5164308cf88415b72854ec6cd150d Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 8 Oct 2021 14:19:29 +0800 Subject: [PATCH 692/966] fix document issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 85c7779705..cdd5609675 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -412,8 +412,9 @@ static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur, /** * \brief This macro checks if the remaining length in an input buffer is * greater or equal than a needed length. If it is not the case, it - * returns an SSL_DECODE_ERROR error and pends DECODE_ERROR alert - * message. + * returns #MBEDTLS_SSL_DECODE_ERROR error and pends a + * #MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR alert message. + * It is used to guaranteed remaining length. * * \param cur Pointer to the current position in the buffer. * \param end Pointer to one past the end of the buffer. @@ -1449,7 +1450,7 @@ static inline int mbedtls_ssl_conf_tls13_some_psk_enabled( mbedtls_ssl_context * * \param kex_modes_mask Mask of the key exchange modes to check * * \return 0 if at least one of the key exchange modes is supported, - * <>0 otherwise. + * !=0 otherwise. */ static inline unsigned mbedtls_ssl_tls1_3_check_kex_modes( mbedtls_ssl_context *ssl, int kex_modes_mask ) From c1ddeef53aa547956f63a5da74f4e93f1865fa35 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 8 Oct 2021 15:14:45 +0800 Subject: [PATCH 693/966] fix various issues Signed-off-by: Jerry Yu --- library/ssl_misc.h | 4 +--- library/ssl_msg.c | 3 --- library/ssl_tls.c | 20 +++++++++++--------- library/ssl_tls13_keys.h | 8 ++------ 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 6f83fc3276..06351fc0c7 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1501,9 +1501,7 @@ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, size_t buf_len, size_t msg_len ); -/* - * Update checksum with handshake header - */ + void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, unsigned hs_type, size_t total_hs_len ); diff --git a/library/ssl_msg.c b/library/ssl_msg.c index e636762c53..13a9e0ff31 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -5558,9 +5558,6 @@ void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform ) void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, mbedtls_ssl_transform *transform ) { - if( ssl->transform_in == transform ) - return; - ssl->transform_in = transform; mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_COUNTER_LEN ); } diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 58b81ff26d..26cf6b3e09 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -7062,20 +7062,22 @@ int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl, size_t dst_len, size_t *olen ) { + switch( md ) + { + #if defined(MBEDTLS_SHA384_C) - if( md == MBEDTLS_MD_SHA384 ) - { + case MBEDTLS_MD_SHA384: return( ssl_get_handshake_transcript_sha384( ssl, dst, dst_len, olen ) ); - } - else -#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_SHA384_C */ + #if defined(MBEDTLS_SHA256_C) - if( md == MBEDTLS_MD_SHA256 ) - { + case MBEDTLS_MD_SHA256: return( ssl_get_handshake_transcript_sha256( ssl, dst, dst_len, olen ) ); - } - else #endif /* MBEDTLS_SHA256_C */ + + default: + break; + } return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } #endif /* !MBEDTLS_USE_PSA_CRYPTO */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 45b0fdfa4c..866aae9117 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -534,22 +534,18 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, /* * TLS 1.3 key schedule evolutions * - * Early Data -> Handshake -> Application + * Early -> Handshake -> Application * * Small wrappers around mbedtls_ssl_tls1_3_evolve_secret(). */ /** - * \brief Begin TLS 1.3 key schedule by calculating early secret - * from chosen PSK. + * \brief Begin TLS 1.3 key schedule by calculating early secret. * * The TLS 1.3 key schedule can be viewed as a simple state machine * with states Initial -> Early -> Handshake -> Application, and * this function represents the Initial -> Early transition. * - * In the early stage, mbedtls_ssl_tls1_3_generate_early_data_keys() - * can be used to derive the 0-RTT traffic keys. - * * \param ssl The SSL context to operate on. * * \returns \c 0 on success. From ae0b2e2a2f5de804bf450ec7da12761c2f53af91 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 8 Oct 2021 15:21:19 +0800 Subject: [PATCH 694/966] Rename counter_len Signed-off-by: Jerry Yu --- include/mbedtls/ssl.h | 4 ++-- library/ssl_misc.h | 20 ++++++++++---------- library/ssl_msg.c | 25 ++++++++++++++----------- library/ssl_tls.c | 6 +++--- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 2b75267e84..2c77dbed55 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -594,7 +594,7 @@ union mbedtls_ssl_premaster_secret #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret ) /* Length in number of bytes of the TLS sequence number */ -#define MBEDTLS_SSL_COUNTER_LEN 8 +#define MBEDTLS_SSL_SEQUENCE_NUMBER_LEN 8 #ifdef __cplusplus extern "C" { @@ -1555,7 +1555,7 @@ struct mbedtls_ssl_context size_t MBEDTLS_PRIVATE(out_buf_len); /*!< length of output buffer */ #endif - unsigned char MBEDTLS_PRIVATE(cur_out_ctr)[MBEDTLS_SSL_COUNTER_LEN]; /*!< Outgoing record sequence number. */ + unsigned char MBEDTLS_PRIVATE(cur_out_ctr)[MBEDTLS_SSL_SEQUENCE_NUMBER_LEN]; /*!< Outgoing record sequence number. */ #if defined(MBEDTLS_SSL_PROTO_DTLS) uint16_t MBEDTLS_PRIVATE(mtu); /*!< path mtu, used to fragment outgoing messages */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 06351fc0c7..d194b0e1eb 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -573,8 +573,8 @@ struct mbedtls_ssl_handshake_params flight being received */ mbedtls_ssl_transform *alt_transform_out; /*!< Alternative transform for resending messages */ - unsigned char alt_out_ctr[MBEDTLS_SSL_COUNTER_LEN]; /*!< Alternative record epoch/counter - for resending messages */ + unsigned char alt_out_ctr[MBEDTLS_SSL_SEQUENCE_NUMBER_LEN]; /*!< Alternative record epoch/counter + for resending messages */ #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) /* The state of CID configuration in this handshake. */ @@ -873,14 +873,14 @@ static inline int mbedtls_ssl_transform_uses_aead( typedef struct { - uint8_t ctr[MBEDTLS_SSL_COUNTER_LEN]; /* In TLS: The implicit record sequence number. - * In DTLS: The 2-byte epoch followed by - * the 6-byte sequence number. - * This is stored as a raw big endian byte array - * as opposed to a uint64_t because we rarely - * need to perform arithmetic on this, but do - * need it as a Byte array for the purpose of - * MAC computations. */ + uint8_t ctr[MBEDTLS_SSL_SEQUENCE_NUMBER_LEN]; /* In TLS: The implicit record sequence number. + * In DTLS: The 2-byte epoch followed by + * the 6-byte sequence number. + * This is stored as a raw big endian byte array + * as opposed to a uint64_t because we rarely + * need to perform arithmetic on this, but do + * need it as a Byte array for the purpose of + * MAC computations. */ uint8_t type; /* The record content type. */ uint8_t ver[2]; /* SSL/TLS version as present on the wire. * Convert to internal presentation of versions diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 13a9e0ff31..7fa0a56174 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2101,7 +2101,7 @@ void mbedtls_ssl_flight_free( mbedtls_ssl_flight_item *flight ) static int ssl_swap_epochs( mbedtls_ssl_context *ssl ) { mbedtls_ssl_transform *tmp_transform; - unsigned char tmp_out_ctr[MBEDTLS_SSL_COUNTER_LEN]; + unsigned char tmp_out_ctr[MBEDTLS_SSL_SEQUENCE_NUMBER_LEN]; if( ssl->transform_out == ssl->handshake->alt_transform_out ) { @@ -2564,7 +2564,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, ssl->conf->transport, ssl->out_hdr + 1 ); - memcpy( ssl->out_ctr, ssl->cur_out_ctr, MBEDTLS_SSL_COUNTER_LEN ); + memcpy( ssl->out_ctr, ssl->cur_out_ctr, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); MBEDTLS_PUT_UINT16_BE( len, ssl->out_len, 0); if( ssl->transform_out != NULL ) @@ -3651,9 +3651,12 @@ static int ssl_prepare_record_content( mbedtls_ssl_context *ssl, #endif { unsigned i; - for( i = MBEDTLS_SSL_COUNTER_LEN; i > mbedtls_ssl_ep_len( ssl ); i-- ) + for( i = MBEDTLS_SSL_SEQUENCE_NUMBER_LEN; + i > mbedtls_ssl_ep_len( ssl ); i-- ) + { if( ++ssl->in_ctr[i - 1] != 0 ) break; + } /* The loop goes to its end iff the counter is wrapping */ if( i == mbedtls_ssl_ep_len( ssl ) ) @@ -4793,7 +4796,7 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_COUNTER_LEN ); + mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); mbedtls_ssl_update_in_pointers( ssl ); @@ -4829,12 +4832,12 @@ void mbedtls_ssl_update_out_pointers( mbedtls_ssl_context *ssl, { ssl->out_ctr = ssl->out_hdr + 3; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) - ssl->out_cid = ssl->out_ctr + MBEDTLS_SSL_COUNTER_LEN; + ssl->out_cid = ssl->out_ctr + MBEDTLS_SSL_SEQUENCE_NUMBER_LEN; ssl->out_len = ssl->out_cid; if( transform != NULL ) ssl->out_len += transform->out_cid_len; #else /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ - ssl->out_len = ssl->out_ctr + MBEDTLS_SSL_COUNTER_LEN; + ssl->out_len = ssl->out_ctr + MBEDTLS_SSL_SEQUENCE_NUMBER_LEN; #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ ssl->out_iv = ssl->out_len + 2; } @@ -4883,17 +4886,17 @@ void mbedtls_ssl_update_in_pointers( mbedtls_ssl_context *ssl ) * ssl_parse_record_header(). */ ssl->in_ctr = ssl->in_hdr + 3; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) - ssl->in_cid = ssl->in_ctr + MBEDTLS_SSL_COUNTER_LEN; + ssl->in_cid = ssl->in_ctr + MBEDTLS_SSL_SEQUENCE_NUMBER_LEN; ssl->in_len = ssl->in_cid; /* Default: no CID */ #else /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ - ssl->in_len = ssl->in_ctr + MBEDTLS_SSL_COUNTER_LEN; + ssl->in_len = ssl->in_ctr + MBEDTLS_SSL_SEQUENCE_NUMBER_LEN; #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ ssl->in_iv = ssl->in_len + 2; } else #endif { - ssl->in_ctr = ssl->in_hdr - MBEDTLS_SSL_COUNTER_LEN; + ssl->in_ctr = ssl->in_hdr - MBEDTLS_SSL_SEQUENCE_NUMBER_LEN; ssl->in_len = ssl->in_hdr + 3; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) ssl->in_cid = ssl->in_len; @@ -5068,7 +5071,7 @@ static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl ) in_ctr_cmp = memcmp( ssl->in_ctr + ep_len, &ssl->conf->renego_period[ep_len], - MBEDTLS_SSL_COUNTER_LEN - ep_len ); + MBEDTLS_SSL_SEQUENCE_NUMBER_LEN - ep_len ); out_ctr_cmp = memcmp( &ssl->cur_out_ctr[ep_len], &ssl->conf->renego_period[ep_len], sizeof( ssl->cur_out_ctr ) - ep_len ); @@ -5559,7 +5562,7 @@ void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, mbedtls_ssl_transform *transform ) { ssl->transform_in = transform; - mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_COUNTER_LEN ); + mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); } void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 26cf6b3e09..8c1fdd816e 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5778,11 +5778,11 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl, } #endif /* MBEDTLS_SSL_PROTO_DTLS */ - used += MBEDTLS_SSL_COUNTER_LEN; + used += MBEDTLS_SSL_SEQUENCE_NUMBER_LEN; if( used <= buf_len ) { - memcpy( p, ssl->cur_out_ctr, MBEDTLS_SSL_COUNTER_LEN ); - p += MBEDTLS_SSL_COUNTER_LEN; + memcpy( p, ssl->cur_out_ctr, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); + p += MBEDTLS_SSL_SEQUENCE_NUMBER_LEN; } #if defined(MBEDTLS_SSL_PROTO_DTLS) From 205fd82f7ec395ba7da1a24f0573f18840fab431 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 8 Oct 2021 16:16:24 +0800 Subject: [PATCH 695/966] fix check_name fail Signed-off-by: Jerry Yu --- library/ssl_misc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index cdd5609675..4205a477c1 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -412,7 +412,7 @@ static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur, /** * \brief This macro checks if the remaining length in an input buffer is * greater or equal than a needed length. If it is not the case, it - * returns #MBEDTLS_SSL_DECODE_ERROR error and pends a + * returns #MBEDTLS_ERR_SSL_DECODE_ERROR error and pends a * #MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR alert message. * It is used to guaranteed remaining length. * From d1ab2628444324a5784b813b1c9c2b53d296595b Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 8 Oct 2021 15:36:57 +0800 Subject: [PATCH 696/966] define max md size for tls1_3 Signed-off-by: Jerry Yu --- include/mbedtls/md.h | 4 ++++ library/ssl_misc.h | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/md.h b/include/mbedtls/md.h index fa2b152f96..34f314f3f4 100644 --- a/include/mbedtls/md.h +++ b/include/mbedtls/md.h @@ -74,6 +74,10 @@ typedef enum { #define MBEDTLS_MD_MAX_BLOCK_SIZE 64 #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +#define MBEDTLS_TLS1_3_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /** * Opaque struct. * diff --git a/library/ssl_misc.h b/library/ssl_misc.h index d194b0e1eb..b8361dbb65 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -678,9 +678,9 @@ struct mbedtls_ssl_handshake_params union { - unsigned char early [MBEDTLS_MD_MAX_SIZE]; - unsigned char handshake[MBEDTLS_MD_MAX_SIZE]; - unsigned char app [MBEDTLS_MD_MAX_SIZE]; + unsigned char early [MBEDTLS_TLS1_3_MD_MAX_SIZE]; + unsigned char handshake[MBEDTLS_TLS1_3_MD_MAX_SIZE]; + unsigned char app [MBEDTLS_TLS1_3_MD_MAX_SIZE]; } tls1_3_master_secrets; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From f4d2fd4a057762358485f879900777e04d41f6a4 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 8 Oct 2021 11:45:47 +0200 Subject: [PATCH 697/966] Fix cmake invocation syntax Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 646055d63b..85f6848c39 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1926,7 +1926,7 @@ component_build_no_std_function () { scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT - CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . make } @@ -2095,7 +2095,7 @@ component_test_when_no_ciphersuites_have_mac () { component_test_no_date_time () { msg "build: default config without MBEDTLS_HAVE_TIME_DATE" scripts/config.py unset MBEDTLS_HAVE_TIME_DATE - CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . make msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites" From d9d630cdf301f88b49458f163b7f0b01bcdbc9fb Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Fri, 8 Oct 2021 12:26:21 +0200 Subject: [PATCH 698/966] Addapt psa_generate_key() tests Signed-off-by: Przemyslaw Stekiel --- tests/scripts/generate_psa_tests.py | 17 +++++++++++------ tests/suites/test_suite_psa_crypto.data | 2 +- ...st_suite_psa_crypto_not_supported.function | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index c788ce6d6d..1cdd28f89a 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -133,7 +133,7 @@ class Information: return constructors -def test_case_for_key_type_not_supported( +def test_case_for_key_type_not_supported_invalid_arg( verb: str, key_type: str, bits: int, dependencies: List[str], *args: str, @@ -148,10 +148,15 @@ def test_case_for_key_type_not_supported( adverb = 'not' if dependencies else 'never' if param_descr: adverb = param_descr + ' ' + adverb - tc.set_description('PSA {} {} {}-bit {} supported' - .format(verb, short_key_type, bits, adverb)) + if (verb == "generate") and ("PUBLIC" in short_key_type): + tc.set_description('PSA {} {} {}-bit invalid argument' + .format(verb, short_key_type, bits)) + tc.set_function(verb + '_invalid_arg') + else: + tc.set_description('PSA {} {} {}-bit {} supported' + .format(verb, short_key_type, bits, adverb)) + tc.set_function(verb + '_not_supported') tc.set_dependencies(dependencies) - tc.set_function(verb + '_not_supported') tc.set_arguments([key_type] + list(args)) return tc @@ -192,7 +197,7 @@ class NotSupported: else: generate_dependencies = import_dependencies for bits in kt.sizes_to_test(): - yield test_case_for_key_type_not_supported( + yield test_case_for_key_type_not_supported_invalid_arg( 'import', kt.expression, bits, finish_family_dependencies(import_dependencies, bits), test_case.hex_string(kt.key_material(bits)), @@ -203,7 +208,7 @@ class NotSupported: # supported or not depending on implementation capabilities, # only generate the test case once. continue - yield test_case_for_key_type_not_supported( + yield test_case_for_key_type_not_supported_invalid_arg( 'generate', kt.expression, bits, finish_family_dependencies(generate_dependencies, bits), str(bits), diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 063629e599..350537b051 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -4705,7 +4705,7 @@ generate_random:2 * MBEDTLS_CTR_DRBG_MAX_REQUEST + 1 PSA generate key: bad type (RSA public key) depends_on:PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY -generate_key:PSA_KEY_TYPE_RSA_PUBLIC_KEY:512:PSA_KEY_USAGE_EXPORT:0:PSA_ERROR_NOT_SUPPORTED:0 +generate_key:PSA_KEY_TYPE_RSA_PUBLIC_KEY:512:PSA_KEY_USAGE_EXPORT:0:PSA_ERROR_INVALID_ARGUMENT:0 PSA generate key: raw data, 0 bits: invalid argument # The spec allows either INVALID_ARGUMENT or NOT_SUPPORTED diff --git a/tests/suites/test_suite_psa_crypto_not_supported.function b/tests/suites/test_suite_psa_crypto_not_supported.function index e3253d8405..6b85fd75a7 100644 --- a/tests/suites/test_suite_psa_crypto_not_supported.function +++ b/tests/suites/test_suite_psa_crypto_not_supported.function @@ -50,3 +50,22 @@ exit: PSA_DONE( ); } /* END_CASE */ + +/* BEGIN_CASE */ +void generate_invalid_arg( int key_type, int bits ) +{ + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + mbedtls_svc_key_id_t key_id = INVALID_KEY_ID; + + PSA_ASSERT( psa_crypto_init( ) ); + psa_set_key_type( &attributes, key_type ); + psa_set_key_bits( &attributes, bits ); + TEST_EQUAL( psa_generate_key( &attributes, &key_id ), + PSA_ERROR_INVALID_ARGUMENT ); + TEST_ASSERT( mbedtls_svc_key_id_equal( key_id, MBEDTLS_SVC_KEY_ID_INIT ) ); + +exit: + psa_destroy_key( key_id ); + PSA_DONE( ); +} +/* END_CASE */ From 88b756bacb410918b91897bdcd96973be54e6198 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 8 Oct 2021 18:41:38 +0800 Subject: [PATCH 699/966] move tls1_3 max md size It should be internal definition Signed-off-by: Jerry Yu --- include/mbedtls/md.h | 4 ---- library/ssl_misc.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mbedtls/md.h b/include/mbedtls/md.h index 34f314f3f4..fa2b152f96 100644 --- a/include/mbedtls/md.h +++ b/include/mbedtls/md.h @@ -74,10 +74,6 @@ typedef enum { #define MBEDTLS_MD_MAX_BLOCK_SIZE 64 #endif -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -#define MBEDTLS_TLS1_3_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ - /** * Opaque struct. * diff --git a/library/ssl_misc.h b/library/ssl_misc.h index b8361dbb65..76962d3fa6 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -307,6 +307,10 @@ + ( MBEDTLS_SSL_CID_OUT_LEN_MAX ) ) #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +#define MBEDTLS_TLS1_3_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) /** * \brief Return the maximum fragment length (payload, in bytes) for From 25f70635330eb295577368a55cb17febf3e881d1 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Fri, 8 Oct 2021 14:45:04 +0200 Subject: [PATCH 700/966] enerate_psa_tests.py fix format Signed-off-by: Przemyslaw Stekiel --- tests/scripts/generate_psa_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 1cdd28f89a..45d940ea97 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -150,11 +150,11 @@ def test_case_for_key_type_not_supported_invalid_arg( adverb = param_descr + ' ' + adverb if (verb == "generate") and ("PUBLIC" in short_key_type): tc.set_description('PSA {} {} {}-bit invalid argument' - .format(verb, short_key_type, bits)) + .format(verb, short_key_type, bits)) tc.set_function(verb + '_invalid_arg') else: tc.set_description('PSA {} {} {}-bit {} supported' - .format(verb, short_key_type, bits, adverb)) + .format(verb, short_key_type, bits, adverb)) tc.set_function(verb + '_not_supported') tc.set_dependencies(dependencies) tc.set_arguments([key_type] + list(args)) From 09c46da27ed735a200251da5f66b9a9a82f31dda Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 8 Oct 2021 15:48:16 +0200 Subject: [PATCH 701/966] Implement PSA_WANT_KEY_TYPE_ARIA Follow what has been done for CAMELLIA. Signed-off-by: Gilles Peskine --- include/mbedtls/config_psa.h | 22 +++++++++++++++++++++- include/psa/crypto_config.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/mbedtls/config_psa.h b/include/mbedtls/config_psa.h index 9080cd19bc..87997c3891 100644 --- a/include/mbedtls/config_psa.h +++ b/include/mbedtls/config_psa.h @@ -267,6 +267,18 @@ extern "C" { #endif /* PSA_HAVE_SOFT_KEY_TYPE_AES || PSA_HAVE_SOFT_BLOCK_MODE */ #endif /* PSA_WANT_KEY_TYPE_AES */ +#if defined(PSA_WANT_KEY_TYPE_ARIA) +#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ARIA) +#define PSA_HAVE_SOFT_KEY_TYPE_ARIA 1 +#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_ARIA */ +#if defined(PSA_HAVE_SOFT_KEY_TYPE_ARIA) || \ + defined(PSA_HAVE_SOFT_BLOCK_MODE) || \ + defined(PSA_HAVE_SOFT_BLOCK_AEAD) +#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ARIA 1 +#define MBEDTLS_ARIA_C +#endif /* PSA_HAVE_SOFT_KEY_TYPE_ARIA || PSA_HAVE_SOFT_BLOCK_MODE */ +#endif /* PSA_WANT_KEY_TYPE_ARIA */ + #if defined(PSA_WANT_KEY_TYPE_CAMELLIA) #if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA) #define PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA 1 @@ -301,6 +313,7 @@ extern "C" { * PSA_HAVE_SOFT_BLOCK_CIPHER, which can be used in any of these * situations. */ #if defined(PSA_HAVE_SOFT_KEY_TYPE_AES) || \ + defined(PSA_HAVE_SOFT_KEY_TYPE_ARIA) || \ defined(PSA_HAVE_SOFT_KEY_TYPE_DES) || \ defined(PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA) #define PSA_HAVE_SOFT_BLOCK_CIPHER 1 @@ -381,6 +394,7 @@ extern "C" { #if defined(PSA_WANT_ALG_CCM) #if !defined(MBEDTLS_PSA_ACCEL_ALG_CCM) || \ defined(PSA_HAVE_SOFT_KEY_TYPE_AES) || \ + defined(PSA_HAVE_SOFT_KEY_TYPE_ARIA) || \ defined(PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA) #define MBEDTLS_PSA_BUILTIN_ALG_CCM 1 #define MBEDTLS_CCM_C @@ -390,6 +404,7 @@ extern "C" { #if defined(PSA_WANT_ALG_GCM) #if !defined(MBEDTLS_PSA_ACCEL_ALG_GCM) || \ defined(PSA_HAVE_SOFT_KEY_TYPE_AES) || \ + defined(PSA_HAVE_SOFT_KEY_TYPE_ARIA) || \ defined(PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA) #define MBEDTLS_PSA_BUILTIN_ALG_GCM 1 #define MBEDTLS_GCM_C @@ -629,6 +644,11 @@ extern "C" { #define MBEDTLS_PSA_BUILTIN_KEY_TYPE_AES 1 #endif +#if defined(MBEDTLS_ARIA_C) +#define PSA_WANT_KEY_TYPE_ARIA 1 +#define MBEDTLS_PSA_BUILTIN_KEY_TYPE_ARIA 1 +#endif + #if defined(MBEDTLS_CAMELLIA_C) #define PSA_WANT_KEY_TYPE_CAMELLIA 1 #define MBEDTLS_PSA_BUILTIN_KEY_TYPE_CAMELLIA 1 @@ -660,7 +680,7 @@ extern "C" { #endif #if defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) || \ - defined(MBEDTLS_CAMELLIA_C) + defined(MBEDTLS_ARIA_C) || defined(MBEDTLS_CAMELLIA_C) #define MBEDTLS_PSA_BUILTIN_ALG_ECB_NO_PADDING 1 #define PSA_WANT_ALG_ECB_NO_PADDING 1 #endif diff --git a/include/psa/crypto_config.h b/include/psa/crypto_config.h index 64d8c58169..6476e3cffb 100644 --- a/include/psa/crypto_config.h +++ b/include/psa/crypto_config.h @@ -111,6 +111,7 @@ #define PSA_WANT_KEY_TYPE_DERIVE 1 #define PSA_WANT_KEY_TYPE_HMAC 1 #define PSA_WANT_KEY_TYPE_AES 1 +#define PSA_WANT_KEY_TYPE_ARIA 1 #define PSA_WANT_KEY_TYPE_CAMELLIA 1 #define PSA_WANT_KEY_TYPE_CHACHA20 1 #define PSA_WANT_KEY_TYPE_DES 1 From fd320e9a6e521650aab86126da9627aec55e4db0 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 8 Oct 2021 21:52:41 +0800 Subject: [PATCH 702/966] Replace zeroize with memset Signed-off-by: Jerry Yu --- library/ssl_msg.c | 6 +++--- library/ssl_tls.c | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 7fa0a56174..fdb647a508 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -4796,7 +4796,7 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); + memset( ssl->in_ctr, 0, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); mbedtls_ssl_update_in_pointers( ssl ); @@ -5562,14 +5562,14 @@ void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, mbedtls_ssl_transform *transform ) { ssl->transform_in = transform; - mbedtls_platform_zeroize( ssl->in_ctr, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); + memset( ssl->in_ctr, 0, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); } void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, mbedtls_ssl_transform *transform ) { ssl->transform_out = transform; - mbedtls_platform_zeroize( ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); + memset( ssl->cur_out_ctr, 0, sizeof( ssl->cur_out_ctr ) ); } #if defined(MBEDTLS_SSL_PROTO_DTLS) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 8c1fdd816e..bf3ab09397 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -2824,8 +2824,7 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) sizeof( ssl->handshake->alt_out_ctr ) ); /* Set sequence_number to zero */ - mbedtls_platform_zeroize( &ssl->cur_out_ctr[2], - sizeof( ssl->cur_out_ctr ) - 2 ); + memset( &ssl->cur_out_ctr[2], 0, sizeof( ssl->cur_out_ctr ) - 2 ); /* Increment epoch */ @@ -2842,7 +2841,7 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - mbedtls_platform_zeroize( ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); + memset( ssl->cur_out_ctr, 0, sizeof( ssl->cur_out_ctr ) ); ssl->transform_out = ssl->transform_negotiate; ssl->session_out = ssl->session_negotiate; @@ -3327,7 +3326,7 @@ static void ssl_session_reset_msg_layer( mbedtls_ssl_context *ssl, ssl->out_msglen = 0; ssl->out_left = 0; memset( ssl->out_buf, 0, out_buf_len ); - mbedtls_platform_zeroize( ssl->cur_out_ctr, sizeof( ssl->cur_out_ctr ) ); + memset( ssl->cur_out_ctr, 0, sizeof( ssl->cur_out_ctr ) ); ssl->transform_out = NULL; #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) From f6892dec2a24781dfc6e3bc5fcd637993797d1d2 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 8 Oct 2021 16:28:32 +0200 Subject: [PATCH 703/966] Readability improvements Signed-off-by: Gilles Peskine --- include/psa/crypto_values.h | 4 ++-- library/psa_crypto_rsa.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index aa7d02ef39..86a03d125f 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -1425,8 +1425,8 @@ * a supported algorithm identifier or policy. */ #define PSA_ALG_IS_RSA_PSS(alg) \ - ((((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_BASE) || \ - (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_ANY_SALT_BASE)) + (PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) || \ + PSA_ALG_IS_RSA_PSS_ANY_SALT(alg)) #define PSA_ALG_ECDSA_BASE ((psa_algorithm_t)0x06000600) /** ECDSA signature with hashing. diff --git a/library/psa_crypto_rsa.c b/library/psa_crypto_rsa.c index 7ee15ea077..8318ef47b3 100644 --- a/library/psa_crypto_rsa.c +++ b/library/psa_crypto_rsa.c @@ -462,7 +462,7 @@ static int rsa_pss_expected_salt_len( psa_algorithm_t alg, return( MBEDTLS_RSA_SALT_LEN_ANY ); /* Otherwise: standard salt length, i.e. largest possible salt length * up to the hash length. */ - int klen = (int) (int) mbedtls_rsa_get_len( rsa ); // known to fit + int klen = (int) mbedtls_rsa_get_len( rsa ); // known to fit int hlen = (int) hash_length; // known to fit int room = klen - 2 - hlen; if( room < 0 ) From e4eefc716a16fd7a879189b5322b9275b5b80b9e Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sat, 9 Oct 2021 10:40:40 +0800 Subject: [PATCH 704/966] Improve document for chk_buf_read_ptr Signed-off-by: Jerry Yu --- library/ssl_misc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 4205a477c1..6b33cb5dbc 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -414,7 +414,9 @@ static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur, * greater or equal than a needed length. If it is not the case, it * returns #MBEDTLS_ERR_SSL_DECODE_ERROR error and pends a * #MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR alert message. - * It is used to guaranteed remaining length. + * + * This is a function-like macro. It is guaranteed to evaluate each + * argument exactly once. * * \param cur Pointer to the current position in the buffer. * \param end Pointer to one past the end of the buffer. From b576c7b779edb2c9f2e45206f13a0ca8b1c93cbf Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Mon, 11 Oct 2021 10:15:25 +0200 Subject: [PATCH 705/966] Address review comments Signed-off-by: Przemyslaw Stekiel --- ChangeLog.d/fix-psa_gen_key-status.txt | 2 +- tests/scripts/generate_psa_tests.py | 66 +++++++++++++------ ...st_suite_psa_crypto_not_supported.function | 2 +- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/ChangeLog.d/fix-psa_gen_key-status.txt b/ChangeLog.d/fix-psa_gen_key-status.txt index c46bd6f01f..78609882f9 100644 --- a/ChangeLog.d/fix-psa_gen_key-status.txt +++ b/ChangeLog.d/fix-psa_gen_key-status.txt @@ -1,2 +1,2 @@ Bugfix - * Fix status ret by psa_generate_key() for public key. Fixes #4551. + * Fix the error returned by psa_generate_key() for a public key. Fixes #4551. diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 45d940ea97..4c8143ff09 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -133,7 +133,7 @@ class Information: return constructors -def test_case_for_key_type_not_supported_invalid_arg( +def test_case_for_key_type_not_supported( verb: str, key_type: str, bits: int, dependencies: List[str], *args: str, @@ -148,20 +148,37 @@ def test_case_for_key_type_not_supported_invalid_arg( adverb = 'not' if dependencies else 'never' if param_descr: adverb = param_descr + ' ' + adverb - if (verb == "generate") and ("PUBLIC" in short_key_type): - tc.set_description('PSA {} {} {}-bit invalid argument' - .format(verb, short_key_type, bits)) - tc.set_function(verb + '_invalid_arg') - else: - tc.set_description('PSA {} {} {}-bit {} supported' - .format(verb, short_key_type, bits, adverb)) - tc.set_function(verb + '_not_supported') + tc.set_description('PSA {} {} {}-bit {} supported' + .format(verb, short_key_type, bits, adverb)) + tc.set_dependencies(dependencies) + tc.set_function(verb + '_not_supported') + tc.set_arguments([key_type] + list(args)) + return tc + +def test_case_for_key_type_invalid_argument( + verb: str, key_type: str, bits: int, + dependencies: List[str], + *args: str, + param_descr: str = '' +) -> test_case.TestCase: + """Return one test case exercising a key creation method + for an invalid argument when key is public. + """ + hack_dependencies_not_implemented(dependencies) + tc = test_case.TestCase() + short_key_type = re.sub(r'PSA_(KEY_TYPE|ECC_FAMILY)_', r'', key_type) + adverb = 'not' if dependencies else 'never' + if param_descr: + adverb = param_descr + ' ' + adverb + tc.set_description('PSA {} {} {}-bit invalid argument' + .format(verb, short_key_type, bits)) + tc.set_function(verb + '_invalid_argument') tc.set_dependencies(dependencies) tc.set_arguments([key_type] + list(args)) return tc class NotSupported: - """Generate test cases for when something is not supported.""" + """Generate test cases for when something is not supported or argument is inavlid.""" def __init__(self, info: Information) -> None: self.constructors = info.constructors @@ -176,11 +193,13 @@ class NotSupported: param: Optional[int] = None, param_descr: str = '', ) -> Iterator[test_case.TestCase]: - """Return test cases exercising key creation when the given type is unsupported. + """Return test cases exercising key creation when the given type is unsupported + or argument is invalid. If param is present and not None, emit test cases conditioned on this parameter not being supported. If it is absent or None, emit test cases - conditioned on the base type not being supported. + conditioned on the base type not being supported. If key is public emit test + case for invalid argument. """ if kt.name in self.ALWAYS_SUPPORTED: # Don't generate test cases for key types that are always supported. @@ -197,7 +216,7 @@ class NotSupported: else: generate_dependencies = import_dependencies for bits in kt.sizes_to_test(): - yield test_case_for_key_type_not_supported_invalid_arg( + yield test_case_for_key_type_not_supported( 'import', kt.expression, bits, finish_family_dependencies(import_dependencies, bits), test_case.hex_string(kt.key_material(bits)), @@ -208,12 +227,20 @@ class NotSupported: # supported or not depending on implementation capabilities, # only generate the test case once. continue - yield test_case_for_key_type_not_supported_invalid_arg( - 'generate', kt.expression, bits, - finish_family_dependencies(generate_dependencies, bits), - str(bits), - param_descr=param_descr, - ) + if kt.name.endswith('_PUBLIC_KEY'): + yield test_case_for_key_type_invalid_argument( + 'generate', kt.expression, bits, + finish_family_dependencies(generate_dependencies, bits), + str(bits), + param_descr=param_descr, + ) + else: + yield test_case_for_key_type_not_supported( + 'generate', kt.expression, bits, + finish_family_dependencies(generate_dependencies, bits), + str(bits), + param_descr=param_descr, + ) # To be added: derive ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR', @@ -234,7 +261,6 @@ class NotSupported: yield from self.test_cases_for_key_type_not_supported( kt, 0, param_descr='curve') - class StorageKey(psa_storage.Key): """Representation of a key for storage format testing.""" diff --git a/tests/suites/test_suite_psa_crypto_not_supported.function b/tests/suites/test_suite_psa_crypto_not_supported.function index 6b85fd75a7..0665230d72 100644 --- a/tests/suites/test_suite_psa_crypto_not_supported.function +++ b/tests/suites/test_suite_psa_crypto_not_supported.function @@ -52,7 +52,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void generate_invalid_arg( int key_type, int bits ) +void generate_invalid_argument( int key_type, int bits ) { psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; mbedtls_svc_key_id_t key_id = INVALID_KEY_ID; From 77804132ba8b43360fc01012cd70bf68e34972ba Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Mon, 11 Oct 2021 16:38:17 +0200 Subject: [PATCH 706/966] Use PSA_HASH_LENGTH instead hardcoded integer values --- tests/suites/test_suite_psa_crypto.data | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 063629e599..6090cdf006 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -4422,19 +4422,19 @@ derive_output:PSA_ALG_TLS12_PSK_TO_MS(PSA_ALG_SHA_384):PSA_KEY_DERIVATION_INPUT_ PSA key derivation: HKDF SHA-256, request maximum capacity 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_KEY_DERIVATION_INPUT_SECRET:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":PSA_KEY_DERIVATION_INPUT_INFO:"f0f1f2f3f4f5f6f7f8f9":255 * 32:"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865":"" +derive_output:PSA_ALG_HKDF(PSA_ALG_SHA_256):PSA_KEY_DERIVATION_INPUT_SALT:"000102030405060708090a0b0c":PSA_KEY_DERIVATION_INPUT_SECRET:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":PSA_KEY_DERIVATION_INPUT_INFO:"f0f1f2f3f4f5f6f7f8f9":255 * PSA_HASH_LENGTH(PSA_ALG_SHA_256):"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865":"" PSA key derivation: HKDF SHA-1, request maximum capacity depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_1 -derive_output:PSA_ALG_HKDF(PSA_ALG_SHA_1):PSA_KEY_DERIVATION_INPUT_SALT:"":PSA_KEY_DERIVATION_INPUT_SECRET:"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c":PSA_KEY_DERIVATION_INPUT_INFO:"":255 * 20:"2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48":"" +derive_output:PSA_ALG_HKDF(PSA_ALG_SHA_1):PSA_KEY_DERIVATION_INPUT_SALT:"":PSA_KEY_DERIVATION_INPUT_SECRET:"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c":PSA_KEY_DERIVATION_INPUT_INFO:"":255 * PSA_HASH_LENGTH(PSA_ALG_SHA_1):"2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48":"" PSA key derivation: HKDF SHA-256, request too much capacity depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_256 -derive_set_capacity:PSA_ALG_HKDF(PSA_ALG_SHA_256):255 * 32 + 1:PSA_ERROR_INVALID_ARGUMENT +derive_set_capacity:PSA_ALG_HKDF(PSA_ALG_SHA_256):255 * PSA_HASH_LENGTH(PSA_ALG_SHA_256) + 1:PSA_ERROR_INVALID_ARGUMENT PSA key derivation: HKDF SHA-1, request too much capacity depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_1 -derive_set_capacity:PSA_ALG_HKDF(PSA_ALG_SHA_1):255 * 20 + 1:PSA_ERROR_INVALID_ARGUMENT +derive_set_capacity:PSA_ALG_HKDF(PSA_ALG_SHA_1):255 * PSA_HASH_LENGTH(PSA_ALG_SHA_1) + 1:PSA_ERROR_INVALID_ARGUMENT PSA key derivation: over capacity 42: output 42+1 depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_256 @@ -4454,19 +4454,19 @@ derive_output:PSA_ALG_HKDF(PSA_ALG_SHA_256):PSA_KEY_DERIVATION_INPUT_SALT:"00010 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 * 32 - 1 +derive_full:PSA_ALG_HKDF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":255 * PSA_HASH_LENGTH(PSA_ALG_SHA_256) - 1 PSA key derivation: HKDF SHA-256, read maximum capacity depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_256 -derive_full:PSA_ALG_HKDF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":255 * 32 +derive_full:PSA_ALG_HKDF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":255 * PSA_HASH_LENGTH(PSA_ALG_SHA_256) PSA key derivation: TLS 1.2 PRF SHA-256, read maximum capacity minus 1 depends_on:PSA_WANT_ALG_SHA_256:PSA_WANT_ALG_TLS12_PRF -derive_full:PSA_ALG_TLS12_PRF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":255 * 32 - 1 +derive_full:PSA_ALG_TLS12_PRF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":255 * PSA_HASH_LENGTH(PSA_ALG_SHA_256) - 1 PSA key derivation: TLS 1.2 PRF SHA-256, read maximum capacity depends_on:PSA_WANT_ALG_SHA_256:PSA_WANT_ALG_TLS12_PRF -derive_full:PSA_ALG_TLS12_PRF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":255 * 32 +derive_full:PSA_ALG_TLS12_PRF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":255 * PSA_HASH_LENGTH(PSA_ALG_SHA_256) PSA key derivation: HKDF SHA-256, exercise AES128-CTR depends_on:PSA_WANT_ALG_CTR:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_256:PSA_WANT_KEY_TYPE_AES From 78521966b0fce063229398e1b589efe9e969f173 Mon Sep 17 00:00:00 2001 From: openluopworld Date: Tue, 12 Oct 2021 18:15:06 +0800 Subject: [PATCH 707/966] changelog for #4950 Signed-off-by: openluopworld --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index ebf8a36add..a9fecb8e15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ mbed TLS ChangeLog (Sorted per branch, date) += mbed TLS x.x.x branch released xxxx-xx-xx + +Bugfix + * Fix a bug in mbedtls_gcm_starts() when bits of iv are longer than 2^32. + * Fix #4950. + = Mbed TLS 3.0.0 branch released 2021-07-07 API changes From 506752299b4f1961efe81558a2a5309f2a97c08c Mon Sep 17 00:00:00 2001 From: openluopworld Date: Tue, 12 Oct 2021 18:38:50 +0800 Subject: [PATCH 708/966] add changelog file for #4950 Signed-off-by: openluopworld --- ChangeLog | 6 ------ ChangeLog.d/bugfix-for-gcm-long-iv-size.txt | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 ChangeLog.d/bugfix-for-gcm-long-iv-size.txt diff --git a/ChangeLog b/ChangeLog index a9fecb8e15..ebf8a36add 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,5 @@ mbed TLS ChangeLog (Sorted per branch, date) -= mbed TLS x.x.x branch released xxxx-xx-xx - -Bugfix - * Fix a bug in mbedtls_gcm_starts() when bits of iv are longer than 2^32. - * Fix #4950. - = Mbed TLS 3.0.0 branch released 2021-07-07 API changes diff --git a/ChangeLog.d/bugfix-for-gcm-long-iv-size.txt b/ChangeLog.d/bugfix-for-gcm-long-iv-size.txt new file mode 100644 index 0000000000..0e2e5117ec --- /dev/null +++ b/ChangeLog.d/bugfix-for-gcm-long-iv-size.txt @@ -0,0 +1,4 @@ +Bugfix + * Fix a bug in mbedtls_gcm_starts() when bits of iv are longer than 2^32. + * Fix #4950. + From 151ccb297766b6263cdce69f8ca0b785b5323499 Mon Sep 17 00:00:00 2001 From: openluopworld Date: Wed, 13 Oct 2021 00:23:30 +0800 Subject: [PATCH 709/966] update changelog for #4884 Signed-off-by: openluopworld --- ChangeLog.d/bugfix-for-gcm-long-iv-size.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.d/bugfix-for-gcm-long-iv-size.txt b/ChangeLog.d/bugfix-for-gcm-long-iv-size.txt index 0e2e5117ec..c04c4aa182 100644 --- a/ChangeLog.d/bugfix-for-gcm-long-iv-size.txt +++ b/ChangeLog.d/bugfix-for-gcm-long-iv-size.txt @@ -1,4 +1,4 @@ Bugfix * Fix a bug in mbedtls_gcm_starts() when bits of iv are longer than 2^32. - * Fix #4950. + * Fix #4884. From d60950c2d0cfc421ddfca68ad801bbf44c2ef0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 13 Oct 2021 13:12:47 +0200 Subject: [PATCH 710/966] Use newer OpenSSL for tests failing with the old MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- tests/ssl-opt.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 66c648573b..0422c1b1b8 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -2694,10 +2694,13 @@ run_test "Session resume using tickets, DTLS: openssl server" \ -c "parse new session ticket" \ -c "a session has been resumed" +# For reasons that aren't fully understood, this test randomly fails with high +# probabiliby with OpenSSL 1.0.2g on the CI, see #5012. +requires_openssl_next run_test "Session resume using tickets, DTLS: openssl client" \ "$P_SRV dtls=1 debug_level=3 tickets=1" \ - "( $O_CLI -dtls -sess_out $SESSION; \ - $O_CLI -dtls -sess_in $SESSION; \ + "( $O_NEXT_CLI -dtls -sess_out $SESSION; \ + $O_NEXT_CLI -dtls -sess_in $SESSION; \ rm -f $SESSION )" \ 0 \ -s "found session ticket extension" \ @@ -2894,10 +2897,13 @@ run_test "Session resume using cache, DTLS: session copy" \ -s "a session has been resumed" \ -c "a session has been resumed" +# For reasons that aren't fully understood, this test randomly fails with high +# probabiliby with OpenSSL 1.0.2g on the CI, see #5012. +requires_openssl_next run_test "Session resume using cache, DTLS: openssl client" \ "$P_SRV dtls=1 debug_level=3 tickets=0" \ - "( $O_CLI -dtls -sess_out $SESSION; \ - $O_CLI -dtls -sess_in $SESSION; \ + "( $O_NEXT_CLI -dtls -sess_out $SESSION; \ + $O_NEXT_CLI -dtls -sess_in $SESSION; \ rm -f $SESSION )" \ 0 \ -s "found session ticket extension" \ From 1ecfdea002aee1ba9e4ef805a8ddd194e92fe58f Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 13 Oct 2021 11:09:44 +0200 Subject: [PATCH 711/966] all.sh: add full - MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305 Signed-off-by: Przemyslaw Stekiel --- tests/scripts/all.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 1bcc2e4a58..ed5faf5db9 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1596,6 +1596,19 @@ component_test_psa_crypto_config_no_driver() { make test } +component_test_psa_crypto_config_chachapoly_disabled() { + # full - MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305 + msg "build: full - MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305" + scripts/config.py full + scripts/config.py unset MBEDTLS_CHACHAPOLY_C + scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_GCM + scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_CHACHA20_POLY1305 + make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" + + msg "test: full - MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305" + make test +} + # This should be renamed to test and updated once the accelerator ECDSA code is in place and ready to test. component_build_psa_accel_alg_ecdsa() { # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_ECDSA From 4cad4fc8a94e1a42bae3f705a0d59f1022c1ea41 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 13 Oct 2021 11:12:08 +0200 Subject: [PATCH 712/966] psa_crypto.c: use switch instead if-else in psa_aead_check_nonce_length and psa_aead_set_lengths (fixes #5065) Signed-off-by: Przemyslaw Stekiel --- library/psa_crypto.c | 97 ++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ece64b100d..2299da3a59 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3621,34 +3621,35 @@ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, { psa_algorithm_t base_alg = psa_aead_get_base_algorithm( alg ); -#if defined(PSA_WANT_ALG_GCM) - if( base_alg == PSA_ALG_GCM ) + switch(base_alg) { - /* Not checking max nonce size here as GCM spec allows almost - * arbitrarily large nonces. Please note that we do not generally - * recommend the usage of nonces of greater length than - * PSA_AEAD_NONCE_MAX_SIZE, as large nonces are hashed to a shorter - * size, which can then lead to collisions if you encrypt a very - * large number of messages.*/ - if( nonce_length != 0 ) - return( PSA_SUCCESS ); - } +#if defined(PSA_WANT_ALG_GCM) + case PSA_ALG_GCM: + /* Not checking max nonce size here as GCM spec allows almost + * arbitrarily large nonces. Please note that we do not generally + * recommend the usage of nonces of greater length than + * PSA_AEAD_NONCE_MAX_SIZE, as large nonces are hashed to a shorter + * size, which can then lead to collisions if you encrypt a very + * large number of messages.*/ + if( nonce_length != 0 ) + return( PSA_SUCCESS ); + break; #endif /* PSA_WANT_ALG_GCM */ #if defined(PSA_WANT_ALG_CCM) - if( base_alg == PSA_ALG_CCM ) - { - if( nonce_length >= 7 && nonce_length <= 13 ) - return( PSA_SUCCESS ); - } - else + case PSA_ALG_CCM: + if( nonce_length >= 7 && nonce_length <= 13 ) + return( PSA_SUCCESS ); + break; #endif /* PSA_WANT_ALG_CCM */ #if defined(PSA_WANT_ALG_CHACHA20_POLY1305) - if( base_alg == PSA_ALG_CHACHA20_POLY1305 ) - { - if( nonce_length == 12 ) - return( PSA_SUCCESS ); - } + case PSA_ALG_CHACHA20_POLY1305: + if( nonce_length == 12 ) + return( PSA_SUCCESS ); + break; #endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */ + default: + break; + } return( PSA_ERROR_NOT_SUPPORTED ); } @@ -3950,40 +3951,40 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, goto exit; } -#if defined(PSA_WANT_ALG_GCM) - if( operation->alg == PSA_ALG_GCM ) + switch(operation->alg) { - /* Lengths can only be too large for GCM if size_t is bigger than 32 - * bits. Without the guard this code will generate warnings on 32bit - * builds. */ +#if defined(PSA_WANT_ALG_GCM) + case PSA_ALG_GCM: + /* Lengths can only be too large for GCM if size_t is bigger than 32 + * bits. Without the guard this code will generate warnings on 32bit + * builds. */ #if SIZE_MAX > UINT32_MAX - if( (( uint64_t ) ad_length ) >> 61 != 0 || - (( uint64_t ) plaintext_length ) > 0xFFFFFFFE0ull ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } + if( (( uint64_t ) ad_length ) >> 61 != 0 || + (( uint64_t ) plaintext_length ) > 0xFFFFFFFE0ull ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } #endif - } - else + break; #endif /* PSA_WANT_ALG_GCM */ #if defined(PSA_WANT_ALG_CCM) - if( operation->alg == PSA_ALG_CCM ) - { - if( ad_length > 0xFF00 ) - { - status = PSA_ERROR_INVALID_ARGUMENT; - goto exit; - } - } - else + case PSA_ALG_CCM: + if( ad_length > 0xFF00 ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + break; #endif /* PSA_WANT_ALG_CCM */ #if defined(PSA_WANT_ALG_CHACHA20_POLY1305) - if( operation->alg == PSA_ALG_CHACHA20_POLY1305 ) - { - /* No length restrictions for ChaChaPoly. */ - } + case PSA_ALG_CHACHA20_POLY1305: + /* No length restrictions for ChaChaPoly. */ + break; #endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */ + default: + break; + } status = psa_driver_wrapper_aead_set_lengths( operation, ad_length, plaintext_length ); From 09cfa18976fa0b14d2dd78f377bf173b4eb60403 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 13 Oct 2021 16:13:44 +0100 Subject: [PATCH 713/966] Spelling fix Signed-off-by: Paul Elliott --- tests/ssl-opt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 0422c1b1b8..fb4403c3ef 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -2695,7 +2695,7 @@ run_test "Session resume using tickets, DTLS: openssl server" \ -c "a session has been resumed" # For reasons that aren't fully understood, this test randomly fails with high -# probabiliby with OpenSSL 1.0.2g on the CI, see #5012. +# probability with OpenSSL 1.0.2g on the CI, see #5012. requires_openssl_next run_test "Session resume using tickets, DTLS: openssl client" \ "$P_SRV dtls=1 debug_level=3 tickets=1" \ @@ -2898,7 +2898,7 @@ run_test "Session resume using cache, DTLS: session copy" \ -c "a session has been resumed" # For reasons that aren't fully understood, this test randomly fails with high -# probabiliby with OpenSSL 1.0.2g on the CI, see #5012. +# probability with OpenSSL 1.0.2g on the CI, see #5012. requires_openssl_next run_test "Session resume using cache, DTLS: openssl client" \ "$P_SRV dtls=1 debug_level=3 tickets=0" \ From 1428f252ad9b506d1fe9bfa9e6834a2f857a1e20 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 12 Oct 2021 16:02:55 +0100 Subject: [PATCH 714/966] Fix incorrect check for DTLS Missing wildcards meant that some servers were not identified as DTLS, which lead to port checking on TCP rather than UDP, and thus mistakenly cancelling tests as the server had not come up. Signed-off-by: Paul Elliott --- tests/ssl-opt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index fb4403c3ef..e9d67182ae 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -753,7 +753,7 @@ wait_client_done() { # check if the given command uses dtls and sets global variable DTLS detect_dtls() { case "$1" in - *dtls=1*|-dtls|-u) DTLS=1;; + *dtls=1*|*-dtls*|*-u*) DTLS=1;; *) DTLS=0;; esac } From 0421715ade83391430ae6071f8734aa0154f4a77 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 12 Oct 2021 16:10:37 +0100 Subject: [PATCH 715/966] Use 127.0.0.1 rather than localhost This was causing some tests using the openssl s_client to not connect - I suspect this was due to localhost (at least on my machine) resolving to ::1 rather than 127.0.0.1. Note that the error seen would have been that the session file specified with -sess_out did not get created. Signed-off-by: Paul Elliott --- tests/ssl-opt.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index e9d67182ae..b5ddc37c9a 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1309,22 +1309,24 @@ SRV_DELAY_SECONDS=0 # fix commands to use this port, force IPv4 while at it # +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later +# Note: Using 'localhost' rather than 127.0.0.1 here is unwise, as on many +# machines that will resolve to ::1, and we don't want ipv6 here. P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT" P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT" P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}" O_SRV="$O_SRV -accept $SRV_PORT" -O_CLI="$O_CLI -connect localhost:+SRV_PORT" +O_CLI="$O_CLI -connect 127.0.0.1:+SRV_PORT" G_SRV="$G_SRV -p $SRV_PORT" G_CLI="$G_CLI -p +SRV_PORT" if [ -n "${OPENSSL_LEGACY:-}" ]; then O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem" - O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT" + O_LEGACY_CLI="$O_LEGACY_CLI -connect 127.0.0.1:+SRV_PORT" fi if [ -n "${OPENSSL_NEXT:-}" ]; then O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT" - O_NEXT_CLI="$O_NEXT_CLI -connect localhost:+SRV_PORT" + O_NEXT_CLI="$O_NEXT_CLI -connect 127.0.0.1:+SRV_PORT" fi if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then From ed61c5e8b000898f99a8f02995ac4bef605700a2 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 13 Oct 2021 15:24:25 +0200 Subject: [PATCH 716/966] Add change-log file (issue #5065) Signed-off-by: Przemyslaw Stekiel --- ChangeLog.d/issue5065.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 ChangeLog.d/issue5065.txt diff --git a/ChangeLog.d/issue5065.txt b/ChangeLog.d/issue5065.txt new file mode 100644 index 0000000000..f468c63ff2 --- /dev/null +++ b/ChangeLog.d/issue5065.txt @@ -0,0 +1,4 @@ +Bugfix + * Use switch statement instead if-else in + psa_aead_check_nonce_length() + and psa_aead_set_lengths(). Fixes #5065. From 316c4fa3ce1e3bb7d615d268e26ea4ccc44b6d96 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Fri, 15 Oct 2021 08:04:53 +0200 Subject: [PATCH 717/966] Address review comments Signed-off-by: Przemyslaw Stekiel --- ChangeLog.d/issue5065.txt | 5 ++--- tests/scripts/all.sh | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ChangeLog.d/issue5065.txt b/ChangeLog.d/issue5065.txt index f468c63ff2..943ee47d91 100644 --- a/ChangeLog.d/issue5065.txt +++ b/ChangeLog.d/issue5065.txt @@ -1,4 +1,3 @@ Bugfix - * Use switch statement instead if-else in - psa_aead_check_nonce_length() - and psa_aead_set_lengths(). Fixes #5065. + * Fix compile-time or run-time errors in PSA + AEAD functions when ChachaPoly is disabled. Fixes #5065. diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index ed5faf5db9..28387f443f 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1597,15 +1597,15 @@ component_test_psa_crypto_config_no_driver() { } component_test_psa_crypto_config_chachapoly_disabled() { - # full - MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305 - msg "build: full - MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305" + # full minus MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305 + msg "build: full minus MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305" scripts/config.py full scripts/config.py unset MBEDTLS_CHACHAPOLY_C scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_GCM scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_CHACHA20_POLY1305 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" - msg "test: full - MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305" + msg "test: full minus MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305" make test } From c8aaac89d05bf225531793d52d944ab4284da3bb Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Mon, 18 Oct 2021 12:56:53 +0100 Subject: [PATCH 718/966] Fix naming examples in TLS 1.3 style guide Signed-off-by: Dave Rodgman --- docs/architecture/tls13-experimental.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/architecture/tls13-experimental.md b/docs/architecture/tls13-experimental.md index 5d7c14f1bb..88d0b73ddc 100644 --- a/docs/architecture/tls13-experimental.md +++ b/docs/architecture/tls13-experimental.md @@ -255,7 +255,7 @@ TLS 1.3 specific coding rules: Example 1: #define CLIENT_HELLO_RANDOM_LEN 32, macro for the length of the `random` field of the ClientHello message. - Example 2 (consistent abbreviation): `mbedtls_ssl_tls1_3_write_sig_alg_ext()` + Example 2 (consistent abbreviation): `mbedtls_ssl_tls13_write_sig_alg_ext()` and `MBEDTLS_TLS_EXT_SIG_ALG`, `sig_alg` standing for `signature_algorithms`. @@ -279,7 +279,7 @@ TLS 1.3 specific coding rules: of another one which could potentially lead to some nasty issues. Example: `cipher_suites` vector of ClientHello in - `ssl_tls1_3_write_client_hello_cipher_suites()` + `ssl_tls13_write_client_hello_cipher_suites()` ``` size_t cipher_suites_len; unsigned char *p_cipher_suites_len; From 236bf98cfdcabc31ba7e76d40a0dd28ce43b384f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 19 Oct 2021 16:25:10 +0200 Subject: [PATCH 719/966] Move some code of run_test into auxiliary functions No behavior change. Signed-off-by: Gilles Peskine --- tests/ssl-opt.sh | 237 +++++++++++++++++++++++++++-------------------- 1 file changed, 134 insertions(+), 103 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index e90a35226b..1d73d3af05 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -795,68 +795,12 @@ skip_handshake_stage_check() { SKIP_HANDSHAKE_CHECK="YES" } -# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]] -# Options: -s pattern pattern that must be present in server output -# -c pattern pattern that must be present in client output -# -u pattern lines after pattern must be unique in client output -# -f call shell function on client output -# -S pattern pattern that must be absent in server output -# -C pattern pattern that must be absent in client output -# -U pattern lines after pattern must be unique in server output -# -F call shell function on server output -# -g call shell function on server and client output -run_test() { - NAME="$1" - shift 1 - - if is_excluded "$NAME"; then - SKIP_NEXT="NO" - # There was no request to run the test, so don't record its outcome. - return - fi - - print_name "$NAME" - - # Do we only run numbered tests? - if [ -n "$RUN_TEST_NUMBER" ]; then - case ",$RUN_TEST_NUMBER," in - *",$TESTS,"*) :;; - *) SKIP_NEXT="YES";; - esac - fi - - # does this test use a proxy? - if [ "X$1" = "X-p" ]; then - PXY_CMD="$2" - shift 2 - else - PXY_CMD="" - fi - - # get commands and client output - SRV_CMD="$1" - CLI_CMD="$2" - CLI_EXPECT="$3" - shift 3 - - # Check if test uses files - case "$SRV_CMD $CLI_CMD" in - *data_files/*) - requires_config_enabled MBEDTLS_FS_IO;; - esac - - # If the client or serve requires a ciphersuite, check that it's enabled. - maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@" - maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@" - - # should we skip? - if [ "X$SKIP_NEXT" = "XYES" ]; then - SKIP_NEXT="NO" - record_outcome "SKIP" - SKIPS=$(( $SKIPS + 1 )) - return - fi - +# Analyze the commands that will be used in a test. +# +# Analyze and possibly instrument $PXY_CMD, $CLI_CMD, $SRV_CMD to pass +# extra arguments or go through wrappers. +# Set $DTLS (0=TLS, 1=DTLS). +analyze_test_commands() { # update DTLS variable detect_dtls "$SRV_CMD" @@ -910,48 +854,21 @@ run_test() { CLI_CMD="valgrind --leak-check=full $CLI_CMD" fi fi +} - TIMES_LEFT=2 - while [ $TIMES_LEFT -gt 0 ]; do - TIMES_LEFT=$(( $TIMES_LEFT - 1 )) - - # run the commands - if [ -n "$PXY_CMD" ]; then - printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT - $PXY_CMD >> $PXY_OUT 2>&1 & - PXY_PID=$! - wait_proxy_start "$PXY_PORT" "$PXY_PID" - fi - - check_osrv_dtls - printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT - provide_input | $SRV_CMD >> $SRV_OUT 2>&1 & - SRV_PID=$! - wait_server_start "$SRV_PORT" "$SRV_PID" - - printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT - eval "$CLI_CMD" >> $CLI_OUT 2>&1 & - wait_client_done - - sleep 0.05 - - # terminate the server (and the proxy) - kill $SRV_PID - wait $SRV_PID - SRV_RET=$? - - if [ -n "$PXY_CMD" ]; then - kill $PXY_PID >/dev/null 2>&1 - wait $PXY_PID - fi - - # retry only on timeouts - if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then - printf "RETRY " - else - TIMES_LEFT=0 - fi - done +# Check for failure conditions after a test case. +# +# Inputs from run_test: +# * positional parameters: test options (see run_test documentation) +# * $CLI_EXIT: client return code +# * $CLI_EXPECT: expected client return code +# * $SRV_RET: server return code +# * $CLI_OUT, $SRV_OUT, $PXY_OUT: files containing client/server/proxy logs +# +# Outputs: +# * $pass: set to 1 if no failures are detected, 0 otherwise +check_test_failure() { + pass=0 # check if the client and server went at least to the handshake stage # (useful to avoid tests with only negative assertions and non-zero @@ -1085,6 +1002,120 @@ run_test() { fi # if we're here, everything is ok + pass=1 +} + +# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]] +# Options: -s pattern pattern that must be present in server output +# -c pattern pattern that must be present in client output +# -u pattern lines after pattern must be unique in client output +# -f call shell function on client output +# -S pattern pattern that must be absent in server output +# -C pattern pattern that must be absent in client output +# -U pattern lines after pattern must be unique in server output +# -F call shell function on server output +# -g call shell function on server and client output +run_test() { + NAME="$1" + shift 1 + + if is_excluded "$NAME"; then + SKIP_NEXT="NO" + # There was no request to run the test, so don't record its outcome. + return + fi + + print_name "$NAME" + + # Do we only run numbered tests? + if [ -n "$RUN_TEST_NUMBER" ]; then + case ",$RUN_TEST_NUMBER," in + *",$TESTS,"*) :;; + *) SKIP_NEXT="YES";; + esac + fi + + # does this test use a proxy? + if [ "X$1" = "X-p" ]; then + PXY_CMD="$2" + shift 2 + else + PXY_CMD="" + fi + + # get commands and client output + SRV_CMD="$1" + CLI_CMD="$2" + CLI_EXPECT="$3" + shift 3 + + # Check if test uses files + case "$SRV_CMD $CLI_CMD" in + *data_files/*) + requires_config_enabled MBEDTLS_FS_IO;; + esac + + # If the client or serve requires a ciphersuite, check that it's enabled. + maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@" + maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@" + + # should we skip? + if [ "X$SKIP_NEXT" = "XYES" ]; then + SKIP_NEXT="NO" + record_outcome "SKIP" + SKIPS=$(( $SKIPS + 1 )) + return + fi + + analyze_test_commands "$@" + + TIMES_LEFT=2 + while [ $TIMES_LEFT -gt 0 ]; do + TIMES_LEFT=$(( $TIMES_LEFT - 1 )) + + # run the commands + if [ -n "$PXY_CMD" ]; then + printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT + $PXY_CMD >> $PXY_OUT 2>&1 & + PXY_PID=$! + wait_proxy_start "$PXY_PORT" "$PXY_PID" + fi + + check_osrv_dtls + printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT + provide_input | $SRV_CMD >> $SRV_OUT 2>&1 & + SRV_PID=$! + wait_server_start "$SRV_PORT" "$SRV_PID" + + printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT + eval "$CLI_CMD" >> $CLI_OUT 2>&1 & + wait_client_done + + sleep 0.05 + + # terminate the server (and the proxy) + kill $SRV_PID + wait $SRV_PID + SRV_RET=$? + + if [ -n "$PXY_CMD" ]; then + kill $PXY_PID >/dev/null 2>&1 + wait $PXY_PID + fi + + # retry only on timeouts + if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then + printf "RETRY " + else + TIMES_LEFT=0 + fi + done + + check_test_failure "$@" + if [ "$pass" -eq 0 ]; then + return + fi + record_outcome "PASS" if [ "$PRESERVE_LOGS" -gt 0 ]; then mv $SRV_OUT o-srv-${TESTS}.log From 196d73bc1b9dd4a97c3a271af07ac9cf6a3fb4fb Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 19 Oct 2021 16:35:35 +0200 Subject: [PATCH 720/966] Move the core loop of run_test into an auxiliary function No behavior change. Signed-off-by: Gilles Peskine --- tests/ssl-opt.sh | 73 +++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 1d73d3af05..8f403113cc 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1005,6 +1005,49 @@ check_test_failure() { pass=1 } +# Run the current test case: start the server and if applicable the proxy, run +# the client, wait for all processes to finish or time out. +# +# Inputs: +# * $NAME: test case name +# * $CLI_CMD, $SRV_CMD, $PXY_CMD: commands to run +# * $CLI_OUT, $SRV_OUT, $PXY_OUT: files to contain client/server/proxy logs +# +# Outputs: +# * $CLI_EXIT: client return code +# * $SRV_RET: server return code +do_run_test_once() { + # run the commands + if [ -n "$PXY_CMD" ]; then + printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT + $PXY_CMD >> $PXY_OUT 2>&1 & + PXY_PID=$! + wait_proxy_start "$PXY_PORT" "$PXY_PID" + fi + + check_osrv_dtls + printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT + provide_input | $SRV_CMD >> $SRV_OUT 2>&1 & + SRV_PID=$! + wait_server_start "$SRV_PORT" "$SRV_PID" + + printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT + eval "$CLI_CMD" >> $CLI_OUT 2>&1 & + wait_client_done + + sleep 0.05 + + # terminate the server (and the proxy) + kill $SRV_PID + wait $SRV_PID + SRV_RET=$? + + if [ -n "$PXY_CMD" ]; then + kill $PXY_PID >/dev/null 2>&1 + wait $PXY_PID + fi +} + # Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]] # Options: -s pattern pattern that must be present in server output # -c pattern pattern that must be present in client output @@ -1073,35 +1116,7 @@ run_test() { while [ $TIMES_LEFT -gt 0 ]; do TIMES_LEFT=$(( $TIMES_LEFT - 1 )) - # run the commands - if [ -n "$PXY_CMD" ]; then - printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT - $PXY_CMD >> $PXY_OUT 2>&1 & - PXY_PID=$! - wait_proxy_start "$PXY_PORT" "$PXY_PID" - fi - - check_osrv_dtls - printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT - provide_input | $SRV_CMD >> $SRV_OUT 2>&1 & - SRV_PID=$! - wait_server_start "$SRV_PORT" "$SRV_PID" - - printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT - eval "$CLI_CMD" >> $CLI_OUT 2>&1 & - wait_client_done - - sleep 0.05 - - # terminate the server (and the proxy) - kill $SRV_PID - wait $SRV_PID - SRV_RET=$? - - if [ -n "$PXY_CMD" ]; then - kill $PXY_PID >/dev/null 2>&1 - wait $PXY_PID - fi + do_run_test_once # retry only on timeouts if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then From 0e3534c67b396539a3bf498a92b9f0241d0a37f7 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 19 Oct 2021 17:23:25 +0200 Subject: [PATCH 721/966] Move retry logic into check_test_failure This will allow having other retry conditions, in particular based on run_test options. Signed-off-by: Gilles Peskine --- tests/ssl-opt.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 8f403113cc..b41a91f6ff 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -864,11 +864,19 @@ analyze_test_commands() { # * $CLI_EXPECT: expected client return code # * $SRV_RET: server return code # * $CLI_OUT, $SRV_OUT, $PXY_OUT: files containing client/server/proxy logs +# * $TIMES_LEFT: if nonzero, a RETRY outcome is allowed # # Outputs: -# * $pass: set to 1 if no failures are detected, 0 otherwise +# * $outcome: one of PASS/RETRY/FAIL check_test_failure() { - pass=0 + outcome=FAIL + + if [ $TIMES_LEFT -gt 0 ] && + grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null + then + outcome=RETRY + return + fi # check if the client and server went at least to the handshake stage # (useful to avoid tests with only negative assertions and non-zero @@ -1002,7 +1010,7 @@ check_test_failure() { fi # if we're here, everything is ok - pass=1 + outcome=PASS } # Run the current test case: start the server and if applicable the proxy, run @@ -1118,19 +1126,15 @@ run_test() { do_run_test_once - # retry only on timeouts - if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then - printf "RETRY " - else - TIMES_LEFT=0 - fi + check_test_failure "$@" + case $outcome in + PASS) break;; + RETRY) printf "RETRY ";; + FAIL) return;; + esac done - check_test_failure "$@" - if [ "$pass" -eq 0 ]; then - return - fi - + # If we get this far, the test case passed. record_outcome "PASS" if [ "$PRESERVE_LOGS" -gt 0 ]; then mv $SRV_OUT o-srv-${TESTS}.log From f11d30ecda8c6ea046972edfdd001eacf102e213 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 19 Oct 2021 18:00:10 +0200 Subject: [PATCH 722/966] Retry if a test case fails because of an unexpected resend Palliative for https://github.com/ARMmbed/mbedtls/issues/3377. If a test case fails due to an unexpected resend, allow retrying, like in the case of a client timeout. Signed-off-by: Gilles Peskine --- tests/ssl-opt.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index b41a91f6ff..23169e466d 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -867,14 +867,14 @@ analyze_test_commands() { # * $TIMES_LEFT: if nonzero, a RETRY outcome is allowed # # Outputs: -# * $outcome: one of PASS/RETRY/FAIL +# * $outcome: one of PASS/RETRY*/FAIL check_test_failure() { outcome=FAIL if [ $TIMES_LEFT -gt 0 ] && grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null then - outcome=RETRY + outcome="RETRY(client-timeout)" return fi @@ -939,14 +939,22 @@ check_test_failure() { "-S") if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then - fail "pattern '$2' MUST NOT be present in the Server output" + if [ "$2" = "resend" ] && [ $TIMES_LEFT -gt 0 ]; then + outcome="RETRY(resend)" + else + fail "pattern '$2' MUST NOT be present in the Server output" + fi return fi ;; "-C") if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then - fail "pattern '$2' MUST NOT be present in the Client output" + if [ "$2" = "resend" ] && [ $TIMES_LEFT -gt 0 ]; then + outcome="RETRY(resend)" + else + fail "pattern '$2' MUST NOT be present in the Client output" + fi return fi ;; @@ -1129,7 +1137,7 @@ run_test() { check_test_failure "$@" case $outcome in PASS) break;; - RETRY) printf "RETRY ";; + RETRY*) printf "$outcome ";; FAIL) return;; esac done From 58ed8a7594ce279a13f85762d7449d369fb1f530 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 19 Oct 2021 17:56:39 +0100 Subject: [PATCH 723/966] Remove use of -p with lsof On machines with more modern kernels (>5.4 from testing so far) the useage of -b seems to conflict with the usage of -p. Whilst the usage of -b seems like a good idea to avoid blocks as we are tight looping on it, the usage of -p seems to require the usage of stat() (specifically in /proc) which -b forbids. All you get is a load of warnings (suppressable by -w) but never a positive result, which means that all servers are reported as "Failed to start". We are not keen on losing -b, so instead parse the output of lsof (using -F to format it) to check the if PIDs that it outputs match that we are looking for. Signed-off-by: Paul Elliott --- tests/ssl-opt.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index e90a35226b..d5b9150ca0 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -633,7 +633,21 @@ if type lsof >/dev/null 2>/dev/null; then proto=TCP fi # Make a tight loop, server normally takes less than 1s to start. - while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do + while true; do + SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p | cut -c2-) + SERVER_FOUND=false + # When proxies are used, more than one PID can be listening on + # the same port. Each PID will be on its own line. + while read -r PID; do + if [[ $PID == $2 ]]; then + SERVER_FOUND=true + break + fi + done <<< "$SERVER_PIDS" + + if ($SERVER_FOUND == true); then + break + fi if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then echo "$3 START TIMEOUT" echo "$3 START TIMEOUT" >> $4 From e7fc7ef38b9be6b4565f0d8af3d69850d18c23f6 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 19 Oct 2021 21:33:32 +0200 Subject: [PATCH 724/966] Always set a build type for cmake when building for testing Set the build type to Release (-O2) when running CPU-intensive tests (ssl-opt, or unit tests with debug features). A build type of Check (-Os) would be best when the main objective of the build is to check for build errors or warnings and there aren't many tests to run; in this commit there are no such test cases to change. Only use cmake with no build type (which results in not passing a -O option, and thus missing some GCC warnings) when exercising cmake features. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 85f6848c39..5fe8db61cf 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1960,7 +1960,7 @@ component_test_memory_buffer_allocator_backtrace () { scripts/config.py set MBEDTLS_PLATFORM_MEMORY scripts/config.py set MBEDTLS_MEMORY_BACKTRACE scripts/config.py set MBEDTLS_MEMORY_DEBUG - CC=gcc cmake . + CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . make msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" @@ -1971,7 +1971,7 @@ component_test_memory_buffer_allocator () { msg "build: default config with memory buffer allocator" scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C scripts/config.py set MBEDTLS_PLATFORM_MEMORY - CC=gcc cmake . + CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . make msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" @@ -2068,7 +2068,7 @@ component_test_ssl_alloc_buffer_and_mfl () { scripts/config.py set MBEDTLS_MEMORY_DEBUG scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH - CC=gcc cmake . + CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . make msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" From 89615eefe738be97d9d61fe824f9a3f766df0670 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 29 Apr 2021 20:28:54 +0200 Subject: [PATCH 725/966] Show values when TEST_EQUAL fails When TEST_EQUAL fails, show the two numerical values in the test log (only with host_test). The values are printed in hexa and signed decimal. The arguments of TEST_EQUAL must now be integers, not pointers or floats. The current implementation requires them to fit in unsigned long long Signed values no larger than long long will work too. The implementation uses unsigned long long rather than uintmax_t to reduce portability concerns. The snprintf function must support "%llx" and "%lld". For this purpose, add room for two lines of text to the mbedtls_test_info structure. This adds 154 bytes of global data. Signed-off-by: Gilles Peskine --- tests/include/test/helpers.h | 23 +++++++++++++++++++++++ tests/include/test/macros.h | 20 +++++++++++++------- tests/src/helpers.c | 25 +++++++++++++++++++++++++ tests/src/psa_exercise_key.c | 8 ++++---- tests/suites/host_test.function | 6 ++++++ 5 files changed, 71 insertions(+), 11 deletions(-) diff --git a/tests/include/test/helpers.h b/tests/include/test/helpers.h index 27e5599ed1..ef32cdf83b 100644 --- a/tests/include/test/helpers.h +++ b/tests/include/test/helpers.h @@ -73,6 +73,8 @@ typedef struct const char *filename; int line_no; unsigned long step; + char line1[76]; + char line2[76]; #if defined(MBEDTLS_TEST_MUTEX_USAGE) const char *mutex_usage_error; #endif @@ -131,6 +133,27 @@ void mbedtls_test_set_step( unsigned long step ); */ void mbedtls_test_info_reset( void ); +/** + * \brief Record the current test case as a failure if two integers + * have a different value. + * + * This function is usually called via the macro + * #TEST_EQUAL. + * + * \param test Description of the failure or assertion that failed. This + * MUST be a string literal. This normally has the form + * "EXPR1 == EXPR2" where EXPR1 has the value \p value1 + * and EXPR2 has the value \p value2. + * \param line_no Line number where the failure originated. + * \param filename Filename where the failure originated. + * \param value1 The first value to compare. + * \param value2 The second value to compare. + * + * \return \c 1 if the values are equal, otherwise \c 0. + */ +int mbedtls_test_equal( const char *test, int line_no, const char* filename, + unsigned long long value1, unsigned long long value2 ); + /** * \brief This function decodes the hexadecimal representation of * data. diff --git a/tests/include/test/macros.h b/tests/include/test/macros.h index 9b3fc9c809..a88b2e8115 100644 --- a/tests/include/test/macros.h +++ b/tests/include/test/macros.h @@ -73,15 +73,21 @@ } \ } while( 0 ) -/** Evaluate two expressions and fail the test case if they have different - * values. +/** Evaluate two integer expressions and fail the test case if they have + * different values. * - * \param expr1 An expression to evaluate. - * \param expr2 The expected value of \p expr1. This can be any - * expression, but it is typically a constant. + * The two expressions should have the same signedness, otherwise the + * comparison is not meaningful if the signed value is negative. + * + * \param expr1 An integral-typed expression to evaluate. + * \param expr2 Another integral-typed expression to evaluate. */ -#define TEST_EQUAL( expr1, expr2 ) \ - TEST_ASSERT( ( expr1 ) == ( expr2 ) ) +#define TEST_EQUAL( expr1, expr2 ) \ + do { \ + if( ! mbedtls_test_equal( #expr1 " == " #expr2, __LINE__, __FILE__, \ + expr1, expr2 ) ) \ + goto exit; \ + } while( 0 ) /** Allocate memory dynamically and fail the test case if this fails. * The allocated memory will be filled with zeros. diff --git a/tests/src/helpers.c b/tests/src/helpers.c index 4d3d53da50..ec4d84eac1 100644 --- a/tests/src/helpers.c +++ b/tests/src/helpers.c @@ -95,6 +95,31 @@ void mbedtls_test_info_reset( void ) mbedtls_test_info.test = 0; mbedtls_test_info.line_no = 0; mbedtls_test_info.filename = 0; + memset( mbedtls_test_info.line1, 0, sizeof( mbedtls_test_info.line1 ) ); + memset( mbedtls_test_info.line2, 0, sizeof( mbedtls_test_info.line2 ) ); +} + +int mbedtls_test_equal( const char *test, int line_no, const char* filename, + unsigned long long value1, unsigned long long value2 ) +{ + if( value1 == value2 ) + return( 1 ); + if( mbedtls_test_info.result == MBEDTLS_TEST_RESULT_FAILED ) + { + /* We've already recorded the test as having failed. Don't + * overwrite any previous information about the failure. */ + return( 0 ); + } + mbedtls_test_fail( test, line_no, filename ); + (void) mbedtls_snprintf( mbedtls_test_info.line1, + sizeof( mbedtls_test_info.line1 ), + "lhs = 0x%016llx = %lld", + value1, (long long) value1 ); + (void) mbedtls_snprintf( mbedtls_test_info.line2, + sizeof( mbedtls_test_info.line2 ), + "rhs = 0x%016llx = %lld", + value2, (long long) value2 ); + return( 0 ); } int mbedtls_test_unhexify( unsigned char *obuf, diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index e4e55c9c2c..923d2c136a 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -663,7 +663,7 @@ int mbedtls_test_psa_exported_key_sanity_check( TEST_EQUAL( mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED ), 0 ); - TEST_EQUAL( p + len, end ); + TEST_EQUAL( len, end - p ); if( ! mbedtls_test_asn1_skip_integer( &p, end, 0, 0, 0 ) ) goto exit; if( ! mbedtls_test_asn1_skip_integer( &p, end, bits, bits, 1 ) ) @@ -684,7 +684,7 @@ int mbedtls_test_psa_exported_key_sanity_check( goto exit; if( ! mbedtls_test_asn1_skip_integer( &p, end, 1, bits / 2 + 1, 0 ) ) goto exit; - TEST_EQUAL( p, end ); + TEST_EQUAL( p - end, 0 ); TEST_ASSERT( exported_length <= PSA_EXPORT_KEY_PAIR_MAX_SIZE ); } @@ -716,12 +716,12 @@ int mbedtls_test_psa_exported_key_sanity_check( MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED ), 0 ); - TEST_EQUAL( p + len, end ); + TEST_EQUAL( len, end - p ); if( ! mbedtls_test_asn1_skip_integer( &p, end, bits, bits, 1 ) ) goto exit; if( ! mbedtls_test_asn1_skip_integer( &p, end, 2, bits, 1 ) ) goto exit; - TEST_EQUAL( p, end ); + TEST_EQUAL( p - end, 0 ); TEST_ASSERT( exported_length <= diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function index a5fd7179b6..17926ebb3c 100644 --- a/tests/suites/host_test.function +++ b/tests/suites/host_test.function @@ -778,6 +778,12 @@ int execute_tests( int argc , const char ** argv ) mbedtls_fprintf( stdout, "line %d, %s", mbedtls_test_info.line_no, mbedtls_test_info.filename ); + if( mbedtls_test_info.line1[0] != 0 ) + mbedtls_fprintf( stdout, "\n %s", + mbedtls_test_info.line1 ); + if( mbedtls_test_info.line2[0] != 0 ) + mbedtls_fprintf( stdout, "\n %s", + mbedtls_test_info.line2 ); } fflush( stdout ); } From 1b0978b8032c9b9fe814104e93548835d3e4b0ff Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Fri, 15 Oct 2021 15:21:51 +0200 Subject: [PATCH 726/966] Add test class for key generation Genertae test_suite_psa_crypto_generate_key.generated.data. Use test_suite_psa_crypto_generate_key.function as a test function. Signed-off-by: Przemyslaw Stekiel --- scripts/mbedtls_dev/test_case.py | 12 ++- tests/scripts/generate_psa_tests.py | 79 +++++++++++++++++++ ...est_suite_psa_crypto_generate_key.function | 54 +++++++++++++ 3 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 tests/suites/test_suite_psa_crypto_generate_key.function diff --git a/scripts/mbedtls_dev/test_case.py b/scripts/mbedtls_dev/test_case.py index d01e1432b6..11117fcdd7 100644 --- a/scripts/mbedtls_dev/test_case.py +++ b/scripts/mbedtls_dev/test_case.py @@ -42,6 +42,7 @@ class TestCase: self.dependencies = [] #type: List[str] self.function = None #type: Optional[str] self.arguments = [] #type: List[str] + self.result = '' #type: str def add_comment(self, *lines: str) -> None: self.comments += lines @@ -58,6 +59,9 @@ class TestCase: def set_arguments(self, arguments: List[str]) -> None: self.arguments = arguments + def set_result(self, result: str) -> None: + self.result = result + def check_completeness(self) -> None: if self.description is None: raise MissingDescription @@ -81,9 +85,11 @@ class TestCase: out.write(self.description + '\n') if self.dependencies: out.write('depends_on:' + ':'.join(self.dependencies) + '\n') - out.write(self.function + ':' + ':'.join(self.arguments) + '\n') - - + out.write(self.function + ':' + ':'.join(self.arguments)) + if self.result: + out.write(':' + self.result + '\n') + else: + out.write('\n') def write_data_file(filename: str, test_cases: Iterable[TestCase], diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 4c8143ff09..b4a13bac3d 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -261,6 +261,83 @@ class NotSupported: yield from self.test_cases_for_key_type_not_supported( kt, 0, param_descr='curve') +def test_case_for_key_generation( + key_type: str, bits: int, + dependencies: List[str], + *args: str, + result: str = '', + param_descr: str = '', +) -> test_case.TestCase: + """Return one test case exercising a key generation. + """ + hack_dependencies_not_implemented(dependencies) + tc = test_case.TestCase() + short_key_type = re.sub(r'PSA_(KEY_TYPE|ECC_FAMILY)_', r'', key_type) + tc.set_description('PSA {} {}-bit' + .format( short_key_type, bits)) + tc.set_dependencies(dependencies) + tc.set_function('generate_key') + tc.set_arguments([key_type] + list(args)) + tc.set_result(result) + + return tc + +class KeyGenerate: + """Generate positive and negative (invalid argument) test cases for key generation.""" + + def __init__(self, info: Information) -> None: + self.constructors = info.constructors + + def test_cases_for_key_type_key_generation( + self, + kt: crypto_knowledge.KeyType, + param: Optional[int] = None, + param_descr: str = '', + ) -> Iterator[test_case.TestCase]: + """Return test cases exercising key generation. + + All key types can be generated except for public keys. For public key + PSA_ERROR_INVALID_ARGUMENT status is expected. + """ + result = 'PSA_SUCCESS' + + import_dependencies = [psa_want_symbol(kt.name)] + if kt.params is not None: + import_dependencies += [psa_want_symbol(sym) + for i, sym in enumerate(kt.params)] + if kt.name.endswith('_PUBLIC_KEY'): + generate_dependencies = [] + result = 'PSA_ERROR_INVALID_ARGUMENT' + else: + generate_dependencies = import_dependencies + for bits in kt.sizes_to_test(): + yield test_case_for_key_generation( + kt.expression, bits, + finish_family_dependencies(generate_dependencies, bits), + str(bits), + result, + param_descr=param_descr + ) + + ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR', + 'PSA_KEY_TYPE_ECC_PUBLIC_KEY') + + def test_cases_for_key_generation(self) -> Iterator[test_case.TestCase]: + """Generate test cases that exercise the generation of keys.""" + for key_type in sorted(self.constructors.key_types): + if key_type in self.ECC_KEY_TYPES: + continue + kt = crypto_knowledge.KeyType(key_type) + yield from self.test_cases_for_key_type_key_generation(kt) + for curve_family in sorted(self.constructors.ecc_curves): + for constr in self.ECC_KEY_TYPES: + kt = crypto_knowledge.KeyType(constr, [curve_family]) + yield from self.test_cases_for_key_type_key_generation( + kt, param_descr='type') + yield from self.test_cases_for_key_type_key_generation( + kt, 0, param_descr='curve') + + class StorageKey(psa_storage.Key): """Representation of a key for storage format testing.""" @@ -682,6 +759,8 @@ class TestGenerator: test_case.write_data_file(filename, test_cases) TARGETS = { + 'test_suite_psa_crypto_generate_key.generated': + lambda info: KeyGenerate(info).test_cases_for_key_generation(), 'test_suite_psa_crypto_not_supported.generated': lambda info: NotSupported(info).test_cases_for_not_supported(), 'test_suite_psa_crypto_storage_format.current': diff --git a/tests/suites/test_suite_psa_crypto_generate_key.function b/tests/suites/test_suite_psa_crypto_generate_key.function new file mode 100644 index 0000000000..7404d382a9 --- /dev/null +++ b/tests/suites/test_suite_psa_crypto_generate_key.function @@ -0,0 +1,54 @@ +/* BEGIN_HEADER */ + +#include "psa/crypto.h" +#include "test/psa_crypto_helpers.h" + +#define INVALID_KEY_ID mbedtls_svc_key_id_make( 0, 0xfedcba98 ) + +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_PSA_CRYPTO_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE */ +void generate_key( int key_type, int bits, int result) +{ + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + mbedtls_svc_key_id_t key_id = INVALID_KEY_ID; + + // key lifetiem, usage flags, algorithm are irrelevant for this test + psa_key_lifetime_t _key_life_time = (psa_key_lifetime_t) 0; + psa_key_usage_t _key_usage_flags = (psa_key_usage_t) 0; + psa_algorithm_t _key_algorithm = (psa_algorithm_t) 0; + psa_key_type_t _key_type = (psa_key_type_t) key_type; + size_t _key_bits = (size_t) bits; + psa_status_t _result = (psa_status_t) result; + + PSA_ASSERT( psa_crypto_init( ) ); + psa_set_key_lifetime( &attributes, _key_life_time ); + psa_set_key_usage_flags( &attributes, _key_usage_flags ); + psa_set_key_algorithm( &attributes, _key_algorithm ); + psa_set_key_type( &attributes, _key_type ); + psa_set_key_bits( &attributes, _key_bits ); + TEST_EQUAL( psa_generate_key( &attributes, &key_id ), + _result ); + + // Verify attributes of the created key on success + if (_result == PSA_SUCCESS) + { + psa_key_attributes_t key_attributes = {0}; + PSA_ASSERT( psa_get_key_attributes( key_id, &key_attributes ) ); + TEST_EQUAL( psa_get_key_lifetime( &key_attributes ), 0 ); + TEST_EQUAL( psa_get_key_usage_flags( &key_attributes ), 0 ); + TEST_EQUAL( psa_get_key_algorithm( &key_attributes ), 0 ); + TEST_EQUAL( psa_get_key_type( &key_attributes ), _key_type ); + TEST_EQUAL( psa_get_key_bits( &key_attributes ), _key_bits ); + } + +exit: + psa_destroy_key( key_id ); + PSA_DONE( ); +} +/* END_CASE */ From 8d468e4ee87cbee2197070bcfc2ef4a508770352 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Mon, 18 Oct 2021 14:58:20 +0200 Subject: [PATCH 727/966] Remove key generation when given argument is invalid from NotSupported class Signed-off-by: Przemyslaw Stekiel --- tests/scripts/generate_psa_tests.py | 42 +++---------------- ...st_suite_psa_crypto_not_supported.function | 19 --------- 2 files changed, 6 insertions(+), 55 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index b4a13bac3d..589820265c 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -155,30 +155,8 @@ def test_case_for_key_type_not_supported( tc.set_arguments([key_type] + list(args)) return tc -def test_case_for_key_type_invalid_argument( - verb: str, key_type: str, bits: int, - dependencies: List[str], - *args: str, - param_descr: str = '' -) -> test_case.TestCase: - """Return one test case exercising a key creation method - for an invalid argument when key is public. - """ - hack_dependencies_not_implemented(dependencies) - tc = test_case.TestCase() - short_key_type = re.sub(r'PSA_(KEY_TYPE|ECC_FAMILY)_', r'', key_type) - adverb = 'not' if dependencies else 'never' - if param_descr: - adverb = param_descr + ' ' + adverb - tc.set_description('PSA {} {} {}-bit invalid argument' - .format(verb, short_key_type, bits)) - tc.set_function(verb + '_invalid_argument') - tc.set_dependencies(dependencies) - tc.set_arguments([key_type] + list(args)) - return tc - class NotSupported: - """Generate test cases for when something is not supported or argument is inavlid.""" + """Generate test cases for when something is not supported.""" def __init__(self, info: Information) -> None: self.constructors = info.constructors @@ -193,13 +171,11 @@ class NotSupported: param: Optional[int] = None, param_descr: str = '', ) -> Iterator[test_case.TestCase]: - """Return test cases exercising key creation when the given type is unsupported - or argument is invalid. + """Return test cases exercising key creation when the given type is unsupported. If param is present and not None, emit test cases conditioned on this parameter not being supported. If it is absent or None, emit test cases - conditioned on the base type not being supported. If key is public emit test - case for invalid argument. + conditioned on the base type not being supported. """ if kt.name in self.ALWAYS_SUPPORTED: # Don't generate test cases for key types that are always supported. @@ -227,14 +203,8 @@ class NotSupported: # supported or not depending on implementation capabilities, # only generate the test case once. continue - if kt.name.endswith('_PUBLIC_KEY'): - yield test_case_for_key_type_invalid_argument( - 'generate', kt.expression, bits, - finish_family_dependencies(generate_dependencies, bits), - str(bits), - param_descr=param_descr, - ) - else: + # Public key cannot be generated + if not kt.name.endswith('_PUBLIC_KEY'): yield test_case_for_key_type_not_supported( 'generate', kt.expression, bits, finish_family_dependencies(generate_dependencies, bits), @@ -266,7 +236,7 @@ def test_case_for_key_generation( dependencies: List[str], *args: str, result: str = '', - param_descr: str = '', + param_descr: str = '' ) -> test_case.TestCase: """Return one test case exercising a key generation. """ diff --git a/tests/suites/test_suite_psa_crypto_not_supported.function b/tests/suites/test_suite_psa_crypto_not_supported.function index 0665230d72..e3253d8405 100644 --- a/tests/suites/test_suite_psa_crypto_not_supported.function +++ b/tests/suites/test_suite_psa_crypto_not_supported.function @@ -50,22 +50,3 @@ exit: PSA_DONE( ); } /* END_CASE */ - -/* BEGIN_CASE */ -void generate_invalid_argument( int key_type, int bits ) -{ - psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; - mbedtls_svc_key_id_t key_id = INVALID_KEY_ID; - - PSA_ASSERT( psa_crypto_init( ) ); - psa_set_key_type( &attributes, key_type ); - psa_set_key_bits( &attributes, bits ); - TEST_EQUAL( psa_generate_key( &attributes, &key_id ), - PSA_ERROR_INVALID_ARGUMENT ); - TEST_ASSERT( mbedtls_svc_key_id_equal( key_id, MBEDTLS_SVC_KEY_ID_INIT ) ); - -exit: - psa_destroy_key( key_id ); - PSA_DONE( ); -} -/* END_CASE */ From bca03e5f7d29dd7566a725bfee83be87cab2aa4a Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Thu, 9 Sep 2021 09:42:37 +0000 Subject: [PATCH 728/966] Add code size comparison script. Signed-off-by: Xiaofei Bai --- scripts/code_size_compare.py | 210 +++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100755 scripts/code_size_compare.py diff --git a/scripts/code_size_compare.py b/scripts/code_size_compare.py new file mode 100755 index 0000000000..19a6c43d01 --- /dev/null +++ b/scripts/code_size_compare.py @@ -0,0 +1,210 @@ +#!/usr/bin/env python3 + +""" +Purpose + +This script is for comparing the size of the library files from two +different Git revisions within an Mbed TLS repository. +The results of the comparison is formatted as csv and stored at a +configurable location. +Note: must be run from Mbed TLS root. +""" + +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import os +import subprocess +import sys + +class CodeSizeComparison: + """compare code size between two Git revisions""" + + def __init__(self, old_revision, new_revision, result_dir): + """ + old_revision: revision to compare against + new_revision: + result_dir: directory for comparision result + """ + self.repo_path = "." + self.result_dir = os.path.abspath(result_dir) + if os.path.exists(self.result_dir) is False: + os.makedirs(self.result_dir) + + self.csv_dir = os.path.abspath("code_size_records/") + if os.path.exists(self.csv_dir) is False: + os.makedirs(self.csv_dir) + + self.old_rev = old_revision + self.new_rev = new_revision + self.git_command = "git" + self.make_command = "make" + + @staticmethod + def check_repo_path(): + if not all(os.path.isdir(d) for d in ["include", "library", "tests"]): + raise Exception("Must be run from Mbed TLS root") + + def _create_git_worktree(self, revision): + """Make a separate worktree for revision. + Do not modify the current worktree.""" + + if revision == "head": + print("Using current work directory.") + git_worktree_path = self.repo_path + else: + print("Creating git worktree for", revision) + git_worktree_path = os.path.join(self.repo_path, "temp-" + revision) + subprocess.check_output( + [self.git_command, "worktree", "add", "--detach", + git_worktree_path, revision], cwd=self.repo_path, + stderr=subprocess.STDOUT + ) + return git_worktree_path + + def _build_libraries(self, git_worktree_path): + """Build libraries in the specified worktree.""" + + my_environment = os.environ.copy() + subprocess.check_output( + [self.make_command, "-j", "lib"], env=my_environment, + cwd=git_worktree_path, stderr=subprocess.STDOUT, + ) + + def _gen_code_size_csv(self, revision, git_worktree_path): + """Generate code size csv file.""" + + csv_fname = revision + ".csv" + print("Measuring code size for", revision) + result = subprocess.check_output( + ["size library/*.o"], cwd=git_worktree_path, shell=True + ) + size_text = result.decode() + csv_file = open(os.path.join(self.csv_dir, csv_fname), "w") + for line in size_text.splitlines()[1:]: + data = line.split() + csv_file.write("{}, {}\n".format(data[5], data[3])) + + def _remove_worktree(self, git_worktree_path): + """Remove temporary worktree.""" + if git_worktree_path != self.repo_path: + print("Removing temporary worktree", git_worktree_path) + subprocess.check_output( + [self.git_command, "worktree", "remove", "--force", + git_worktree_path], cwd=self.repo_path, + stderr=subprocess.STDOUT + ) + + def _get_code_size_for_rev(self, revision): + """Generate code size csv file for the specified git revision.""" + + # Check if the corresponding record exists + csv_fname = revision + ".csv" + if (revision != "head") and \ + os.path.exists(os.path.join(self.csv_dir, csv_fname)): + print("Code size csv file for", revision, "already exists.") + else: + git_worktree_path = self._create_git_worktree(revision) + self._build_libraries(git_worktree_path) + self._gen_code_size_csv(revision, git_worktree_path) + self._remove_worktree(git_worktree_path) + + def compare_code_size(self): + """Generate results of the size changes between two revisions, + old and new. Measured code size results of these two revisions + must be available""" + + old_file = open(os.path.join(self.csv_dir, self.old_rev + ".csv"), "r") + new_file = open(os.path.join(self.csv_dir, self.new_rev + ".csv"), "r") + res_file = open(os.path.join(self.result_dir, "compare-" + self.old_rev + + "-" + self.new_rev + ".csv"), "w") + res_file.write("file_name, this_size, old_size, change, change %\n") + print("Generate comparision results.") + + old_ds = {} + for line in old_file.readlines()[1:]: + cols = line.split(", ") + fname = cols[0] + size = int(cols[1]) + if size != 0: + old_ds[fname] = size + + new_ds = {} + for line in new_file.readlines()[1:]: + cols = line.split(", ") + fname = cols[0] + size = int(cols[1]) + new_ds[fname] = size + + for fname in new_ds: + this_size = new_ds[fname] + if fname in old_ds: + old_size = old_ds[fname] + change = this_size - old_size + change_pct = change / old_size + res_file.write("{}, {}, {}, {}, {:.2%}\n".format(fname, \ + this_size, old_size, change, float(change_pct))) + else: + res_file.write("{}, {}\n".format(fname, this_size)) + return 1 + + def get_comparision_results(self): + """Compare size of library/*.o between self.old_rev and self.new_rev, + and generate the result file.""" + self.check_repo_path() + self._get_code_size_for_rev(self.old_rev) + self._get_code_size_for_rev(self.new_rev) + return self.compare_code_size() + +def run_main(): + parser = argparse.ArgumentParser( + description=( + """This script is for comparing the size of the library files + from two different Git revisions within an Mbed TLS repository. + The results of the comparison is formatted as csv, and stored at + a configurable location. + Note: must be run from Mbed TLS root.""" + ) + ) + parser.add_argument( + "-r", "--result-dir", type=str, default="comparison", + help="directory where comparison result is stored, \ + default is comparison", + ) + parser.add_argument( + "-o", "--old-rev", type=str, help="old revision for comparison", + required=True, + ) + parser.add_argument( + "-n", "--new-rev", type=str, default="head", + help="new revision for comparison, default is current work directory." + ) + comp_args = parser.parse_args() + + if os.path.isfile(comp_args.result_dir): + print("Error: {} is not a directory".format(comp_args.result_dir)) + parser.exit() + + old_revision = comp_args.old_rev + new_revision = comp_args.new_rev + result_dir = comp_args.result_dir + size_compare = CodeSizeComparison(old_revision, new_revision, result_dir) + return_code = size_compare.get_comparision_results() + sys.exit(return_code) + + +if __name__ == "__main__": + run_main() From 788ad339b8cbf1dbb6233f6be92e2261c3e67194 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 20 Oct 2021 14:17:02 +0200 Subject: [PATCH 729/966] Move is-it-resend logic into a function Improve the code structure in case we want to add other similar conditions later. Document better what we're doing, and document why we're doing it. Signed-off-by: Gilles Peskine --- tests/ssl-opt.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 23169e466d..fa34ff66f3 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -552,6 +552,32 @@ record_outcome() { fi } +# True if the presence of the given pattern in a log definitely indicates +# that the test has failed. False if the presence is inconclusive. +# +# Inputs: +# * $1: pattern found in the logs +# * $TIMES_LEFT: >0 if retrying is an option +# +# Outputs: +# * $outcome: set to a retry reason if the pattern is inconclusive, +# unchanged otherwise. +# * Return value: 1 if the pattern is inconclusive, +# 0 if the failure is definitive. +log_pattern_presence_is_conclusive() { + # If we've run out of attempts, then don't retry no matter what. + if [ $TIMES_LEFT -eq 0 ]; then + return 0 + fi + case $1 in + "resend") + # An undesired resend may have been caused by the OS dropping or + # delaying a packet at an inopportune time. + outcome="RETRY(resend)" + return 1;; + esac +} + # fail fail() { record_outcome "FAIL" "$1" @@ -939,9 +965,7 @@ check_test_failure() { "-S") if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then - if [ "$2" = "resend" ] && [ $TIMES_LEFT -gt 0 ]; then - outcome="RETRY(resend)" - else + if log_pattern_presence_is_conclusive "$2"; then fail "pattern '$2' MUST NOT be present in the Server output" fi return @@ -950,9 +974,7 @@ check_test_failure() { "-C") if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then - if [ "$2" = "resend" ] && [ $TIMES_LEFT -gt 0 ]; then - outcome="RETRY(resend)" - else + if log_pattern_presence_is_conclusive "$2"; then fail "pattern '$2' MUST NOT be present in the Client output" fi return From 3a96d09898b501c6002d471b6461e77a796b1d8e Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Tue, 19 Oct 2021 22:01:12 +0100 Subject: [PATCH 730/966] export MBEDTLS_DEPRECATED from platform_util.h Since there are no longer any alternative MBEDTLS_DEPRECATED definitions in the codebase, MBEDTLS_DEPRECATED can now be exported without breaking anything. Signed-off-by: Brett Warren --- include/mbedtls/platform_util.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 36e3718e6c..26e628b4e9 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -42,10 +42,6 @@ extern "C" { /* Internal helper macros for deprecating API constants. */ #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) -/* Deliberately don't (yet) export MBEDTLS_DEPRECATED here - * to avoid conflict with other headers which define and use - * it, too. We might want to move all these definitions here at - * some point for uniformity. */ #define MBEDTLS_DEPRECATED __attribute__((deprecated)) MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_string_constant_t; #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \ @@ -53,7 +49,6 @@ MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_string_constant_t; MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) \ ( (mbedtls_deprecated_numeric_constant_t) ( VAL ) ) -#undef MBEDTLS_DEPRECATED #else /* MBEDTLS_DEPRECATED_WARNING */ #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) VAL From 9e98573ca2a6e6be35f3dd1634bd55212bdeb2a0 Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Tue, 19 Oct 2021 22:16:51 +0100 Subject: [PATCH 731/966] fix build fail with MBEDTLS_DEPRECATED When deprecated functions are allowed Signed-off-by: Brett Warren --- include/mbedtls/platform_util.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 26e628b4e9..5d2fefc36f 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -50,6 +50,7 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) \ ( (mbedtls_deprecated_numeric_constant_t) ( VAL ) ) #else /* MBEDTLS_DEPRECATED_WARNING */ +#define MBEDTLS_DEPRECATED #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) VAL #endif /* MBEDTLS_DEPRECATED_WARNING */ From 80b31c56eba2634ddc60d3cf8e2cdc7eb9c639ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 19 Oct 2021 15:05:36 +0200 Subject: [PATCH 732/966] Run the PSA Compliance test suite in all.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a component to all.sh which clones, builds and runs the compliance test suite. Signed-off-by: Bence Szépkúti --- tests/scripts/all.sh | 13 ++++ tests/scripts/test_psa_compliance.py | 96 ++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100755 tests/scripts/test_psa_compliance.py diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 099174372e..68163559a8 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2756,6 +2756,19 @@ component_test_zeroize () { unset gdb_disable_aslr } +component_test_psa_compliance () { + msg "build: make, default config (out-of-box), libmbedcrypto.a only" + make library/libmbedcrypto.a + + msg "unit test: test_psa_compliance.py" + ./tests/scripts/test_psa_compliance.py +} + +support_test_psa_compliance () { + local ver=($(cmake --version | sed 's/cmake version //; y/./ /; q')) + [ "${ver[0]}" -eq 3 ] && [ "${ver[1]}" -ge 10 ] +} + component_check_python_files () { msg "Lint: Python scripts" tests/scripts/check-python-files.sh diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py new file mode 100755 index 0000000000..07fa76e60f --- /dev/null +++ b/tests/scripts/test_psa_compliance.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +#pylint: disable=missing-module-docstring +import os +import re +import shutil +import subprocess +import sys + +EXPECTED_FAILURES = { + 216, 221, 224, 225, 248, 249, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263 +} +PSA_ARCH_TESTS_REPO = 'https://github.com/ronald-cron-arm/psa-arch-tests.git' +PSA_ARCH_TESTS_REF = 'crypto1.0-3.0' + +#pylint: disable=too-many-statements +def main(): + mbedtls_dir = os.getcwd() + + mbedcrypto_lib = 'library/libmbedcrypto.a' + if not os.path.exists(mbedcrypto_lib): + subprocess.check_call(['make', mbedcrypto_lib]) + + psa_arch_tests_dir = 'psa-arch-tests' + try: + os.mkdir(psa_arch_tests_dir) + except FileExistsError: + pass + os.chdir(psa_arch_tests_dir) + + subprocess.check_call(['git', 'init']) + subprocess.check_call(['git', 'fetch', PSA_ARCH_TESTS_REPO, PSA_ARCH_TESTS_REF]) + subprocess.check_call(['git', 'checkout', 'FETCH_HEAD']) + + build_dir = 'api-tests/build' + try: + shutil.rmtree(build_dir) + except FileNotFoundError: + pass + os.mkdir(build_dir) + os.chdir(build_dir) + + #pylint: disable=bad-continuation + subprocess.check_call([ + 'cmake', '..', '-GUnix Makefiles', + '-DTARGET=tgt_dev_apis_stdc', + '-DTOOLCHAIN=HOST_GCC', + '-DSUITE=CRYPTO', + '-DPSA_CRYPTO_LIB_FILENAME={}/library/libmbedcrypto.a'.format(mbedtls_dir), + '-DPSA_INCLUDE_PATHS={}/include'.format(mbedtls_dir) + ]) + subprocess.check_call(['cmake', '--build', '.']) + + proc = subprocess.Popen(['./psa-arch-tests-crypto'], + bufsize=1, stdout=subprocess.PIPE, universal_newlines=True) + + test_re = re.compile('^TEST(?:: ([0-9]*)| RESULT: FAILED)') + test = -1 + unexpected_successes = set(EXPECTED_FAILURES) + expected_failures = [] + unexpected_failures = [] + for line in proc.stdout: + print(line[:-1]) + match = test_re.match(line) + if match is not None: + if match.group(1) is not None: + test = int(match.group(1)) + else: + try: + unexpected_successes.remove(test) + expected_failures.append(test) + except KeyError: + unexpected_failures.append(test) + proc.wait() + + print() + print('***** test_psa_compliance.py report ******') + print() + print('Expected failures:', ', '.join(str(i) for i in expected_failures)) + print('Unexpected failures:', ', '.join(str(i) for i in unexpected_failures)) + print('Unexpected successes:', ', '.join(str(i) for i in sorted(unexpected_successes))) + print() + if unexpected_successes or unexpected_failures: + if unexpected_successes: + print('Unexpected successes encountered.') + #pylint: disable=line-too-long + print('Please remove the corresponding tests from EXPECTED_FAILURES in tests/scripts/compliance_test.py') + print() + print('FAILED') + sys.exit(1) + else: + os.chdir(mbedtls_dir) + shutil.rmtree(psa_arch_tests_dir) + print('SUCCESS') + +if __name__ == '__main__': + main() From bb2ced33dd8ff2b90aff907301cb4d1c0c7a06d9 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 13 Oct 2021 13:37:30 +0200 Subject: [PATCH 733/966] Ignore plaintext length for CCM*-no-tag. Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 4 ++++ library/ccm.c | 22 ++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index 6f991fefbd..0dc5b59683 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -198,6 +198,7 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, * \param ctx The CCM context to use for encryption. This must be * initialized and bound to a key. * \param length The length of the input data in Bytes. + * For tag length = 0, input length is ignored. * \param iv The initialization vector (nonce). This must be a readable * buffer of at least \p iv_len Bytes. * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, @@ -207,6 +208,7 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, * at least \p ad_len Bytes. * \param ad_len The length of additional data in Bytes. * This must be less than 2^16 - 2^8. + * For tag length = 0, AD length can be 0. * \param input The buffer holding the input data. If \p length is greater * than zero, \p input must be a readable buffer of at least * that length. @@ -279,6 +281,7 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, * \param ctx The CCM context to use for decryption. This must be * initialized and bound to a key. * \param length The length of the input data in Bytes. + * For tag length = 0, input length is ignored. * \param iv The initialization vector (nonce). This must be a readable * buffer of at least \p iv_len Bytes. * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, @@ -288,6 +291,7 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, * at least that \p ad_len Bytes. * \param ad_len The length of additional data in Bytes. * This must be less than 2^16 - 2^8. + * For tag length = 0, AD length can be 0. * \param input The buffer holding the input data. If \p length is greater * than zero, \p input must be a readable buffer of at least * that length. diff --git a/library/ccm.c b/library/ccm.c index 15efff79f0..e062678569 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -150,9 +150,20 @@ static int ccm_calculate_first_block_if_ready(mbedtls_ccm_context *ctx) if( !(ctx->state & CCM_STATE__STARTED) || !(ctx->state & CCM_STATE__LENGHTS_SET) ) return 0; - if( ctx->tag_len == 0 && \ - ( ctx->mode == MBEDTLS_CCM_ENCRYPT || ctx->mode == MBEDTLS_CCM_DECRYPT ) ) - return( MBEDTLS_ERR_CCM_BAD_INPUT ); + /* CCM expects non-empty tag. + * CCM* allows empty tag. For CCM* without tag, ignore plaintext length. + */ + if( ctx->tag_len == 0 ) + { + if( ctx->mode == MBEDTLS_CCM_STAR_ENCRYPT || ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) + { + ctx->plaintext_len = 0; + } + else + { + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + } + } /* * First block: @@ -342,7 +353,10 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, return MBEDTLS_ERR_CCM_BAD_INPUT; } - if( ctx->processed + input_len > ctx->plaintext_len ) + /* Check against plaintext length only if performing operation with + * authentication + */ + if( ctx->tag_len != 0 && ctx->processed + input_len > ctx->plaintext_len ) { return MBEDTLS_ERR_CCM_BAD_INPUT; } From 594215be6e00e1bb921497091213ed601df5e4f4 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 14 Oct 2021 12:23:06 +0200 Subject: [PATCH 734/966] Add support for CCM*-no-tag to PSA. Signed-off-by: Mateusz Starzyk --- include/psa/crypto_sizes.h | 3 ++- include/psa/crypto_values.h | 11 +++++++++++ library/cipher.c | 35 +++++++++++++++++++++++++++++++++++ library/psa_crypto.c | 7 ++++++- library/psa_crypto_cipher.c | 3 +++ 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/include/psa/crypto_sizes.h b/include/psa/crypto_sizes.h index 4c67f10afa..e9a7a350bc 100644 --- a/include/psa/crypto_sizes.h +++ b/include/psa/crypto_sizes.h @@ -959,7 +959,8 @@ (alg) == PSA_ALG_CBC_PKCS7) ? PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \ (key_type) == PSA_KEY_TYPE_CHACHA20 && \ (alg) == PSA_ALG_STREAM_CIPHER ? 12 : \ - 0) + (alg) == PSA_ALG_CCM_STAR_NO_TAG ? 13 : \ + 0) /** The maximum IV size for all supported cipher algorithms, in bytes. * diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index daef9416cc..9f0b7517d4 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -1195,6 +1195,17 @@ */ #define PSA_ALG_CCM ((psa_algorithm_t)0x05500100) +/** The CCM* cipher mode without authentication. + * + * This is CCM* as specified in IEEE 802.15.4 §7, with a tag length of 0. + * For CCM* with a nonzero tag length, use the AEAD algorithm #PSA_ALG_CCM. + * + * The underlying block cipher is determined by the key type. + * + * Currently only 13-byte long IV's are supported. + */ +#define PSA_ALG_CCM_STAR_NO_TAG ((psa_algorithm_t)0x04c01300) + /** The GCM authenticated encryption algorithm. * * The underlying block cipher is determined by the key type. diff --git a/library/cipher.c b/library/cipher.c index dc801894b7..4ed6c910f0 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -424,6 +424,31 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, } #endif +#if defined(MBEDTLS_CCM_C) + if( MBEDTLS_MODE_CCM == ctx->cipher_info->mode ) + { + int set_lengths_result; + int ccm_star_mode; + + set_lengths_result = mbedtls_ccm_set_lengths( + (mbedtls_ccm_context *) ctx->cipher_ctx, + 0, 0, 0 ); + if( set_lengths_result != 0 ) + return set_lengths_result; + + if( ctx->operation == MBEDTLS_DECRYPT ) + ccm_star_mode = MBEDTLS_CCM_STAR_DECRYPT; + else if( ctx->operation == MBEDTLS_ENCRYPT ) + ccm_star_mode = MBEDTLS_CCM_STAR_ENCRYPT; + else + return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + + return( mbedtls_ccm_starts( (mbedtls_ccm_context *) ctx->cipher_ctx, + ccm_star_mode, + iv, iv_len ) ); + } +#endif + if ( actual_iv_size != 0 ) { memcpy( ctx->iv, iv, actual_iv_size ); @@ -560,6 +585,15 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i } #endif +#if defined(MBEDTLS_CCM_C) + if( ctx->cipher_info->mode == MBEDTLS_MODE_CCM ) + { + return( mbedtls_ccm_update( (mbedtls_ccm_context *) ctx->cipher_ctx, + input, ilen, + output, ilen, olen ) ); + } +#endif + #if defined(MBEDTLS_CHACHAPOLY_C) if ( ctx->cipher_info->type == MBEDTLS_CIPHER_CHACHA20_POLY1305 ) { @@ -947,6 +981,7 @@ int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, MBEDTLS_MODE_OFB == ctx->cipher_info->mode || MBEDTLS_MODE_CTR == ctx->cipher_info->mode || MBEDTLS_MODE_GCM == ctx->cipher_info->mode || + MBEDTLS_MODE_CCM == ctx->cipher_info->mode || MBEDTLS_MODE_XTS == ctx->cipher_info->mode || MBEDTLS_MODE_STREAM == ctx->cipher_info->mode ) { diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ece64b100d..67494dd249 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3587,7 +3587,12 @@ psa_status_t psa_cipher_decrypt( mbedtls_svc_key_id_t key, .core = slot->attr }; - if( input_length < PSA_CIPHER_IV_LENGTH( slot->attr.type, alg ) ) + if( alg == PSA_ALG_CCM_STAR_NO_TAG && input_length < PSA_BLOCK_CIPHER_BLOCK_LENGTH( slot->attr.type ) ) + { + status = PSA_ERROR_INVALID_ARGUMENT; + goto exit; + } + else if ( input_length < PSA_CIPHER_IV_LENGTH( slot->attr.type, alg ) ) { status = PSA_ERROR_INVALID_ARGUMENT; goto exit; diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index 2268fc5850..acbbd5ca6b 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -92,6 +92,9 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_psa( case PSA_ALG_CBC_PKCS7: mode = MBEDTLS_MODE_CBC; break; + case PSA_ALG_CCM_STAR_NO_TAG: + mode = MBEDTLS_MODE_CCM; + break; case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 0 ): mode = MBEDTLS_MODE_CCM; break; From ed71e9273045b173e647a0cfd0259299753c1283 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 21 Oct 2021 10:04:57 +0200 Subject: [PATCH 735/966] Add tests for CCM*-no-tag. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_ccm.data | 8 +++++ tests/suites/test_suite_ccm.function | 25 ++++++++++++++ tests/suites/test_suite_psa_crypto.data | 36 +++++++++++++++++++++ tests/suites/test_suite_psa_crypto.function | 34 +++++++++++++++++++ 4 files changed, 103 insertions(+) diff --git a/tests/suites/test_suite_ccm.data b/tests/suites/test_suite_ccm.data index 591e0d9067..61e6e9b991 100644 --- a/tests/suites/test_suite_ccm.data +++ b/tests/suites/test_suite_ccm.data @@ -1744,3 +1744,11 @@ mbedtls_ccm_unexpected_ad::MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50d CCM encrypt, unexpected ciphertext/plaintext data, NIST VPT AES-128 #14 (P=13, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C mbedtls_ccm_unexpected_text:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_ENCRYPT:"d32088d50df9aba14d9022c870a0cb85":"4b10788c1a03bca656f04f1f98":"e16c69861efc206e85aab1255e":"0eff7d7bcceb873c3203a8df74f4e91b04bd607ec11202f96cfeb99f5bcdb7aa" + +CCM* encrypt, no auth NIST VADT AES-256 #1 (P=24, N=13) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_star_no_tag:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_ENCRYPT:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886df3ba3e6da3a1389":"30d56ff2a25b83fee791110fcaea48e41db7c7f098a81000":"72a60f345a1978fb40f28a2fa4":"55f068c0bbba8b598013dd1841fd740fda2902322148ab5e" + +CCM* decrypt, no auth NIST DVPT AES-128 #15 (P=24, N=13) +depends_on:MBEDTLS_AES_C +mbedtls_ccm_star_no_tag:MBEDTLS_CIPHER_ID_AES:MBEDTLS_CCM_STAR_DECRYPT:"90929a4b0ac65b350ad1591611fe4829":"4bfe4e35784f0a65b545477e5e2f4bae0e1e6fa717eaf2cb":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" diff --git a/tests/suites/test_suite_ccm.function b/tests/suites/test_suite_ccm.function index e48b1f990a..a7ba0dea20 100644 --- a/tests/suites/test_suite_ccm.function +++ b/tests/suites/test_suite_ccm.function @@ -231,6 +231,31 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void mbedtls_ccm_star_no_tag( int cipher_id, int mode, data_t * key, + data_t * msg, data_t * iv, data_t * result ) +{ + mbedtls_ccm_context ctx; + uint8_t *output = NULL; + size_t olen; + + mbedtls_ccm_init( &ctx ); + TEST_EQUAL( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ), 0 ); + TEST_EQUAL( 0, mbedtls_ccm_starts( &ctx, mode, iv->x, iv->len ) ); + TEST_EQUAL( 0, mbedtls_ccm_set_lengths( &ctx, 0, msg->len, 0 ) ); + + ASSERT_ALLOC( output, msg->len ); + TEST_EQUAL( 0, mbedtls_ccm_update( &ctx, msg->x, msg->len, output, msg->len, &olen ) ); + TEST_EQUAL( result->len, olen ); + ASSERT_COMPARE( output, olen, result->x, result->len ); + + TEST_EQUAL( 0, mbedtls_ccm_finish( &ctx, NULL, 0 ) ); +exit: + mbedtls_free(output); + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + /* BEGIN_CASE */ void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, data_t * msg, data_t * iv, diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 063629e599..e7ba9d3eb3 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -1946,6 +1946,10 @@ PSA symmetric encrypt validation: 3-key 3DES-CBC-nopad, 8 bytes, good depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_DES cipher_encrypt_validation:PSA_ALG_CBC_NO_PADDING:PSA_KEY_TYPE_DES:"01020407080b0d0ec1c2c4c7c8cbcdce31323437383b3d3e":"eda4011239bc3ac9" +PSA symmetric encrypt validation: CCM*-no-tag, 15 bytes, good +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +cipher_encrypt_validation:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"d24a3d3dde8c84830280cb87abad0bb3":"6bc1bee22e409f96e93d7e11739317" + PSA symmetric encrypt multipart: AES-ECB, 0 bytes, good depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_encrypt_multipart:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"":"":0:0:0:"":PSA_SUCCESS @@ -2006,6 +2010,10 @@ PSA symmetric encrypt multipart: 3-key 3DES-ECB, 8 bytes, good depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_DES cipher_encrypt_multipart:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_DES:"01020407080b0d0ec1c2c4c7c8cbcdce31323437383b3d3e":"":"c78e2b38139610e3":8:8:0:"817ca7d69b80d86a":PSA_SUCCESS +PSA symmetric encrypt multipart: CCM*-no-tag, AES, 24 bytes, good +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +cipher_encrypt_multipart:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"d24a3d3dde8c84830280cb87abad0bb3":"f1100035bb24a8d26004e0e24b":"7c86135ed9c2a515aaae0e9a208133897269220f30870006":10:10:14:"1faeb0ee2ca2cd52f0aa3966578344f24e69b742c4ab37ab":PSA_SUCCESS + PSA cipher decrypt: without initialization depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_decrypt_fail:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_AES:"":"":"":PSA_ERROR_BAD_STATE @@ -2038,6 +2046,10 @@ PSA symmetric decrypt: AES-CBC-nopad, input too short (5 bytes) depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_decrypt_fail:PSA_ALG_CBC_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a":"6bc1bee223":PSA_ERROR_INVALID_ARGUMENT +PSA symetric decrypt: CCM*-no-tag, input too short (15 bytes) +depends_on:MBEDTLS_AES_C +cipher_decrypt_fail:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"19ebfde2d5468ba0a3031bde629b11fd":"5a8aa485c316e9":"2a2a2a2a2a2a2a2a":PSA_ERROR_INVALID_ARGUMENT + PSA symmetric decrypt: AES-ECB, 0 bytes, good depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_decrypt:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"":"":"" @@ -2086,6 +2098,10 @@ PSA symmetric decrypt: 3-key 3DES-ECB, 8 bytes, good depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_DES cipher_decrypt:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_DES:"01020407080b0d0ec1c2c4c7c8cbcdce31323437383b3d3e":"":"817ca7d69b80d86a":"c78e2b38139610e3" +PSA symmetric decrypt: CCM*-no-tag, NIST DVPT AES-128 #15 +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +cipher_decrypt:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"90929a4b0ac65b350ad1591611fe4829":"5a8aa485c316e9403aff859fbb":"4bfe4e35784f0a65b545477e5e2f4bae0e1e6fa717eaf2cb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" + PSA symmetric decrypt multipart: AES-ECB, 0 bytes, good depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_decrypt_multipart:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"":"":0:0:0:"":PSA_SUCCESS @@ -2146,6 +2162,10 @@ PSA symmetric decrypt multipart: 3-key 3DES-ECB, 8 bytes, good depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_DES cipher_decrypt_multipart:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_DES:"01020407080b0d0ec1c2c4c7c8cbcdce31323437383b3d3e":"":"817ca7d69b80d86a":8:8:0:"c78e2b38139610e3":PSA_SUCCESS +PSA symmetric decrypt multipart: CCM*-no-tag, 24 bytes, good +depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_DES +cipher_decrypt_multipart:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"197afb02ffbd8f699dacae87094d5243":"5a8aa485c316e9403aff859fbb":"4a550134f94455979ec4bf89ad2bd80d25a77ae94e456134":10:10:14:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697":PSA_SUCCESS + PSA symmetric encrypt/decrypt: AES-ECB, 16 bytes, good depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_verify_output:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"6bc1bee22e409f96e93d7e117393172a" @@ -2166,6 +2186,22 @@ PSA symmetric encrypt/decrypt: AES-CTR depends_on:PSA_WANT_ALG_CTR:PSA_WANT_KEY_TYPE_AES cipher_verify_output:PSA_ALG_CTR:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"6bc1bee22e409f96e93d7e117393172a" +PSA symmetric encrypt/decrypt: CCM*-no-tag, AES +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +cipher_verify_output:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"6bc1bee22e409f96e93d7e117393172a" + +CCM*-no-tag encrypt, iv_length = 14, bad +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +cipher_encrypt_validate_iv_length:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"90929a4b0ac65b350ad1591611fe4829":"2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a":14:PSA_ERROR_INVALID_ARGUMENT + +CCM*-no-tag encrypt, iv_length = 13, good +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +cipher_encrypt_validate_iv_length:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"90929a4b0ac65b350ad1591611fe4829":"2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a":13:PSA_SUCCESS + +CCM*-no-tag encrypt, iv_length = 12, bad +depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES +cipher_encrypt_validate_iv_length:PSA_ALG_CCM_STAR_NO_TAG:PSA_KEY_TYPE_AES:"90929a4b0ac65b350ad1591611fe4829":"2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a":12:PSA_ERROR_INVALID_ARGUMENT + PSA symmetric encryption multipart: AES-ECB, 16+16 bytes depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_encrypt_multipart:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"":"6bc1bee22e409f96e93d7e117393172a5434f378a597bcef1389318c7fc865ef":16:16:16:"3ad77bb40d7a3660a89ecaf32466ef9755ed5e9e066820fa52c729886d18854c":PSA_SUCCESS diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 591c2960de..99f2628256 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -2863,6 +2863,40 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void cipher_encrypt_validate_iv_length( int alg, int key_type, data_t* key_data, + data_t *input, int iv_length, + int expected_result ) +{ + mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT; + psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT; + psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; + size_t output_buffer_size = 0; + unsigned char *output = NULL; + + output_buffer_size = PSA_CIPHER_ENCRYPT_OUTPUT_SIZE( key_type, alg, input->len ); + ASSERT_ALLOC( output, output_buffer_size ); + + PSA_ASSERT( psa_crypto_init( ) ); + + psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT ); + psa_set_key_algorithm( &attributes, alg ); + psa_set_key_type( &attributes, key_type ); + + PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, + &key ) ); + PSA_ASSERT( psa_cipher_encrypt_setup( &operation, key, alg ) ); + TEST_EQUAL( expected_result, psa_cipher_set_iv( &operation, output, + iv_length ) ); + +exit: + psa_cipher_abort( &operation ); + mbedtls_free( output ); + psa_destroy_key( key ); + PSA_DONE( ); +} +/* END_CASE */ + /* BEGIN_CASE */ void cipher_encrypt_alg_without_iv( int alg_arg, int key_type_arg, From 8132c2ff46d532ce9350860b25f6955d842438f6 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Thu, 21 Oct 2021 12:26:58 +0200 Subject: [PATCH 736/966] Address review comments Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_server2.c | 50 ++++++++++++++++++++++++++------------ tests/ssl-opt.sh | 4 +-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 68e92b7121..c23d73045f 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -203,7 +203,7 @@ int main( void ) #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_X509_CRT_PARSE_C) #define USAGE_KEY_OPAQUE \ - " key_opaque=%%d Handle your private key as if it were opaque\n" \ + " key_opaque=%%d Handle your private keys as if they were opaque\n" \ " default: 0 (disabled)\n" #else #define USAGE_KEY_OPAQUE "" @@ -1325,8 +1325,9 @@ int main( int argc, char *argv[] ) mbedtls_pk_context pkey; mbedtls_x509_crt srvcert2; mbedtls_pk_context pkey2; -#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_USE_PSA_CRYPTO) +#if defined(MBEDTLS_USE_PSA_CRYPTO) psa_key_id_t key_slot = 0; /* invalid key slot */ + psa_key_id_t key_slot2 = 0; /* invalid key slot */ #endif int key_cert_init = 0, key_cert_init2 = 0; #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) @@ -2491,23 +2492,38 @@ int main( int argc, char *argv[] ) (unsigned int) -ret ); goto exit; } -#if defined(MBEDTLS_USE_PSA_CRYPTO) - if( opt.key_opaque != 0 ) - { - if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey2, &key_slot, - PSA_ALG_SHA_256 ) ) != 0 ) - { - mbedtls_printf( " failed\n ! " - "mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret ); - goto exit; - } - } -#endif /* MBEDTLS_USE_PSA_CRYPTO */ key_cert_init2 = 2; #endif /* MBEDTLS_ECDSA_C */ } - mbedtls_printf( " ok (key type: %s)\n", mbedtls_pk_get_name( &pkey2 ) ); +#if defined(MBEDTLS_USE_PSA_CRYPTO) + if( opt.key_opaque != 0 ) + { + if ( mbedtls_pk_get_type( &pkey ) == MBEDTLS_PK_ECKEY ) + { + if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey, &key_slot, + PSA_ALG_SHA_256 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! " + "mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret ); + goto exit; + } + } + + if ( mbedtls_pk_get_type( &pkey2 ) == MBEDTLS_PK_ECKEY ) + { + if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey2, &key_slot2, + PSA_ALG_SHA_256 ) ) != 0 ) + { + mbedtls_printf( " failed\n ! " + "mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret ); + goto exit; + } + } + } +#endif /* MBEDTLS_USE_PSA_CRYPTO */ + + mbedtls_printf( " ok (key types: %s - %s)\n", mbedtls_pk_get_name( &pkey ), mbedtls_pk_get_name( &pkey2 ) ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) @@ -3953,6 +3969,10 @@ exit: mbedtls_pk_free( &pkey ); mbedtls_x509_crt_free( &srvcert2 ); mbedtls_pk_free( &pkey2 ); +#if defined(MBEDTLS_USE_PSA_CRYPTO) + psa_destroy_key( key_slot ); + psa_destroy_key( key_slot2 ); +#endif #endif #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) for( i = 0; (size_t) i < ssl_async_keys.slots_used; i++ ) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 7d0b31381f..628fad9560 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1455,7 +1455,7 @@ run_test "Opaque key for server authentication" \ key_file=data_files/server5.key" \ 0 \ -c "Verifying peer X.509 certificate... ok" \ - -s "key type: Opaque" \ + -s "key types: RSA - Opaque" \ -S "error" \ -C "error" @@ -1471,7 +1471,7 @@ run_test "Opaque key for client/server authentication" \ 0 \ -c "key type: Opaque" \ -c "Verifying peer X.509 certificate... ok" \ - -s "key type: Opaque" \ + -s "key types: RSA - Opaque" \ -s "Verifying peer X.509 certificate... ok" \ -S "error" \ -C "error" From 33d01ffe60fe7ce2ebb8e649b657e89a4a8318dd Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 21 Oct 2021 14:55:59 +0200 Subject: [PATCH 737/966] Remove redundant value assignemnt to olen. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_gcm.function | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/suites/test_suite_gcm.function b/tests/suites/test_suite_gcm.function index 816ebc4ec5..5696679ea9 100644 --- a/tests/suites/test_suite_gcm.function +++ b/tests/suites/test_suite_gcm.function @@ -438,7 +438,7 @@ void gcm_update_output_buffer_too_small( int cipher_id, int mode, { mbedtls_gcm_context ctx; uint8_t *output = NULL; - size_t olen; + size_t olen = 0; size_t output_len = input->len - 1; mbedtls_gcm_init( &ctx ); @@ -446,7 +446,6 @@ void gcm_update_output_buffer_too_small( int cipher_id, int mode, TEST_EQUAL( 0, mbedtls_gcm_starts( &ctx, mode, iv->x, iv->len ) ); ASSERT_ALLOC( output, output_len ); - olen = 0xdeadbeef; TEST_EQUAL( MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL, mbedtls_gcm_update( &ctx, input->x, input->len, output, output_len, &olen ) ); exit: From e05e126933b81403620ca56f40f08cfad1a3ecc3 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 20 Oct 2021 15:59:33 +0100 Subject: [PATCH 738/966] Remove bash specific code Use case pattern matching instead of multiline split, given there is only the well formatted PIDs to match on this should be safe. Signed-off-by: Paul Elliott --- tests/ssl-opt.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index d5b9150ca0..25aa5bafe7 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -626,6 +626,8 @@ has_mem_err() { # Wait for process $2 named $3 to be listening on port $1. Print error to $4. if type lsof >/dev/null 2>/dev/null; then wait_app_start() { + newline=' +' START_TIME=$(date +%s) if [ "$DTLS" -eq 1 ]; then proto=UDP @@ -634,20 +636,14 @@ if type lsof >/dev/null 2>/dev/null; then fi # Make a tight loop, server normally takes less than 1s to start. while true; do - SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p | cut -c2-) - SERVER_FOUND=false - # When proxies are used, more than one PID can be listening on - # the same port. Each PID will be on its own line. - while read -r PID; do - if [[ $PID == $2 ]]; then - SERVER_FOUND=true - break - fi - done <<< "$SERVER_PIDS" - - if ($SERVER_FOUND == true); then - break - fi + SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p) + # When we use a proxy, it will be listening on the same port we + # are checking for as well as the server and lsof will list both. + # If multiple PIDs are returned, each one will be on a separate + # line, each prepended with 'p'. + case ${newline}${SERVER_PIDS}${newline} in + *${newline}p${2}${newline}*) break;; + esac if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then echo "$3 START TIMEOUT" echo "$3 START TIMEOUT" >> $4 From 2400b50250a8be764571f6ae9381b5fd3d57c545 Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Thu, 21 Oct 2021 12:22:58 +0000 Subject: [PATCH 739/966] Add revision validation and escape filenames Signed-off-by: Xiaofei Bai --- scripts/code_size_compare.py | 51 ++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/scripts/code_size_compare.py b/scripts/code_size_compare.py index 19a6c43d01..96ebf3d54b 100755 --- a/scripts/code_size_compare.py +++ b/scripts/code_size_compare.py @@ -31,7 +31,7 @@ import subprocess import sys class CodeSizeComparison: - """compare code size between two Git revisions""" + """Compare code size between two Git revisions.""" def __init__(self, old_revision, new_revision, result_dir): """ @@ -58,16 +58,22 @@ class CodeSizeComparison: if not all(os.path.isdir(d) for d in ["include", "library", "tests"]): raise Exception("Must be run from Mbed TLS root") + @staticmethod + def validate_revision(revision): + result = subprocess.run(["git", "cat-file", "-e", revision], check=False) + return result.returncode + def _create_git_worktree(self, revision): """Make a separate worktree for revision. Do not modify the current worktree.""" - if revision == "head": + if revision == "HEAD": print("Using current work directory.") git_worktree_path = self.repo_path else: print("Creating git worktree for", revision) - git_worktree_path = os.path.join(self.repo_path, "temp-" + revision) + rev_dirname = revision.replace("/", "_") + git_worktree_path = os.path.join(self.repo_path, "temp-" + rev_dirname) subprocess.check_output( [self.git_command, "worktree", "add", "--detach", git_worktree_path, revision], cwd=self.repo_path, @@ -87,7 +93,7 @@ class CodeSizeComparison: def _gen_code_size_csv(self, revision, git_worktree_path): """Generate code size csv file.""" - csv_fname = revision + ".csv" + csv_fname = revision.replace("/", "_") + ".csv" print("Measuring code size for", revision) result = subprocess.check_output( ["size library/*.o"], cwd=git_worktree_path, shell=True @@ -112,8 +118,8 @@ class CodeSizeComparison: """Generate code size csv file for the specified git revision.""" # Check if the corresponding record exists - csv_fname = revision + ".csv" - if (revision != "head") and \ + csv_fname = revision.replace("/", "_") + ".csv" + if (revision != "HEAD") and \ os.path.exists(os.path.join(self.csv_dir, csv_fname)): print("Code size csv file for", revision, "already exists.") else: @@ -125,14 +131,17 @@ class CodeSizeComparison: def compare_code_size(self): """Generate results of the size changes between two revisions, old and new. Measured code size results of these two revisions - must be available""" + must be available.""" - old_file = open(os.path.join(self.csv_dir, self.old_rev + ".csv"), "r") - new_file = open(os.path.join(self.csv_dir, self.new_rev + ".csv"), "r") - res_file = open(os.path.join(self.result_dir, "compare-" + self.old_rev - + "-" + self.new_rev + ".csv"), "w") + old_file = open(os.path.join(self.csv_dir, \ + self.old_rev.replace("/", "_") + ".csv"), "r") + new_file = open(os.path.join(self.csv_dir, \ + self.new_rev.replace("/", "_") + ".csv"), "r") + res_file = open(os.path.join(self.result_dir, \ + "compare-" + self.old_rev.replace("/", "_") + "-" \ + + self.new_rev.replace("/", "_") + ".csv"), "w") res_file.write("file_name, this_size, old_size, change, change %\n") - print("Generate comparision results.") + print("Generating comparision results.") old_ds = {} for line in old_file.readlines()[1:]: @@ -159,7 +168,7 @@ class CodeSizeComparison: this_size, old_size, change, float(change_pct))) else: res_file.write("{}, {}\n".format(fname, this_size)) - return 1 + return 0 def get_comparision_results(self): """Compare size of library/*.o between self.old_rev and self.new_rev, @@ -169,7 +178,7 @@ class CodeSizeComparison: self._get_code_size_for_rev(self.new_rev) return self.compare_code_size() -def run_main(): +def main(): parser = argparse.ArgumentParser( description=( """This script is for comparing the size of the library files @@ -185,11 +194,11 @@ def run_main(): default is comparison", ) parser.add_argument( - "-o", "--old-rev", type=str, help="old revision for comparison", + "-o", "--old-rev", type=str, help="old revision for comparison.(prefer commit ID)", required=True, ) parser.add_argument( - "-n", "--new-rev", type=str, default="head", + "-n", "--new-rev", type=str, default="HEAD", help="new revision for comparison, default is current work directory." ) comp_args = parser.parse_args() @@ -198,8 +207,16 @@ def run_main(): print("Error: {} is not a directory".format(comp_args.result_dir)) parser.exit() + validate_result = CodeSizeComparison.validate_revision(comp_args.old_rev) + if validate_result != 0: + sys.exit(validate_result) old_revision = comp_args.old_rev + + validate_result = CodeSizeComparison.validate_revision(comp_args.new_rev) + if validate_result != 0: + sys.exit(validate_result) new_revision = comp_args.new_rev + result_dir = comp_args.result_dir size_compare = CodeSizeComparison(old_revision, new_revision, result_dir) return_code = size_compare.get_comparision_results() @@ -207,4 +224,4 @@ def run_main(): if __name__ == "__main__": - run_main() + main() From 437da19f4f1a5f66b3e838534c251b4bd6e63c4d Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 20 Oct 2021 11:59:50 +0200 Subject: [PATCH 740/966] Remove unused param and duplicated test cases Signed-off-by: Przemyslaw Stekiel --- tests/scripts/generate_psa_tests.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 589820265c..d1307ad11a 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -235,8 +235,7 @@ def test_case_for_key_generation( key_type: str, bits: int, dependencies: List[str], *args: str, - result: str = '', - param_descr: str = '' + result: str = '' ) -> test_case.TestCase: """Return one test case exercising a key generation. """ @@ -244,7 +243,7 @@ def test_case_for_key_generation( tc = test_case.TestCase() short_key_type = re.sub(r'PSA_(KEY_TYPE|ECC_FAMILY)_', r'', key_type) tc.set_description('PSA {} {}-bit' - .format( short_key_type, bits)) + .format(short_key_type, bits)) tc.set_dependencies(dependencies) tc.set_function('generate_key') tc.set_arguments([key_type] + list(args)) @@ -258,11 +257,12 @@ class KeyGenerate: def __init__(self, info: Information) -> None: self.constructors = info.constructors + ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR', + 'PSA_KEY_TYPE_ECC_PUBLIC_KEY') + + @staticmethod def test_cases_for_key_type_key_generation( - self, - kt: crypto_knowledge.KeyType, - param: Optional[int] = None, - param_descr: str = '', + kt: crypto_knowledge.KeyType ) -> Iterator[test_case.TestCase]: """Return test cases exercising key generation. @@ -285,13 +285,9 @@ class KeyGenerate: kt.expression, bits, finish_family_dependencies(generate_dependencies, bits), str(bits), - result, - param_descr=param_descr + result ) - ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR', - 'PSA_KEY_TYPE_ECC_PUBLIC_KEY') - def test_cases_for_key_generation(self) -> Iterator[test_case.TestCase]: """Generate test cases that exercise the generation of keys.""" for key_type in sorted(self.constructors.key_types): @@ -302,11 +298,7 @@ class KeyGenerate: for curve_family in sorted(self.constructors.ecc_curves): for constr in self.ECC_KEY_TYPES: kt = crypto_knowledge.KeyType(constr, [curve_family]) - yield from self.test_cases_for_key_type_key_generation( - kt, param_descr='type') - yield from self.test_cases_for_key_type_key_generation( - kt, 0, param_descr='curve') - + yield from self.test_cases_for_key_type_key_generation(kt) class StorageKey(psa_storage.Key): """Representation of a key for storage format testing.""" From 30bd7fa607f63f1a7fa013898817ecd8385b60e6 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Fri, 22 Oct 2021 10:33:25 +0200 Subject: [PATCH 741/966] Change error code for MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL. Signed-off-by: Mateusz Starzyk --- include/mbedtls/error.h | 2 +- include/mbedtls/gcm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h index 27420ce4fc..8b2b9ea580 100644 --- a/include/mbedtls/error.h +++ b/include/mbedtls/error.h @@ -56,7 +56,7 @@ * Module Nr Codes assigned * ERROR 2 0x006E 0x0001 * MPI 7 0x0002-0x0010 - * GCM 3 0x0012-0x0014 0x0013-0x0013 + * GCM 3 0x0012-0x0016 0x0013-0x0013 * THREADING 3 0x001A-0x001E * AES 5 0x0020-0x0022 0x0021-0x0025 * CAMELLIA 3 0x0024-0x0026 0x0027-0x0027 diff --git a/include/mbedtls/gcm.h b/include/mbedtls/gcm.h index a4de9191d8..7dc9dfb8ec 100644 --- a/include/mbedtls/gcm.h +++ b/include/mbedtls/gcm.h @@ -46,7 +46,7 @@ /** Bad input parameters to function. */ #define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014 /** An output buffer is too small. */ -#define MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL -0x0018 +#define MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL -0x0016 #ifdef __cplusplus extern "C" { From ba20fc98b8fe0fdde376a14ca9b61091fea45875 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Fri, 22 Oct 2021 10:39:56 +0200 Subject: [PATCH 742/966] Fix issues pointed by CI Signed-off-by: Przemyslaw Stekiel --- tests/scripts/generate_psa_tests.py | 9 +++++++-- tests/suites/test_suite_psa_crypto_generate_key.function | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index d1307ad11a..a850ea7cbf 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -96,7 +96,7 @@ def hack_dependencies_not_implemented(dependencies: List[str]) -> None: if _implemented_dependencies is None: _implemented_dependencies = \ read_implemented_dependencies('include/psa/crypto_config.h') - if not all(dep.lstrip('!') in _implemented_dependencies + if not all((dep.lstrip('!') in _implemented_dependencies or 'PSA_WANT' not in dep) for dep in dependencies): dependencies.append('DEPENDENCY_NOT_IMPLEMENTED_YET') @@ -260,8 +260,11 @@ class KeyGenerate: ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR', 'PSA_KEY_TYPE_ECC_PUBLIC_KEY') - @staticmethod + RSA_KEY_TYPES = ('PSA_KEY_TYPE_RSA_KEY_PAIR', + 'PSA_KEY_TYPE_RSA_PUBLIC_KEY') + def test_cases_for_key_type_key_generation( + self, kt: crypto_knowledge.KeyType ) -> Iterator[test_case.TestCase]: """Return test cases exercising key generation. @@ -280,6 +283,8 @@ class KeyGenerate: result = 'PSA_ERROR_INVALID_ARGUMENT' else: generate_dependencies = import_dependencies + if kt.name in self.RSA_KEY_TYPES: + generate_dependencies.append("MBEDTLS_GENPRIME") for bits in kt.sizes_to_test(): yield test_case_for_key_generation( kt.expression, bits, diff --git a/tests/suites/test_suite_psa_crypto_generate_key.function b/tests/suites/test_suite_psa_crypto_generate_key.function index 7404d382a9..d30c0e4876 100644 --- a/tests/suites/test_suite_psa_crypto_generate_key.function +++ b/tests/suites/test_suite_psa_crypto_generate_key.function @@ -38,7 +38,7 @@ void generate_key( int key_type, int bits, int result) // Verify attributes of the created key on success if (_result == PSA_SUCCESS) { - psa_key_attributes_t key_attributes = {0}; + psa_key_attributes_t key_attributes = PSA_KEY_ATTRIBUTES_INIT; PSA_ASSERT( psa_get_key_attributes( key_id, &key_attributes ) ); TEST_EQUAL( psa_get_key_lifetime( &key_attributes ), 0 ); TEST_EQUAL( psa_get_key_usage_flags( &key_attributes ), 0 ); From 61a8b2daf210beb6a78e6065d725d839241ce1ce Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 21 Oct 2021 11:46:42 +0200 Subject: [PATCH 743/966] Add changelog entry for CCM*-no-tag. Signed-off-by: Mateusz Starzyk --- ChangeLog.d/ccm_star_no_tag.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 ChangeLog.d/ccm_star_no_tag.txt diff --git a/ChangeLog.d/ccm_star_no_tag.txt b/ChangeLog.d/ccm_star_no_tag.txt new file mode 100644 index 0000000000..88c0d1fb1f --- /dev/null +++ b/ChangeLog.d/ccm_star_no_tag.txt @@ -0,0 +1,8 @@ +Changes + * Ignore plaintext/ciphertext lengths for CCM*-no-tag operations. + For CCM* encryption/decryption without authentication, input + length will be ignored. + * Add support for CCM*-no-tag cipher to the PSA. + Currently only 13-byte long IV's are supported. + For decryption a minimum of 16-byte long input is expected. + These restrictions may be subject to change. From a5a2399cb0543d73fb0957c0cce8f1963252165d Mon Sep 17 00:00:00 2001 From: Aaron Erhardt Date: Fri, 22 Oct 2021 22:05:04 +0200 Subject: [PATCH 744/966] Remove mode param from AES-CTR docs Signed-off-by: Aaron Erhardt --- include/mbedtls/aes.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/mbedtls/aes.h b/include/mbedtls/aes.h index becbfae1d9..e381c11838 100644 --- a/include/mbedtls/aes.h +++ b/include/mbedtls/aes.h @@ -511,10 +511,6 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, * \brief This function performs an AES-CTR encryption or decryption * operation. * - * This function performs the operation defined in the \p mode - * parameter (encrypt/decrypt), on the input data buffer - * defined in the \p input parameter. - * * Due to the nature of CTR, you must use the same key schedule * for both encryption and decryption operations. Therefore, you * must use the context initialized with mbedtls_aes_setkey_enc() From 9bb56dc6bed9a5a4ace7d970aab928a68e7b7668 Mon Sep 17 00:00:00 2001 From: Aaron Erhardt Date: Fri, 22 Oct 2021 22:05:10 +0200 Subject: [PATCH 745/966] Add return info to sha256 docs Signed-off-by: Aaron Erhardt --- include/mbedtls/sha256.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/mbedtls/sha256.h b/include/mbedtls/sha256.h index 9e6f59dc4b..0cbbac11f2 100644 --- a/include/mbedtls/sha256.h +++ b/include/mbedtls/sha256.h @@ -167,6 +167,9 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, * for SHA-256, \c 28 bytes for SHA-224. * \param is224 Determines which function to use. This must be * either \c 0 for SHA-256, or \c 1 for SHA-224. + * + * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha256( const unsigned char *input, size_t ilen, From 61e35e0047271167720935ecf458778c1bd9ffae Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 16 Sep 2021 18:59:08 +0800 Subject: [PATCH 746/966] tls13: add generate handshake keys Signed-off-by: Jerry Yu --- library/ssl_misc.h | 23 ++++++++ library/ssl_tls13_keys.c | 117 +++++++++++++++++++++++++++++++++++++++ library/ssl_tls13_keys.h | 36 +++++------- 3 files changed, 155 insertions(+), 21 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 9041c51d2c..b801499ca1 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -508,6 +508,27 @@ struct mbedtls_ssl_key_set }; typedef struct mbedtls_ssl_key_set mbedtls_ssl_key_set; +typedef struct +{ + unsigned char binder_key [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char client_early_traffic_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char early_exporter_master_secret[ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_early_secrets; + +typedef struct +{ + unsigned char client_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char server_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_handshake_secrets; + +typedef struct +{ + unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_application_secrets; + /* * This structure contains the parameters only needed during handshake. */ @@ -715,6 +736,8 @@ struct mbedtls_ssl_handshake_params unsigned char handshake[MBEDTLS_TLS1_3_MD_MAX_SIZE]; unsigned char app [MBEDTLS_TLS1_3_MD_MAX_SIZE]; } tls1_3_master_secrets; + + mbedtls_ssl_tls1_3_handshake_secrets tls1_3_hs_secrets; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index b07c1c3b9e..a20fa51507 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -846,4 +846,121 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ) return( 0 ); } +/* mbedtls_ssl_tls1_3_generate_handshake_keys() generates keys necessary for + * protecting the handshake messages, as described in Section 7 of TLS 1.3. */ +int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, + mbedtls_ssl_key_set *traffic_keys ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + mbedtls_md_type_t md_type; + mbedtls_md_info_t const *md_info; + size_t md_size; + + unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; + size_t transcript_len; + + mbedtls_cipher_info_t const *cipher_info; + size_t keylen, ivlen; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls1_3_generate_handshake_keys" ) ); + + cipher_info = mbedtls_cipher_info_from_type( + ssl->handshake->ciphersuite_info->cipher ); + keylen = cipher_info->key_bitlen >> 3; + ivlen = cipher_info->iv_size; + + md_type = ssl->handshake->ciphersuite_info->mac; + md_info = mbedtls_md_info_from_type( md_type ); + md_size = mbedtls_md_get_size( md_info ); + + ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type, + transcript, + sizeof( transcript ), + &transcript_len ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, + "mbedtls_ssl_get_handshake_transcript", + ret ); + return( ret ); + } + + ret = mbedtls_ssl_tls1_3_derive_handshake_secrets( md_type, + ssl->handshake->tls1_3_master_secrets.handshake, + transcript, transcript_len, + &ssl->handshake->tls1_3_hs_secrets ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_handshake_secrets", + ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "Client handshake traffic secret", + ssl->handshake->tls1_3_hs_secrets.client_handshake_traffic_secret, + md_size ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "Server handshake traffic secret", + ssl->handshake->tls1_3_hs_secrets.server_handshake_traffic_secret, + md_size ); + + /* + * Export client handshake traffic secret + */ +#if defined(MBEDTLS_SSL_EXPORT_KEYS) + if( ssl->f_export_keys != NULL ) + { + ssl->f_export_keys( ssl->p_export_keys, + MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_HANDSHAKE_TRAFFIC_SECRET, + ssl->handshake->tls1_3_hs_secrets.client_handshake_traffic_secret, + md_size, + ssl->handshake->randbytes + 32, + ssl->handshake->randbytes, + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + + ssl->f_export_keys( ssl->p_export_keys, + MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_HANDSHAKE_TRAFFIC_SECRET, + ssl->handshake->tls1_3_hs_secrets.server_handshake_traffic_secret, + md_size, + ssl->handshake->randbytes + 32, + ssl->handshake->randbytes, + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + } +#endif /* MBEDTLS_SSL_EXPORT_KEYS */ + + ret = mbedtls_ssl_tls1_3_make_traffic_keys( md_type, + ssl->handshake->tls1_3_hs_secrets.client_handshake_traffic_secret, + ssl->handshake->tls1_3_hs_secrets.server_handshake_traffic_secret, + md_size, + keylen, ivlen, traffic_keys ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_make_traffic_keys", ret ); + goto exit; + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "client_handshake write_key", + traffic_keys->client_write_key, + traffic_keys->key_len); + + MBEDTLS_SSL_DEBUG_BUF( 4, "server_handshake write_key", + traffic_keys->server_write_key, + traffic_keys->key_len); + + MBEDTLS_SSL_DEBUG_BUF( 4, "client_handshake write_iv", + traffic_keys->client_write_iv, + traffic_keys->iv_len); + + MBEDTLS_SSL_DEBUG_BUF( 4, "server_handshake write_iv", + traffic_keys->server_write_iv, + traffic_keys->iv_len); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls1_3_generate_handshake_keys" ) ); + +exit: + + return( ret ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 866aae9117..602d06def4 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -70,27 +70,6 @@ extern const struct mbedtls_ssl_tls1_3_labels_struct mbedtls_ssl_tls1_3_labels; #define MBEDTLS_SSL_TLS1_3_KEY_SCHEDULE_MAX_CONTEXT_LEN \ MBEDTLS_MD_MAX_SIZE -typedef struct -{ - unsigned char binder_key [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char client_early_traffic_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char early_exporter_master_secret[ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_early_secrets; - -typedef struct -{ - unsigned char client_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_handshake_secrets; - -typedef struct -{ - unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_application_secrets; - /* Maximum desired length for expanded key material generated * by HKDF-Expand-Label. * @@ -553,4 +532,19 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, */ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ); +/** + * \brief Compute TLS 1.3 handshake traffic keys. + * + * \param ssl The SSL context to operate on. This must be in + * key schedule stage \c Handshake, see + * mbedtls_ssl_tls13_key_schedule_stage_handshake(). + * \param traffic_keys The address at which to store the handshake traffic key + * keys. This must be writable but may be uninitialized. + * + * \returns \c 0 on success. + * \returns A negative error code on failure. + */ +int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, + mbedtls_ssl_key_set *traffic_keys ); + #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From a0650ebb9d99204d1e14183ee2da0893ade4efab Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 17:14:45 +0800 Subject: [PATCH 747/966] tls13: add handshake key schedule Signed-off-by: Jerry Yu --- library/ssl_tls13_keys.c | 92 ++++++++++++++++++++++++++++++++++++++++ library/ssl_tls13_keys.h | 20 ++++++++- 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index a20fa51507..165cf4cbed 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -963,4 +963,96 @@ exit: return( ret ); } +static int ssl_tls1_3_complete_ephemeral_secret( mbedtls_ssl_context *ssl, + unsigned char *secret, + size_t secret_len, + unsigned char **actual_secret, + size_t *actual_len ) +{ + int ret = 0; + + *actual_secret = NULL; + *actual_len = 0; + /* + * Compute ECDHE secret for second stage of secret evolution. + */ +#if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED) + if( mbedtls_ssl_tls1_3_some_ephemeral_enabled( ssl ) ) + { + if( mbedtls_ssl_tls13_named_group_is_ecdhe( + ssl->handshake->offered_group_id ) ) + { +#if defined(MBEDTLS_ECDH_C) + ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, + actual_len, secret, secret_len, + ssl->conf->f_rng, + ssl->conf->p_rng ); + + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_calc_secret", ret ); + return( ret ); + } + + *actual_secret = secret; +#endif /* MBEDTLS_ECDH_C */ + } + else if( mbedtls_ssl_tls13_named_group_is_dhe( + ssl->handshake->offered_group_id ) ) + { + /* TODO: Not supported yet */ + } + } +#else + ((void) ssl); + ((void) secret); + ((void) secret_len); +#endif /* MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED */ + + return( ret ); +} + +int mbedtls_ssl_tls1_3_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + mbedtls_md_type_t const md_type = ssl->handshake->ciphersuite_info->mac; +#if defined(MBEDTLS_DEBUG_C) + mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); + size_t const md_size = mbedtls_md_get_size( md_info ); +#endif /* MBEDTLS_DEBUG_C */ + + unsigned char *ephemeral; + size_t ephemeral_len; + + unsigned char ecdhe[66]; /* TODO: Magic constant! */ + + /* Finalize calculation of ephemeral input to key schedule, if present. */ + ret = ssl_tls1_3_complete_ephemeral_secret( ssl, ecdhe, sizeof( ecdhe ), + &ephemeral, &ephemeral_len ); + if( ret != 0 ) + return( ret ); + + /* + * Compute HandshakeSecret + */ + + ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, + ssl->handshake->tls1_3_master_secrets.early, + ephemeral, ephemeral_len, + ssl->handshake->tls1_3_master_secrets.handshake ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_evolve_secret", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "Handshake secret", + ssl->handshake->tls1_3_master_secrets.handshake, md_size ); + +#if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED) + mbedtls_platform_zeroize( ecdhe, sizeof( ecdhe ) ); +#endif /* MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED */ + return( 0 ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 602d06def4..536d976cd8 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -532,12 +532,30 @@ int mbedtls_ssl_tls13_populate_transform( mbedtls_ssl_transform *transform, */ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ); +/** + * \brief Transition into handshake stage of TLS 1.3 key schedule. + * + * The TLS 1.3 key schedule can be viewed as a simple state machine + * with states Initial -> Early -> Handshake -> Application, and + * this function represents the Early -> Handshake transition. + * + * In the handshake stage, mbedtls_ssl_tls1_3_generate_handshake_keys() + * can be used to derive the handshake traffic keys. + * + * \param ssl The SSL context to operate on. This must be in key schedule + * stage \c Early. + * + * \returns \c 0 on success. + * \returns A negative error code on failure. + */ +int mbedtls_ssl_tls1_3_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ); + /** * \brief Compute TLS 1.3 handshake traffic keys. * * \param ssl The SSL context to operate on. This must be in * key schedule stage \c Handshake, see - * mbedtls_ssl_tls13_key_schedule_stage_handshake(). + * mbedtls_ssl_tls1_3_key_schedule_stage_handshake(). * \param traffic_keys The address at which to store the handshake traffic key * keys. This must be writable but may be uninitialized. * From 1efa815db78808b70c7e0856a8ebb944376d82a2 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 9 Sep 2021 15:42:32 +0800 Subject: [PATCH 748/966] tls13: add ecdh_read_public Signed-off-by: Jerry Yu --- library/ecdh.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ library/ecdh_misc.h | 6 +++++ 2 files changed, 64 insertions(+) diff --git a/library/ecdh.c b/library/ecdh.c index b72bd1fe08..0067e0bd4b 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -806,6 +806,64 @@ int mbedtls_ecdh_setup_no_everest( mbedtls_ecdh_context *ctx, #endif } +static int ecdh_tls1_3_read_public_internal( mbedtls_ecdh_context_mbed *ctx, + const unsigned char *buf, + size_t blen ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + const unsigned char *p = buf; + const unsigned char *end = buf + blen; + size_t data_len; + + if( end - p < 3 ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + data_len = MBEDTLS_GET_UINT16_BE( p, 0 ); + p += 2; + + if( data_len < 1 || data_len != ( blen - 2 ) ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + + /* + * Save buffer start for read_binary and update buf + */ + if( ( ret = mbedtls_ecp_point_read_binary( &ctx->grp, + &ctx->Qp, p, data_len ) ) != 0) + { + return( ret ); + } + + return( 0 ); +} + +/* + * Parse and import the client's TLS 1.3 public value + */ +int mbedtls_ecdh_tls1_3_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, + size_t blen ) +{ + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( buf != NULL ); + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_tls1_3_read_public_internal( ctx, buf, blen ) ); +#else + switch( ctx->var ) + { +#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) + case MBEDTLS_ECDH_VARIANT_EVEREST: + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); +#endif + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_tls1_3_read_public_internal( &ctx->ctx.mbed_ecdh, + buf, blen ) ); + default: + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } +#endif +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_ECDH_C */ diff --git a/library/ecdh_misc.h b/library/ecdh_misc.h index d1342f8b91..94d31394b1 100644 --- a/library/ecdh_misc.h +++ b/library/ecdh_misc.h @@ -43,6 +43,12 @@ int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, int ( *f_rng )( void *, unsigned char *, size_t ), void *p_rng ); +/* + * TLS 1.3 version of mbedtls_ecdh_read_public in ecdh.h + */ +int mbedtls_ecdh_tls1_3_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, + size_t blen ); #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From e1b9c297b9c9ce845a1dd325d9cfd69fa5f12465 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 10 Sep 2021 10:08:31 +0800 Subject: [PATCH 749/966] Add read_server_hello Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 584 ++++++++++++++++++++++++++++++++++++- 1 file changed, 581 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 633bb8da2e..054a45d7f6 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -29,11 +29,14 @@ #include "mbedtls/debug.h" #include "mbedtls/error.h" +#include "mbedtls/platform.h" #include "ssl_misc.h" #include "ecdh_misc.h" +#include "ssl_tls13_keys.h" #define CLIENT_HELLO_RANDOM_LEN 32 +#define SERVER_HELLO_RANDOM_LEN 32 /* Write extensions */ @@ -92,6 +95,36 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, return( 0 ); } +static int ssl_tls1_3_parse_supported_versions_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + /* TODO: Implement full version and remove force version set in + * ssl_tls_parse_server_hello. + * + * From page 40,RFC 8446 + * If supported_versions extension is present, clients MUST ignore the + * ServerHello.legacy_version value and MUST use only the + * "supported_versions" extension to determine the selected version. If + * the "supported_versions" extension in the ServerHello contains a + * version not offered by the client or contains a version prior to + * TLS 1.3, the client MUST abort the handshake with an + * "illegal_parameter" alert. + */ + + ((void) ssl); + + if( len != 2 || + buf[0] != MBEDTLS_SSL_MAJOR_VERSION_3 || + buf[1] != MBEDTLS_SSL_MINOR_VERSION_4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "unexpected version" ) ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + + return( 0 ); +} + #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* @@ -452,6 +485,125 @@ cleanup: return( ret ); } +#if defined(MBEDTLS_ECDH_C) + +/* TODO: Code for MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED missing */ +static int ssl_tls1_3_check_ecdh_params( const mbedtls_ssl_context *ssl ) +{ + const mbedtls_ecp_curve_info *curve_info; + mbedtls_ecp_group_id grp_id; +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + grp_id = ssl->handshake->ecdh_ctx.grp.id; +#else + grp_id = ssl->handshake->ecdh_ctx.grp_id; +#endif + + curve_info = mbedtls_ecp_curve_info_from_grp_id( grp_id ); + if( curve_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDH curve: %s", curve_info->name ) ); + +#if defined(MBEDTLS_ECP_C) + if( mbedtls_ssl_check_curve( ssl, grp_id ) != 0 ) +#else + if( ssl->handshake->ecdh_ctx.grp.nbits < 163 || + ssl->handshake->ecdh_ctx.grp.nbits > 521 ) +#endif + return( -1 ); + + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_QP ); + + return( 0 ); +} + +/* The ssl_tls1_3_parse_key_share_ext() function is used + * by the client to parse a KeyShare extension in + * a ServerHello message. + * + * The server only provides a single KeyShareEntry. + */ +static int ssl_tls1_3_read_public_ecdhe_share( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t len ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + ret = mbedtls_ecdh_tls1_3_read_public( &ssl->handshake->ecdh_ctx, + buf, len ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ecdh_tls13_read_public" ), ret ); + return( ret ); + } + + if( ssl_tls1_3_check_ecdh_params( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ssl_tls1_3_check_ecdh_params() failed!" ) ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + + return( 0 ); +} +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */ + +/* + * Parse key_share extension in Server Hello + * struct { + * KeyShareEntry server_share; + * } KeyShareServerHello; + * struct { + * NamedGroup group; + * opaque key_exchange<1..2^16-1>; + * } KeyShareEntry; + */ +static int ssl_tls1_3_parse_key_share_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ) +{ + int ret = 0; + const unsigned char *p = buf; + uint16_t server_share_group, offered_group; + + /* server_share_group (2 bytes) */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2); + server_share_group = MBEDTLS_GET_UINT16_BE( p, 0 ); + p += 2; + + /* Check that chosen group matches the one we offered. */ + offered_group = ssl->handshake->offered_group_id; + if( offered_group != server_share_group ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, + ( "Invalid server key share, our group %u, their group %u", + (unsigned) offered_group, (unsigned) server_share_group ) ); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + } + +#if defined(MBEDTLS_ECDH_C) + if( mbedtls_ssl_tls13_named_group_is_ecdhe( server_share_group ) ) + { + /* Complete ECDHE key agreement */ + ret = ssl_tls1_3_read_public_ecdhe_share( ssl, p, end - p ); + if( ret != 0 ) + return( ret ); + } +#endif /* MBEDTLS_ECDH_C */ + else if( 0 /* other KEMs? */ ) + { + /* Do something */ + } + else + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + ssl->handshake->extensions_present |= MBEDTLS_SSL_EXT_KEY_SHARE; + return( ret ); +} + #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ /* Write cipher_suites @@ -738,13 +890,439 @@ cleanup: } /* + * Functions for parsing and processing ServerHello + */ +static int ssl_server_hello_is_hrr( unsigned const char *buf ) +{ + const unsigned char magic_hrr_string[32] = + { 0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, + 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91, + 0xC2, 0xA2, 0x11, 0x16, 0x7A, 0xBB, 0x8C, 0x5E, + 0x07, 0x9E, 0x09, 0xE2, 0xC8, 0xA8, 0x33 ,0x9C }; + + /* Check whether this message is a HelloRetryRequest ( HRR ) message. + * + * ServerHello and HRR are only distinguished by Random set to the + * special value of the SHA-256 of "HelloRetryRequest". + * + * struct { + * ProtocolVersion legacy_version = 0x0303; + * Random random; + * opaque legacy_session_id_echo<0..32>; + * CipherSuite cipher_suite; + * uint8 legacy_compression_method = 0; + * Extension extensions<6..2 ^ 16 - 1>; + * } ServerHello; + * + */ + if( memcmp( buf + 2, magic_hrr_string, + sizeof( magic_hrr_string ) ) == 0 ) + { + return( 1 ); + } + + return( 0 ); +} + +/* Fetch and preprocess + * Returns a negative value on failure, and otherwise + * - SSL_SERVER_HELLO_COORDINATE_HELLO or + * - SSL_SERVER_HELLO_COORDINATE_HRR + * to indicate which message is expected and to be parsed next. */ +#define SSL_SERVER_HELLO_COORDINATE_HELLO 0 +#define SSL_SERVER_HELLO_COORDINATE_HRR 1 +static int ssl_server_hello_coordinate( mbedtls_ssl_context *ssl, + unsigned char **buf, + size_t *buf_len ) +{ + int ret; + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_read_record( ssl, 0 ) ); + + /* TBD: If we do an HRR, keep track of the number + * of ClientHello's we sent, and fail if it + * exceeds the configured threshold. */ + + if( ( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) || + ( ssl->in_msg[0] != MBEDTLS_SSL_HS_SERVER_HELLO ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "unexpected message" ) ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE, + MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + } + + *buf = ssl->in_msg + 4; + *buf_len = ssl->in_hslen - 4; + + if( ssl_server_hello_is_hrr( ssl->in_msg + 4 ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received HelloRetryRequest message" ) ); + ret = SSL_SERVER_HELLO_COORDINATE_HRR; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received ServerHello message" ) ); + ret = SSL_SERVER_HELLO_COORDINATE_HELLO; + } + +cleanup: + + return( ret ); +} + +static int ssl_tls1_3_check_server_hello_session_id( mbedtls_ssl_context *ssl, + const unsigned char **buf, + const unsigned char *end ) +{ + const unsigned char *p = *buf; + size_t recv_id_len; + + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 1 ); + recv_id_len = *p++ ; + + MBEDTLS_SSL_CHK_BUF_PTR( p, end, recv_id_len ); + + /* legacy_session_id_echo */ + if( ssl->session_negotiate->id_len != recv_id_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Mismatch of session id length:" + " id_len = %" MBEDTLS_PRINTF_SIZET + " , recv_id_len = %" MBEDTLS_PRINTF_SIZET, + ssl->session_negotiate->id_len, recv_id_len ) ); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + } + + if( memcmp( ssl->session_negotiate->id, p , recv_id_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unexpected legacy_session_id_echo" ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "Expected Session ID", + ssl->session_negotiate->id, + ssl->session_negotiate->id_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "Received Session ID", p, + ssl->session_negotiate->id_len ); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + } + + p += recv_id_len; + *buf = p; + + MBEDTLS_SSL_DEBUG_BUF( 3, "Session ID", ssl->session_negotiate->id, + recv_id_len ); + return( 0 ); +} + +static int ssl_tls1_3_cipher_suite_is_offered( mbedtls_ssl_context *ssl, + uint16_t cipher_suite ) +{ + /* Check whether we have offered this ciphersuite */ + for ( int i = 0; ssl->conf->ciphersuite_list[i] != 0; i++ ) + { + if( ssl->conf->ciphersuite_list[i] == cipher_suite ) + { + return( 1 ); + } + } + return( 0 ); +} + +/* Parse ServerHello message and configure context + * + * struct { + * ProtocolVersion legacy_version = 0x0303; // TLS 1.2 + * Random random; + * opaque legacy_session_id_echo<0..32>; + * CipherSuite cipher_suite; + * uint8 legacy_compression_method = 0; + * Extension extensions<6..2 ^ 16 - 1>; + * } ServerHello; + */ +static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ) +{ + + int ret; + const unsigned char *p = buf; + size_t field_len; /* Length of field */ + const unsigned char *ext_end; /* Pointer to end of individual extension */ + uint16_t cipher_suite; + const mbedtls_ssl_ciphersuite_t* ciphersuite_info; + + /* + * Check there is space for minimal fields + * + * - legacy_version ( 2 bytes) + * - random (32 bytes) + * - legacy_session_id_echo ( 1 byte ), minimum size + * - cipher_suite ( 2 bytes) + * - legacy_compression_method ( 1 byte ) + */ + if( mbedtls_ssl_chk_buf_ptr( p, end, 38 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, + ( "bad server hello message - min size not reached" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "server hello", p, end - p ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, version", p, 2 ); + + /* legacy_version must be 0x0303 (TLS 1.2) */ + if( !( p[0] == MBEDTLS_SSL_MAJOR_VERSION_3 && + p[1] == MBEDTLS_SSL_MINOR_VERSION_3 ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unsupported version of TLS." ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION, + MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION ); + return( MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION ); + } + p += 2; + /* Internally we use the correct 1.3 version + * TODO: Remove below lines after supported_versions extension + * finished. + */ + ssl->major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; + ssl->minor_ver = MBEDTLS_SSL_MINOR_VERSION_4; + + /* Store server-provided random values */ + memcpy( ssl->handshake->randbytes + CLIENT_HELLO_RANDOM_LEN, p, + SERVER_HELLO_RANDOM_LEN ); + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, random bytes", + p, SERVER_HELLO_RANDOM_LEN ); + p += SERVER_HELLO_RANDOM_LEN; + + /* Read and store session id (legacy_session_id_echo) */ + if( ssl_tls1_3_check_server_hello_session_id( ssl, &p, end ) != 0 ) + { + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, + MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + } + + /* Read server-selected ciphersuite, + Check if there is space for cipher_suite. */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2); + cipher_suite = MBEDTLS_GET_UINT16_BE( p, 0 ); + p += 2; + + /* Configure ciphersuites */ + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( cipher_suite ); + ssl->handshake->ciphersuite_info = ciphersuite_info; + if( ciphersuite_info == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite info for %04x not found", + cipher_suite ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + } + + mbedtls_ssl_optimize_checksum( ssl, ssl->handshake->ciphersuite_info ); + + ssl->session_negotiate->ciphersuite = cipher_suite; + + ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( cipher_suite ); + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: ( %04x ) - %s", + cipher_suite, ciphersuite_info->name ) ); + +#if defined(MBEDTLS_HAVE_TIME) + ssl->session_negotiate->start = time( NULL ); +#endif /* MBEDTLS_HAVE_TIME */ + + /* Check whether we have offered this ciphersuite */ + /* Via the force_ciphersuite version we may have instructed the client */ + /* to use a difference ciphersuite. */ + if( ssl_tls1_3_cipher_suite_is_offered( ssl, cipher_suite ) == 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite(%04x) is not in offered list", + cipher_suite ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + + /* Ensure that compression method is set to zero + * + * legacy_compression_method == 0 ( 1 byte) + */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 1 ); + if( p[0] != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, + MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + } + p++; + + /* Check there is space fore extensions_length */ + if( mbedtls_ssl_chk_buf_ptr( p, end, 2 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + /* Get length of extensions field (2 bytes)*/ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); + field_len = MBEDTLS_GET_UINT16_BE( p, 0 ); + p += 2; + /* Check there is space for extensions_data */ + if( mbedtls_ssl_chk_buf_ptr( p, end, field_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + /* Set end of extensions */ + ext_end = p + field_len; + + MBEDTLS_SSL_DEBUG_MSG( 3, + ( "server hello, total extension length: %" MBEDTLS_PRINTF_SIZET , + field_len ) ); + + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello extensions", p, field_len ); + + while ( p < ext_end ) + { + unsigned int extension_type; + size_t extension_data_len; + + /* + * .... + * Extension extensions<6..2 ^ 16 - 1>; + * .... + * struct { + * ExtensionType extension_type; + * opaque extension_data<0..2^16-1>; + * } Extension; + * extension_type (2 bytes) + * extension_data_length (2 bytes) + */ + MBEDTLS_SSL_CHK_BUF_PTR( p, ext_end, 4 ); + extension_type = MBEDTLS_GET_UINT16_BE( p, 0 ); + extension_data_len = MBEDTLS_GET_UINT16_BE( p, 2 ); + p += 4; + + if( mbedtls_ssl_chk_buf_ptr( p, ext_end, extension_data_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + switch( extension_type ) + { + case MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS: + MBEDTLS_SSL_DEBUG_MSG( 3, + ( "found supported_versions extension" ) ); + + ret = ssl_tls1_3_parse_supported_versions_ext( ssl, + p, extension_data_len ); + if( ret != 0 ) + return( ret ); + break; + + case MBEDTLS_TLS_EXT_PRE_SHARED_KEY: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found pre_shared_key extension." ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "pre_shared_key:Not supported yet" ) ); + break; + +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + case MBEDTLS_TLS_EXT_KEY_SHARE: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found key_shares extension" ) ); + if( ( ret = ssl_tls1_3_parse_key_share_ext( ssl, + p, p + extension_data_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, + "ssl_tls1_3_parse_key_share_ext", + ret ); + return( ret ); + } + break; +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + + default: + MBEDTLS_SSL_DEBUG_MSG( 3, + ( "unknown extension found: %u ( ignoring )", + extension_type ) ); + } + + p += extension_data_len; + } + + return( 0 ); +} + +static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) +{ + ((void) ssl); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "postprocess hasn't been implemented" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} + +/* + * Wait and Parse ServerHello handshake message. * Handler for MBEDTLS_SSL_SERVER_HELLO */ static int ssl_tls1_3_process_server_hello( mbedtls_ssl_context *ssl ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); - return( 0 ); + int ret = 0; + unsigned char *buf; + size_t buf_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> %s", __func__ ) ); + + /* Coordination step + * - Fetch record + * - Make sure it's either a ServerHello or a HRR. + * - Switch processing routine in case of HRR + */ + + ssl->major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; + ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; + + + ret = ssl_server_hello_coordinate( ssl, &buf, &buf_len ); + /* Parsing step + * We know what message to expect by now and call + * the respective parsing function. + */ + if( ret == SSL_SERVER_HELLO_COORDINATE_HELLO ) + { + MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_parse_server_hello( ssl, buf, + buf + buf_len ) ); + + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, + MBEDTLS_SSL_HS_SERVER_HELLO, + buf, buf_len ); + + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_server_hello( ssl ) ); + } + else if( ret == SSL_SERVER_HELLO_COORDINATE_HRR ) + { + /* TODO: Implement HRR in future #4915 */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "HRR hasn't been implemented" ) ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE, + MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + } + +cleanup: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= %s", __func__ ) ); + return( ret ); } /* From 0b17784932d4094e39f0ec090cb2663012ef2821 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sun, 5 Sep 2021 19:41:30 +0800 Subject: [PATCH 750/966] Add finalize function Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 98 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 5 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 054a45d7f6..5502c885f8 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1265,11 +1265,99 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, return( 0 ); } -static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) { - ((void) ssl); - MBEDTLS_SSL_DEBUG_MSG( 1, ( "postprocess hasn't been implemented" ) ); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + int ret; + mbedtls_ssl_key_set traffic_keys; + mbedtls_ssl_transform *transform_handshake; + + /* We need to set the key exchange algorithm based on the + * following rules: + * + * 1 ) IF PRE_SHARED_KEY extension was received + * THEN set MBEDTLS_KEY_EXCHANGE_PSK + * 2 ) IF PRE_SHARED_KEY extension && KEY_SHARE was received + * THEN set MBEDTLS_KEY_EXCHANGE_ECDHE_PSK + * 3 ) IF KEY_SHARES extension was received && SIG_ALG extension received + * THEN set MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA + * ELSE unknown key exchange mechanism. + */ + + if( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_PRE_SHARED_KEY ) + { + if( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_KEY_SHARE ) + ssl->handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; + else + ssl->handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; + } + else if( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_KEY_SHARE ) + ssl->handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unknown key exchange." ) ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + + /* Start the TLS 1.3 key schedule: Set the PSK and derive early secret. + * + * TODO: We don't have to do this in case we offered 0-RTT and the + * server accepted it. In this case, we could skip generating + * the early secret. */ + ret = mbedtls_ssl_tls1_3_key_schedule_stage_early( ssl ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_key_schedule_stage_early_data", + ret ); + return( ret ); + } + + /* Compute handshake secret */ + ret = mbedtls_ssl_tls1_3_key_schedule_stage_handshake( ssl ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_master_secret", ret ); + return( ret ); + } + + /* Next evolution in key schedule: Establish handshake secret and + * key material. */ + ret = mbedtls_ssl_tls1_3_generate_handshake_keys( ssl, &traffic_keys ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, + "mbedtls_ssl_tls1_3_generate_handshake_keys", ret ); + return( ret ); + } + + transform_handshake = + mbedtls_calloc( 1, sizeof( mbedtls_ssl_transform ) ); + if( transform_handshake == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + ret = mbedtls_ssl_tls13_populate_transform( transform_handshake, + ssl->conf->endpoint, + ssl->session_negotiate->ciphersuite, + &traffic_keys, + ssl ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_populate_transform", ret ); + return( ret ); + } + + ssl->handshake->transform_handshake = transform_handshake; + mbedtls_ssl_set_inbound_transform( ssl, ssl->handshake->transform_handshake ); + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Switch to handshake keys for inbound traffic" ) ); + ssl->session_in = ssl->session_negotiate; + + /* + * State machine update + */ + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); + + mbedtls_platform_zeroize( &traffic_keys, sizeof( traffic_keys ) ); + return( 0 ); } /* @@ -1308,7 +1396,7 @@ static int ssl_tls1_3_process_server_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_HS_SERVER_HELLO, buf, buf_len ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_server_hello( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_finalize_server_hello( ssl ) ); } else if( ret == SSL_SERVER_HELLO_COORDINATE_HRR ) { From 4ae2d62ccee7083bf7a18d5c7db68f1dbf174ada Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 15 Sep 2021 15:34:56 +0800 Subject: [PATCH 751/966] Improve tls13 handshake test Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index e90a35226b..ec37221279 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8692,7 +8692,9 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "tls1_3 client state: 20" \ -c "tls1_3 client state: 11" \ -c "tls1_3 client state: 14" \ - -c "tls1_3 client state: 15" + -c "tls1_3 client state: 15" \ + -c "<= ssl_tls1_3_process_server_hello" \ + -c "=> ssl_tls1_3_process_server_hello" requires_gnutls_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL @@ -8713,7 +8715,9 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "tls1_3 client state: 20" \ -c "tls1_3 client state: 11" \ -c "tls1_3 client state: 14" \ - -c "tls1_3 client state: 15" + -c "tls1_3 client state: 15" \ + -c "<= ssl_tls1_3_process_server_hello" \ + -c "=> ssl_tls1_3_process_server_hello" # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From fd532e506b5ebc313e7d2ef9330d13d643bbb623 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sun, 19 Sep 2021 15:57:53 +0800 Subject: [PATCH 752/966] fix set key exchange mode issue Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 5502c885f8..463821b28d 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1274,26 +1274,38 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) /* We need to set the key exchange algorithm based on the * following rules: * - * 1 ) IF PRE_SHARED_KEY extension was received - * THEN set MBEDTLS_KEY_EXCHANGE_PSK - * 2 ) IF PRE_SHARED_KEY extension && KEY_SHARE was received - * THEN set MBEDTLS_KEY_EXCHANGE_ECDHE_PSK - * 3 ) IF KEY_SHARES extension was received && SIG_ALG extension received - * THEN set MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA + * 1) IF PRE_SHARED_KEY extension was received + * THEN set KEY_EXCHANGE_MODE_PSK_EPHEMERAL; + * 2) IF PRE_SHARED_KEY extension && KEY_SHARE was received + * THEN set KEY_EXCHANGE_MODE_PSK; + * 3) IF KEY_SHARES extension was received && SIG_ALG extension received + * THEN set KEY_EXCHANGE_MODE_EPHEMERAL * ELSE unknown key exchange mechanism. */ - if( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_PRE_SHARED_KEY ) { if( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_KEY_SHARE ) - ssl->handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; + { + /* Condition 2) */ + ssl->handshake->tls1_3_kex_modes = + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; + } else - ssl->handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; + { + /* Condition 1) */ + ssl->handshake->tls1_3_kex_modes = + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; + } + } + else if( ( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_KEY_SHARE ) ) + { + /* Condition 3) */ + ssl->handshake->tls1_3_kex_modes = + MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; } - else if( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_KEY_SHARE ) - ssl->handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; else { + /* ELSE case */ MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unknown key exchange." ) ); return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); } From de4fb2cc346be9b977ead03a9e932abc575b3c57 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sun, 19 Sep 2021 18:05:08 +0800 Subject: [PATCH 753/966] Apply check read ptr macro Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 52 +++++++++----------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 463821b28d..57a0b2882a 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -570,7 +570,7 @@ static int ssl_tls1_3_parse_key_share_ext( mbedtls_ssl_context *ssl, uint16_t server_share_group, offered_group; /* server_share_group (2 bytes) */ - MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2); server_share_group = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; @@ -979,10 +979,10 @@ static int ssl_tls1_3_check_server_hello_session_id( mbedtls_ssl_context *ssl, const unsigned char *p = *buf; size_t recv_id_len; - MBEDTLS_SSL_CHK_BUF_PTR( p, end, 1 ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 1 ); recv_id_len = *p++ ; - MBEDTLS_SSL_CHK_BUF_PTR( p, end, recv_id_len ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, recv_id_len ); /* legacy_session_id_echo */ if( ssl->session_negotiate->id_len != recv_id_len ) @@ -1042,13 +1042,12 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end ) { - int ret; const unsigned char *p = buf; size_t field_len; /* Length of field */ const unsigned char *ext_end; /* Pointer to end of individual extension */ uint16_t cipher_suite; - const mbedtls_ssl_ciphersuite_t* ciphersuite_info; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info; /* * Check there is space for minimal fields @@ -1059,14 +1058,7 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, * - cipher_suite ( 2 bytes) * - legacy_compression_method ( 1 byte ) */ - if( mbedtls_ssl_chk_buf_ptr( p, end, 38 ) != 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, - ( "bad server hello message - min size not reached" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, - MBEDTLS_ERR_SSL_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 38 ); MBEDTLS_SSL_DEBUG_BUF( 4, "server hello", p, end - p ); @@ -1106,7 +1098,7 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, /* Read server-selected ciphersuite, Check if there is space for cipher_suite. */ - MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2); cipher_suite = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; @@ -1153,7 +1145,7 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, * * legacy_compression_method == 0 ( 1 byte) */ - MBEDTLS_SSL_CHK_BUF_PTR( p, end, 1 ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 1 ); if( p[0] != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); @@ -1164,26 +1156,13 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, p++; /* Check there is space fore extensions_length */ - if( mbedtls_ssl_chk_buf_ptr( p, end, 2 ) != 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, - MBEDTLS_ERR_SSL_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } - + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); /* Get length of extensions field (2 bytes)*/ - MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); field_len = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; + /* Check there is space for extensions_data */ - if( mbedtls_ssl_chk_buf_ptr( p, end, field_len ) != 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, - MBEDTLS_ERR_SSL_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, field_len ); /* Set end of extensions */ ext_end = p + field_len; @@ -1209,18 +1188,12 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, * extension_type (2 bytes) * extension_data_length (2 bytes) */ - MBEDTLS_SSL_CHK_BUF_PTR( p, ext_end, 4 ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, ext_end, 4 ); extension_type = MBEDTLS_GET_UINT16_BE( p, 0 ); extension_data_len = MBEDTLS_GET_UINT16_BE( p, 2 ); p += 4; - if( mbedtls_ssl_chk_buf_ptr( p, ext_end, extension_data_len ) != 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, - MBEDTLS_ERR_SSL_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, ext_end, extension_data_len ); switch( extension_type ) { @@ -1393,7 +1366,6 @@ static int ssl_tls1_3_process_server_hello( mbedtls_ssl_context *ssl ) ssl->major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; - ret = ssl_server_hello_coordinate( ssl, &buf, &buf_len ); /* Parsing step * We know what message to expect by now and call From 42920ec5a59a4453ec55f824a64c10776bf61f71 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 28 Sep 2021 14:31:15 +0800 Subject: [PATCH 754/966] tls1_3:skip handshake msg test with PSA_CRYPTO tls1_3 hasn't implemented PSA version get transcript Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index ec37221279..2b91025fd2 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8675,6 +8675,7 @@ run_test "TLS1.3: handshake dispatch test: tls1_3 only" \ requires_openssl_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS1.3: Test client hello msg work - openssl" \ "$O_NEXT_SRV -tls1_3 -msg" \ "$P_CLI debug_level=2 min_version=tls1_3 max_version=tls1_3" \ @@ -8698,6 +8699,7 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ requires_gnutls_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS1.3: Test client hello msg work - gnutls" \ "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3 --debug=4" \ "$P_CLI debug_level=2 min_version=tls1_3 max_version=tls1_3" \ From 5ccfcd4ca13577ee578ddef5b985a4d0087665e7 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 11 Oct 2021 16:39:29 +0800 Subject: [PATCH 755/966] Add local variable to represent handshake Signed-off-by: Jerry Yu --- library/ssl_tls13_keys.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 165cf4cbed..5e6182f1cf 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -826,17 +826,18 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; mbedtls_md_type_t md_type; + mbedtls_ssl_handshake_params *handshake = ssl->handshake; - if( ssl->handshake->ciphersuite_info == NULL ) + if( handshake->ciphersuite_info == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "cipher suite info not found" ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } - md_type = ssl->handshake->ciphersuite_info->mac; + md_type = handshake->ciphersuite_info->mac; ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, NULL, NULL, 0, - ssl->handshake->tls1_3_master_secrets.early ); + handshake->tls1_3_master_secrets.early ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_evolve_secret", ret ); @@ -1015,7 +1016,8 @@ static int ssl_tls1_3_complete_ephemeral_secret( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls1_3_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) { int ret = 0; - mbedtls_md_type_t const md_type = ssl->handshake->ciphersuite_info->mac; + mbedtls_ssl_handshake_params *handshake = ssl->handshake; + mbedtls_md_type_t const md_type = handshake->ciphersuite_info->mac; #if defined(MBEDTLS_DEBUG_C) mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); size_t const md_size = mbedtls_md_get_size( md_info ); @@ -1037,9 +1039,9 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) */ ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, - ssl->handshake->tls1_3_master_secrets.early, - ephemeral, ephemeral_len, - ssl->handshake->tls1_3_master_secrets.handshake ); + handshake->tls1_3_master_secrets.early, + ephemeral, ephemeral_len, + handshake->tls1_3_master_secrets.handshake ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_evolve_secret", ret ); @@ -1047,7 +1049,7 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) } MBEDTLS_SSL_DEBUG_BUF( 4, "Handshake secret", - ssl->handshake->tls1_3_master_secrets.handshake, md_size ); + handshake->tls1_3_master_secrets.handshake, md_size ); #if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED) mbedtls_platform_zeroize( ecdhe, sizeof( ecdhe ) ); From f0ac2352d6b8cc3f63902fcb4cdd72cf1190df3c Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 11 Oct 2021 17:47:07 +0800 Subject: [PATCH 756/966] Refactor key_schedule_stage_handshake Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 2 +- library/ssl_tls13_keys.c | 102 ++++++++++++++----------------------- library/ssl_tls13_keys.h | 4 +- 3 files changed, 41 insertions(+), 67 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 57a0b2882a..8a167a51d4 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1297,7 +1297,7 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) } /* Compute handshake secret */ - ret = mbedtls_ssl_tls1_3_key_schedule_stage_handshake( ssl ); + ret = mbedtls_ssl_tls13_key_schedule_stage_handshake( ssl ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_master_secret", ret ); diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 5e6182f1cf..7ba5b5f8f6 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -964,83 +964,57 @@ exit: return( ret ); } -static int ssl_tls1_3_complete_ephemeral_secret( mbedtls_ssl_context *ssl, - unsigned char *secret, - size_t secret_len, - unsigned char **actual_secret, - size_t *actual_len ) +int mbedtls_ssl_tls13_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) { - int ret = 0; - - *actual_secret = NULL; - *actual_len = 0; - /* - * Compute ECDHE secret for second stage of secret evolution. - */ -#if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED) - if( mbedtls_ssl_tls1_3_some_ephemeral_enabled( ssl ) ) - { - if( mbedtls_ssl_tls13_named_group_is_ecdhe( - ssl->handshake->offered_group_id ) ) - { -#if defined(MBEDTLS_ECDH_C) - ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, - actual_len, secret, secret_len, - ssl->conf->f_rng, - ssl->conf->p_rng ); - - if( ret != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_calc_secret", ret ); - return( ret ); - } - - *actual_secret = secret; -#endif /* MBEDTLS_ECDH_C */ - } - else if( mbedtls_ssl_tls13_named_group_is_dhe( - ssl->handshake->offered_group_id ) ) - { - /* TODO: Not supported yet */ - } - } -#else - ((void) ssl); - ((void) secret); - ((void) secret_len); -#endif /* MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED */ - - return( ret ); -} - -int mbedtls_ssl_tls1_3_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) -{ - int ret = 0; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; mbedtls_ssl_handshake_params *handshake = ssl->handshake; mbedtls_md_type_t const md_type = handshake->ciphersuite_info->mac; + size_t ephemeral_len = 0; + unsigned char ecdhe[MBEDTLS_ECP_MAX_BYTES]; #if defined(MBEDTLS_DEBUG_C) mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); size_t const md_size = mbedtls_md_get_size( md_info ); #endif /* MBEDTLS_DEBUG_C */ - unsigned char *ephemeral; - size_t ephemeral_len; - - unsigned char ecdhe[66]; /* TODO: Magic constant! */ - - /* Finalize calculation of ephemeral input to key schedule, if present. */ - ret = ssl_tls1_3_complete_ephemeral_secret( ssl, ecdhe, sizeof( ecdhe ), - &ephemeral, &ephemeral_len ); - if( ret != 0 ) - return( ret ); +#if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED) + /* + * Compute ECDHE secret used to compute the handshake secret from which + * client_handshake_traffic_secret and server_handshake_traffic_secret + * are derived in the handshake secret derivation stage. + */ + if( mbedtls_ssl_tls1_3_ephemeral_enabled( ssl ) ) + { + if( mbedtls_ssl_tls13_named_group_is_ecdhe( handshake->offered_group_id ) ) + { +#if defined(MBEDTLS_ECDH_C) + ret = mbedtls_ecdh_calc_secret( &handshake->ecdh_ctx, + &ephemeral_len, ecdhe, sizeof( ecdhe ), + ssl->conf->f_rng, + ssl->conf->p_rng ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_calc_secret", ret ); + return( ret ); + } +#endif /* MBEDTLS_ECDH_C */ + } + else if( mbedtls_ssl_tls13_named_group_is_dhe( handshake->offered_group_id ) ) + { + /* TODO: Not supported yet */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "DHE not supported." ) ); + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); + } + } +#else + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); +#endif /* MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED */ /* - * Compute HandshakeSecret + * Compute the Handshake Secret */ - ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, handshake->tls1_3_master_secrets.early, - ephemeral, ephemeral_len, + ecdhe, ephemeral_len, handshake->tls1_3_master_secrets.handshake ); if( ret != 0 ) { diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 536d976cd8..71bd90de24 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -548,14 +548,14 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ); * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls1_3_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ); /** * \brief Compute TLS 1.3 handshake traffic keys. * * \param ssl The SSL context to operate on. This must be in * key schedule stage \c Handshake, see - * mbedtls_ssl_tls1_3_key_schedule_stage_handshake(). + * mbedtls_ssl_tls13_key_schedule_stage_handshake(). * \param traffic_keys The address at which to store the handshake traffic key * keys. This must be writable but may be uninitialized. * From 4a1733831e4c1d0fd66e3ee1fef413892335f274 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 11 Oct 2021 21:45:31 +0800 Subject: [PATCH 757/966] fix various issues Signed-off-by: Jerry Yu --- library/ecdh.c | 5 +- library/ssl_tls13_client.c | 332 +++++++++++++++++++------------------ 2 files changed, 173 insertions(+), 164 deletions(-) diff --git a/library/ecdh.c b/library/ecdh.c index 0067e0bd4b..8884260e81 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -812,10 +812,9 @@ static int ecdh_tls1_3_read_public_internal( mbedtls_ecdh_context_mbed *ctx, { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const unsigned char *p = buf; - const unsigned char *end = buf + blen; size_t data_len; - if( end - p < 3 ) + if( blen < 3 ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); data_len = MBEDTLS_GET_UINT16_BE( p, 0 ); @@ -828,7 +827,7 @@ static int ecdh_tls1_3_read_public_internal( mbedtls_ecdh_context_mbed *ctx, * Save buffer start for read_binary and update buf */ if( ( ret = mbedtls_ecp_point_read_binary( &ctx->grp, - &ctx->Qp, p, data_len ) ) != 0) + &ctx->Qp, p, data_len ) ) != 0) { return( ret ); } diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 8a167a51d4..57195b3296 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -97,29 +97,19 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, static int ssl_tls1_3_parse_supported_versions_ext( mbedtls_ssl_context *ssl, const unsigned char *buf, - size_t len ) + size_t buf_len ) { - /* TODO: Implement full version and remove force version set in - * ssl_tls_parse_server_hello. - * - * From page 40,RFC 8446 - * If supported_versions extension is present, clients MUST ignore the - * ServerHello.legacy_version value and MUST use only the - * "supported_versions" extension to determine the selected version. If - * the "supported_versions" extension in the ServerHello contains a - * version not offered by the client or contains a version prior to - * TLS 1.3, the client MUST abort the handshake with an - * "illegal_parameter" alert. - */ - ((void) ssl); - if( len != 2 || + if( buf_len != 2 || buf[0] != MBEDTLS_SSL_MAJOR_VERSION_3 || buf[1] != MBEDTLS_SSL_MINOR_VERSION_4 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "unexpected version" ) ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, + MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } return( 0 ); @@ -487,7 +477,6 @@ cleanup: #if defined(MBEDTLS_ECDH_C) -/* TODO: Code for MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED missing */ static int ssl_tls1_3_check_ecdh_params( const mbedtls_ssl_context *ssl ) { const mbedtls_ecp_curve_info *curve_info; @@ -507,12 +496,7 @@ static int ssl_tls1_3_check_ecdh_params( const mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDH curve: %s", curve_info->name ) ); -#if defined(MBEDTLS_ECP_C) if( mbedtls_ssl_check_curve( ssl, grp_id ) != 0 ) -#else - if( ssl->handshake->ecdh_ctx.grp.nbits < 163 || - ssl->handshake->ecdh_ctx.grp.nbits > 521 ) -#endif return( -1 ); MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, @@ -521,20 +505,20 @@ static int ssl_tls1_3_check_ecdh_params( const mbedtls_ssl_context *ssl ) return( 0 ); } -/* The ssl_tls1_3_parse_key_share_ext() function is used +/* The ssl_tls13_parse_key_share_ext() function is used * by the client to parse a KeyShare extension in - * a ServerHello message. + * a Server Hello message. * * The server only provides a single KeyShareEntry. */ static int ssl_tls1_3_read_public_ecdhe_share( mbedtls_ssl_context *ssl, const unsigned char *buf, - size_t len ) + size_t buf_len ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; ret = mbedtls_ecdh_tls1_3_read_public( &ssl->handshake->ecdh_ctx, - buf, len ); + buf, buf_len ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ecdh_tls13_read_public" ), ret ); @@ -544,12 +528,14 @@ static int ssl_tls1_3_read_public_ecdhe_share( mbedtls_ssl_context *ssl, if( ssl_tls1_3_check_ecdh_params( ssl ) != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "ssl_tls1_3_check_ecdh_params() failed!" ) ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, + MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } return( 0 ); } -#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */ +#endif /* MBEDTLS_ECDH_C */ /* * Parse key_share extension in Server Hello @@ -561,31 +547,36 @@ static int ssl_tls1_3_read_public_ecdhe_share( mbedtls_ssl_context *ssl, * opaque key_exchange<1..2^16-1>; * } KeyShareEntry; */ -static int ssl_tls1_3_parse_key_share_ext( mbedtls_ssl_context *ssl, +static int ssl_tls13_parse_key_share_ext( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end ) { int ret = 0; const unsigned char *p = buf; - uint16_t server_share_group, offered_group; + uint16_t group, offered_group; - /* server_share_group (2 bytes) */ - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2); - server_share_group = MBEDTLS_GET_UINT16_BE( p, 0 ); + /* ... + * NamedGroup group; (2 bytes) + * ... + */ + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); + group = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; - /* Check that chosen group matches the one we offered. */ + /* Check that the chosen group matches the one we offered. */ offered_group = ssl->handshake->offered_group_id; - if( offered_group != server_share_group ) + if( offered_group != group ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "Invalid server key share, our group %u, their group %u", - (unsigned) offered_group, (unsigned) server_share_group ) ); - return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + (unsigned) offered_group, (unsigned) group ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); } #if defined(MBEDTLS_ECDH_C) - if( mbedtls_ssl_tls13_named_group_is_ecdhe( server_share_group ) ) + if( mbedtls_ssl_tls13_named_group_is_ecdhe( group ) ) { /* Complete ECDHE key agreement */ ret = ssl_tls1_3_read_public_ecdhe_share( ssl, p, end - p ); @@ -890,11 +881,11 @@ cleanup: } /* - * Functions for parsing and processing ServerHello + * Functions for parsing and processing Server Hello */ -static int ssl_server_hello_is_hrr( unsigned const char *buf ) +static int ssl_server_hello_is_hrr( unsigned const char *buf, size_t blen ) { - const unsigned char magic_hrr_string[32] = + static const unsigned char magic_hrr_string[32] = { 0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91, 0xC2, 0xA2, 0x11, 0x16, 0x7A, 0xBB, 0x8C, 0x5E, @@ -902,7 +893,7 @@ static int ssl_server_hello_is_hrr( unsigned const char *buf ) /* Check whether this message is a HelloRetryRequest ( HRR ) message. * - * ServerHello and HRR are only distinguished by Random set to the + * Server Hello and HRR are only distinguished by Random set to the * special value of the SHA-256 of "HelloRetryRequest". * * struct { @@ -915,8 +906,10 @@ static int ssl_server_hello_is_hrr( unsigned const char *buf ) * } ServerHello; * */ - if( memcmp( buf + 2, magic_hrr_string, - sizeof( magic_hrr_string ) ) == 0 ) + if( blen < 2 + sizeof( magic_hrr_string ) ) + return (MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + + if( memcmp( buf + 2, magic_hrr_string, sizeof( magic_hrr_string ) ) == 0 ) { return( 1 ); } @@ -929,20 +922,16 @@ static int ssl_server_hello_is_hrr( unsigned const char *buf ) * - SSL_SERVER_HELLO_COORDINATE_HELLO or * - SSL_SERVER_HELLO_COORDINATE_HRR * to indicate which message is expected and to be parsed next. */ -#define SSL_SERVER_HELLO_COORDINATE_HELLO 0 +#define SSL_SERVER_HELLO_COORDINATE_HELLO 0 #define SSL_SERVER_HELLO_COORDINATE_HRR 1 static int ssl_server_hello_coordinate( mbedtls_ssl_context *ssl, unsigned char **buf, size_t *buf_len ) { - int ret; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_read_record( ssl, 0 ) ); - /* TBD: If we do an HRR, keep track of the number - * of ClientHello's we sent, and fail if it - * exceeds the configured threshold. */ - if( ( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) || ( ssl->in_msg[0] != MBEDTLS_SSL_HS_SERVER_HELLO ) ) { @@ -956,7 +945,7 @@ static int ssl_server_hello_coordinate( mbedtls_ssl_context *ssl, *buf = ssl->in_msg + 4; *buf_len = ssl->in_hslen - 4; - if( ssl_server_hello_is_hrr( ssl->in_msg + 4 ) ) + if( ssl_server_hello_is_hrr( *buf, *buf_len ) ) { MBEDTLS_SSL_DEBUG_MSG( 2, ( "received HelloRetryRequest message" ) ); ret = SSL_SERVER_HELLO_COORDINATE_HRR; @@ -972,54 +961,55 @@ cleanup: return( ret ); } -static int ssl_tls1_3_check_server_hello_session_id( mbedtls_ssl_context *ssl, - const unsigned char **buf, - const unsigned char *end ) +static int ssl_tls13_check_server_hello_session_id_echo( mbedtls_ssl_context *ssl, + const unsigned char **buf, + const unsigned char *end ) { const unsigned char *p = *buf; - size_t recv_id_len; + size_t legacy_session_id_echo_len; MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 1 ); - recv_id_len = *p++ ; + legacy_session_id_echo_len = *p++ ; - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, recv_id_len ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, legacy_session_id_echo_len ); /* legacy_session_id_echo */ - if( ssl->session_negotiate->id_len != recv_id_len ) + if( ssl->session_negotiate->id_len != legacy_session_id_echo_len || + memcmp( ssl->session_negotiate->id, p , legacy_session_id_echo_len ) != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "Mismatch of session id length:" " id_len = %" MBEDTLS_PRINTF_SIZET - " , recv_id_len = %" MBEDTLS_PRINTF_SIZET, - ssl->session_negotiate->id_len, recv_id_len ) ); - return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); - } - - if( memcmp( ssl->session_negotiate->id, p , recv_id_len ) != 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unexpected legacy_session_id_echo" ) ); + " , legacy_session_id_echo_len = %" MBEDTLS_PRINTF_SIZET, + ssl->session_negotiate->id_len, legacy_session_id_echo_len ) ); MBEDTLS_SSL_DEBUG_BUF( 3, "Expected Session ID", ssl->session_negotiate->id, ssl->session_negotiate->id_len ); MBEDTLS_SSL_DEBUG_BUF( 3, "Received Session ID", p, - ssl->session_negotiate->id_len ); + legacy_session_id_echo_len ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, + MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } - p += recv_id_len; + p += legacy_session_id_echo_len; *buf = p; MBEDTLS_SSL_DEBUG_BUF( 3, "Session ID", ssl->session_negotiate->id, - recv_id_len ); + ssl->session_negotiate->id_len ); return( 0 ); } -static int ssl_tls1_3_cipher_suite_is_offered( mbedtls_ssl_context *ssl, - uint16_t cipher_suite ) +static int ssl_tls13_cipher_suite_is_offered( mbedtls_ssl_context *ssl, + int cipher_suite ) { + const int *ciphersuite_list = ssl->conf->ciphersuite_list; + /* Check whether we have offered this ciphersuite */ - for ( int i = 0; ssl->conf->ciphersuite_list[i] != 0; i++ ) + for ( size_t i = 0; ciphersuite_list[i] != 0; i++ ) { - if( ssl->conf->ciphersuite_list[i] == cipher_suite ) + if( ciphersuite_list[i] == cipher_suite ) { return( 1 ); } @@ -1044,8 +1034,8 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, { int ret; const unsigned char *p = buf; - size_t field_len; /* Length of field */ - const unsigned char *ext_end; /* Pointer to end of individual extension */ + size_t extensions_len; /* Length of field */ + const unsigned char *extensions_end; /* Pointer to end of individual extension */ uint16_t cipher_suite; const mbedtls_ssl_ciphersuite_t *ciphersuite_info; @@ -1053,18 +1043,22 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, * Check there is space for minimal fields * * - legacy_version ( 2 bytes) - * - random (32 bytes) + * - random (SERVER_HELLO_RANDOM_LEN bytes) * - legacy_session_id_echo ( 1 byte ), minimum size * - cipher_suite ( 2 bytes) * - legacy_compression_method ( 1 byte ) */ - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 38 ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, SERVER_HELLO_RANDOM_LEN + 6 ); MBEDTLS_SSL_DEBUG_BUF( 4, "server hello", p, end - p ); - MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, version", p, 2 ); - /* legacy_version must be 0x0303 (TLS 1.2) */ + /* ... + * ProtocaolVersion legacy_version = 0x0303; // TLS 1.2 + * ... + * with ProtocolVersion defined as: + * uint16 ProtocolVersion; + */ if( !( p[0] == MBEDTLS_SSL_MAJOR_VERSION_3 && p[1] == MBEDTLS_SSL_MINOR_VERSION_3 ) ) { @@ -1074,54 +1068,66 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION ); } p += 2; - /* Internally we use the correct 1.3 version - * TODO: Remove below lines after supported_versions extension - * finished. - */ - ssl->major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; - ssl->minor_ver = MBEDTLS_SSL_MINOR_VERSION_4; - /* Store server-provided random values */ + /* ... + * Random random; + * ... + * with Random defined as: + * opaque Random[32]; + */ memcpy( ssl->handshake->randbytes + CLIENT_HELLO_RANDOM_LEN, p, SERVER_HELLO_RANDOM_LEN ); MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, random bytes", p, SERVER_HELLO_RANDOM_LEN ); p += SERVER_HELLO_RANDOM_LEN; - /* Read and store session id (legacy_session_id_echo) */ - if( ssl_tls1_3_check_server_hello_session_id( ssl, &p, end ) != 0 ) + /* ... + * opaque legacy_session_id_echo<0..32>; + * ... + */ + if( ssl_tls13_check_server_hello_session_id_echo( ssl, &p, end ) != 0 ) { MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } - /* Read server-selected ciphersuite, - Check if there is space for cipher_suite. */ - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2); + /* ... + * CipherSuite cipher_suite; + * ... + * with CipherSuite defined as: + * uint8 CipherSuite[2]; + */ + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); cipher_suite = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; - /* Configure ciphersuites */ + + /* + * Check whether this ciphersuite is supported and offered. + * Via the force_ciphersuite version we may have instructed the client + * to use a different ciphersuite. + */ ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( cipher_suite ); - ssl->handshake->ciphersuite_info = ciphersuite_info; - if( ciphersuite_info == NULL ) + if( ciphersuite_info == NULL || + ssl_tls13_cipher_suite_is_offered( ssl, cipher_suite ) == 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite info for %04x not found", cipher_suite ) ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, + MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } - mbedtls_ssl_optimize_checksum( ssl, ssl->handshake->ciphersuite_info ); + /* Configure ciphersuites */ + mbedtls_ssl_optimize_checksum( ssl, ciphersuite_info ); + + ssl->handshake->ciphersuite_info = ciphersuite_info; ssl->session_negotiate->ciphersuite = cipher_suite; - ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( cipher_suite ); - MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: ( %04x ) - %s", cipher_suite, ciphersuite_info->name ) ); @@ -1129,21 +1135,9 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, ssl->session_negotiate->start = time( NULL ); #endif /* MBEDTLS_HAVE_TIME */ - /* Check whether we have offered this ciphersuite */ - /* Via the force_ciphersuite version we may have instructed the client */ - /* to use a difference ciphersuite. */ - if( ssl_tls1_3_cipher_suite_is_offered( ssl, cipher_suite ) == 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite(%04x) is not in offered list", - cipher_suite ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - } - - /* Ensure that compression method is set to zero - * - * legacy_compression_method == 0 ( 1 byte) + /* ... + * uint8 legacy_compression_method = 0; + * ... */ MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 1 ); if( p[0] != 0 ) @@ -1155,45 +1149,39 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, } p++; - /* Check there is space fore extensions_length */ + /* + * .... + * Extension extensions<6..2 ^ 16 - 1>; + * .... + * struct { + * ExtensionType extension_type; (2 bytes) + * opaque extension_data<0..2^16-1>; + * } Extension; + */ MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); - /* Get length of extensions field (2 bytes)*/ - field_len = MBEDTLS_GET_UINT16_BE( p, 0 ); + extensions_len = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; - /* Check there is space for extensions_data */ - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, field_len ); - /* Set end of extensions */ - ext_end = p + field_len; + /* Check extensions do not go beyond the buffer of data. */ + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, extensions_len ); + extensions_end = p + extensions_len; MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, total extension length: %" MBEDTLS_PRINTF_SIZET , - field_len ) ); + extensions_len ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "server hello extensions", p, extensions_len ); - MBEDTLS_SSL_DEBUG_BUF( 3, "server hello extensions", p, field_len ); - - while ( p < ext_end ) + while( p < extensions_end ) { unsigned int extension_type; size_t extension_data_len; - /* - * .... - * Extension extensions<6..2 ^ 16 - 1>; - * .... - * struct { - * ExtensionType extension_type; - * opaque extension_data<0..2^16-1>; - * } Extension; - * extension_type (2 bytes) - * extension_data_length (2 bytes) - */ - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, ext_end, 4 ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, extensions_end, 4 ); extension_type = MBEDTLS_GET_UINT16_BE( p, 0 ); extension_data_len = MBEDTLS_GET_UINT16_BE( p, 2 ); p += 4; - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, ext_end, extension_data_len ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, extensions_end, extension_data_len ); switch( extension_type ) { @@ -1210,16 +1198,20 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, case MBEDTLS_TLS_EXT_PRE_SHARED_KEY: MBEDTLS_SSL_DEBUG_MSG( 3, ( "found pre_shared_key extension." ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "pre_shared_key:Not supported yet" ) ); - break; + + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT, + MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); + return( MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) case MBEDTLS_TLS_EXT_KEY_SHARE: MBEDTLS_SSL_DEBUG_MSG( 3, ( "found key_shares extension" ) ); - if( ( ret = ssl_tls1_3_parse_key_share_ext( ssl, + if( ( ret = ssl_tls13_parse_key_share_ext( ssl, p, p + extension_data_len ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, - "ssl_tls1_3_parse_key_share_ext", + "ssl_tls13_parse_key_share_ext", ret ); return( ret ); } @@ -1227,9 +1219,15 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ default: - MBEDTLS_SSL_DEBUG_MSG( 3, - ( "unknown extension found: %u ( ignoring )", - extension_type ) ); + MBEDTLS_SSL_DEBUG_MSG( + 3, + ( "unknown extension found: %u ( ignoring )", + extension_type ) ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT, + MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); + return( MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); } p += extension_data_len; @@ -1242,7 +1240,7 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) { int ret; mbedtls_ssl_key_set traffic_keys; - mbedtls_ssl_transform *transform_handshake; + mbedtls_ssl_transform *transform_handshake = NULL; /* We need to set the key exchange algorithm based on the * following rules: @@ -1280,7 +1278,8 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) { /* ELSE case */ MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unknown key exchange." ) ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + ret = MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; + goto cleanup; } /* Start the TLS 1.3 key schedule: Set the PSK and derive early secret. @@ -1293,7 +1292,7 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_key_schedule_stage_early_data", ret ); - return( ret ); + goto cleanup; } /* Compute handshake secret */ @@ -1301,7 +1300,7 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_master_secret", ret ); - return( ret ); + goto cleanup; } /* Next evolution in key schedule: Establish handshake secret and @@ -1311,13 +1310,16 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_generate_handshake_keys", ret ); - return( ret ); + goto cleanup; } transform_handshake = mbedtls_calloc( 1, sizeof( mbedtls_ssl_transform ) ); if( transform_handshake == NULL ) - return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + { + ret = MBEDTLS_ERR_SSL_ALLOC_FAILED; + goto cleanup; + } ret = mbedtls_ssl_tls13_populate_transform( transform_handshake, ssl->conf->endpoint, @@ -1327,7 +1329,7 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_populate_transform", ret ); - return( ret ); + goto cleanup; } ssl->handshake->transform_handshake = transform_handshake; @@ -1341,17 +1343,27 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) */ mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); +cleanup: + mbedtls_platform_zeroize( &traffic_keys, sizeof( traffic_keys ) ); - return( 0 ); + if( ret != 0 ) + { + if( transform_handshake != NULL ) + mbedtls_free( transform_handshake ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + return( ret ); } /* - * Wait and Parse ServerHello handshake message. + * Wait and parse ServerHello handshake message. * Handler for MBEDTLS_SSL_SERVER_HELLO */ static int ssl_tls1_3_process_server_hello( mbedtls_ssl_context *ssl ) { - int ret = 0; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char *buf; size_t buf_len; @@ -1384,12 +1396,10 @@ static int ssl_tls1_3_process_server_hello( mbedtls_ssl_context *ssl ) } else if( ret == SSL_SERVER_HELLO_COORDINATE_HRR ) { - /* TODO: Implement HRR in future #4915 */ - MBEDTLS_SSL_DEBUG_MSG( 1, ( "HRR hasn't been implemented" ) ); - - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE, - MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); - ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + MBEDTLS_SSL_DEBUG_MSG( 1, ( "HRR not supported" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE , + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + ret = MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; } cleanup: From c068b6671e2e2748f968d8b4dd4da583f2c25926 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 11 Oct 2021 22:30:19 +0800 Subject: [PATCH 758/966] Rename tls13 prefix to fix coding issues Signed-off-by: Jerry Yu --- library/ecdh.c | 18 +++++++-------- library/ecdh_misc.h | 6 ++--- library/ssl_misc.h | 2 +- library/ssl_tls13_client.c | 45 +++++++++++++++++++------------------- library/ssl_tls13_keys.c | 24 ++++++++++---------- library/ssl_tls13_keys.h | 6 ++--- 6 files changed, 51 insertions(+), 50 deletions(-) diff --git a/library/ecdh.c b/library/ecdh.c index 8884260e81..27e5d739c6 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -806,9 +806,9 @@ int mbedtls_ecdh_setup_no_everest( mbedtls_ecdh_context *ctx, #endif } -static int ecdh_tls1_3_read_public_internal( mbedtls_ecdh_context_mbed *ctx, - const unsigned char *buf, - size_t blen ) +static int ecdh_tls13_read_public_internal( mbedtls_ecdh_context_mbed *ctx, + const unsigned char *buf, + size_t blen ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const unsigned char *p = buf; @@ -838,15 +838,15 @@ static int ecdh_tls1_3_read_public_internal( mbedtls_ecdh_context_mbed *ctx, /* * Parse and import the client's TLS 1.3 public value */ -int mbedtls_ecdh_tls1_3_read_public( mbedtls_ecdh_context *ctx, - const unsigned char *buf, - size_t blen ) +int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, + size_t blen ) { ECDH_VALIDATE_RET( ctx != NULL ); ECDH_VALIDATE_RET( buf != NULL ); #if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) - return( ecdh_tls1_3_read_public_internal( ctx, buf, blen ) ); + return( ecdh_tls13_read_public_internal( ctx, buf, blen ) ); #else switch( ctx->var ) { @@ -855,8 +855,8 @@ int mbedtls_ecdh_tls1_3_read_public( mbedtls_ecdh_context *ctx, return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); #endif case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: - return( ecdh_tls1_3_read_public_internal( &ctx->ctx.mbed_ecdh, - buf, blen ) ); + return( ecdh_tls13_read_public_internal( &ctx->ctx.mbed_ecdh, + buf, blen ) ); default: return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; } diff --git a/library/ecdh_misc.h b/library/ecdh_misc.h index 94d31394b1..228f54a31a 100644 --- a/library/ecdh_misc.h +++ b/library/ecdh_misc.h @@ -46,9 +46,9 @@ int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, /* * TLS 1.3 version of mbedtls_ecdh_read_public in ecdh.h */ -int mbedtls_ecdh_tls1_3_read_public( mbedtls_ecdh_context *ctx, - const unsigned char *buf, - size_t blen ); +int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, + size_t blen ); #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index b801499ca1..216035933b 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -737,7 +737,7 @@ struct mbedtls_ssl_handshake_params unsigned char app [MBEDTLS_TLS1_3_MD_MAX_SIZE]; } tls1_3_master_secrets; - mbedtls_ssl_tls1_3_handshake_secrets tls1_3_hs_secrets; + mbedtls_ssl_tls1_3_handshake_secrets tls13_hs_secrets; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_SESSION_TICKETS) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 57195b3296..768caed96b 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -95,9 +95,9 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, return( 0 ); } -static int ssl_tls1_3_parse_supported_versions_ext( mbedtls_ssl_context *ssl, - const unsigned char *buf, - size_t buf_len ) +static int ssl_tls13_parse_supported_versions_ext( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t buf_len ) { ((void) ssl); @@ -477,7 +477,7 @@ cleanup: #if defined(MBEDTLS_ECDH_C) -static int ssl_tls1_3_check_ecdh_params( const mbedtls_ssl_context *ssl ) +static int ssl_tls13_check_ecdh_params( const mbedtls_ssl_context *ssl ) { const mbedtls_ecp_curve_info *curve_info; mbedtls_ecp_group_id grp_id; @@ -511,13 +511,13 @@ static int ssl_tls1_3_check_ecdh_params( const mbedtls_ssl_context *ssl ) * * The server only provides a single KeyShareEntry. */ -static int ssl_tls1_3_read_public_ecdhe_share( mbedtls_ssl_context *ssl, - const unsigned char *buf, - size_t buf_len ) +static int ssl_tls13_read_public_ecdhe_share( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t buf_len ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - ret = mbedtls_ecdh_tls1_3_read_public( &ssl->handshake->ecdh_ctx, + ret = mbedtls_ecdh_tls13_read_public( &ssl->handshake->ecdh_ctx, buf, buf_len ); if( ret != 0 ) { @@ -525,9 +525,9 @@ static int ssl_tls1_3_read_public_ecdhe_share( mbedtls_ssl_context *ssl, return( ret ); } - if( ssl_tls1_3_check_ecdh_params( ssl ) != 0 ) + if( ssl_tls13_check_ecdh_params( ssl ) != 0 ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "ssl_tls1_3_check_ecdh_params() failed!" ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ssl_tls13_check_ecdh_params() failed!" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); @@ -579,7 +579,7 @@ static int ssl_tls13_parse_key_share_ext( mbedtls_ssl_context *ssl, if( mbedtls_ssl_tls13_named_group_is_ecdhe( group ) ) { /* Complete ECDHE key agreement */ - ret = ssl_tls1_3_read_public_ecdhe_share( ssl, p, end - p ); + ret = ssl_tls13_read_public_ecdhe_share( ssl, p, end - p ); if( ret != 0 ) return( ret ); } @@ -1028,9 +1028,9 @@ static int ssl_tls13_cipher_suite_is_offered( mbedtls_ssl_context *ssl, * Extension extensions<6..2 ^ 16 - 1>; * } ServerHello; */ -static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, - const unsigned char *buf, - const unsigned char *end ) +static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ) { int ret; const unsigned char *p = buf; @@ -1189,7 +1189,7 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported_versions extension" ) ); - ret = ssl_tls1_3_parse_supported_versions_ext( ssl, + ret = ssl_tls13_parse_supported_versions_ext( ssl, p, extension_data_len ); if( ret != 0 ) return( ret ); @@ -1236,7 +1236,7 @@ static int ssl_tls1_3_parse_server_hello( mbedtls_ssl_context *ssl, return( 0 ); } -static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) +static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) { int ret; mbedtls_ssl_key_set traffic_keys; @@ -1305,11 +1305,11 @@ static int ssl_tls1_3_finalize_server_hello( mbedtls_ssl_context *ssl ) /* Next evolution in key schedule: Establish handshake secret and * key material. */ - ret = mbedtls_ssl_tls1_3_generate_handshake_keys( ssl, &traffic_keys ); + ret = mbedtls_ssl_tls13_generate_handshake_keys( ssl, &traffic_keys ); if( ret != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, - "mbedtls_ssl_tls1_3_generate_handshake_keys", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_generate_handshake_keys", + ret ); goto cleanup; } @@ -1350,6 +1350,7 @@ cleanup: { if( transform_handshake != NULL ) mbedtls_free( transform_handshake ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); @@ -1385,14 +1386,14 @@ static int ssl_tls1_3_process_server_hello( mbedtls_ssl_context *ssl ) */ if( ret == SSL_SERVER_HELLO_COORDINATE_HELLO ) { - MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_parse_server_hello( ssl, buf, - buf + buf_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_server_hello( ssl, buf, + buf + buf_len ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_SERVER_HELLO, buf, buf_len ); - MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_finalize_server_hello( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_server_hello( ssl ) ); } else if( ret == SSL_SERVER_HELLO_COORDINATE_HRR ) { diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 7ba5b5f8f6..b568f3fd89 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -847,10 +847,10 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ) return( 0 ); } -/* mbedtls_ssl_tls1_3_generate_handshake_keys() generates keys necessary for +/* mbedtls_ssl_tls13_generate_handshake_keys() generates keys necessary for * protecting the handshake messages, as described in Section 7 of TLS 1.3. */ -int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, - mbedtls_ssl_key_set *traffic_keys ) +int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, + mbedtls_ssl_key_set *traffic_keys ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; @@ -864,7 +864,7 @@ int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, mbedtls_cipher_info_t const *cipher_info; size_t keylen, ivlen; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls1_3_generate_handshake_keys" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls13_generate_handshake_keys" ) ); cipher_info = mbedtls_cipher_info_from_type( ssl->handshake->ciphersuite_info->cipher ); @@ -890,7 +890,7 @@ int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, ret = mbedtls_ssl_tls1_3_derive_handshake_secrets( md_type, ssl->handshake->tls1_3_master_secrets.handshake, transcript, transcript_len, - &ssl->handshake->tls1_3_hs_secrets ); + &ssl->handshake->tls13_hs_secrets ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_handshake_secrets", @@ -899,11 +899,11 @@ int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, } MBEDTLS_SSL_DEBUG_BUF( 4, "Client handshake traffic secret", - ssl->handshake->tls1_3_hs_secrets.client_handshake_traffic_secret, + ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, md_size ); MBEDTLS_SSL_DEBUG_BUF( 4, "Server handshake traffic secret", - ssl->handshake->tls1_3_hs_secrets.server_handshake_traffic_secret, + ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, md_size ); /* @@ -914,7 +914,7 @@ int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, { ssl->f_export_keys( ssl->p_export_keys, MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_HANDSHAKE_TRAFFIC_SECRET, - ssl->handshake->tls1_3_hs_secrets.client_handshake_traffic_secret, + ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, md_size, ssl->handshake->randbytes + 32, ssl->handshake->randbytes, @@ -922,7 +922,7 @@ int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, ssl->f_export_keys( ssl->p_export_keys, MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_HANDSHAKE_TRAFFIC_SECRET, - ssl->handshake->tls1_3_hs_secrets.server_handshake_traffic_secret, + ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, md_size, ssl->handshake->randbytes + 32, ssl->handshake->randbytes, @@ -931,8 +931,8 @@ int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_SSL_EXPORT_KEYS */ ret = mbedtls_ssl_tls1_3_make_traffic_keys( md_type, - ssl->handshake->tls1_3_hs_secrets.client_handshake_traffic_secret, - ssl->handshake->tls1_3_hs_secrets.server_handshake_traffic_secret, + ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, + ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, md_size, keylen, ivlen, traffic_keys ); if( ret != 0 ) @@ -957,7 +957,7 @@ int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, traffic_keys->server_write_iv, traffic_keys->iv_len); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls1_3_generate_handshake_keys" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls13_generate_handshake_keys" ) ); exit: diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 71bd90de24..384f433b59 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -539,7 +539,7 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_early( mbedtls_ssl_context *ssl ); * with states Initial -> Early -> Handshake -> Application, and * this function represents the Early -> Handshake transition. * - * In the handshake stage, mbedtls_ssl_tls1_3_generate_handshake_keys() + * In the handshake stage, mbedtls_ssl_tls13_generate_handshake_keys() * can be used to derive the handshake traffic keys. * * \param ssl The SSL context to operate on. This must be in key schedule @@ -562,7 +562,7 @@ int mbedtls_ssl_tls13_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ); * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls1_3_generate_handshake_keys( mbedtls_ssl_context *ssl, - mbedtls_ssl_key_set *traffic_keys ); +int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, + mbedtls_ssl_key_set *traffic_keys ); #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From f532bb2577180650174bfd227ca946a410328f59 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 13 Oct 2021 10:34:03 +0800 Subject: [PATCH 759/966] Change MD size for tls13 keys Signed-off-by: Jerry Yu --- library/ssl_misc.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 216035933b..fb611662c7 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -510,15 +510,15 @@ typedef struct mbedtls_ssl_key_set mbedtls_ssl_key_set; typedef struct { - unsigned char binder_key [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char client_early_traffic_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char early_exporter_master_secret[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char binder_key [ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char client_early_traffic_secret [ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char early_exporter_master_secret[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; } mbedtls_ssl_tls1_3_early_secrets; typedef struct { - unsigned char client_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_handshake_traffic_secret[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char client_handshake_traffic_secret[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char server_handshake_traffic_secret[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; } mbedtls_ssl_tls1_3_handshake_secrets; typedef struct From 435208a9490ebe24764b008592360a0b958c4d9c Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 13 Oct 2021 11:22:16 +0800 Subject: [PATCH 760/966] Improve generate_handshake_keys Signed-off-by: Jerry Yu --- library/ssl_tls13_keys.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index b568f3fd89..4fe1d5c65e 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -858,20 +858,23 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, mbedtls_md_info_t const *md_info; size_t md_size; - unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; + unsigned char transcript[MBEDTLS_TLS1_3_MD_MAX_SIZE]; size_t transcript_len; mbedtls_cipher_info_t const *cipher_info; size_t keylen, ivlen; + mbedtls_ssl_handshake_params *handshake = ssl->handshake; + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = handshake->ciphersuite_info; + mbedtls_ssl_tls1_3_handshake_secrets *tls13_hs_secrets = &handshake->tls13_hs_secrets; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls13_generate_handshake_keys" ) ); - cipher_info = mbedtls_cipher_info_from_type( - ssl->handshake->ciphersuite_info->cipher ); + cipher_info = mbedtls_cipher_info_from_type( ciphersuite_info->cipher ); keylen = cipher_info->key_bitlen >> 3; ivlen = cipher_info->iv_size; - md_type = ssl->handshake->ciphersuite_info->mac; + md_type = ciphersuite_info->mac; md_info = mbedtls_md_info_from_type( md_type ); md_size = mbedtls_md_get_size( md_info ); @@ -888,9 +891,8 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, } ret = mbedtls_ssl_tls1_3_derive_handshake_secrets( md_type, - ssl->handshake->tls1_3_master_secrets.handshake, - transcript, transcript_len, - &ssl->handshake->tls13_hs_secrets ); + handshake->tls1_3_master_secrets.handshake, + transcript, transcript_len, tls13_hs_secrets ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_handshake_secrets", @@ -899,11 +901,10 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, } MBEDTLS_SSL_DEBUG_BUF( 4, "Client handshake traffic secret", - ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, + tls13_hs_secrets->client_handshake_traffic_secret, md_size ); - MBEDTLS_SSL_DEBUG_BUF( 4, "Server handshake traffic secret", - ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, + tls13_hs_secrets->server_handshake_traffic_secret, md_size ); /* @@ -914,27 +915,26 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, { ssl->f_export_keys( ssl->p_export_keys, MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_HANDSHAKE_TRAFFIC_SECRET, - ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, + tls13_hs_secrets->client_handshake_traffic_secret, md_size, - ssl->handshake->randbytes + 32, - ssl->handshake->randbytes, + handshake->randbytes + 32, + handshake->randbytes, MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); ssl->f_export_keys( ssl->p_export_keys, MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_HANDSHAKE_TRAFFIC_SECRET, - ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, + tls13_hs_secrets->server_handshake_traffic_secret, md_size, - ssl->handshake->randbytes + 32, - ssl->handshake->randbytes, + handshake->randbytes + 32, + handshake->randbytes, MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); } #endif /* MBEDTLS_SSL_EXPORT_KEYS */ ret = mbedtls_ssl_tls1_3_make_traffic_keys( md_type, - ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret, - ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret, - md_size, - keylen, ivlen, traffic_keys ); + tls13_hs_secrets->client_handshake_traffic_secret, + tls13_hs_secrets->server_handshake_traffic_secret, + md_size, keylen, ivlen, traffic_keys ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_make_traffic_keys", ret ); From b85277e3af889e21bd779e2ba365f1af5253573a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 13 Oct 2021 13:36:05 +0800 Subject: [PATCH 761/966] Address various issues Signed-off-by: Jerry Yu --- library/ecdh.c | 15 ++- library/ecdh_misc.h | 8 +- library/ssl_tls13_client.c | 185 +++++++++++++++++-------------------- library/ssl_tls13_keys.c | 1 - 4 files changed, 95 insertions(+), 114 deletions(-) diff --git a/library/ecdh.c b/library/ecdh.c index 27e5d739c6..ddd4ef545e 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -808,24 +808,21 @@ int mbedtls_ecdh_setup_no_everest( mbedtls_ecdh_context *ctx, static int ecdh_tls13_read_public_internal( mbedtls_ecdh_context_mbed *ctx, const unsigned char *buf, - size_t blen ) + size_t buf_len ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const unsigned char *p = buf; size_t data_len; - if( blen < 3 ) + if( buf_len < 3 ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); data_len = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; - if( data_len < 1 || data_len != ( blen - 2 ) ) + if( data_len < 1 || data_len != ( buf_len - 2 ) ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - /* - * Save buffer start for read_binary and update buf - */ if( ( ret = mbedtls_ecp_point_read_binary( &ctx->grp, &ctx->Qp, p, data_len ) ) != 0) { @@ -840,13 +837,13 @@ static int ecdh_tls13_read_public_internal( mbedtls_ecdh_context_mbed *ctx, */ int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, const unsigned char *buf, - size_t blen ) + size_t buf_len ) { ECDH_VALIDATE_RET( ctx != NULL ); ECDH_VALIDATE_RET( buf != NULL ); #if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) - return( ecdh_tls13_read_public_internal( ctx, buf, blen ) ); + return( ecdh_tls13_read_public_internal( ctx, buf, buf_len ) ); #else switch( ctx->var ) { @@ -856,7 +853,7 @@ int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, #endif case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: return( ecdh_tls13_read_public_internal( &ctx->ctx.mbed_ecdh, - buf, blen ) ); + buf, buf_len ) ); default: return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; } diff --git a/library/ecdh_misc.h b/library/ecdh_misc.h index 228f54a31a..d0f338a837 100644 --- a/library/ecdh_misc.h +++ b/library/ecdh_misc.h @@ -36,19 +36,19 @@ int mbedtls_ecdh_setup_no_everest( mbedtls_ecdh_context *ctx, mbedtls_ecp_group_id grp_id ); /* - * TLS 1.3 version of mbedtls_ecdh_make_params in ecdh.h + * TLS 1.3 version of mbedtls_ecdh_make_params */ int mbedtls_ecdh_tls13_make_params( mbedtls_ecdh_context *ctx, size_t *olen, - unsigned char *buf, size_t blen, + unsigned char *buf, size_t buf_len, int ( *f_rng )( void *, unsigned char *, size_t ), void *p_rng ); /* - * TLS 1.3 version of mbedtls_ecdh_read_public in ecdh.h + * TLS 1.3 version of mbedtls_ecdh_read_public */ int mbedtls_ecdh_tls13_read_public( mbedtls_ecdh_context *ctx, const unsigned char *buf, - size_t blen ); + size_t buf_len ); #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 768caed96b..15bf43bb1c 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -97,12 +97,12 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, static int ssl_tls13_parse_supported_versions_ext( mbedtls_ssl_context *ssl, const unsigned char *buf, - size_t buf_len ) + const unsigned char *end ) { ((void) ssl); - if( buf_len != 2 || - buf[0] != MBEDTLS_SSL_MAJOR_VERSION_3 || + MBEDTLS_SSL_CHK_BUF_READ_PTR( buf, end, 2); + if( buf[0] != MBEDTLS_SSL_MAJOR_VERSION_3 || buf[1] != MBEDTLS_SSL_MINOR_VERSION_4 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "unexpected version" ) ); @@ -497,7 +497,7 @@ static int ssl_tls13_check_ecdh_params( const mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDH curve: %s", curve_info->name ) ); if( mbedtls_ssl_check_curve( ssl, grp_id ) != 0 ) - return( -1 ); + return( -1 ); MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, MBEDTLS_DEBUG_ECDH_QP ); @@ -505,12 +505,6 @@ static int ssl_tls13_check_ecdh_params( const mbedtls_ssl_context *ssl ) return( 0 ); } -/* The ssl_tls13_parse_key_share_ext() function is used - * by the client to parse a KeyShare extension in - * a Server Hello message. - * - * The server only provides a single KeyShareEntry. - */ static int ssl_tls13_read_public_ecdhe_share( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t buf_len ) @@ -522,12 +516,16 @@ static int ssl_tls13_read_public_ecdhe_share( mbedtls_ssl_context *ssl, if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ecdh_tls13_read_public" ), ret ); - return( ret ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, + MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } if( ssl_tls13_check_ecdh_params( ssl ) != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "ssl_tls13_check_ecdh_params() failed!" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); @@ -538,7 +536,9 @@ static int ssl_tls13_read_public_ecdhe_share( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_ECDH_C */ /* - * Parse key_share extension in Server Hello + * ssl_tls13_parse_key_share_ext() + * Parse key_share extension in Server Hello + * * struct { * KeyShareEntry server_share; * } KeyShareServerHello; @@ -551,7 +551,7 @@ static int ssl_tls13_parse_key_share_ext( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end ) { - int ret = 0; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const unsigned char *p = buf; uint16_t group, offered_group; @@ -583,8 +583,9 @@ static int ssl_tls13_parse_key_share_ext( mbedtls_ssl_context *ssl, if( ret != 0 ) return( ret ); } + else #endif /* MBEDTLS_ECDH_C */ - else if( 0 /* other KEMs? */ ) + if( 0 /* other KEMs? */ ) { /* Do something */ } @@ -883,9 +884,18 @@ cleanup: /* * Functions for parsing and processing Server Hello */ -static int ssl_server_hello_is_hrr( unsigned const char *buf, size_t blen ) +/* Fetch and preprocess + * Returns a negative value on failure, and otherwise + * - SSL_SERVER_HELLO_COORDINATE_HELLO or + * - SSL_SERVER_HELLO_COORDINATE_HRR + * to indicate which message is expected and to be parsed next. */ +#define SSL_SERVER_HELLO_COORDINATE_HELLO 0 +#define SSL_SERVER_HELLO_COORDINATE_HRR 1 +static int ssl_server_hello_is_hrr( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ) { - static const unsigned char magic_hrr_string[32] = + static const unsigned char magic_hrr_string[SERVER_HELLO_RANDOM_LEN] = { 0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91, 0xC2, 0xA2, 0x11, 0x16, 0x7A, 0xBB, 0x8C, 0x5E, @@ -902,31 +912,23 @@ static int ssl_server_hello_is_hrr( unsigned const char *buf, size_t blen ) * opaque legacy_session_id_echo<0..32>; * CipherSuite cipher_suite; * uint8 legacy_compression_method = 0; - * Extension extensions<6..2 ^ 16 - 1>; + * Extension extensions<6..2^16-1>; * } ServerHello; * */ - if( blen < 2 + sizeof( magic_hrr_string ) ) - return (MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( buf, end, 2 + sizeof( magic_hrr_string ) ); if( memcmp( buf + 2, magic_hrr_string, sizeof( magic_hrr_string ) ) == 0 ) { - return( 1 ); + return( SSL_SERVER_HELLO_COORDINATE_HRR ); } - return( 0 ); + return( SSL_SERVER_HELLO_COORDINATE_HELLO ); } -/* Fetch and preprocess - * Returns a negative value on failure, and otherwise - * - SSL_SERVER_HELLO_COORDINATE_HELLO or - * - SSL_SERVER_HELLO_COORDINATE_HRR - * to indicate which message is expected and to be parsed next. */ -#define SSL_SERVER_HELLO_COORDINATE_HELLO 0 -#define SSL_SERVER_HELLO_COORDINATE_HRR 1 -static int ssl_server_hello_coordinate( mbedtls_ssl_context *ssl, - unsigned char **buf, - size_t *buf_len ) +static int ssl_tls13_server_hello_coordinate( mbedtls_ssl_context *ssl, + unsigned char **buf, + size_t *buf_len ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; @@ -945,15 +947,15 @@ static int ssl_server_hello_coordinate( mbedtls_ssl_context *ssl, *buf = ssl->in_msg + 4; *buf_len = ssl->in_hslen - 4; - if( ssl_server_hello_is_hrr( *buf, *buf_len ) ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "received HelloRetryRequest message" ) ); - ret = SSL_SERVER_HELLO_COORDINATE_HRR; - } - else + ret = ssl_server_hello_is_hrr( ssl, *buf, *buf + *buf_len ); + switch( ret ) { + case SSL_SERVER_HELLO_COORDINATE_HELLO: MBEDTLS_SSL_DEBUG_MSG( 2, ( "received ServerHello message" ) ); - ret = SSL_SERVER_HELLO_COORDINATE_HELLO; + break; + case SSL_SERVER_HELLO_COORDINATE_HRR: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received HelloRetryRequest message" ) ); + break; } cleanup: @@ -977,10 +979,6 @@ static int ssl_tls13_check_server_hello_session_id_echo( mbedtls_ssl_context *ss if( ssl->session_negotiate->id_len != legacy_session_id_echo_len || memcmp( ssl->session_negotiate->id, p , legacy_session_id_echo_len ) != 0 ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "Mismatch of session id length:" - " id_len = %" MBEDTLS_PRINTF_SIZET - " , legacy_session_id_echo_len = %" MBEDTLS_PRINTF_SIZET, - ssl->session_negotiate->id_len, legacy_session_id_echo_len ) ); MBEDTLS_SSL_DEBUG_BUF( 3, "Expected Session ID", ssl->session_negotiate->id, ssl->session_negotiate->id_len ); @@ -1025,17 +1023,17 @@ static int ssl_tls13_cipher_suite_is_offered( mbedtls_ssl_context *ssl, * opaque legacy_session_id_echo<0..32>; * CipherSuite cipher_suite; * uint8 legacy_compression_method = 0; - * Extension extensions<6..2 ^ 16 - 1>; + * Extension extensions<6..2^16-1>; * } ServerHello; */ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end ) { - int ret; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const unsigned char *p = buf; - size_t extensions_len; /* Length of field */ - const unsigned char *extensions_end; /* Pointer to end of individual extension */ + size_t extensions_len; + const unsigned char *extensions_end; uint16_t cipher_suite; const mbedtls_ssl_ciphersuite_t *ciphersuite_info; @@ -1054,7 +1052,7 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, version", p, 2 ); /* ... - * ProtocaolVersion legacy_version = 0x0303; // TLS 1.2 + * ProtocolVersion legacy_version = 0x0303; // TLS 1.2 * ... * with ProtocolVersion defined as: * uint16 ProtocolVersion; @@ -1112,9 +1110,8 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, if( ciphersuite_info == NULL || ssl_tls13_cipher_suite_is_offered( ssl, cipher_suite ) == 0 ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite info for %04x not found", + MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite(%04x) not found or not offered", cipher_suite ) ); - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); @@ -1142,17 +1139,16 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 1 ); if( p[0] != 0 ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad legacy compression method" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); return( MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); } p++; - /* - * .... - * Extension extensions<6..2 ^ 16 - 1>; - * .... + /* ... + * Extension extensions<6..2^16-1>; + * ... * struct { * ExtensionType extension_type; (2 bytes) * opaque extension_data<0..2^16-1>; @@ -1166,9 +1162,6 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, extensions_len ); extensions_end = p + extensions_len; - MBEDTLS_SSL_DEBUG_MSG( 3, - ( "server hello, total extension length: %" MBEDTLS_PRINTF_SIZET , - extensions_len ) ); MBEDTLS_SSL_DEBUG_BUF( 3, "server hello extensions", p, extensions_len ); while( p < extensions_end ) @@ -1190,7 +1183,8 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, ( "found supported_versions extension" ) ); ret = ssl_tls13_parse_supported_versions_ext( ssl, - p, extension_data_len ); + p, + p + extension_data_len ); if( ret != 0 ) return( ret ); break; @@ -1238,45 +1232,39 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) { - int ret; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; mbedtls_ssl_key_set traffic_keys; mbedtls_ssl_transform *transform_handshake = NULL; + mbedtls_ssl_handshake_params *handshake = ssl->handshake; - /* We need to set the key exchange algorithm based on the - * following rules: - * - * 1) IF PRE_SHARED_KEY extension was received - * THEN set KEY_EXCHANGE_MODE_PSK_EPHEMERAL; - * 2) IF PRE_SHARED_KEY extension && KEY_SHARE was received - * THEN set KEY_EXCHANGE_MODE_PSK; - * 3) IF KEY_SHARES extension was received && SIG_ALG extension received - * THEN set KEY_EXCHANGE_MODE_EPHEMERAL - * ELSE unknown key exchange mechanism. + /* Determine the key exchange mode: + * 1) If both the pre_shared_key and key_share extensions were received + * then the key exchange mode is PSK with EPHEMERAL. + * 2) If only the pre_shared_key extension was received then the key + * exchange mode is PSK-only. + * 3) If only the key_share extension was received then the key + * exchange mode is EPHEMERAL-only. */ - if( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_PRE_SHARED_KEY ) + switch( handshake->extensions_present & + ( MBEDTLS_SSL_EXT_PRE_SHARED_KEY | MBEDTLS_SSL_EXT_KEY_SHARE ) ) { - if( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_KEY_SHARE ) - { - /* Condition 2) */ - ssl->handshake->tls1_3_kex_modes = - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; - } - else - { - /* Condition 1) */ - ssl->handshake->tls1_3_kex_modes = - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; - } - } - else if( ( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_KEY_SHARE ) ) - { - /* Condition 3) */ - ssl->handshake->tls1_3_kex_modes = - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; - } - else - { - /* ELSE case */ + /* Only the pre_shared_key extension was received */ + case MBEDTLS_SSL_EXT_PRE_SHARED_KEY: + handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; + break; + + /* Only the key_share extension was received */ + case MBEDTLS_SSL_EXT_KEY_SHARE: + handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; + break; + + /* Both the pre_shared_key and key_share extensions were received */ + case ( MBEDTLS_SSL_EXT_PRE_SHARED_KEY | MBEDTLS_SSL_EXT_KEY_SHARE ): + handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; + break; + + /* Neither pre_shared_key nor key_share extension was received */ + default: MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unknown key exchange." ) ); ret = MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; goto cleanup; @@ -1313,8 +1301,7 @@ static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) goto cleanup; } - transform_handshake = - mbedtls_calloc( 1, sizeof( mbedtls_ssl_transform ) ); + transform_handshake = mbedtls_calloc( 1, sizeof( mbedtls_ssl_transform ) ); if( transform_handshake == NULL ) { ret = MBEDTLS_ERR_SSL_ALLOC_FAILED; @@ -1332,8 +1319,8 @@ static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) goto cleanup; } - ssl->handshake->transform_handshake = transform_handshake; - mbedtls_ssl_set_inbound_transform( ssl, ssl->handshake->transform_handshake ); + handshake->transform_handshake = transform_handshake; + mbedtls_ssl_set_inbound_transform( ssl, transform_handshake ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "Switch to handshake keys for inbound traffic" ) ); ssl->session_in = ssl->session_negotiate; @@ -1348,8 +1335,7 @@ cleanup: mbedtls_platform_zeroize( &traffic_keys, sizeof( traffic_keys ) ); if( ret != 0 ) { - if( transform_handshake != NULL ) - mbedtls_free( transform_handshake ); + mbedtls_free( transform_handshake ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, @@ -1375,11 +1361,10 @@ static int ssl_tls1_3_process_server_hello( mbedtls_ssl_context *ssl ) * - Make sure it's either a ServerHello or a HRR. * - Switch processing routine in case of HRR */ - ssl->major_ver = MBEDTLS_SSL_MAJOR_VERSION_3; ssl->handshake->extensions_present = MBEDTLS_SSL_EXT_NONE; - ret = ssl_server_hello_coordinate( ssl, &buf, &buf_len ); + ret = ssl_tls13_server_hello_coordinate( ssl, &buf, &buf_len ); /* Parsing step * We know what message to expect by now and call * the respective parsing function. diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 4fe1d5c65e..35829f2323 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -1000,7 +1000,6 @@ int mbedtls_ssl_tls13_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) } else if( mbedtls_ssl_tls13_named_group_is_dhe( handshake->offered_group_id ) ) { - /* TODO: Not supported yet */ MBEDTLS_SSL_DEBUG_MSG( 1, ( "DHE not supported." ) ); return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); } From 193f0e74497fc97e56a31a075fb395cca8e85494 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 13 Oct 2021 18:33:13 +0800 Subject: [PATCH 762/966] fix build fail on tls1_3_md_max_size Signed-off-by: Jerry Yu --- library/ssl_misc.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index fb611662c7..ceaf0588f3 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -307,9 +307,7 @@ + ( MBEDTLS_SSL_CID_OUT_LEN_MAX ) ) #endif -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #define MBEDTLS_TLS1_3_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) /** From 745bb616a47d48378f4e4f2ce572f0f1678c4e96 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 13 Oct 2021 22:01:04 +0800 Subject: [PATCH 763/966] Fix format issue and enhance test Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 51 +++++++++++++++++++++----------------- tests/ssl-opt.sh | 9 +++++-- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 15bf43bb1c..2924fd8b68 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -926,6 +926,11 @@ static int ssl_server_hello_is_hrr( mbedtls_ssl_context *ssl, return( SSL_SERVER_HELLO_COORDINATE_HELLO ); } +/* Fetch and preprocess + * Returns a negative value on failure, and otherwise + * - SSL_SERVER_HELLO_COORDINATE_HELLO or + * - SSL_SERVER_HELLO_COORDINATE_HRR + */ static int ssl_tls13_server_hello_coordinate( mbedtls_ssl_context *ssl, unsigned char **buf, size_t *buf_len ) @@ -950,12 +955,12 @@ static int ssl_tls13_server_hello_coordinate( mbedtls_ssl_context *ssl, ret = ssl_server_hello_is_hrr( ssl, *buf, *buf + *buf_len ); switch( ret ) { - case SSL_SERVER_HELLO_COORDINATE_HELLO: - MBEDTLS_SSL_DEBUG_MSG( 2, ( "received ServerHello message" ) ); - break; - case SSL_SERVER_HELLO_COORDINATE_HRR: - MBEDTLS_SSL_DEBUG_MSG( 2, ( "received HelloRetryRequest message" ) ); - break; + case SSL_SERVER_HELLO_COORDINATE_HELLO: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received ServerHello message" ) ); + break; + case SSL_SERVER_HELLO_COORDINATE_HRR: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received HelloRetryRequest message" ) ); + break; } cleanup: @@ -1248,26 +1253,26 @@ static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) switch( handshake->extensions_present & ( MBEDTLS_SSL_EXT_PRE_SHARED_KEY | MBEDTLS_SSL_EXT_KEY_SHARE ) ) { - /* Only the pre_shared_key extension was received */ - case MBEDTLS_SSL_EXT_PRE_SHARED_KEY: - handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; - break; + /* Only the pre_shared_key extension was received */ + case MBEDTLS_SSL_EXT_PRE_SHARED_KEY: + handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK; + break; - /* Only the key_share extension was received */ - case MBEDTLS_SSL_EXT_KEY_SHARE: - handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; - break; + /* Only the key_share extension was received */ + case MBEDTLS_SSL_EXT_KEY_SHARE: + handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL; + break; - /* Both the pre_shared_key and key_share extensions were received */ - case ( MBEDTLS_SSL_EXT_PRE_SHARED_KEY | MBEDTLS_SSL_EXT_KEY_SHARE ): - handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; - break; + /* Both the pre_shared_key and key_share extensions were received */ + case ( MBEDTLS_SSL_EXT_PRE_SHARED_KEY | MBEDTLS_SSL_EXT_KEY_SHARE ): + handshake->tls1_3_kex_modes = MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL; + break; - /* Neither pre_shared_key nor key_share extension was received */ - default: - MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unknown key exchange." ) ); - ret = MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; - goto cleanup; + /* Neither pre_shared_key nor key_share extension was received */ + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Unknown key exchange." ) ); + ret = MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; + goto cleanup; } /* Start the TLS 1.3 key schedule: Set the PSK and derive early secret. diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 2b91025fd2..ad7abbba07 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8678,7 +8678,7 @@ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS1.3: Test client hello msg work - openssl" \ "$O_NEXT_SRV -tls1_3 -msg" \ - "$P_CLI debug_level=2 min_version=tls1_3 max_version=tls1_3" \ + "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3" \ 1 \ -c "SSL - The requested feature is not available" \ -s "ServerHello" \ @@ -8695,6 +8695,8 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "tls1_3 client state: 14" \ -c "tls1_3 client state: 15" \ -c "<= ssl_tls1_3_process_server_hello" \ + -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ + -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" requires_gnutls_tls1_3 @@ -8702,7 +8704,7 @@ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS1.3: Test client hello msg work - gnutls" \ "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3 --debug=4" \ - "$P_CLI debug_level=2 min_version=tls1_3 max_version=tls1_3" \ + "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3" \ 1 \ -c "SSL - The requested feature is not available" \ -s "SERVER HELLO was queued" \ @@ -8719,8 +8721,11 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "tls1_3 client state: 14" \ -c "tls1_3 client state: 15" \ -c "<= ssl_tls1_3_process_server_hello" \ + -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ + -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" + # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C From 337d5318aed405853849be13a16a2a4e4dc05592 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 15 Oct 2021 10:09:05 +0800 Subject: [PATCH 764/966] replace md_max_size with tls13_md_max_size Signed-off-by: Jerry Yu --- library/ssl_misc.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index ceaf0588f3..904d8c77db 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -521,10 +521,10 @@ typedef struct typedef struct { - unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char client_application_traffic_secret_N[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char server_application_traffic_secret_N[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char exporter_master_secret [ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char resumption_master_secret [ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; } mbedtls_ssl_tls1_3_application_secrets; /* From 7a186a0cbfc9e8b1b6c7184f5df050830a3cb4d1 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 15 Oct 2021 18:46:14 +0800 Subject: [PATCH 765/966] fix comment issue Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 2924fd8b68..ca82fdcc58 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -884,8 +884,7 @@ cleanup: /* * Functions for parsing and processing Server Hello */ -/* Fetch and preprocess - * Returns a negative value on failure, and otherwise +/* Returns a negative value on failure, and otherwise * - SSL_SERVER_HELLO_COORDINATE_HELLO or * - SSL_SERVER_HELLO_COORDINATE_HRR * to indicate which message is expected and to be parsed next. */ From ad3a113fc6aa6dd8bf2255228813e8218729d53a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 25 Oct 2021 10:46:43 +0800 Subject: [PATCH 766/966] Remove MBEDTLS_SSL_EXPORT_KEYS It is always on now in `development` Signed-off-by: Jerry Yu --- library/ssl_tls13_keys.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 35829f2323..96f5310797 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -910,7 +910,6 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, /* * Export client handshake traffic secret */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) if( ssl->f_export_keys != NULL ) { ssl->f_export_keys( ssl->p_export_keys, @@ -929,7 +928,6 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, handshake->randbytes, MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); } -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ ret = mbedtls_ssl_tls1_3_make_traffic_keys( md_type, tls13_hs_secrets->client_handshake_traffic_secret, From 188468b5f441ebab28289f8fb271ded078eab78a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 25 Oct 2021 10:48:24 +0800 Subject: [PATCH 767/966] Add reference link for Random definition Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index ca82fdcc58..989bdc0abc 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1071,7 +1071,8 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, } p += 2; - /* ... + /* From RFC8446, page 27. + * ... * Random random; * ... * with Random defined as: From cbdedc54b9f0d532cf6920a6a2a6efb89182a66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 11 May 2021 12:47:30 +0200 Subject: [PATCH 768/966] Allow cmake to generate error.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- library/CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index a5d692cbe4..a6d626b52e 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -109,6 +109,24 @@ set(src_tls ssl_tls13_generic.c ) +find_package(Perl REQUIRED) + +file(GLOB error_headers ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls/*.h) +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/error.c + COMMAND + ${PERL_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_errors.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files + ${CMAKE_CURRENT_BINARY_DIR}/error.c + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_errors.pl + ${error_headers} + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files/error.fmt +) + if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes") endif(CMAKE_COMPILER_IS_GNUCC) From 65a72031198b846546aeae90d484200282273a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 11 May 2021 13:02:44 +0200 Subject: [PATCH 769/966] Allow cmake to generate version_features.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- library/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index a6d626b52e..187693d563 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -127,6 +127,21 @@ add_custom_command( ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files/error.fmt ) +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/version_features.c + COMMAND + ${PERL_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_features.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files + ${CMAKE_CURRENT_BINARY_DIR}/version_features.c + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_features.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls/mbedtls_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files/version_features.fmt +) + if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes") endif(CMAKE_COMPILER_IS_GNUCC) From aedca0c993bddb4996d1980b962e360d891a9c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 11 May 2021 13:45:54 +0200 Subject: [PATCH 770/966] Simplify source declarations in ssl/CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit query_config was added twice, and while at it let's declare all the sources in one place Signed-off-by: Manuel Pégourié-Gonnard --- programs/ssl/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt index def9c7cf6c..bdce56bfcc 100644 --- a/programs/ssl/CMakeLists.txt +++ b/programs/ssl/CMakeLists.txt @@ -22,6 +22,7 @@ foreach(exe IN LISTS executables) set(extra_sources "") if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2") list(APPEND extra_sources + ssl_test_lib.c ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.c) endif() add_executable(${exe} ${exe}.c $ @@ -30,11 +31,6 @@ foreach(exe IN LISTS executables) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) endforeach() -set_property(TARGET ssl_client2 APPEND PROPERTY SOURCES - ssl_test_lib.c ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.c) -set_property(TARGET ssl_server2 APPEND PROPERTY SOURCES - ssl_test_lib.c ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.c) - if(THREADS_FOUND) add_executable(ssl_pthread_server ssl_pthread_server.c $) target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) From 3a8413d3165af9b84859ca9e935ad4a183c2622c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 14 May 2021 09:23:57 +0200 Subject: [PATCH 771/966] Allow generate_query_config.pl to take arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- scripts/generate_query_config.pl | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/scripts/generate_query_config.pl b/scripts/generate_query_config.pl index e3bbaa0745..eab986afad 100755 --- a/scripts/generate_query_config.pl +++ b/scripts/generate_query_config.pl @@ -14,7 +14,8 @@ # information is used to automatically generate the body of the query_config() # function by using the template in scripts/data_files/query_config.fmt. # -# Usage: ./scripts/generate_query_config.pl without arguments +# Usage: scripts/generate_query_config.pl without arguments, or +# generate_query_config.pl config_file template_file output_file # # Copyright The Mbed TLS Contributors # SPDX-License-Identifier: Apache-2.0 @@ -33,15 +34,24 @@ use strict; -my $config_file = "./include/mbedtls/mbedtls_config.h"; +my ($config_file, $query_config_format_file, $query_config_file); -my $query_config_format_file = "./scripts/data_files/query_config.fmt"; -my $query_config_file = "./programs/test/query_config.c"; +if( @ARGV ) { + die "Invalid number of arguments" if scalar @ARGV != 3; + ($config_file, $query_config_format_file, $query_config_file) = @ARGV; -unless( -f $config_file && -f $query_config_format_file ) { - chdir '..' or die; - -f $config_file && -f $query_config_format_file - or die "Without arguments, must be run from root or a subdirectory\n"; + -f $config_file or die "No such file: $config_file"; + -f $query_config_format_file or die "No such file: $query_config_format_file"; +} else { + $config_file = "./include/mbedtls/mbedtls_config.h"; + $query_config_format_file = "./scripts/data_files/query_config.fmt"; + $query_config_file = "./programs/test/query_config.c"; + + unless( -f $config_file && -f $query_config_format_file ) { + chdir '..' or die; + -f $config_file && -f $query_config_format_file + or die "Without arguments, must be run from root or a subdirectory\n"; + } } # Excluded macros from the generated query_config.c. For example, macros that From 86cfa6c27f989bca3c18399a27a276645352100c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 14 May 2021 10:07:33 +0200 Subject: [PATCH 772/966] Allow CMake to generate query_config.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This one was trickier for two reasons: 1. It's used from another directory, see https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory 2. The C file being generated after CMake is run means CMake can't automatically scan for included headers and do its usual magic, so we need to declare the dependency and more importantly the include path. Signed-off-by: Manuel Pégourié-Gonnard --- programs/ssl/CMakeLists.txt | 17 ++++++++++++++++- programs/test/CMakeLists.txt | 27 ++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt index bdce56bfcc..a14e264666 100644 --- a/programs/ssl/CMakeLists.txt +++ b/programs/ssl/CMakeLists.txt @@ -18,17 +18,32 @@ set(executables ssl_server2 ) +# Inform CMake the the following file will be generated as part of the build +# process, so it doesn't complain that it doesn't exist yet. Starting from +# CMake 3.20, this will no longer be necessary as CMake will automatically +# propagate this information accross the tree, for now it's only visible +# inside the same directory, so we need to propagate manually. +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c + PROPERTIES GENERATED TRUE) + foreach(exe IN LISTS executables) set(extra_sources "") if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2") list(APPEND extra_sources ssl_test_lib.c - ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.c) + ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.h + ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c) endif() add_executable(${exe} ${exe}.c $ ${extra_sources}) target_link_libraries(${exe} ${libs}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) + if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2") + add_dependencies(${exe} generate_query_config_c) + target_include_directories(${exe} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../test) + endif() endforeach() if(THREADS_FOUND) diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index a0a1b763cc..8193124e9e 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -27,15 +27,40 @@ if(TEST_CPP) target_link_libraries(cpp_dummy_build ${mbedcrypto_target}) endif() +find_package(Perl REQUIRED) + +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/query_config.c + COMMAND + ${PERL} + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt + ${CMAKE_CURRENT_BINARY_DIR}/query_config.c + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt +) +# this file will also be used in anoter directory, so create a target, see +# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory +add_custom_target(generate_query_config_c + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) + foreach(exe IN LISTS executables_libs executables_mbedcrypto) set(extra_sources "") if(exe STREQUAL "query_compile_time_config") list(APPEND extra_sources - ${CMAKE_CURRENT_SOURCE_DIR}/query_config.c) + ${CMAKE_CURRENT_SOURCE_DIR}/query_config.h + ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) endif() add_executable(${exe} ${exe}.c $ ${extra_sources}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) + if(exe STREQUAL "query_compile_time_config") + target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + endif() # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3 list(FIND executables_libs ${exe} exe_index) From 15a42c3e2615c3e47069a63eb6e8b19551cfa2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 14 May 2021 10:33:32 +0200 Subject: [PATCH 773/966] Allow CMake to generate psa_constant_names_generated.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This one's a bit funny too as the generated file is not a source to the executable (ie, it's not passed as an argument to the compiler), so CMake's dependency resolution didn't work even though the file is in the same directory. For some reason, the following didn't work either: add_dependencies(psa_constant_names ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c) So, apply the same strategy as for cross-directory use of a generated file by creating a target and using it as a dependency. Signed-off-by: Manuel Pégourié-Gonnard --- programs/psa/CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/programs/psa/CMakeLists.txt b/programs/psa/CMakeLists.txt index 23e85fea75..01bd687826 100644 --- a/programs/psa/CMakeLists.txt +++ b/programs/psa/CMakeLists.txt @@ -4,6 +4,21 @@ set(executables psa_constant_names ) +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c + COMMAND + ${PYTHON} + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py + ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/../.. + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_values.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_extra.h +) + foreach(exe IN LISTS executables) add_executable(${exe} ${exe}.c $) target_link_libraries(${exe} ${mbedcrypto_target}) @@ -11,6 +26,9 @@ foreach(exe IN LISTS executables) endforeach() target_include_directories(psa_constant_names PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +add_custom_target(generate_psa_constant_names_generated_c + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c) +add_dependencies(psa_constant_names generate_psa_constant_names_generated_c) install(TARGETS ${executables} DESTINATION "bin" From 42681f3bd0142eda32826c8012ac9143c9fc7af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 14 May 2021 10:53:43 +0200 Subject: [PATCH 774/966] Improve formatting of CMake file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - avoid very long lines - match order of command arguments and dependencies - group compiler flags together Signed-off-by: Manuel Pégourié-Gonnard --- tests/CMakeLists.txt | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fbd746e524..574b346dc7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,11 +13,6 @@ if(NOT MBEDTLS_PYTHON_EXECUTABLE) message(FATAL_ERROR "Cannot build test suites without Python 3") endif() -# Enable definition of various functions used throughout the testsuite -# (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless -# on non-POSIX platforms. -add_definitions("-D_POSIX_C_SOURCE=200809L") - # Test suites caught by SKIP_TEST_SUITES are built but not executed. # "foo" as a skip pattern skips "test_suite_foo" and "test_suite_foo.bar" # but not "test_suite_foobar". @@ -33,9 +28,26 @@ function(add_test_suite suite_name) endif() add_custom_command( - OUTPUT test_suite_${data_name}.c - COMMAND ${MBEDTLS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function -s ${CMAKE_CURRENT_SOURCE_DIR}/suites --helpers-file ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function -o . - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py ${mbedtls_target} ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data + OUTPUT + test_suite_${data_name}.c + COMMAND + ${MBEDTLS_PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py + -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function + -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data + -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function + -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function + -s ${CMAKE_CURRENT_SOURCE_DIR}/suites + --helpers-file ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function + -o . + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py + ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function + ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data + ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function + ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function + ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function + ${mbedtls_target} ) add_executable(test_suite_${data_name} test_suite_${data_name}.c $) @@ -55,6 +67,11 @@ function(add_test_suite suite_name) endif() endfunction(add_test_suite) +# Enable definition of various functions used throughout the testsuite +# (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless +# on non-POSIX platforms. +add_definitions("-D_POSIX_C_SOURCE=200809L") + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) From a9cb8941688a886a9ba7c6f0eaedd4f89d5004ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 14 May 2021 11:37:09 +0200 Subject: [PATCH 775/966] Add --directory option to generate_psa_tests.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- tests/scripts/generate_psa_tests.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 4c8143ff09..260a4c4c99 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -699,6 +699,8 @@ def main(args): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--list', action='store_true', help='List available targets and exit') + parser.add_argument('--directory', metavar='DIR', + help='Output directory (default: tests/suites)') parser.add_argument('targets', nargs='*', metavar='TARGET', help='Target file to generate (default: all; "-": none)') options = parser.parse_args(args) From ce3ba8f030b101df116ee3634df255e3e022f6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 14 May 2021 12:03:37 +0200 Subject: [PATCH 776/966] Allow CMake to run generate_psa_tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: the test suites are actually generated in the source tree, due to the use of link_to_source(suites) This will be fixed in the next commit. Signed-off-by: Manuel Pégourié-Gonnard --- tests/CMakeLists.txt | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 574b346dc7..cddedb455e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,6 +13,24 @@ if(NOT MBEDTLS_PYTHON_EXECUTABLE) message(FATAL_ERROR "Cannot build test suites without Python 3") endif() +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_not_supported.generated.data + ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.current.data + ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.v0.data + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/.. + COMMAND + ${MBEDTLS_PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py + --directory ${CMAKE_CURRENT_BINARY_DIR}/suites + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py + ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_values.h + ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_extra.h +) + # Test suites caught by SKIP_TEST_SUITES are built but not executed. # "foo" as a skip pattern skips "test_suite_foo" and "test_suite_foo.bar" # but not "test_suite_foobar". @@ -27,6 +45,16 @@ function(add_test_suite suite_name) set(data_name ${suite_name}) endif() + if(data_name STREQUAL "psa_crypto_not_supported.generated" OR + data_name STREQUAL "psa_crypto_storage_format.current" OR + data_name STREQUAL "psa_crypto_storage_format.v0") + set(data_file + ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_${data_name}.data) + else() + set(data_file + ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data) + endif() + add_custom_command( OUTPUT test_suite_${data_name}.c @@ -34,7 +62,7 @@ function(add_test_suite suite_name) ${MBEDTLS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function - -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data + -d ${data_file} -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function -s ${CMAKE_CURRENT_SOURCE_DIR}/suites @@ -43,7 +71,7 @@ function(add_test_suite suite_name) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function - ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data + ${data_file} ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function From 313bcfcde8188286874d21e8de4d19c05e0c4786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 7 Sep 2021 12:16:49 +0200 Subject: [PATCH 777/966] Stop writing to the source tree. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to the directory test/suites being linked, the files generated there where actually written to the source tree, not just the binary tree. We no longer need this directory to be linked, that was a remnant of the time where the .data files were read while running the tests; nowadays they're processed when generating the test .c file. Just create the directory, as the generating script quite reasonably assumes that the output directory passed on the command line exists. Signed-off-by: Manuel Pégourié-Gonnard --- tests/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cddedb455e..48716ae286 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,6 +13,9 @@ if(NOT MBEDTLS_PYTHON_EXECUTABLE) message(FATAL_ERROR "Cannot build test suites without Python 3") endif() +# generated .data files will go there +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/suites) + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_not_supported.generated.data @@ -215,5 +218,4 @@ if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) link_to_source(data_files) link_to_source(scripts) link_to_source(ssl-opt.sh) - link_to_source(suites) endif() From e90e405e15195414e50505c364183eba858763ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 8 Sep 2021 13:27:09 +0200 Subject: [PATCH 778/966] Introduce "Dev mode" option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the option is On, CMake will have rules to generate the generated files using scripts etc. When the option is Off, CMake will assume the files are available from the source tree; in that mode, it won't require any extra tools (Perl for example) compared to when we committed the files to git. The intention is that users will never need to adjust this option: - in the development branch (and features branches etc.) the option is always On (development mode); - in released tarballs, which include the generated files, we'll switch the option to Off (release mode) in the same commit that re-adds the generated files. Signed-off-by: Manuel Pégourié-Gonnard --- CMakeLists.txt | 1 + library/CMakeLists.txt | 61 +++++++++++++++++++----------------- programs/psa/CMakeLists.txt | 38 ++++++++++++---------- programs/ssl/CMakeLists.txt | 22 +++++++------ programs/test/CMakeLists.txt | 36 +++++++++++---------- tests/CMakeLists.txt | 40 +++++++++++++---------- 6 files changed, 112 insertions(+), 86 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 210aba4893..2731d727c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ option(ENABLE_PROGRAMS "Build mbed TLS programs." ON) option(UNSAFE_BUILD "Allow unsafe builds. These builds ARE NOT SECURE." OFF) option(MBEDTLS_FATAL_WARNINGS "Compiler warnings treated as errors" ON) +option(DEV_MODE "Development mode: (re)generate some files as needed" ON) string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") string(REGEX MATCH "GNU" CMAKE_COMPILER_IS_GNU "${CMAKE_C_COMPILER_ID}") diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 187693d563..f3b93fbdff 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -109,38 +109,43 @@ set(src_tls ssl_tls13_generic.c ) -find_package(Perl REQUIRED) +if(DEV_MODE) + find_package(Perl REQUIRED) -file(GLOB error_headers ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls/*.h) -add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/error.c - COMMAND - ${PERL_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_errors.pl - ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls - ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files + file(GLOB error_headers ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls/*.h) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/error.c - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_errors.pl - ${error_headers} - ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files/error.fmt -) + COMMAND + ${PERL_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_errors.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files + ${CMAKE_CURRENT_BINARY_DIR}/error.c + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_errors.pl + ${error_headers} + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files/error.fmt + ) -add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/version_features.c - COMMAND - ${PERL_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_features.pl - ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls - ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version_features.c - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_features.pl - ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls/mbedtls_config.h - ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files/version_features.fmt -) + COMMAND + ${PERL_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_features.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files + ${CMAKE_CURRENT_BINARY_DIR}/version_features.c + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/generate_features.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls/mbedtls_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data_files/version_features.fmt + ) +else() + link_to_source(error.c) + link_to_source(version_features.c) +endif() if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes") diff --git a/programs/psa/CMakeLists.txt b/programs/psa/CMakeLists.txt index 01bd687826..c5d0d28dd4 100644 --- a/programs/psa/CMakeLists.txt +++ b/programs/psa/CMakeLists.txt @@ -4,20 +4,24 @@ set(executables psa_constant_names ) -add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c - COMMAND - ${PYTHON} +if(DEV_MODE) + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c + COMMAND + ${PYTHON} + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py + ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/../.. + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py - ${CMAKE_CURRENT_BINARY_DIR} - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR}/../.. - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py - ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_values.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_extra.h -) + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_values.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_extra.h + ) +else() + link_to_source(psa_constant_names_generated.c) +endif() foreach(exe IN LISTS executables) add_executable(${exe} ${exe}.c $) @@ -26,9 +30,11 @@ foreach(exe IN LISTS executables) endforeach() target_include_directories(psa_constant_names PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -add_custom_target(generate_psa_constant_names_generated_c - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c) -add_dependencies(psa_constant_names generate_psa_constant_names_generated_c) +if(DEV_MODE) + add_custom_target(generate_psa_constant_names_generated_c + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c) + add_dependencies(psa_constant_names generate_psa_constant_names_generated_c) +endif() install(TARGETS ${executables} DESTINATION "bin" diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt index a14e264666..e8d2865d9e 100644 --- a/programs/ssl/CMakeLists.txt +++ b/programs/ssl/CMakeLists.txt @@ -18,14 +18,16 @@ set(executables ssl_server2 ) -# Inform CMake the the following file will be generated as part of the build -# process, so it doesn't complain that it doesn't exist yet. Starting from -# CMake 3.20, this will no longer be necessary as CMake will automatically -# propagate this information accross the tree, for now it's only visible -# inside the same directory, so we need to propagate manually. -set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c - PROPERTIES GENERATED TRUE) +if(DEV_MODE) + # Inform CMake the the following file will be generated as part of the build + # process, so it doesn't complain that it doesn't exist yet. Starting from + # CMake 3.20, this will no longer be necessary as CMake will automatically + # propagate this information accross the tree, for now it's only visible + # inside the same directory, so we need to propagate manually. + set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c + PROPERTIES GENERATED TRUE) +endif() foreach(exe IN LISTS executables) set(extra_sources "") @@ -40,7 +42,9 @@ foreach(exe IN LISTS executables) target_link_libraries(${exe} ${libs}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2") - add_dependencies(${exe} generate_query_config_c) + if(DEV_MODE) + add_dependencies(${exe} generate_query_config_c) + endif() target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../test) endif() diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 8193124e9e..053b03c952 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -27,26 +27,30 @@ if(TEST_CPP) target_link_libraries(cpp_dummy_build ${mbedcrypto_target}) endif() -find_package(Perl REQUIRED) +if(DEV_MODE) + find_package(Perl REQUIRED) -add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/query_config.c - COMMAND - ${PERL} + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/query_config.c + COMMAND + ${PERL} + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt + ${CMAKE_CURRENT_BINARY_DIR}/query_config.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt - ${CMAKE_CURRENT_BINARY_DIR}/query_config.c - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl - ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt -) -# this file will also be used in anoter directory, so create a target, see -# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory -add_custom_target(generate_query_config_c - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) + ) + # this file will also be used in anoter directory, so create a target, see + # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory + add_custom_target(generate_query_config_c + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) +else() + link_to_source(query_config.c) +endif() foreach(exe IN LISTS executables_libs executables_mbedcrypto) set(extra_sources "") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 48716ae286..454fe5aabd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,23 +16,29 @@ endif() # generated .data files will go there file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/suites) -add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_not_supported.generated.data - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.current.data - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.v0.data - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR}/.. - COMMAND - ${MBEDTLS_PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py - --directory ${CMAKE_CURRENT_BINARY_DIR}/suites - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py - ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_config.h - ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_values.h - ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_extra.h -) +if(DEV_MODE) + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_not_supported.generated.data + ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.current.data + ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.v0.data + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/.. + COMMAND + ${MBEDTLS_PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py + --directory ${CMAKE_CURRENT_BINARY_DIR}/suites + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py + ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_values.h + ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_extra.h + ) +else() + link_to_source(suites/test_suite_psa_crypto_not_supported.generated.data) + link_to_source(suites/test_suite_psa_crypto_storage_format.current.data) + link_to_source(suites/test_suite_psa_crypto_storage_format.v0.data) +endif() # Test suites caught by SKIP_TEST_SUITES are built but not executed. # "foo" as a skip pattern skips "test_suite_foo" and "test_suite_foo.bar" From 389150d4dbb6a8ee0666cd5ccf78d6fdb8b349f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 9 Sep 2021 10:51:16 +0200 Subject: [PATCH 779/966] Cleanup: remove *.datax files with CMake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unrelated to other commits in this PR, except when running manual tests I kept noticing these files where left over. Signed-off-by: Manuel Pégourié-Gonnard --- tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 454fe5aabd..6d54d7c576 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -85,6 +85,8 @@ function(add_test_suite suite_name) ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${mbedtls_target} + BYPRODUCTS + test_suite_${data_name}.datax ) add_executable(test_suite_${data_name} test_suite_${data_name}.c $) From bfe54d703d2709ae9b24780d4382bf801e11a54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 9 Sep 2021 11:11:44 +0200 Subject: [PATCH 780/966] Cleanup: rm all files generated by cmake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Again, unrelated, except I kept noticing. Signed-off-by: Manuel Pégourié-Gonnard --- tests/scripts/all.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 099174372e..27a83a23b4 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -292,7 +292,8 @@ cleanup() -iname CMakeFiles -exec rm -rf {} \+ -o \ \( -iname cmake_install.cmake -o \ -iname CTestTestfile.cmake -o \ - -iname CMakeCache.txt \) -exec rm -f {} \+ + -iname CMakeCache.txt -o \ + -path './cmake/*.cmake' \) -exec rm -f {} \+ # Recover files overwritten by in-tree CMake builds rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile From 9327fb33a6fa32daa42926d5bc500df08b54c51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 9 Sep 2021 11:46:25 +0200 Subject: [PATCH 781/966] Fix test_ref_config component of all.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- tests/scripts/all.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 27a83a23b4..d3fba17877 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -999,7 +999,16 @@ component_test_psa_crypto_rsa_no_genprime() { component_test_ref_configs () { msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s - CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + # test-ref-configs works by overwriting mbedtls_config.h; this makes cmake + # want to re-generate generated files that depend on it, quite correctly. + # However this doesn't work as the generation script expects a specific + # format for mbedtls_config.h, which the other files don't follow. Also, + # cmake can't know this, but re-generation is actually not necessary as + # the generated files only depend on the list of availabe options, not + # whether they're on or off. So, disable cmake's (over-sensitive here) + # dependency resolution for generated files and just rely on them being + # present (thanks for pre_generate_files) by turning DEV_MODE off. + CC=gcc cmake -D DEV_MODE=Off -D CMAKE_BUILD_TYPE:String=Asan . tests/scripts/test-ref-configs.pl } From e12e7f47de986686c257e549841de557f9851f77 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Fri, 15 Oct 2021 19:10:15 +0100 Subject: [PATCH 782/966] Get generated data file list from script Use the generate_psa_tests.py script to generate the list of test data files used as output files by cmake. Do this by introducing a new option --list-for-cmake that prints a semicolon-separated list of the data files with no terminating newline (since this is how a cmake list is represented). Replace the hard-coded output file list with a variable generated by the script using this option. Signed-off-by: David Horstmann --- tests/CMakeLists.txt | 13 ++++++++++--- tests/scripts/generate_psa_tests.py | 11 +++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6d54d7c576..ef41f2996e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,11 +17,18 @@ endif() file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/suites) if(DEV_MODE) + execute_process( + COMMAND + ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py + --list-for-cmake + --directory ${CMAKE_CURRENT_BINARY_DIR}/suites + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/.. + OUTPUT_VARIABLE + TEST_SUITE_DATA_FILES) add_custom_command( OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_not_supported.generated.data - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.current.data - ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_psa_crypto_storage_format.v0.data + ${TEST_SUITE_DATA_FILES} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. COMMAND diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 260a4c4c99..16e27ee6bb 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -699,6 +699,8 @@ def main(args): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--list', action='store_true', help='List available targets and exit') + parser.add_argument('--list-for-cmake', action='store_true', + help='Print \';\'-separated list of available targets and exit') parser.add_argument('--directory', metavar='DIR', help='Output directory (default: tests/suites)') parser.add_argument('targets', nargs='*', metavar='TARGET', @@ -710,6 +712,15 @@ def main(args): for name in sorted(generator.TARGETS): print(generator.filename_for(name)) return + # List in a cmake list format (i.e. ';'-separated) + if options.list_for_cmake: + filenames = [] + for name in sorted(generator.TARGETS): + if ';' in generator.filename_for(name): + raise ValueError('Cannot pass filename containing \';\' to cmake: ' + name) + filenames.append(generator.filename_for(name)) + print(';'.join(filenames), end='') + return if options.targets: # Allow "-" as a special case so you can run # ``generate_psa_tests.py - $targets`` and it works uniformly whether From 7b78ec88a4b6dff9345ff534541aa80f8f92b4dc Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Tue, 19 Oct 2021 14:43:54 +0100 Subject: [PATCH 783/966] Change variable name to lowercase This seems more correct for variables that are only used in a small area of the cmake file. Signed-off-by: David Horstmann --- tests/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ef41f2996e..ef484f68e2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,10 +25,10 @@ if(DEV_MODE) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. OUTPUT_VARIABLE - TEST_SUITE_DATA_FILES) + test_suite_data_files) add_custom_command( OUTPUT - ${TEST_SUITE_DATA_FILES} + ${test_suite_data_files} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. COMMAND From 1732b5d6ee51aa6bb7c7b61bf265864c79ebbdab Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Tue, 19 Oct 2021 16:43:53 +0100 Subject: [PATCH 784/966] Move test link_to_source() calls into a foreach This removes a hardcoded list of generated test names Signed-off-by: David Horstmann --- tests/CMakeLists.txt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ef484f68e2..4e44f88211 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,16 +16,17 @@ endif() # generated .data files will go there file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/suites) +execute_process( + COMMAND + ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py + --list-for-cmake + --directory ${CMAKE_CURRENT_BINARY_DIR}/suites + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR}/.. + OUTPUT_VARIABLE + test_suite_data_files) + if(DEV_MODE) - execute_process( - COMMAND - ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py - --list-for-cmake - --directory ${CMAKE_CURRENT_BINARY_DIR}/suites - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR}/.. - OUTPUT_VARIABLE - test_suite_data_files) add_custom_command( OUTPUT ${test_suite_data_files} @@ -42,9 +43,9 @@ if(DEV_MODE) ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_extra.h ) else() - link_to_source(suites/test_suite_psa_crypto_not_supported.generated.data) - link_to_source(suites/test_suite_psa_crypto_storage_format.current.data) - link_to_source(suites/test_suite_psa_crypto_storage_format.v0.data) + foreach(file ${test_suite_data_files}) + link_to_source(${file}) + endforeach() endif() # Test suites caught by SKIP_TEST_SUITES are built but not executed. From b3a5424a4e6e1c09d9b38ed1aa2b9cc1644bf3ce Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Tue, 19 Oct 2021 18:37:04 +0100 Subject: [PATCH 785/966] Add function to remove last filename extension Add a new function that takes a string and removes the portion following the last '.' character, usually a file extension. This would transform: * "a.b.c" into "a.b" * "name." into "name" * ".name" into "" * "no_dot" into "no_dot" (i.e. no change) CMake's existing file-extension-removal command removes the largest possible extension which would make "a.b.c" into "a", which is incorrect for handling tests that have '.'s within their names. The desired behaviour was added in CMake 3.14, but we support CMake >= 3.5.1 (for 3.0) and >= 2.8.12.2 (for 2.x) at the time of writing. Signed-off-by: David Horstmann --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2731d727c4..9c34da9228 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,22 @@ function(link_to_source base_name) endif() endfunction(link_to_source) +# Get the filename without the final extension (i.e. convert "a.b.c" to "a.b") +function(get_name_without_last_ext dest_var full_name) + # Split into a list on '.' (but a cmake list is just a ';'-separated string) + string(REPLACE "." ";" ext_parts "${full_name}") + # Remove the last item if there are more than one + list(LENGTH ext_parts ext_parts_len) + if (${ext_parts_len} GREATER "1") + math(EXPR ext_parts_last_item "${ext_parts_len} - 1") + list(REMOVE_AT ext_parts ${ext_parts_last_item}) + endif() + # Convert back to a string by replacing separators with '.' + string(REPLACE ";" "." no_ext_name "${ext_parts}") + # Copy into the desired variable + set(${dest_var} ${no_ext_name} PARENT_SCOPE) +endfunction(get_name_without_last_ext) + string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") include(CheckCCompilerFlag) From ae7bd3513cf1c47740cbdeccc105728f07025086 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Tue, 19 Oct 2021 19:05:42 +0100 Subject: [PATCH 786/966] Select test data directory using generated list Remove a hardcoded list of tests that use generated ".data" files, and instead derive this list from the existing list of test files (created using generate_psa_tests.py). This reduces the maintenance burden as only the list in generate_psa_tests.py needs to be updated. Signed-off-by: David Horstmann --- tests/CMakeLists.txt | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4e44f88211..d25f77239c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,12 +24,12 @@ execute_process( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. OUTPUT_VARIABLE - test_suite_data_files) + generated_data_files) if(DEV_MODE) add_custom_command( OUTPUT - ${test_suite_data_files} + ${generated_data_files} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. COMMAND @@ -43,7 +43,7 @@ if(DEV_MODE) ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_extra.h ) else() - foreach(file ${test_suite_data_files}) + foreach(file ${generated_data_files}) link_to_source(${file}) endforeach() endif() @@ -62,9 +62,20 @@ function(add_test_suite suite_name) set(data_name ${suite_name}) endif() - if(data_name STREQUAL "psa_crypto_not_supported.generated" OR - data_name STREQUAL "psa_crypto_storage_format.current" OR - data_name STREQUAL "psa_crypto_storage_format.v0") + # Get the test names of the tests with generated .data files + # from the generated_data_files list in parent scope. + set(generated_data_names "") + foreach(generated_data_file ${generated_data_files}) + # Get the plain filename + get_filename_component(generated_data_name ${generated_data_file} NAME) + # Remove the ".data" extension + get_name_without_last_ext(generated_data_name ${generated_data_name}) + # Remove leading "test_suite_" + string(SUBSTRING ${generated_data_name} 11 -1 generated_data_name) + list(APPEND generated_data_names ${generated_data_name}) + endforeach() + + if(";${generated_data_names};" MATCHES ";${data_name};") set(data_file ${CMAKE_CURRENT_BINARY_DIR}/suites/test_suite_${data_name}.data) else() From d64f4b249c62954da87648bbb7e26f1980a6615c Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 20 Oct 2021 12:29:47 +0100 Subject: [PATCH 787/966] Fix assorted spelling and wording issues Signed-off-by: David Horstmann --- programs/ssl/CMakeLists.txt | 4 ++-- programs/test/CMakeLists.txt | 2 +- scripts/generate_query_config.pl | 2 +- tests/scripts/all.sh | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt index e8d2865d9e..066940e91b 100644 --- a/programs/ssl/CMakeLists.txt +++ b/programs/ssl/CMakeLists.txt @@ -19,10 +19,10 @@ set(executables ) if(DEV_MODE) - # Inform CMake the the following file will be generated as part of the build + # Inform CMake that the following file will be generated as part of the build # process, so it doesn't complain that it doesn't exist yet. Starting from # CMake 3.20, this will no longer be necessary as CMake will automatically - # propagate this information accross the tree, for now it's only visible + # propagate this information across the tree, for now it's only visible # inside the same directory, so we need to propagate manually. set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 053b03c952..94331b8c7b 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -44,7 +44,7 @@ if(DEV_MODE) ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt ) - # this file will also be used in anoter directory, so create a target, see + # this file will also be used in another directory, so create a target, see # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory add_custom_target(generate_query_config_c DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) diff --git a/scripts/generate_query_config.pl b/scripts/generate_query_config.pl index eab986afad..b565024719 100755 --- a/scripts/generate_query_config.pl +++ b/scripts/generate_query_config.pl @@ -50,7 +50,7 @@ if( @ARGV ) { unless( -f $config_file && -f $query_config_format_file ) { chdir '..' or die; -f $config_file && -f $query_config_format_file - or die "Without arguments, must be run from root or a subdirectory\n"; + or die "No arguments supplied, must be run from project root or a first-level subdirectory\n"; } } diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index d3fba17877..f0e9a7d6c0 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1004,10 +1004,10 @@ component_test_ref_configs () { # However this doesn't work as the generation script expects a specific # format for mbedtls_config.h, which the other files don't follow. Also, # cmake can't know this, but re-generation is actually not necessary as - # the generated files only depend on the list of availabe options, not + # the generated files only depend on the list of available options, not # whether they're on or off. So, disable cmake's (over-sensitive here) # dependency resolution for generated files and just rely on them being - # present (thanks for pre_generate_files) by turning DEV_MODE off. + # present (thanks to pre_generate_files) by turning DEV_MODE off. CC=gcc cmake -D DEV_MODE=Off -D CMAKE_BUILD_TYPE:String=Asan . tests/scripts/test-ref-configs.pl } From ff0a3b3aa6d1c55f0beec9b59ff7284a97e50f6d Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 20 Oct 2021 14:04:02 +0100 Subject: [PATCH 788/966] Improve error message in generate_query_config.pl Add usage information to the ARGV-incorrect-length error message in generate_query_config.pl. A plain usage message looks a bit incongruous when raised as an error, but the error message alone is unhelpful. Signed-off-by: David Horstmann --- scripts/generate_query_config.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_query_config.pl b/scripts/generate_query_config.pl index b565024719..7855c7caa4 100755 --- a/scripts/generate_query_config.pl +++ b/scripts/generate_query_config.pl @@ -37,7 +37,7 @@ use strict; my ($config_file, $query_config_format_file, $query_config_file); if( @ARGV ) { - die "Invalid number of arguments" if scalar @ARGV != 3; + die "Invalid number of arguments - usage: $0 [CONFIG_FILE TEMPLATE_FILE OUTPUT_FILE]" if scalar @ARGV != 3; ($config_file, $query_config_format_file, $query_config_file) = @ARGV; -f $config_file or die "No such file: $config_file"; From 7570d24d3d9336aa57373b4b71cadfae9074e422 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 20 Oct 2021 16:27:24 +0100 Subject: [PATCH 789/966] Fix issue with DEV_MODE=OFF case When DEV_MODE=OFF, link_to_source() was being called with a full path in the build directory, rather than just a base name starting at "suites/" as was intended. Fix this by generating a list of base names and using that for link_to_source(), then deriving full paths afterwards. Signed-off-by: David Horstmann --- tests/CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d25f77239c..53692465b7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,15 +16,22 @@ endif() # generated .data files will go there file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/suites) +# Get base names for generated files (starting at "suites/") execute_process( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py --list-for-cmake - --directory ${CMAKE_CURRENT_BINARY_DIR}/suites + --directory suites WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. OUTPUT_VARIABLE - generated_data_files) + base_generated_data_files) + +# Derive generated file paths in the build directory +set(generated_data_files "") +foreach(file ${base_generated_data_files}) + list(APPEND generated_data_files ${CMAKE_CURRENT_BINARY_DIR}/${file}) +endforeach() if(DEV_MODE) add_custom_command( @@ -43,7 +50,7 @@ if(DEV_MODE) ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_extra.h ) else() - foreach(file ${generated_data_files}) + foreach(file ${base_generated_data_files}) link_to_source(${file}) endforeach() endif() From f602eb19bacaa5d411b1ccf000db361ca3b1c468 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 20 Oct 2021 16:40:56 +0100 Subject: [PATCH 790/966] Add comment explaining generate_psa_code.py Explain that the output filename is derived from the -d argument, so that it's obvious why the CMakefile code does what it does. Signed-off-by: David Horstmann --- tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 53692465b7..c884769682 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -92,6 +92,8 @@ function(add_test_suite suite_name) add_custom_command( OUTPUT + # The output filename of generate_test_code.py is derived from the -d + # input argument. test_suite_${data_name}.c COMMAND ${MBEDTLS_PYTHON_EXECUTABLE} From 3e30ad9b0d8ec230f490088ddd7273e7d592abcf Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 20 Oct 2021 16:53:58 +0100 Subject: [PATCH 791/966] Use MBEDTLS_PYTHON_EXECUTABLE Change one occurrence of ${PYTHON} to ${MBEDTLS_PYTHON_EXECUTABLE} and add implied ${MBEDTLS_PYTHON_EXECUTABLE} to the start of a different command. Signed-off-by: David Horstmann --- programs/psa/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/programs/psa/CMakeLists.txt b/programs/psa/CMakeLists.txt index c5d0d28dd4..fd8eeea783 100644 --- a/programs/psa/CMakeLists.txt +++ b/programs/psa/CMakeLists.txt @@ -9,7 +9,7 @@ if(DEV_MODE) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c COMMAND - ${PYTHON} + ${MBEDTLS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c884769682..0bd94baa27 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,6 +19,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/suites) # Get base names for generated files (starting at "suites/") execute_process( COMMAND + ${MBEDTLS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../tests/scripts/generate_psa_tests.py --list-for-cmake --directory suites From a8d14061073055ce619b2e254cb8f5e5e827ac0d Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 20 Oct 2021 17:14:23 +0100 Subject: [PATCH 792/966] Rename DEV_MODE to GEN_FILES GEN_FILES is a bit clearer as it describes what the setting does more precisely. Signed-off-by: David Horstmann --- CMakeLists.txt | 2 +- library/CMakeLists.txt | 2 +- programs/psa/CMakeLists.txt | 4 ++-- programs/ssl/CMakeLists.txt | 4 ++-- programs/test/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- tests/scripts/all.sh | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c34da9228..b0ece2a0ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ option(ENABLE_PROGRAMS "Build mbed TLS programs." ON) option(UNSAFE_BUILD "Allow unsafe builds. These builds ARE NOT SECURE." OFF) option(MBEDTLS_FATAL_WARNINGS "Compiler warnings treated as errors" ON) -option(DEV_MODE "Development mode: (re)generate some files as needed" ON) +option(GEN_FILES "Generate the auto-generated files as needed" ON) string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") string(REGEX MATCH "GNU" CMAKE_COMPILER_IS_GNU "${CMAKE_C_COMPILER_ID}") diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index f3b93fbdff..18aff5af39 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -109,7 +109,7 @@ set(src_tls ssl_tls13_generic.c ) -if(DEV_MODE) +if(GEN_FILES) find_package(Perl REQUIRED) file(GLOB error_headers ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls/*.h) diff --git a/programs/psa/CMakeLists.txt b/programs/psa/CMakeLists.txt index fd8eeea783..26ca73c185 100644 --- a/programs/psa/CMakeLists.txt +++ b/programs/psa/CMakeLists.txt @@ -4,7 +4,7 @@ set(executables psa_constant_names ) -if(DEV_MODE) +if(GEN_FILES) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c @@ -30,7 +30,7 @@ foreach(exe IN LISTS executables) endforeach() target_include_directories(psa_constant_names PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -if(DEV_MODE) +if(GEN_FILES) add_custom_target(generate_psa_constant_names_generated_c DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/psa_constant_names_generated.c) add_dependencies(psa_constant_names generate_psa_constant_names_generated_c) diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt index 066940e91b..280bbcf3d2 100644 --- a/programs/ssl/CMakeLists.txt +++ b/programs/ssl/CMakeLists.txt @@ -18,7 +18,7 @@ set(executables ssl_server2 ) -if(DEV_MODE) +if(GEN_FILES) # Inform CMake that the following file will be generated as part of the build # process, so it doesn't complain that it doesn't exist yet. Starting from # CMake 3.20, this will no longer be necessary as CMake will automatically @@ -42,7 +42,7 @@ foreach(exe IN LISTS executables) target_link_libraries(${exe} ${libs}) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2") - if(DEV_MODE) + if(GEN_FILES) add_dependencies(${exe} generate_query_config_c) endif() target_include_directories(${exe} diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 94331b8c7b..142a831667 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -27,7 +27,7 @@ if(TEST_CPP) target_link_libraries(cpp_dummy_build ${mbedcrypto_target}) endif() -if(DEV_MODE) +if(GEN_FILES) find_package(Perl REQUIRED) add_custom_command( diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0bd94baa27..41dceed939 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,7 +34,7 @@ foreach(file ${base_generated_data_files}) list(APPEND generated_data_files ${CMAKE_CURRENT_BINARY_DIR}/${file}) endforeach() -if(DEV_MODE) +if(GEN_FILES) add_custom_command( OUTPUT ${generated_data_files} diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f0e9a7d6c0..595b1baf91 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1007,8 +1007,8 @@ component_test_ref_configs () { # the generated files only depend on the list of available options, not # whether they're on or off. So, disable cmake's (over-sensitive here) # dependency resolution for generated files and just rely on them being - # present (thanks to pre_generate_files) by turning DEV_MODE off. - CC=gcc cmake -D DEV_MODE=Off -D CMAKE_BUILD_TYPE:String=Asan . + # present (thanks to pre_generate_files) by turning GEN_FILES off. + CC=gcc cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan . tests/scripts/test-ref-configs.pl } From 65d8c69e80734454204c9dcc1a3c11a4a8cbf63d Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Thu, 21 Oct 2021 16:09:51 +0100 Subject: [PATCH 793/966] Remove unnecessary check for ';' in filenames The Makefiles already assume that filenames don't contain special characters anyway, so we don't need to check this in generate_psa_tests.py. Signed-off-by: David Horstmann --- tests/scripts/generate_psa_tests.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 16e27ee6bb..1e5d2041b5 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -715,11 +715,8 @@ def main(args): # List in a cmake list format (i.e. ';'-separated) if options.list_for_cmake: filenames = [] - for name in sorted(generator.TARGETS): - if ';' in generator.filename_for(name): - raise ValueError('Cannot pass filename containing \';\' to cmake: ' + name) - filenames.append(generator.filename_for(name)) - print(';'.join(filenames), end='') + print(';'.join(generator.filename_for(name) + for name in sorted(generator.TARGETS)), end='') return if options.targets: # Allow "-" as a special case so you can run From 774965188a1012e57730e8f18e095eb837b9d94a Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Thu, 21 Oct 2021 19:45:52 +0100 Subject: [PATCH 794/966] Turn GEN_FILES off by default on windows If on windows, turn off GEN_FILES as it does not currently work (for reasons unknown). Note: The WIN32 variable is "True on windows systems, including win64", as one would expect. Signed-off-by: David Horstmann --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0ece2a0ea..cd990abe88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,11 @@ option(ENABLE_PROGRAMS "Build mbed TLS programs." ON) option(UNSAFE_BUILD "Allow unsafe builds. These builds ARE NOT SECURE." OFF) option(MBEDTLS_FATAL_WARNINGS "Compiler warnings treated as errors" ON) -option(GEN_FILES "Generate the auto-generated files as needed" ON) +if(WIN32) + option(GEN_FILES "Generate the auto-generated files as needed" OFF) +else() + option(GEN_FILES "Generate the auto-generated files as needed" ON) +endif() string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") string(REGEX MATCH "GNU" CMAKE_COMPILER_IS_GNU "${CMAKE_C_COMPILER_ID}") From 48a05536841b15b22f2d8c54892a5bb75a24304b Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Fri, 22 Oct 2021 15:10:46 +0100 Subject: [PATCH 795/966] Document the CMake generated files capability Add a line in the README explaining that CMake will generate the files it needs automatically on non-Windows systems when not cross-compiling. Signed-off-by: David Horstmann --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dbe6a2325e..e6924cbe1d 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ If you are cross-compiling, you must set the `CC` environment variable to a C co Any of the following methods are available to generate the configuration-independent files: * If not cross-compiling, running `make` with any target, or just `make`, will automatically generate required files. +* On non-Windows systems, when not cross-compiling, CMake will generate the required files automatically. * Run `make generated_files` to generate all the configuration-independent files. * On Unix/POSIX systems, run `tests/scripts/check-generated-files.sh -u` to generate all the configuration-independent files. * On Windows, run `scripts\make_generated_files.bat` to generate all the configuration-independent files. From 3ee10e841e1ff1398ae9ecebd85c4ad5455d9e14 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Fri, 22 Oct 2021 18:22:11 +0100 Subject: [PATCH 796/966] Fix unused variable in generate_psa_tests.py Remove the newly-unused variable that became unused in a previous commit. Signed-off-by: David Horstmann --- tests/scripts/generate_psa_tests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 1e5d2041b5..39fb210278 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -714,7 +714,6 @@ def main(args): return # List in a cmake list format (i.e. ';'-separated) if options.list_for_cmake: - filenames = [] print(';'.join(generator.filename_for(name) for name in sorted(generator.TARGETS)), end='') return From 2c1442ebc03e7fb3ea3012876f964d4c90a5b2b2 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 26 Jul 2021 20:20:54 +0200 Subject: [PATCH 797/966] New sample program to benchmark certificate loading Signed-off-by: Gilles Peskine --- programs/.gitignore | 1 + programs/Makefile | 5 + programs/x509/CMakeLists.txt | 1 + programs/x509/load_roots.c | 203 +++++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 programs/x509/load_roots.c diff --git a/programs/.gitignore b/programs/.gitignore index d8eb6baa03..deb104a401 100644 --- a/programs/.gitignore +++ b/programs/.gitignore @@ -69,6 +69,7 @@ x509/cert_app x509/cert_req x509/cert_write x509/crl_app +x509/load_roots x509/req_app # Generated data files diff --git a/programs/Makefile b/programs/Makefile index 02eb5a1430..7f9d11e80d 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -110,6 +110,7 @@ APPS = \ x509/cert_req \ x509/cert_write \ x509/crl_app \ + x509/load_roots \ x509/req_app \ # End of APPS @@ -387,6 +388,10 @@ x509/cert_req$(EXEXT): x509/cert_req.c $(DEP) echo " CC x509/cert_req.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/cert_req.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ +x509/load_roots$(EXEXT): x509/load_roots.c $(DEP) + echo " CC x509/load_roots.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/load_roots.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + x509/req_app$(EXEXT): x509/req_app.c $(DEP) echo " CC x509/req_app.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) x509/req_app.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ diff --git a/programs/x509/CMakeLists.txt b/programs/x509/CMakeLists.txt index a04fa8bcf8..5876b8d21d 100644 --- a/programs/x509/CMakeLists.txt +++ b/programs/x509/CMakeLists.txt @@ -7,6 +7,7 @@ set(executables cert_req cert_write crl_app + load_roots req_app ) diff --git a/programs/x509/load_roots.c b/programs/x509/load_roots.c new file mode 100644 index 0000000000..cb168126a2 --- /dev/null +++ b/programs/x509/load_roots.c @@ -0,0 +1,203 @@ +/* + * Root CA reading application + * + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + * + * This file is provided under the Apache License 2.0, or the + * GNU General Public License v2.0 or later. + * + * ********** + * Apache License 2.0: + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ********** + * + * ********** + * GNU General Public License v2.0 or later: + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * ********** + */ + +#include "mbedtls/build_info.h" + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_time time +#define mbedtls_time_t time_t +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif /* MBEDTLS_PLATFORM_C */ + +#if !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_FS_IO) || \ + !defined(MBEDTLS_TIMING_C) +int main( void ) +{ + mbedtls_printf("MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_FS_IO and/or " + "MBEDTLS_TIMING_C not defined.\n"); + mbedtls_exit( 0 ); +} +#else + +#include "mbedtls/error.h" +#include "mbedtls/timing.h" +#include "mbedtls/x509_crt.h" + +#include +#include +#include + +#define DFL_ITERATIONS 1 +#define DFL_PRIME_CACHE 1 + +#define USAGE \ + "\n usage: load_roots param=<>... [--] {FILE|DIR}...\n" \ + "\n acceptable parameters:\n" \ + " iterations=%%d Iteration count (not including cache priming); default: 1\n" \ + " prime=%%d Prime the disk read cache? Default: 1 (yes)\n" \ + "\n" + + +/* + * global options + */ +struct options +{ + const char **filenames; /* NULL-terminated list of file names */ + unsigned iterations; /* Number of iterations to time */ + int prime_cache; /* Prime the disk read cache? */ +} opt; + + +int read_certificates( const char *const *filenames ) +{ + mbedtls_x509_crt cas; + int ret = 0; + const char *const *cur; + char error_message[200]; + + mbedtls_x509_crt_init( &cas ); + + for( cur = filenames; *cur != NULL; cur++ ) + { + ret = mbedtls_x509_crt_parse_file( &cas, *cur ); + if( ret != 0 ) + { + mbedtls_strerror( ret, error_message, sizeof( error_message ) ); + printf( "\n%s: -0x%04x (%s)\n", *cur, -ret, error_message ); + goto exit; + } + } + +exit: + mbedtls_x509_crt_free( &cas ); + return( ret == 0 ); +} + +int main( int argc, char *argv[] ) +{ + int exit_code = MBEDTLS_EXIT_FAILURE; + unsigned i, j; + struct mbedtls_timing_hr_time timer; + unsigned long ms; + + if( argc == 0 ) + { + mbedtls_printf( USAGE ); + goto exit; + } + + opt.filenames = NULL; + opt.iterations = DFL_ITERATIONS; + opt.prime_cache = DFL_PRIME_CACHE; + + for( i = 1; i < (unsigned) argc; i++ ) + { + char *p = argv[i]; + char *q = NULL; + + if( strcmp( p, "--" ) == 0 ) + break; + if( ( q = strchr( p, '=' ) ) == NULL ) + break; + *q++ = '\0'; + + for( j = 0; p + j < q; j++ ) + { + if( argv[i][j] >= 'A' && argv[i][j] <= 'Z' ) + argv[i][j] |= 0x20; + } + + if( strcmp( p, "iterations" ) == 0 ) + { + opt.iterations = atoi( q ); + } + else if( strcmp( p, "prime" ) == 0 ) + { + opt.iterations = atoi( q ) != 0; + } + else + mbedtls_printf( "Unknown option: %s\n", p ); + } + + opt.filenames = (const char**) argv + i; + if( *opt.filenames == 0 ) + { + mbedtls_printf( "Missing list of certificate files to parse\n" ); + goto exit; + } + + mbedtls_printf( "Parsing %u certificates", argc - i ); + if( opt.prime_cache ) + { + if( ! read_certificates( opt.filenames ) ) + goto exit; + mbedtls_printf( " " ); + } + + (void) mbedtls_timing_get_timer( &timer, 1 ); + for( i = 1; i <= opt.iterations; i++ ) + { + if( ! read_certificates( opt.filenames ) ) + goto exit; + mbedtls_printf( "." ); + } + ms = mbedtls_timing_get_timer( &timer, 0 ); + mbedtls_printf( "\n%u iterations -> %lu ms\n", opt.iterations, ms ); + exit_code = MBEDTLS_EXIT_SUCCESS; + +exit: + mbedtls_exit( exit_code ); +} +#endif /* necessary configuration */ From b553eaabeac6cc4a08676accfaad5458bf47c7f7 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 28 Jul 2021 11:33:04 +0200 Subject: [PATCH 798/966] Base64 decoding: don't use the table for '=' Base64 decoding uses equality comparison tests for characters that don't leak information about the content of the data other than its length, such as whitespace. Do this with '=' as well, since it only reveals information about the length. This way the table lookup can focus on character validity and decoding value. Signed-off-by: Gilles Peskine --- library/base64.c | 64 +++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/library/base64.c b/library/base64.c index 9cf5dd41d4..8b818c86a8 100644 --- a/library/base64.c +++ b/library/base64.c @@ -54,7 +54,7 @@ static const unsigned char base64_dec_map[128] = 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 62, 127, 127, 127, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 127, 127, - 127, 64, 127, 127, 127, 0, 1, 2, 3, 4, + 127, 127, 127, 127, 127, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 127, 127, 127, 127, 127, 127, 26, 27, 28, @@ -90,31 +90,6 @@ static void mbedtls_base64_cond_assign_uchar( unsigned char * dest, const unsign *dest = ( ( *src ) & mask ) | ( ( *dest ) & ~mask ); } -/* - * Constant flow conditional assignment to uint_32 - */ -static void mbedtls_base64_cond_assign_uint32( uint32_t * dest, const uint32_t src, - uint32_t condition ) -{ - /* MSVC has a warning about unary minus on unsigned integer types, - * but this is well-defined and precisely what we want to do here. */ -#if defined(_MSC_VER) -#pragma warning( push ) -#pragma warning( disable : 4146 ) -#endif - - /* Generate bitmask from condition, mask will either be 0xFFFFFFFF or 0 */ - uint32_t mask = ( condition | -condition ); - mask >>= 31; - mask = -mask; - -#if defined(_MSC_VER) -#pragma warning( pop ) -#endif - - *dest = ( src & mask ) | ( ( *dest ) & ~mask ); -} - /* * Constant flow check for equality */ @@ -273,17 +248,22 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, if( x != 0 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); - if( src[i] == '=' && ++j > 2 ) - return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); - - dec_map_lookup = mbedtls_base64_table_lookup( base64_dec_map, sizeof( base64_dec_map ), src[i] ); - - if( src[i] > 127 || dec_map_lookup == 127 ) - return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); - - if( dec_map_lookup < 64 && j != 0 ) + if( src[i] > 127 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); + if( src[i] == '=' ) + { + if( ++j > 2 ) + return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); + } + else + { + if( j != 0 ) + return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); + dec_map_lookup = mbedtls_base64_table_lookup( base64_dec_map, sizeof( base64_dec_map ), src[i] ); + if( dec_map_lookup == 127 ) + return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); + } n++; } @@ -311,10 +291,16 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, if( *src == '\r' || *src == '\n' || *src == ' ' ) continue; - dec_map_lookup = mbedtls_base64_table_lookup( base64_dec_map, sizeof( base64_dec_map ), *src ); - - mbedtls_base64_cond_assign_uint32( &j, j - 1, mbedtls_base64_eq( dec_map_lookup, 64 ) ); - x = ( x << 6 ) | ( dec_map_lookup & 0x3F ); + if( *src == '=' ) + { + --j; + x = x << 6; + } + else + { + dec_map_lookup = mbedtls_base64_table_lookup( base64_dec_map, sizeof( base64_dec_map ), *src ); + x = ( x << 6 ) | ( dec_map_lookup & 0x3F ); + } if( ++n == 4 ) { From ab043350525833314b5a2e6d0d2efcd6510a8142 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 28 Jul 2021 13:54:02 +0200 Subject: [PATCH 799/966] Base64 decoding: use ranges instead of tables Instead of doing constant-flow table lookup, which requires 128 memory loads for each lookup into a 128-entry table, do a range-based calculation, which requires more CPU instructions per range but there are only 5 ranges. Experimentally, this is ~12x faster on my PC (based on programs/x509/load_roots). The code is slightly smaller, too. Signed-off-by: Gilles Peskine --- library/base64.c | 64 +++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/library/base64.c b/library/base64.c index 8b818c86a8..7d9ddf9cd8 100644 --- a/library/base64.c +++ b/library/base64.c @@ -46,23 +46,6 @@ static const unsigned char base64_enc_map[64] = '8', '9', '+', '/' }; -static const unsigned char base64_dec_map[128] = -{ - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 62, 127, 127, 127, 63, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 127, 127, - 127, 127, 127, 127, 127, 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 127, 127, 127, 127, 127, 127, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 127, 127, 127, 127, 127 -}; - #define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */ /* @@ -133,6 +116,18 @@ static unsigned char mbedtls_base64_table_lookup( const unsigned char * const ta return result; } +/* Return 0xff if low <= c <= high, 0 otherwise. + * + * Constant flow with respect to c. + */ +static unsigned char mask_of_range( unsigned char low, unsigned char high, + unsigned char c ) +{ + unsigned low_mask = ( c - low ) >> 8; + unsigned high_mask = ( c - high - 1 ) >> 8; + return( ~low_mask & high_mask & 0xff ); +} + /* * Encode a buffer into base64 format */ @@ -211,6 +206,34 @@ int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, return( 0 ); } +/* Given a Base64 digit, return its value. + * If c is not a Base64 digit ('A'..'Z', 'a'..'z', '0'..'9', '+' or '/'), + * return -1. + * + * The implementation assumes that letters are consecutive (e.g. ASCII + * but not EBCDIC). + * + * The implementation is constant-flow (no branch or memory access depending + * on the value of c) unless the compiler inlines and optimizes a specific + * access. + */ +static signed char dec_value( unsigned char c ) +{ + unsigned char val = 0; + /* For each range of digits, if c is in that range, mask val with + * the corresponding value. Since c can only be in a single range, + * only at most one masking will change val. Set val to one plus + * the desired value so that it stays 0 if c is in none of the ranges. */ + val |= mask_of_range( 'A', 'Z', c ) & ( c - 'A' + 0 + 1 ); + val |= mask_of_range( 'a', 'z', c ) & ( c - 'a' + 26 + 1 ); + val |= mask_of_range( '0', '9', c ) & ( c - '0' + 52 + 1 ); + val |= mask_of_range( '+', '+', c ) & ( c - '+' + 62 + 1 ); + val |= mask_of_range( '/', '/', c ) & ( c - '/' + 63 + 1 ); + /* At this point, val is 0 if c is an invalid digit and v+1 if c is + * a digit with the value v. */ + return( val - 1 ); +} + /* * Decode a base64-formatted buffer */ @@ -220,7 +243,6 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, size_t i, n; uint32_t j, x; unsigned char *p; - unsigned char dec_map_lookup; /* First pass: check for validity and get output length */ for( i = n = j = 0; i < slen; i++ ) @@ -260,8 +282,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, { if( j != 0 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); - dec_map_lookup = mbedtls_base64_table_lookup( base64_dec_map, sizeof( base64_dec_map ), src[i] ); - if( dec_map_lookup == 127 ) + if( dec_value( src[i] ) < 0 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); } n++; @@ -298,8 +319,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, } else { - dec_map_lookup = mbedtls_base64_table_lookup( base64_dec_map, sizeof( base64_dec_map ), *src ); - x = ( x << 6 ) | ( dec_map_lookup & 0x3F ); + x = ( x << 6 ) | ( dec_value( *src ) & 0x3F ); } if( ++n == 4 ) From 1121cd29b65f89186102f82bf3ae0dda24029a63 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 28 Jul 2021 14:20:06 +0200 Subject: [PATCH 800/966] Base64 decode: simplify local variables Document what each local variable does when it isn't obvious from the name. Don't reuse a variable for different purposes. This commit has very little impact on the generated code (same code size on a sample Thumb build), although it does fix a theoretical bug that 2^32 spaces inside a line would be ignored instead of treated as an error. Signed-off-by: Gilles Peskine --- library/base64.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/library/base64.c b/library/base64.c index 7d9ddf9cd8..960f778ca1 100644 --- a/library/base64.c +++ b/library/base64.c @@ -240,19 +240,22 @@ static signed char dec_value( unsigned char c ) int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen ) { - size_t i, n; - uint32_t j, x; + size_t i; /* index in source */ + size_t n; /* number of digits or trailing = in source */ + uint32_t x; /* value accumulator */ + unsigned equals = 0; + int spaces_present = 0; unsigned char *p; /* First pass: check for validity and get output length */ - for( i = n = j = 0; i < slen; i++ ) + for( i = n = 0; i < slen; i++ ) { /* Skip spaces before checking for EOL */ - x = 0; + spaces_present = 0; while( i < slen && src[i] == ' ' ) { ++i; - ++x; + spaces_present = 1; } /* Spaces at end of buffer are OK */ @@ -267,7 +270,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, continue; /* Space inside a line is an error */ - if( x != 0 ) + if( spaces_present ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); if( src[i] > 127 ) @@ -275,12 +278,12 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, if( src[i] == '=' ) { - if( ++j > 2 ) + if( ++equals > 2 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); } else { - if( j != 0 ) + if( equals != 0 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); if( dec_value( src[i] ) < 0 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); @@ -299,7 +302,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, * n = ( ( n * 6 ) + 7 ) >> 3; */ n = ( 6 * ( n >> 3 ) ) + ( ( 6 * ( n & 0x7 ) + 7 ) >> 3 ); - n -= j; + n -= equals; if( dst == NULL || dlen < n ) { @@ -307,27 +310,24 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL ); } - for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ ) - { + equals = 0; + for( n = x = 0, p = dst; i > 0; i--, src++ ) + { if( *src == '\r' || *src == '\n' || *src == ' ' ) continue; + x = x << 6; if( *src == '=' ) - { - --j; - x = x << 6; - } + ++equals; else - { - x = ( x << 6 ) | ( dec_value( *src ) & 0x3F ); - } + x |= dec_value( *src ); if( ++n == 4 ) { n = 0; - if( j > 0 ) *p++ = MBEDTLS_BYTE_2( x ); - if( j > 1 ) *p++ = MBEDTLS_BYTE_1( x ); - if( j > 2 ) *p++ = MBEDTLS_BYTE_0( x ); + *p++ = MBEDTLS_BYTE_2( x ); + if( equals <= 1 ) *p++ = MBEDTLS_BYTE_1( x ); + if( equals <= 0 ) *p++ = MBEDTLS_BYTE_0( x ); } } From 2c4a3686bb822c3c67e1f6157e5087ea6a3bf4db Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 28 Jul 2021 14:31:39 +0200 Subject: [PATCH 801/966] Base64 encoding: use ranges instead of tables Instead of doing constant-flow table lookup, which requires 64 memory loads for each lookup into a 64-entry table, do a range-based calculation, which requires more CPU instructions per range but there are only 5 ranges. I expect a significant performance gain (although smaller than for decoding since the encoding table is half the size), but I haven't measured. Code size is slightly smaller. Signed-off-by: Gilles Peskine --- library/base64.c | 122 ++++++++++------------------------------------- 1 file changed, 25 insertions(+), 97 deletions(-) diff --git a/library/base64.c b/library/base64.c index 960f778ca1..832484f98f 100644 --- a/library/base64.c +++ b/library/base64.c @@ -35,87 +35,8 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ -static const unsigned char base64_enc_map[64] = -{ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', '+', '/' -}; - #define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */ -/* - * Constant flow conditional assignment to unsigned char - */ -static void mbedtls_base64_cond_assign_uchar( unsigned char * dest, const unsigned char * const src, - unsigned char condition ) -{ - /* MSVC has a warning about unary minus on unsigned integer types, - * but this is well-defined and precisely what we want to do here. */ -#if defined(_MSC_VER) -#pragma warning( push ) -#pragma warning( disable : 4146 ) -#endif - - /* Generate bitmask from condition, mask will either be 0xFF or 0 */ - unsigned char mask = ( condition | -condition ); - mask >>= 7; - mask = -mask; - -#if defined(_MSC_VER) -#pragma warning( pop ) -#endif - - *dest = ( ( *src ) & mask ) | ( ( *dest ) & ~mask ); -} - -/* - * Constant flow check for equality - */ -static unsigned char mbedtls_base64_eq( size_t in_a, size_t in_b ) -{ - size_t difference = in_a ^ in_b; - - /* MSVC has a warning about unary minus on unsigned integer types, - * but this is well-defined and precisely what we want to do here. */ -#if defined(_MSC_VER) -#pragma warning( push ) -#pragma warning( disable : 4146 ) -#endif - - difference |= -difference; - -#if defined(_MSC_VER) -#pragma warning( pop ) -#endif - - /* cope with the varying size of size_t per platform */ - difference >>= ( sizeof( difference ) * 8 - 1 ); - - return (unsigned char) ( 1 ^ difference ); -} - -/* - * Constant flow lookup into table. - */ -static unsigned char mbedtls_base64_table_lookup( const unsigned char * const table, - const size_t table_size, const size_t table_index ) -{ - size_t i; - unsigned char result = 0; - - for( i = 0; i < table_size; ++i ) - { - mbedtls_base64_cond_assign_uchar( &result, &table[i], mbedtls_base64_eq( i, table_index ) ); - } - - return result; -} - /* Return 0xff if low <= c <= high, 0 otherwise. * * Constant flow with respect to c. @@ -128,6 +49,24 @@ static unsigned char mask_of_range( unsigned char low, unsigned char high, return( ~low_mask & high_mask & 0xff ); } +/* Given a value in the range 0..63, return the corresponding Base64 digit. + * The implementation assumes that letters are consecutive (e.g. ASCII + * but not EBCDIC). + */ +static unsigned char enc_char( unsigned char val ) +{ + unsigned char digit = 0; + /* For each range of values, if val is in that range, mask digit with + * the corresponding value. Since val can only be in a single range, + * only at most one masking will change digit. */ + digit |= mask_of_range( 0, 25, val ) & ( 'A' + val ); + digit |= mask_of_range( 26, 51, val ) & ( 'a' + val - 26 ); + digit |= mask_of_range( 52, 61, val ) & ( '0' + val - 52 ); + digit |= mask_of_range( 62, 62, val ) & '+'; + digit |= mask_of_range( 63, 63, val ) & '/'; + return( digit ); +} + /* * Encode a buffer into base64 format */ @@ -168,17 +107,10 @@ int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, C2 = *src++; C3 = *src++; - *p++ = mbedtls_base64_table_lookup( base64_enc_map, sizeof( base64_enc_map ), - ( ( C1 >> 2 ) & 0x3F ) ); - - *p++ = mbedtls_base64_table_lookup( base64_enc_map, sizeof( base64_enc_map ), - ( ( ( ( C1 & 3 ) << 4 ) + ( C2 >> 4 ) ) & 0x3F ) ); - - *p++ = mbedtls_base64_table_lookup( base64_enc_map, sizeof( base64_enc_map ), - ( ( ( ( C2 & 15 ) << 2 ) + ( C3 >> 6 ) ) & 0x3F ) ); - - *p++ = mbedtls_base64_table_lookup( base64_enc_map, sizeof( base64_enc_map ), - ( C3 & 0x3F ) ); + *p++ = enc_char( ( C1 >> 2 ) & 0x3F ); + *p++ = enc_char( ( ( ( C1 & 3 ) << 4 ) + ( C2 >> 4 ) ) & 0x3F ); + *p++ = enc_char( ( ( ( C2 & 15 ) << 2 ) + ( C3 >> 6 ) ) & 0x3F ); + *p++ = enc_char( C3 & 0x3F ); } if( i < slen ) @@ -186,15 +118,11 @@ int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, C1 = *src++; C2 = ( ( i + 1 ) < slen ) ? *src++ : 0; - *p++ = mbedtls_base64_table_lookup( base64_enc_map, sizeof( base64_enc_map ), - ( ( C1 >> 2 ) & 0x3F ) ); - - *p++ = mbedtls_base64_table_lookup( base64_enc_map, sizeof( base64_enc_map ), - ( ( ( ( C1 & 3 ) << 4 ) + ( C2 >> 4 ) ) & 0x3F ) ); + *p++ = enc_char( ( C1 >> 2 ) & 0x3F ); + *p++ = enc_char( ( ( ( C1 & 3 ) << 4 ) + ( C2 >> 4 ) ) & 0x3F ); if( ( i + 1 ) < slen ) - *p++ = mbedtls_base64_table_lookup( base64_enc_map, sizeof( base64_enc_map ), - ( ( ( C2 & 15 ) << 2 ) & 0x3F ) ); + *p++ = enc_char( ( ( C2 & 15 ) << 2 ) & 0x3F ); else *p++ = '='; *p++ = '='; From 66884e6dae845e1e57b1c9c6b017cfd8f7856abc Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 28 Jul 2021 14:37:14 +0200 Subject: [PATCH 802/966] Base64 range-based constant-flow code: changelog entry Signed-off-by: Gilles Peskine --- ChangeLog.d/base64-ranges.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 ChangeLog.d/base64-ranges.txt diff --git a/ChangeLog.d/base64-ranges.txt b/ChangeLog.d/base64-ranges.txt new file mode 100644 index 0000000000..8ffba2deec --- /dev/null +++ b/ChangeLog.d/base64-ranges.txt @@ -0,0 +1,4 @@ +Changes + * Improve the performance of base64 constant-flow code. The result is still + slower than the original non-constant-flow implementation, but much faster + than the previous constant-flow implemenation. Fixes #4814. From 67468e81a602b2d74fbaf6e0de7b72f7760dad9b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 30 Jul 2021 12:56:21 +0200 Subject: [PATCH 803/966] Base64 decode: simplify local variables (n) n was used for two different purposes. Give it a different name the second time. This does not seem to change the generated code when compiling with optimization for size or performance. Signed-off-by: Gilles Peskine --- library/base64.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/base64.c b/library/base64.c index 832484f98f..d33429645b 100644 --- a/library/base64.c +++ b/library/base64.c @@ -171,6 +171,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, size_t i; /* index in source */ size_t n; /* number of digits or trailing = in source */ uint32_t x; /* value accumulator */ + unsigned accumulated_digits = 0; unsigned equals = 0; int spaces_present = 0; unsigned char *p; @@ -239,7 +240,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, } equals = 0; - for( n = x = 0, p = dst; i > 0; i--, src++ ) + for( x = 0, p = dst; i > 0; i--, src++ ) { if( *src == '\r' || *src == '\n' || *src == ' ' ) continue; @@ -250,9 +251,9 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, else x |= dec_value( *src ); - if( ++n == 4 ) + if( ++accumulated_digits == 4 ) { - n = 0; + accumulated_digits = 0; *p++ = MBEDTLS_BYTE_2( x ); if( equals <= 1 ) *p++ = MBEDTLS_BYTE_1( x ); if( equals <= 0 ) *p++ = MBEDTLS_BYTE_0( x ); From 8635e2301fc2c9232922fce294884de99ea78923 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 30 Jul 2021 12:57:22 +0200 Subject: [PATCH 804/966] mask_of_range: simplify high comparison To test c <= high, instead of testing the sign of (high + 1) - c, negate the sign of high - c (as we're doing for c - low). This is a little easier to read and shaves 2 instructions off the arm thumb build with arm-none-eabi-gcc 7.3.1. Signed-off-by: Gilles Peskine --- library/base64.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/base64.c b/library/base64.c index d33429645b..6ddd501a4f 100644 --- a/library/base64.c +++ b/library/base64.c @@ -44,9 +44,11 @@ static unsigned char mask_of_range( unsigned char low, unsigned char high, unsigned char c ) { - unsigned low_mask = ( c - low ) >> 8; - unsigned high_mask = ( c - high - 1 ) >> 8; - return( ~low_mask & high_mask & 0xff ); + /* low_mask is: 0 if low <= c, 0x...ff if low > c */ + unsigned low_mask = ( (unsigned) c - low ) >> 8; + /* high_mask is: 0 if c <= high, 0x...ff if high > c */ + unsigned high_mask = ( (unsigned) high - c ) >> 8; + return( ~( low_mask | high_mask ) & 0xff ); } /* Given a value in the range 0..63, return the corresponding Base64 digit. From 618a70ede70eefbe84805ef890ad643af74a58fa Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 30 Jul 2021 13:00:10 +0200 Subject: [PATCH 805/966] load_roots: arguments must be files I had originally thought to support directories with mbedtls_x509_crt_parse_path but it would have complicated the code more than I cared for. Remove a remnant of the original project in the documentation. Signed-off-by: Gilles Peskine --- programs/x509/load_roots.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/x509/load_roots.c b/programs/x509/load_roots.c index cb168126a2..3ee5485250 100644 --- a/programs/x509/load_roots.c +++ b/programs/x509/load_roots.c @@ -82,7 +82,7 @@ int main( void ) #define DFL_PRIME_CACHE 1 #define USAGE \ - "\n usage: load_roots param=<>... [--] {FILE|DIR}...\n" \ + "\n usage: load_roots param=<>... [--] FILE...\n" \ "\n acceptable parameters:\n" \ " iterations=%%d Iteration count (not including cache priming); default: 1\n" \ " prime=%%d Prime the disk read cache? Default: 1 (yes)\n" \ From 01997e119f5c3d76c949f59420df0c339ce88c35 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 30 Jul 2021 13:01:36 +0200 Subject: [PATCH 806/966] load_roots: fix no-argument detection Signed-off-by: Gilles Peskine --- programs/x509/load_roots.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/x509/load_roots.c b/programs/x509/load_roots.c index 3ee5485250..2dff951756 100644 --- a/programs/x509/load_roots.c +++ b/programs/x509/load_roots.c @@ -132,7 +132,7 @@ int main( int argc, char *argv[] ) struct mbedtls_timing_hr_time timer; unsigned long ms; - if( argc == 0 ) + if( argc <= 1 ) { mbedtls_printf( USAGE ); goto exit; From 9a2114ca574658fd200d0e966ebf7064e531dc8f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 30 Jul 2021 13:01:52 +0200 Subject: [PATCH 807/966] load_roots: properly error out on an invalid option Signed-off-by: Gilles Peskine --- programs/x509/load_roots.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/programs/x509/load_roots.c b/programs/x509/load_roots.c index 2dff951756..7e52957d8a 100644 --- a/programs/x509/load_roots.c +++ b/programs/x509/load_roots.c @@ -168,7 +168,11 @@ int main( int argc, char *argv[] ) opt.iterations = atoi( q ) != 0; } else + { mbedtls_printf( "Unknown option: %s\n", p ); + mbedtls_printf( USAGE ); + goto exit; + } } opt.filenames = (const char**) argv + i; From d7d3279fdf42c38f392653bfeed1b8f1bed822a8 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 3 Aug 2021 12:19:30 +0200 Subject: [PATCH 808/966] Expose internal base64 functions for testing Signed-off-by: Gilles Peskine --- include/mbedtls/base64.h | 10 ++++++++ library/base64.c | 53 +++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/include/mbedtls/base64.h b/include/mbedtls/base64.h index 8378589f31..f6f755913d 100644 --- a/include/mbedtls/base64.h +++ b/include/mbedtls/base64.h @@ -87,6 +87,16 @@ int mbedtls_base64_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ +#if defined(MBEDTLS_TEST_HOOKS) +/* These functions are only exposed in testing configurations for testing + * purposes and may change or disappear at any time. */ +unsigned char mbedtls_base64_mask_of_range( unsigned char low, + unsigned char high, + unsigned char c ); +unsigned char mbedtls_base64_enc_char( unsigned char val ); +signed char mbedtls_base64_dec_value( unsigned char c ); +#endif + #ifdef __cplusplus } #endif diff --git a/library/base64.c b/library/base64.c index 6ddd501a4f..96c94d1c61 100644 --- a/library/base64.c +++ b/library/base64.c @@ -41,8 +41,10 @@ * * Constant flow with respect to c. */ -static unsigned char mask_of_range( unsigned char low, unsigned char high, - unsigned char c ) +MBEDTLS_STATIC_TESTABLE +unsigned char mbedtls_base64_mask_of_range( unsigned char low, + unsigned char high, + unsigned char c ) { /* low_mask is: 0 if low <= c, 0x...ff if low > c */ unsigned low_mask = ( (unsigned) c - low ) >> 8; @@ -55,17 +57,18 @@ static unsigned char mask_of_range( unsigned char low, unsigned char high, * The implementation assumes that letters are consecutive (e.g. ASCII * but not EBCDIC). */ -static unsigned char enc_char( unsigned char val ) +MBEDTLS_STATIC_TESTABLE +unsigned char mbedtls_base64_enc_char( unsigned char val ) { unsigned char digit = 0; /* For each range of values, if val is in that range, mask digit with * the corresponding value. Since val can only be in a single range, * only at most one masking will change digit. */ - digit |= mask_of_range( 0, 25, val ) & ( 'A' + val ); - digit |= mask_of_range( 26, 51, val ) & ( 'a' + val - 26 ); - digit |= mask_of_range( 52, 61, val ) & ( '0' + val - 52 ); - digit |= mask_of_range( 62, 62, val ) & '+'; - digit |= mask_of_range( 63, 63, val ) & '/'; + digit |= mbedtls_base64_mask_of_range( 0, 25, val ) & ( 'A' + val ); + digit |= mbedtls_base64_mask_of_range( 26, 51, val ) & ( 'a' + val - 26 ); + digit |= mbedtls_base64_mask_of_range( 52, 61, val ) & ( '0' + val - 52 ); + digit |= mbedtls_base64_mask_of_range( 62, 62, val ) & '+'; + digit |= mbedtls_base64_mask_of_range( 63, 63, val ) & '/'; return( digit ); } @@ -109,10 +112,12 @@ int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, C2 = *src++; C3 = *src++; - *p++ = enc_char( ( C1 >> 2 ) & 0x3F ); - *p++ = enc_char( ( ( ( C1 & 3 ) << 4 ) + ( C2 >> 4 ) ) & 0x3F ); - *p++ = enc_char( ( ( ( C2 & 15 ) << 2 ) + ( C3 >> 6 ) ) & 0x3F ); - *p++ = enc_char( C3 & 0x3F ); + *p++ = mbedtls_base64_enc_char( ( C1 >> 2 ) & 0x3F ); + *p++ = mbedtls_base64_enc_char( ( ( ( C1 & 3 ) << 4 ) + ( C2 >> 4 ) ) + & 0x3F ); + *p++ = mbedtls_base64_enc_char( ( ( ( C2 & 15 ) << 2 ) + ( C3 >> 6 ) ) + & 0x3F ); + *p++ = mbedtls_base64_enc_char( C3 & 0x3F ); } if( i < slen ) @@ -120,11 +125,12 @@ int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, C1 = *src++; C2 = ( ( i + 1 ) < slen ) ? *src++ : 0; - *p++ = enc_char( ( C1 >> 2 ) & 0x3F ); - *p++ = enc_char( ( ( ( C1 & 3 ) << 4 ) + ( C2 >> 4 ) ) & 0x3F ); + *p++ = mbedtls_base64_enc_char( ( C1 >> 2 ) & 0x3F ); + *p++ = mbedtls_base64_enc_char( ( ( ( C1 & 3 ) << 4 ) + ( C2 >> 4 ) ) + & 0x3F ); if( ( i + 1 ) < slen ) - *p++ = enc_char( ( ( C2 & 15 ) << 2 ) & 0x3F ); + *p++ = mbedtls_base64_enc_char( ( ( C2 & 15 ) << 2 ) & 0x3F ); else *p++ = '='; *p++ = '='; @@ -147,18 +153,19 @@ int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, * on the value of c) unless the compiler inlines and optimizes a specific * access. */ -static signed char dec_value( unsigned char c ) +MBEDTLS_STATIC_TESTABLE +signed char mbedtls_base64_dec_value( unsigned char c ) { unsigned char val = 0; /* For each range of digits, if c is in that range, mask val with * the corresponding value. Since c can only be in a single range, * only at most one masking will change val. Set val to one plus * the desired value so that it stays 0 if c is in none of the ranges. */ - val |= mask_of_range( 'A', 'Z', c ) & ( c - 'A' + 0 + 1 ); - val |= mask_of_range( 'a', 'z', c ) & ( c - 'a' + 26 + 1 ); - val |= mask_of_range( '0', '9', c ) & ( c - '0' + 52 + 1 ); - val |= mask_of_range( '+', '+', c ) & ( c - '+' + 62 + 1 ); - val |= mask_of_range( '/', '/', c ) & ( c - '/' + 63 + 1 ); + val |= mbedtls_base64_mask_of_range( 'A', 'Z', c ) & ( c - 'A' + 0 + 1 ); + val |= mbedtls_base64_mask_of_range( 'a', 'z', c ) & ( c - 'a' + 26 + 1 ); + val |= mbedtls_base64_mask_of_range( '0', '9', c ) & ( c - '0' + 52 + 1 ); + val |= mbedtls_base64_mask_of_range( '+', '+', c ) & ( c - '+' + 62 + 1 ); + val |= mbedtls_base64_mask_of_range( '/', '/', c ) & ( c - '/' + 63 + 1 ); /* At this point, val is 0 if c is an invalid digit and v+1 if c is * a digit with the value v. */ return( val - 1 ); @@ -216,7 +223,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, { if( equals != 0 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); - if( dec_value( src[i] ) < 0 ) + if( mbedtls_base64_dec_value( src[i] ) < 0 ) return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER ); } n++; @@ -251,7 +258,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, if( *src == '=' ) ++equals; else - x |= dec_value( *src ); + x |= mbedtls_base64_dec_value( *src ); if( ++accumulated_digits == 4 ) { From a64417afe6d59647b3cf182f0a1185416140313a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 3 Aug 2021 12:38:55 +0200 Subject: [PATCH 809/966] Add unit tests for base64 internal functions Add unit tests for mask_of_range(), enc_char() and dec_value(). When constant-flow testing is enabled, verify that these functions are constant-flow. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_base64.data | 30 +++++++++++++ tests/suites/test_suite_base64.function | 58 +++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/tests/suites/test_suite_base64.data b/tests/suites/test_suite_base64.data index 3a892f4792..1f94c54348 100644 --- a/tests/suites/test_suite_base64.data +++ b/tests/suites/test_suite_base64.data @@ -1,3 +1,33 @@ +mask_of_range empty (1..0) +mask_of_range:1:0 + +mask_of_range empty (255..0) +mask_of_range:255:0 + +mask_of_range empty (42..7) +mask_of_range:42:7 + +mask_of_range 0..0 +mask_of_range:0:0 + +mask_of_range 42..42 +mask_of_range:42:42 + +mask_of_range 255..255 +mask_of_range:255:255 + +mask_of_range 0..255 +mask_of_range:0:255 + +mask_of_range 'A'..'Z' +mask_of_range:65:90 + +enc_char (all digits) +enc_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + +dec_value (all characters) +dec_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + Test case mbedtls_base64_encode #1 buffer just right mbedtls_base64_encode:"":"":0:0 diff --git a/tests/suites/test_suite_base64.function b/tests/suites/test_suite_base64.function index be9b6e8c3e..89d7995116 100644 --- a/tests/suites/test_suite_base64.function +++ b/tests/suites/test_suite_base64.function @@ -8,6 +8,64 @@ * END_DEPENDENCIES */ +/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */ +void mask_of_range( int low_arg, int high_arg ) +{ + unsigned char low = low_arg, high = high_arg; + unsigned c; + for( c = 0; c <= 0xff; c++ ) + { + mbedtls_test_set_step( c ); + TEST_CF_SECRET( &c, sizeof( c ) ); + unsigned char m = mbedtls_base64_mask_of_range( low, high, c ); + TEST_CF_PUBLIC( &c, sizeof( c ) ); + if( low <= c && c <= high ) + TEST_EQUAL( m, 0xff ); + else + TEST_EQUAL( m, 0 ); + } +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */ +void enc_chars( char *chars ) +{ + for( unsigned value = 0; value < 64; value++ ) + { + mbedtls_test_set_step( value ); + TEST_CF_SECRET( &value, sizeof( value ) ); + unsigned char digit = mbedtls_base64_enc_char( value ); + TEST_CF_PUBLIC( &value, sizeof( value ) ); + TEST_CF_PUBLIC( &digit, sizeof( digit ) ); + TEST_EQUAL( digit, chars[value] ); + } +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */ +void dec_chars( char *chars ) +{ + char *p; + const size_t chars_len = strlen( chars ); + signed char expected; + + for( unsigned c = 0; c <= 0xff; c++ ) + { + mbedtls_test_set_step( c ); + p = memchr( chars, c, chars_len ); + if( p == NULL ) + expected = -1; + else + expected = p - chars; + TEST_CF_SECRET( &c, sizeof( c ) ); + signed char actual = mbedtls_base64_dec_value( c ); + TEST_CF_PUBLIC( &c, sizeof( c ) ); + TEST_CF_PUBLIC( &actual, sizeof( actual ) ); + TEST_EQUAL( actual, expected ); + } +} +/* END_CASE */ + /* BEGIN_CASE */ void mbedtls_base64_encode( char * src_string, char * dst_string, int dst_buf_size, int result ) From 987984482d46a71d9a9efca9ab4117b0343561d5 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 3 Aug 2021 13:15:04 +0200 Subject: [PATCH 810/966] Fix printf format signedness error Signed-off-by: Gilles Peskine --- programs/x509/load_roots.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/programs/x509/load_roots.c b/programs/x509/load_roots.c index 7e52957d8a..8570a0e62a 100644 --- a/programs/x509/load_roots.c +++ b/programs/x509/load_roots.c @@ -115,7 +115,8 @@ int read_certificates( const char *const *filenames ) if( ret != 0 ) { mbedtls_strerror( ret, error_message, sizeof( error_message ) ); - printf( "\n%s: -0x%04x (%s)\n", *cur, -ret, error_message ); + printf( "\n%s: -0x%04x (%s)\n", + *cur, (unsigned) -ret, error_message ); goto exit; } } From 27298780468b8414ec2d2d9f558f87f400d711f2 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 3 Aug 2021 17:41:49 +0200 Subject: [PATCH 811/966] Mark output as public before testing it Signed-off-by: Gilles Peskine --- tests/suites/test_suite_base64.function | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/suites/test_suite_base64.function b/tests/suites/test_suite_base64.function index 89d7995116..c0548956ef 100644 --- a/tests/suites/test_suite_base64.function +++ b/tests/suites/test_suite_base64.function @@ -19,6 +19,7 @@ void mask_of_range( int low_arg, int high_arg ) TEST_CF_SECRET( &c, sizeof( c ) ); unsigned char m = mbedtls_base64_mask_of_range( low, high, c ); TEST_CF_PUBLIC( &c, sizeof( c ) ); + TEST_CF_PUBLIC( &m, sizeof( m ) ); if( low <= c && c <= high ) TEST_EQUAL( m, 0xff ); else From 680747b8681742ba239cfd1072a52fbaa7e26a78 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 6 Aug 2021 14:37:01 +0200 Subject: [PATCH 812/966] Fix the build of sample programs without mbedtls_strerror Signed-off-by: Gilles Peskine --- ChangeLog.d/no-strerror.txt | 3 +++ programs/pkey/key_app_writer.c | 12 +++++++----- programs/x509/load_roots.c | 7 ++++++- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 ChangeLog.d/no-strerror.txt diff --git a/ChangeLog.d/no-strerror.txt b/ChangeLog.d/no-strerror.txt new file mode 100644 index 0000000000..69743a8715 --- /dev/null +++ b/ChangeLog.d/no-strerror.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix the build of sample programs when neither MBEDTLS_ERROR_C nor + MBEDTLS_ERROR_STRERROR_DUMMY is enabled. diff --git a/programs/pkey/key_app_writer.c b/programs/pkey/key_app_writer.c index 8a09af5125..ed6addfef8 100644 --- a/programs/pkey/key_app_writer.c +++ b/programs/pkey/key_app_writer.c @@ -202,7 +202,9 @@ int main( int argc, char *argv[] ) { int ret = 1; int exit_code = MBEDTLS_EXIT_FAILURE; - char buf[1024]; +#if defined(MBEDTLS_ERROR_C) + char buf[200]; +#endif int i; char *p, *q; @@ -220,7 +222,9 @@ int main( int argc, char *argv[] ) mbedtls_ctr_drbg_init( &ctr_drbg ); mbedtls_pk_init( &key ); +#if defined(MBEDTLS_ERROR_C) memset( buf, 0, sizeof( buf ) ); +#endif mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP ); @@ -316,8 +320,7 @@ int main( int argc, char *argv[] ) mbedtls_ctr_drbg_random, &ctr_drbg ); if( ret != 0 ) { - mbedtls_strerror( ret, (char *) buf, sizeof(buf) ); - mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x - %s\n\n", (unsigned int) -ret, buf ); + mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x", (unsigned int) -ret ); goto exit; } @@ -377,8 +380,7 @@ int main( int argc, char *argv[] ) if( ret != 0 ) { - mbedtls_strerror( ret, (char *) buf, sizeof(buf) ); - mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_key returned -0x%04x - %s\n\n", (unsigned int) -ret, buf ); + mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_key returned -0x%04x", (unsigned int) -ret ); goto exit; } diff --git a/programs/x509/load_roots.c b/programs/x509/load_roots.c index 8570a0e62a..e07bed7211 100644 --- a/programs/x509/load_roots.c +++ b/programs/x509/load_roots.c @@ -105,7 +105,6 @@ int read_certificates( const char *const *filenames ) mbedtls_x509_crt cas; int ret = 0; const char *const *cur; - char error_message[200]; mbedtls_x509_crt_init( &cas ); @@ -114,9 +113,15 @@ int read_certificates( const char *const *filenames ) ret = mbedtls_x509_crt_parse_file( &cas, *cur ); if( ret != 0 ) { +#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY) + char error_message[200]; mbedtls_strerror( ret, error_message, sizeof( error_message ) ); printf( "\n%s: -0x%04x (%s)\n", *cur, (unsigned) -ret, error_message ); +#else + printf( "\n%s: -0x%04x\n", + *cur, (unsigned) -ret ); +#endif goto exit; } } From c1776a01d29a64e9629cdc6417ead16ed8a73ae8 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 6 Aug 2021 14:47:10 +0200 Subject: [PATCH 813/966] Move declarations of testing-only base64 functions to their own header Signed-off-by: Gilles Peskine --- include/mbedtls/base64.h | 10 ----- library/base64.c | 1 + library/base64_invasive.h | 55 +++++++++++++++++++++++++ tests/suites/test_suite_base64.function | 1 + 4 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 library/base64_invasive.h diff --git a/include/mbedtls/base64.h b/include/mbedtls/base64.h index f6f755913d..8378589f31 100644 --- a/include/mbedtls/base64.h +++ b/include/mbedtls/base64.h @@ -87,16 +87,6 @@ int mbedtls_base64_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ -#if defined(MBEDTLS_TEST_HOOKS) -/* These functions are only exposed in testing configurations for testing - * purposes and may change or disappear at any time. */ -unsigned char mbedtls_base64_mask_of_range( unsigned char low, - unsigned char high, - unsigned char c ); -unsigned char mbedtls_base64_enc_char( unsigned char val ); -signed char mbedtls_base64_dec_value( unsigned char c ); -#endif - #ifdef __cplusplus } #endif diff --git a/library/base64.c b/library/base64.c index 96c94d1c61..085c71f3c1 100644 --- a/library/base64.c +++ b/library/base64.c @@ -22,6 +22,7 @@ #if defined(MBEDTLS_BASE64_C) #include "mbedtls/base64.h" +#include "base64_invasive.h" #include diff --git a/library/base64_invasive.h b/library/base64_invasive.h new file mode 100644 index 0000000000..9e264719d4 --- /dev/null +++ b/library/base64_invasive.h @@ -0,0 +1,55 @@ +/** + * \file base_invasive.h + * + * \brief Base64 module: interfaces for invasive testing only. + * + * The interfaces in this file are intended for testing purposes only. + * They SHOULD NOT be made available in library integrations except when + * building the library for testing. + */ +/* + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MBEDTLS_BASE64_INVASIVE_H +#define MBEDTLS_BASE64_INVASIVE_H + +#include "common.h" + +#if defined(MBEDTLS_TEST_HOOKS) +/* Return 0xff if low <= c <= high, 0 otherwise. + * + * Constant flow with respect to c. + */ +unsigned char mbedtls_base64_mask_of_range( unsigned char low, + unsigned char high, + unsigned char c ); + +/* Given a value in the range 0..63, return the corresponding Base64 digit. + * + * Operates in constant time (no branches or memory access depending on val). + */ +unsigned char mbedtls_base64_enc_char( unsigned char val ); + +/* Given a Base64 digit, return its value. + * If c is not a Base64 digit ('A'..'Z', 'a'..'z', '0'..'9', '+' or '/'), + * return -1. + * + * Operates in constant time (no branches or memory access depending on c). + */ +signed char mbedtls_base64_dec_value( unsigned char c ); +#endif /* MBEDTLS_TEST_HOOKS */ + +#endif /* MBEDTLS_SSL_INVASIVE_H */ diff --git a/tests/suites/test_suite_base64.function b/tests/suites/test_suite_base64.function index c0548956ef..d0e1167705 100644 --- a/tests/suites/test_suite_base64.function +++ b/tests/suites/test_suite_base64.function @@ -1,5 +1,6 @@ /* BEGIN_HEADER */ #include "mbedtls/base64.h" +#include "base64_invasive.h" #include /* END_HEADER */ From ba951f558465358bde42b2dd0587adbe5ab54825 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 6 Aug 2021 14:55:55 +0200 Subject: [PATCH 814/966] Move the list of Base64 digits out of the test data This is part of the definition of the encoding, not a choice of test parameter, so keep it with the test code. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_base64.data | 4 ++-- tests/suites/test_suite_base64.function | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/suites/test_suite_base64.data b/tests/suites/test_suite_base64.data index 1f94c54348..555666807d 100644 --- a/tests/suites/test_suite_base64.data +++ b/tests/suites/test_suite_base64.data @@ -23,10 +23,10 @@ mask_of_range 'A'..'Z' mask_of_range:65:90 enc_char (all digits) -enc_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" +enc_chars: dec_value (all characters) -dec_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" +dec_chars: Test case mbedtls_base64_encode #1 buffer just right mbedtls_base64_encode:"":"":0:0 diff --git a/tests/suites/test_suite_base64.function b/tests/suites/test_suite_base64.function index d0e1167705..8775c8dfbc 100644 --- a/tests/suites/test_suite_base64.function +++ b/tests/suites/test_suite_base64.function @@ -2,6 +2,12 @@ #include "mbedtls/base64.h" #include "base64_invasive.h" #include + +#if defined(MBEDTLS_TEST_HOOKS) +static const char digits[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +#endif /* MBEDTLS_TEST_HOOKS */ + /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -30,7 +36,7 @@ void mask_of_range( int low_arg, int high_arg ) /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */ -void enc_chars( char *chars ) +void enc_chars( ) { for( unsigned value = 0; value < 64; value++ ) { @@ -39,26 +45,26 @@ void enc_chars( char *chars ) unsigned char digit = mbedtls_base64_enc_char( value ); TEST_CF_PUBLIC( &value, sizeof( value ) ); TEST_CF_PUBLIC( &digit, sizeof( digit ) ); - TEST_EQUAL( digit, chars[value] ); + TEST_EQUAL( digit, digits[value] ); } } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */ -void dec_chars( char *chars ) +void dec_chars( ) { char *p; - const size_t chars_len = strlen( chars ); signed char expected; for( unsigned c = 0; c <= 0xff; c++ ) { mbedtls_test_set_step( c ); - p = memchr( chars, c, chars_len ); + /* digits is 0-terminated. sizeof()-1 excludes the trailing 0. */ + p = memchr( digits, c, sizeof( digits ) - 1 ); if( p == NULL ) expected = -1; else - expected = p - chars; + expected = p - digits; TEST_CF_SECRET( &c, sizeof( c ) ); signed char actual = mbedtls_base64_dec_value( c ); TEST_CF_PUBLIC( &c, sizeof( c ) ); From 93365a7f450d5bab3ee5176fd36e11d5a23330fe Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 6 Aug 2021 16:54:22 +0200 Subject: [PATCH 815/966] Rename variable to avoid a name clash digits is also a local variable in host_test.function, leading to compilers complaining about that shadowing the global variable in test_suite_base64.function. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_base64.function | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/suites/test_suite_base64.function b/tests/suites/test_suite_base64.function index 8775c8dfbc..67fbb67505 100644 --- a/tests/suites/test_suite_base64.function +++ b/tests/suites/test_suite_base64.function @@ -4,7 +4,7 @@ #include #if defined(MBEDTLS_TEST_HOOKS) -static const char digits[] = +static const char base64_digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; #endif /* MBEDTLS_TEST_HOOKS */ @@ -45,7 +45,7 @@ void enc_chars( ) unsigned char digit = mbedtls_base64_enc_char( value ); TEST_CF_PUBLIC( &value, sizeof( value ) ); TEST_CF_PUBLIC( &digit, sizeof( digit ) ); - TEST_EQUAL( digit, digits[value] ); + TEST_EQUAL( digit, base64_digits[value] ); } } /* END_CASE */ @@ -59,12 +59,12 @@ void dec_chars( ) for( unsigned c = 0; c <= 0xff; c++ ) { mbedtls_test_set_step( c ); - /* digits is 0-terminated. sizeof()-1 excludes the trailing 0. */ - p = memchr( digits, c, sizeof( digits ) - 1 ); + /* base64_digits is 0-terminated. sizeof()-1 excludes the trailing 0. */ + p = memchr( base64_digits, c, sizeof( base64_digits ) - 1 ); if( p == NULL ) expected = -1; else - expected = p - digits; + expected = p - base64_digits; TEST_CF_SECRET( &c, sizeof( c ) ); signed char actual = mbedtls_base64_dec_value( c ); TEST_CF_PUBLIC( &c, sizeof( c ) ); From ac253ea32be3707169a175e1da857ebc1626ebfe Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 25 Oct 2021 21:13:27 +0200 Subject: [PATCH 816/966] Fix copypasta in comment Signed-off-by: Gilles Peskine --- library/base64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/base64.c b/library/base64.c index 085c71f3c1..a516c1d4a3 100644 --- a/library/base64.c +++ b/library/base64.c @@ -49,7 +49,7 @@ unsigned char mbedtls_base64_mask_of_range( unsigned char low, { /* low_mask is: 0 if low <= c, 0x...ff if low > c */ unsigned low_mask = ( (unsigned) c - low ) >> 8; - /* high_mask is: 0 if c <= high, 0x...ff if high > c */ + /* high_mask is: 0 if c <= high, 0x...ff if c > high */ unsigned high_mask = ( (unsigned) high - c ) >> 8; return( ~( low_mask | high_mask ) & 0xff ); } From 66c9b84f932f6671738ee72019ae47b83ad87979 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 25 Oct 2021 21:14:06 +0200 Subject: [PATCH 817/966] Fix typo in documentation Signed-off-by: Gilles Peskine --- ChangeLog.d/base64-ranges.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.d/base64-ranges.txt b/ChangeLog.d/base64-ranges.txt index 8ffba2deec..e3f3862bfb 100644 --- a/ChangeLog.d/base64-ranges.txt +++ b/ChangeLog.d/base64-ranges.txt @@ -1,4 +1,4 @@ Changes * Improve the performance of base64 constant-flow code. The result is still slower than the original non-constant-flow implementation, but much faster - than the previous constant-flow implemenation. Fixes #4814. + than the previous constant-flow implementation. Fixes #4814. From e6d7e5cef6340a70055efa10378704c9c619ab61 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 26 Oct 2021 10:44:32 +0800 Subject: [PATCH 818/966] move CLIENT/SERVER_HELLO_RANDOM_LEN to `ssl_misc.h` Signed-off-by: Jerry Yu --- library/ssl_misc.h | 11 +++++++++-- library/ssl_tls13_client.c | 32 ++++++++++++++------------------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 904d8c77db..66fb26c624 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -309,6 +309,9 @@ #define MBEDTLS_TLS1_3_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE +#define MBEDTLS_CLIENT_HELLO_RANDOM_LEN 32 +#define MBEDTLS_SERVER_HELLO_RANDOM_LEN 32 + #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) /** * \brief Return the maximum fragment length (payload, in bytes) for @@ -715,7 +718,9 @@ struct mbedtls_ssl_handshake_params size_t pmslen; /*!< premaster length */ - unsigned char randbytes[64]; /*!< random bytes */ + unsigned char randbytes[MBEDTLS_CLIENT_HELLO_RANDOM_LEN + + MBEDTLS_SERVER_HELLO_RANDOM_LEN]; + /*!< random bytes */ unsigned char premaster[MBEDTLS_PREMASTER_SIZE]; /*!< premaster secret */ @@ -880,7 +885,9 @@ struct mbedtls_ssl_transform /* We need the Hello random bytes in order to re-derive keys from the * Master Secret and other session info, * see ssl_tls12_populate_transform() */ - unsigned char randbytes[64]; /*!< ServerHello.random+ClientHello.random */ + unsigned char randbytes[MBEDTLS_SERVER_HELLO_RANDOM_LEN + + MBEDTLS_CLIENT_HELLO_RANDOM_LEN]; + /*!< ServerHello.random+ClientHello.random */ #endif /* MBEDTLS_SSL_CONTEXT_SERIALIZATION */ }; diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 989bdc0abc..979db31449 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -35,9 +35,6 @@ #include "ecdh_misc.h" #include "ssl_tls13_keys.h" -#define CLIENT_HELLO_RANDOM_LEN 32 -#define SERVER_HELLO_RANDOM_LEN 32 - /* Write extensions */ /* @@ -709,11 +706,11 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, p += 2; /* Write the random bytes ( random ).*/ - MBEDTLS_SSL_CHK_BUF_PTR( p, end, CLIENT_HELLO_RANDOM_LEN ); - memcpy( p, ssl->handshake->randbytes, CLIENT_HELLO_RANDOM_LEN ); + MBEDTLS_SSL_CHK_BUF_PTR( p, end, MBEDTLS_CLIENT_HELLO_RANDOM_LEN ); + memcpy( p, ssl->handshake->randbytes, MBEDTLS_CLIENT_HELLO_RANDOM_LEN ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", - p, CLIENT_HELLO_RANDOM_LEN ); - p += CLIENT_HELLO_RANDOM_LEN; + p, MBEDTLS_CLIENT_HELLO_RANDOM_LEN ); + p += MBEDTLS_CLIENT_HELLO_RANDOM_LEN; /* * Write legacy_session_id @@ -834,7 +831,7 @@ static int ssl_tls13_prepare_client_hello( mbedtls_ssl_context *ssl ) if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->handshake->randbytes, - CLIENT_HELLO_RANDOM_LEN ) ) != 0 ) + MBEDTLS_CLIENT_HELLO_RANDOM_LEN ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "f_rng", ret ); return( ret ); @@ -894,7 +891,7 @@ static int ssl_server_hello_is_hrr( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end ) { - static const unsigned char magic_hrr_string[SERVER_HELLO_RANDOM_LEN] = + static const unsigned char magic_hrr_string[MBEDTLS_SERVER_HELLO_RANDOM_LEN] = { 0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91, 0xC2, 0xA2, 0x11, 0x16, 0x7A, 0xBB, 0x8C, 0x5E, @@ -1045,12 +1042,12 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, * Check there is space for minimal fields * * - legacy_version ( 2 bytes) - * - random (SERVER_HELLO_RANDOM_LEN bytes) + * - random (MBEDTLS_SERVER_HELLO_RANDOM_LEN bytes) * - legacy_session_id_echo ( 1 byte ), minimum size * - cipher_suite ( 2 bytes) * - legacy_compression_method ( 1 byte ) */ - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, SERVER_HELLO_RANDOM_LEN + 6 ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, MBEDTLS_SERVER_HELLO_RANDOM_LEN + 6 ); MBEDTLS_SSL_DEBUG_BUF( 4, "server hello", p, end - p ); MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, version", p, 2 ); @@ -1071,18 +1068,17 @@ static int ssl_tls13_parse_server_hello( mbedtls_ssl_context *ssl, } p += 2; - /* From RFC8446, page 27. - * ... + /* ... * Random random; * ... * with Random defined as: - * opaque Random[32]; + * opaque Random[MBEDTLS_SERVER_HELLO_RANDOM_LEN]; */ - memcpy( ssl->handshake->randbytes + CLIENT_HELLO_RANDOM_LEN, p, - SERVER_HELLO_RANDOM_LEN ); + memcpy( &ssl->handshake->randbytes[MBEDTLS_CLIENT_HELLO_RANDOM_LEN], p, + MBEDTLS_SERVER_HELLO_RANDOM_LEN ); MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, random bytes", - p, SERVER_HELLO_RANDOM_LEN ); - p += SERVER_HELLO_RANDOM_LEN; + p, MBEDTLS_SERVER_HELLO_RANDOM_LEN ); + p += MBEDTLS_SERVER_HELLO_RANDOM_LEN; /* ... * opaque legacy_session_id_echo<0..32>; From c2d2f217fbba6ae7f275a5c3741e36bb4a674e56 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Tue, 26 Oct 2021 12:21:45 +0200 Subject: [PATCH 819/966] ssl_client2/ssl_server_2: use PSA_ALG_ANY_HASH as algorithm for opaque key Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_client2.c | 2 +- programs/ssl/ssl_server2.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index a970503c87..cd9c8bf356 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1692,7 +1692,7 @@ int main( int argc, char *argv[] ) if( opt.key_opaque != 0 ) { if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey, &key_slot, - PSA_ALG_SHA_256 ) ) != 0 ) + PSA_ALG_ANY_HASH ) ) != 0 ) { mbedtls_printf( " failed\n ! " "mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret ); diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index c23d73045f..1700405ed3 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -2502,7 +2502,7 @@ int main( int argc, char *argv[] ) if ( mbedtls_pk_get_type( &pkey ) == MBEDTLS_PK_ECKEY ) { if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey, &key_slot, - PSA_ALG_SHA_256 ) ) != 0 ) + PSA_ALG_ANY_HASH ) ) != 0 ) { mbedtls_printf( " failed\n ! " "mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret ); @@ -2513,7 +2513,7 @@ int main( int argc, char *argv[] ) if ( mbedtls_pk_get_type( &pkey2 ) == MBEDTLS_PK_ECKEY ) { if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey2, &key_slot2, - PSA_ALG_SHA_256 ) ) != 0 ) + PSA_ALG_ANY_HASH ) ) != 0 ) { mbedtls_printf( " failed\n ! " "mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret ); From bb5d48307325ca4f2ee8c3cdcc81de4112222944 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Tue, 26 Oct 2021 12:25:27 +0200 Subject: [PATCH 820/966] ssl-opt.sh: adapt paramteters of key opaque cases Signed-off-by: Przemyslaw Stekiel --- tests/ssl-opt.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 628fad9560..e0abd3f71e 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1435,12 +1435,15 @@ requires_config_enabled MBEDTLS_X509_CRT_PARSE_C requires_config_enabled MBEDTLS_ECDSA_C requires_config_enabled MBEDTLS_SHA256_C run_test "Opaque key for client authentication" \ - "$P_SRV auth_mode=required" \ + "$P_SRV auth_mode=required crt_file=data_files/server5.crt \ + key_file=data_files/server5.key" \ "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \ key_file=data_files/server5.key" \ 0 \ -c "key type: Opaque" \ + -c "Ciphersuite is TLS-ECDHE-ECDSA" \ -s "Verifying peer X.509 certificate... ok" \ + -s "Ciphersuite is TLS-ECDHE-ECDSA" \ -S "error" \ -C "error" @@ -1450,12 +1453,15 @@ requires_config_enabled MBEDTLS_X509_CRT_PARSE_C requires_config_enabled MBEDTLS_ECDSA_C requires_config_enabled MBEDTLS_SHA256_C run_test "Opaque key for server authentication" \ - "$P_SRV auth_mode=required key_opaque=1" \ + "$P_SRV auth_mode=required key_opaque=1 crt_file=data_files/server5.crt \ + key_file=data_files/server5.key" \ "$P_CLI crt_file=data_files/server5.crt \ key_file=data_files/server5.key" \ 0 \ -c "Verifying peer X.509 certificate... ok" \ - -s "key types: RSA - Opaque" \ + -c "Ciphersuite is TLS-ECDHE-ECDSA" \ + -s "key types: Opaque - invalid PK" \ + -s "Ciphersuite is TLS-ECDHE-ECDSA" \ -S "error" \ -C "error" @@ -1465,14 +1471,17 @@ requires_config_enabled MBEDTLS_X509_CRT_PARSE_C requires_config_enabled MBEDTLS_ECDSA_C requires_config_enabled MBEDTLS_SHA256_C run_test "Opaque key for client/server authentication" \ - "$P_SRV auth_mode=required key_opaque=1" \ + "$P_SRV auth_mode=required key_opaque=1 crt_file=data_files/server5.crt \ + key_file=data_files/server5.key" \ "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \ key_file=data_files/server5.key" \ 0 \ -c "key type: Opaque" \ -c "Verifying peer X.509 certificate... ok" \ - -s "key types: RSA - Opaque" \ + -c "Ciphersuite is TLS-ECDHE-ECDSA" \ + -s "key types: Opaque - invalid PK" \ -s "Verifying peer X.509 certificate... ok" \ + -s "Ciphersuite is TLS-ECDHE-ECDSA" \ -S "error" \ -C "error" From 643d11606a09ece4f7dfb533a30e88641448db29 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 27 Oct 2021 13:52:04 +0800 Subject: [PATCH 821/966] Add GET/PUT_UINT24_BE/LE Signed-off-by: Jerry Yu --- library/common.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/library/common.h b/library/common.h index 9b10ec8fbb..8dfa816dcf 100644 --- a/library/common.h +++ b/library/common.h @@ -226,6 +226,78 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c } #endif +/** + * Get the unsigned 24 bits integer corresponding to four bytes in + * big-endian order (MSB first). + * + * \param data Base address of the memory to get the four bytes from. + * \param offset Offset from \p base of the first and most significant + * byte of the four bytes to build the 24 bits unsigned + * integer from. + */ +#ifndef MBEDTLS_GET_UINT24_BE +#define MBEDTLS_GET_UINT24_BE( data , offset ) \ + ( \ + ( (uint32_t) ( data )[( offset ) ] << 16 ) \ + | ( (uint32_t) ( data )[( offset ) + 1] << 8 ) \ + | ( (uint32_t) ( data )[( offset ) + 2] ) \ + ) +#endif + +/** + * Put in memory a 24 bits unsigned integer in big-endian order. + * + * \param n 24 bits unsigned integer to put in memory. + * \param data Base address of the memory where to put the 24 + * bits unsigned integer in. + * \param offset Offset from \p base where to put the most significant + * byte of the 24 bits unsigned integer \p n. + */ +#ifndef MBEDTLS_PUT_UINT24_BE +#define MBEDTLS_PUT_UINT24_BE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = MBEDTLS_BYTE_2( n ); \ + ( data )[( offset ) + 1] = MBEDTLS_BYTE_1( n ); \ + ( data )[( offset ) + 2] = MBEDTLS_BYTE_0( n ); \ +} +#endif + +/** + * Get the unsigned 24 bits integer corresponding to four bytes in + * little-endian order (LSB first). + * + * \param data Base address of the memory to get the four bytes from. + * \param offset Offset from \p base of the first and least significant + * byte of the four bytes to build the 24 bits unsigned + * integer from. + */ +#ifndef MBEDTLS_GET_UINT24_LE +#define MBEDTLS_GET_UINT24_LE( data, offset ) \ + ( \ + ( (uint32_t) ( data )[( offset ) ] ) \ + | ( (uint32_t) ( data )[( offset ) + 1] << 8 ) \ + | ( (uint32_t) ( data )[( offset ) + 2] << 16 ) \ + ) +#endif + +/** + * Put in memory a 24 bits unsigned integer in little-endian order. + * + * \param n 24 bits unsigned integer to put in memory. + * \param data Base address of the memory where to put the 24 + * bits unsigned integer in. + * \param offset Offset from \p base where to put the least significant + * byte of the 24 bits unsigned integer \p n. + */ +#ifndef MBEDTLS_PUT_UINT24_LE +#define MBEDTLS_PUT_UINT24_LE( n, data, offset ) \ +{ \ + ( data )[( offset ) ] = MBEDTLS_BYTE_0( n ); \ + ( data )[( offset ) + 1] = MBEDTLS_BYTE_1( n ); \ + ( data )[( offset ) + 2] = MBEDTLS_BYTE_2( n ); \ +} +#endif + /** * Get the unsigned 64 bits integer corresponding to eight bytes in * big-endian order (MSB first). From 184e8b6a36c9eadc1326f8a84bc403bede19faf0 Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Tue, 26 Oct 2021 09:23:42 +0000 Subject: [PATCH 822/966] Add exist_ok and use git rev-parse to process revisions Signed-off-by: Xiaofei Bai --- scripts/code_size_compare.py | 65 +++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/scripts/code_size_compare.py b/scripts/code_size_compare.py index 96ebf3d54b..898aaf9f38 100755 --- a/scripts/code_size_compare.py +++ b/scripts/code_size_compare.py @@ -41,12 +41,10 @@ class CodeSizeComparison: """ self.repo_path = "." self.result_dir = os.path.abspath(result_dir) - if os.path.exists(self.result_dir) is False: - os.makedirs(self.result_dir) + os.makedirs(self.result_dir, exist_ok=True) self.csv_dir = os.path.abspath("code_size_records/") - if os.path.exists(self.csv_dir) is False: - os.makedirs(self.csv_dir) + os.makedirs(self.csv_dir, exist_ok=True) self.old_rev = old_revision self.new_rev = new_revision @@ -60,20 +58,20 @@ class CodeSizeComparison: @staticmethod def validate_revision(revision): - result = subprocess.run(["git", "cat-file", "-e", revision], check=False) - return result.returncode + result = subprocess.run(["git", "rev-parse", "--verify", revision], + check=False, stdout=subprocess.PIPE) + return result def _create_git_worktree(self, revision): """Make a separate worktree for revision. Do not modify the current worktree.""" - if revision == "HEAD": + if revision == "current": print("Using current work directory.") git_worktree_path = self.repo_path else: print("Creating git worktree for", revision) - rev_dirname = revision.replace("/", "_") - git_worktree_path = os.path.join(self.repo_path, "temp-" + rev_dirname) + git_worktree_path = os.path.join(self.repo_path, "temp-" + revision) subprocess.check_output( [self.git_command, "worktree", "add", "--detach", git_worktree_path, revision], cwd=self.repo_path, @@ -93,8 +91,11 @@ class CodeSizeComparison: def _gen_code_size_csv(self, revision, git_worktree_path): """Generate code size csv file.""" - csv_fname = revision.replace("/", "_") + ".csv" - print("Measuring code size for", revision) + csv_fname = revision + ".csv" + if revision == "current": + print("Measuring code size in current work directory.") + else: + print("Measuring code size for", revision) result = subprocess.check_output( ["size library/*.o"], cwd=git_worktree_path, shell=True ) @@ -118,8 +119,8 @@ class CodeSizeComparison: """Generate code size csv file for the specified git revision.""" # Check if the corresponding record exists - csv_fname = revision.replace("/", "_") + ".csv" - if (revision != "HEAD") and \ + csv_fname = revision + ".csv" + if (revision != "current") and \ os.path.exists(os.path.join(self.csv_dir, csv_fname)): print("Code size csv file for", revision, "already exists.") else: @@ -133,13 +134,11 @@ class CodeSizeComparison: old and new. Measured code size results of these two revisions must be available.""" - old_file = open(os.path.join(self.csv_dir, \ - self.old_rev.replace("/", "_") + ".csv"), "r") - new_file = open(os.path.join(self.csv_dir, \ - self.new_rev.replace("/", "_") + ".csv"), "r") - res_file = open(os.path.join(self.result_dir, \ - "compare-" + self.old_rev.replace("/", "_") + "-" \ - + self.new_rev.replace("/", "_") + ".csv"), "w") + old_file = open(os.path.join(self.csv_dir, self.old_rev + ".csv"), "r") + new_file = open(os.path.join(self.csv_dir, self.new_rev + ".csv"), "r") + res_file = open(os.path.join(self.result_dir, "compare-" + self.old_rev + + "-" + self.new_rev + ".csv"), "w") + res_file.write("file_name, this_size, old_size, change, change %\n") print("Generating comparision results.") @@ -194,12 +193,13 @@ def main(): default is comparison", ) parser.add_argument( - "-o", "--old-rev", type=str, help="old revision for comparison.(prefer commit ID)", + "-o", "--old-rev", type=str, help="old revision for comparison.", required=True, ) parser.add_argument( - "-n", "--new-rev", type=str, default="HEAD", - help="new revision for comparison, default is current work directory." + "-n", "--new-rev", type=str, default=None, + help="new revision for comparison, default is the current work \ + directory, including uncommited changes." ) comp_args = parser.parse_args() @@ -207,15 +207,18 @@ def main(): print("Error: {} is not a directory".format(comp_args.result_dir)) parser.exit() - validate_result = CodeSizeComparison.validate_revision(comp_args.old_rev) - if validate_result != 0: - sys.exit(validate_result) - old_revision = comp_args.old_rev + validate_res = CodeSizeComparison.validate_revision(comp_args.old_rev) + if validate_res.returncode != 0: + sys.exit(validate_res.returncode) + old_revision = validate_res.stdout.decode().replace("\n", "") - validate_result = CodeSizeComparison.validate_revision(comp_args.new_rev) - if validate_result != 0: - sys.exit(validate_result) - new_revision = comp_args.new_rev + if comp_args.new_rev is not None: + validate_res = CodeSizeComparison.validate_revision(comp_args.new_rev) + if validate_res.returncode != 0: + sys.exit(validate_res.returncode) + new_revision = validate_res.stdout.decode().replace("\n", "") + else: + new_revision = "current" result_dir = comp_args.result_dir size_compare = CodeSizeComparison(old_revision, new_revision, result_dir) From 4cb97390389aab5525fa91ebedb896e7b87d28de Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 27 Oct 2021 10:42:31 +0200 Subject: [PATCH 823/966] Use separate MBEDTLS_MODE for the CCM*. Signed-off-by: Mateusz Starzyk --- include/mbedtls/cipher.h | 10 ++++ library/cipher.c | 6 +- library/cipher_wrap.c | 108 ++++++++++++++++++++++++++++++++++++ library/psa_crypto_cipher.c | 2 +- 4 files changed, 122 insertions(+), 4 deletions(-) diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h index b4630f63cd..892771e638 100644 --- a/include/mbedtls/cipher.h +++ b/include/mbedtls/cipher.h @@ -140,9 +140,15 @@ typedef enum { MBEDTLS_CIPHER_AES_128_CCM, /**< AES cipher with 128-bit CCM mode. */ MBEDTLS_CIPHER_AES_192_CCM, /**< AES cipher with 192-bit CCM mode. */ MBEDTLS_CIPHER_AES_256_CCM, /**< AES cipher with 256-bit CCM mode. */ + MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG, /**< AES cipher with 128-bit CCM_STAR_NO_TAG mode. */ + MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG, /**< AES cipher with 192-bit CCM_STAR_NO_TAG mode. */ + MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG, /**< AES cipher with 256-bit CCM_STAR_NO_TAG mode. */ MBEDTLS_CIPHER_CAMELLIA_128_CCM, /**< Camellia cipher with 128-bit CCM mode. */ MBEDTLS_CIPHER_CAMELLIA_192_CCM, /**< Camellia cipher with 192-bit CCM mode. */ MBEDTLS_CIPHER_CAMELLIA_256_CCM, /**< Camellia cipher with 256-bit CCM mode. */ + MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG, /**< Camellia cipher with 128-bit CCM_STAR_NO_TAG mode. */ + MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG, /**< Camellia cipher with 192-bit CCM_STAR_NO_TAG mode. */ + MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG, /**< Camellia cipher with 256-bit CCM_STAR_NO_TAG mode. */ MBEDTLS_CIPHER_ARIA_128_ECB, /**< Aria cipher with 128-bit key and ECB mode. */ MBEDTLS_CIPHER_ARIA_192_ECB, /**< Aria cipher with 192-bit key and ECB mode. */ MBEDTLS_CIPHER_ARIA_256_ECB, /**< Aria cipher with 256-bit key and ECB mode. */ @@ -161,6 +167,9 @@ typedef enum { MBEDTLS_CIPHER_ARIA_128_CCM, /**< Aria cipher with 128-bit key and CCM mode. */ MBEDTLS_CIPHER_ARIA_192_CCM, /**< Aria cipher with 192-bit key and CCM mode. */ MBEDTLS_CIPHER_ARIA_256_CCM, /**< Aria cipher with 256-bit key and CCM mode. */ + MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG, /**< Aria cipher with 128-bit key and CCM_STAR_NO_TAG mode. */ + MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG, /**< Aria cipher with 192-bit key and CCM_STAR_NO_TAG mode. */ + MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG, /**< Aria cipher with 256-bit key and CCM_STAR_NO_TAG mode. */ MBEDTLS_CIPHER_AES_128_OFB, /**< AES 128-bit cipher in OFB mode. */ MBEDTLS_CIPHER_AES_192_OFB, /**< AES 192-bit cipher in OFB mode. */ MBEDTLS_CIPHER_AES_256_OFB, /**< AES 256-bit cipher in OFB mode. */ @@ -187,6 +196,7 @@ typedef enum { MBEDTLS_MODE_GCM, /**< The GCM cipher mode. */ MBEDTLS_MODE_STREAM, /**< The stream cipher mode. */ MBEDTLS_MODE_CCM, /**< The CCM cipher mode. */ + MBEDTLS_MODE_CCM_STAR_NO_TAG, /**< The CCM*-no-tag cipher mode. */ MBEDTLS_MODE_XTS, /**< The XTS cipher mode. */ MBEDTLS_MODE_CHACHAPOLY, /**< The ChaCha-Poly cipher mode. */ MBEDTLS_MODE_KW, /**< The SP800-38F KW mode */ diff --git a/library/cipher.c b/library/cipher.c index 4ed6c910f0..ff851ec936 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -425,7 +425,7 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, #endif #if defined(MBEDTLS_CCM_C) - if( MBEDTLS_MODE_CCM == ctx->cipher_info->mode ) + if( MBEDTLS_MODE_CCM_STAR_NO_TAG == ctx->cipher_info->mode ) { int set_lengths_result; int ccm_star_mode; @@ -586,7 +586,7 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i #endif #if defined(MBEDTLS_CCM_C) - if( ctx->cipher_info->mode == MBEDTLS_MODE_CCM ) + if( ctx->cipher_info->mode == MBEDTLS_MODE_CCM_STAR_NO_TAG ) { return( mbedtls_ccm_update( (mbedtls_ccm_context *) ctx->cipher_ctx, input, ilen, @@ -981,7 +981,7 @@ int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, MBEDTLS_MODE_OFB == ctx->cipher_info->mode || MBEDTLS_MODE_CTR == ctx->cipher_info->mode || MBEDTLS_MODE_GCM == ctx->cipher_info->mode || - MBEDTLS_MODE_CCM == ctx->cipher_info->mode || + MBEDTLS_MODE_CCM_STAR_NO_TAG == ctx->cipher_info->mode || MBEDTLS_MODE_XTS == ctx->cipher_info->mode || MBEDTLS_MODE_STREAM == ctx->cipher_info->mode ) { diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c index 5776d5e45d..7da7d9d522 100644 --- a/library/cipher_wrap.c +++ b/library/cipher_wrap.c @@ -639,6 +639,39 @@ static const mbedtls_cipher_info_t aes_256_ccm_info = { 16, &ccm_aes_info }; + +static const mbedtls_cipher_info_t aes_128_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 128, + "AES-128-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aes_info +}; + +static const mbedtls_cipher_info_t aes_192_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 192, + "AES-192-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aes_info +}; + +static const mbedtls_cipher_info_t aes_256_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 256, + "AES-256-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aes_info +}; #endif /* MBEDTLS_CCM_C */ #endif /* MBEDTLS_AES_C */ @@ -1014,6 +1047,39 @@ static const mbedtls_cipher_info_t camellia_256_ccm_info = { 16, &ccm_camellia_info }; + +static const mbedtls_cipher_info_t camellia_128_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 128, + "CAMELLIA-128-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_camellia_info +}; + +static const mbedtls_cipher_info_t camellia_192_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 192, + "CAMELLIA-192-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_camellia_info +}; + +static const mbedtls_cipher_info_t camellia_256_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 256, + "CAMELLIA-256-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_camellia_info +}; #endif /* MBEDTLS_CCM_C */ #endif /* MBEDTLS_CAMELLIA_C */ @@ -1390,6 +1456,39 @@ static const mbedtls_cipher_info_t aria_256_ccm_info = { 16, &ccm_aria_info }; + +static const mbedtls_cipher_info_t aria_128_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 128, + "ARIA-128-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aria_info +}; + +static const mbedtls_cipher_info_t aria_192_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 192, + "ARIA-192-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aria_info +}; + +static const mbedtls_cipher_info_t aria_256_ccm_star_no_tag_info = { + MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG, + MBEDTLS_MODE_CCM_STAR_NO_TAG, + 256, + "ARIA-256-CCM*-NO-TAG", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aria_info +}; #endif /* MBEDTLS_CCM_C */ #endif /* MBEDTLS_ARIA_C */ @@ -2055,6 +2154,9 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = { MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info }, { MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info }, { MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info }, + { MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG, &aes_128_ccm_star_no_tag_info }, + { MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG, &aes_192_ccm_star_no_tag_info }, + { MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG, &aes_256_ccm_star_no_tag_info }, #endif #endif /* MBEDTLS_AES_C */ @@ -2086,6 +2188,9 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = { MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info }, { MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info }, { MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info }, + { MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG, &camellia_128_ccm_star_no_tag_info }, + { MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG, &camellia_192_ccm_star_no_tag_info }, + { MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG, &camellia_256_ccm_star_no_tag_info }, #endif #endif /* MBEDTLS_CAMELLIA_C */ @@ -2117,6 +2222,9 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = { MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info }, { MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info }, { MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info }, + { MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG, &aria_128_ccm_star_no_tag_info }, + { MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG, &aria_192_ccm_star_no_tag_info }, + { MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG, &aria_256_ccm_star_no_tag_info }, #endif #endif /* MBEDTLS_ARIA_C */ diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index acbbd5ca6b..69dc0561cd 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -93,7 +93,7 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_psa( mode = MBEDTLS_MODE_CBC; break; case PSA_ALG_CCM_STAR_NO_TAG: - mode = MBEDTLS_MODE_CCM; + mode = MBEDTLS_MODE_CCM_STAR_NO_TAG; break; case PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 0 ): mode = MBEDTLS_MODE_CCM; From f3f5c210cb25408b316d22ab671972cc45a565cc Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 27 Oct 2021 17:05:49 +0800 Subject: [PATCH 824/966] fix comments issue Signed-off-by: Jerry Yu --- library/common.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/common.h b/library/common.h index 8dfa816dcf..7c8d4bf478 100644 --- a/library/common.h +++ b/library/common.h @@ -227,12 +227,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * Get the unsigned 24 bits integer corresponding to four bytes in + * Get the unsigned 24 bits integer corresponding to three bytes in * big-endian order (MSB first). * - * \param data Base address of the memory to get the four bytes from. - * \param offset Offset from \p base of the first and most significant - * byte of the four bytes to build the 24 bits unsigned + * \param data Base address of the memory to get the three bytes from. + * \param offset Offset from \p data of the first and most significant + * byte of the three bytes to build the 24 bits unsigned * integer from. */ #ifndef MBEDTLS_GET_UINT24_BE @@ -250,7 +250,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param n 24 bits unsigned integer to put in memory. * \param data Base address of the memory where to put the 24 * bits unsigned integer in. - * \param offset Offset from \p base where to put the most significant + * \param offset Offset from \p data where to put the most significant * byte of the 24 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT24_BE @@ -263,12 +263,12 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c #endif /** - * Get the unsigned 24 bits integer corresponding to four bytes in + * Get the unsigned 24 bits integer corresponding to three bytes in * little-endian order (LSB first). * - * \param data Base address of the memory to get the four bytes from. - * \param offset Offset from \p base of the first and least significant - * byte of the four bytes to build the 24 bits unsigned + * \param data Base address of the memory to get the three bytes from. + * \param offset Offset from \p data of the first and least significant + * byte of the three bytes to build the 24 bits unsigned * integer from. */ #ifndef MBEDTLS_GET_UINT24_LE @@ -286,7 +286,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param n 24 bits unsigned integer to put in memory. * \param data Base address of the memory where to put the 24 * bits unsigned integer in. - * \param offset Offset from \p base where to put the least significant + * \param offset Offset from \p data where to put the least significant * byte of the 24 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT24_LE From 7de19ddaf50fc310b3170f36b6cf45ceecb0d26e Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 27 Oct 2021 11:25:08 +0200 Subject: [PATCH 825/966] Remove invalid comments in CCM API Signed-off-by: Mateusz Starzyk --- include/mbedtls/ccm.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index 0dc5b59683..1be1689df1 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -208,7 +208,6 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, * at least \p ad_len Bytes. * \param ad_len The length of additional data in Bytes. * This must be less than 2^16 - 2^8. - * For tag length = 0, AD length can be 0. * \param input The buffer holding the input data. If \p length is greater * than zero, \p input must be a readable buffer of at least * that length. @@ -291,7 +290,6 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, * at least that \p ad_len Bytes. * \param ad_len The length of additional data in Bytes. * This must be less than 2^16 - 2^8. - * For tag length = 0, AD length can be 0. * \param input The buffer holding the input data. If \p length is greater * than zero, \p input must be a readable buffer of at least * that length. From 812ef6b379217e186a7e7c52e82d3b9d942ad99b Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 27 Oct 2021 11:26:47 +0200 Subject: [PATCH 826/966] Fix ccm*-no-tag changelog entry Signed-off-by: Mateusz Starzyk --- ChangeLog.d/ccm_star_no_tag.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.d/ccm_star_no_tag.txt b/ChangeLog.d/ccm_star_no_tag.txt index 88c0d1fb1f..dbd25d1eec 100644 --- a/ChangeLog.d/ccm_star_no_tag.txt +++ b/ChangeLog.d/ccm_star_no_tag.txt @@ -2,6 +2,8 @@ Changes * Ignore plaintext/ciphertext lengths for CCM*-no-tag operations. For CCM* encryption/decryption without authentication, input length will be ignored. + +Features * Add support for CCM*-no-tag cipher to the PSA. Currently only 13-byte long IV's are supported. For decryption a minimum of 16-byte long input is expected. From d025422c288c10243f568548f3b54065c049f513 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 14 Sep 2021 11:28:22 +0200 Subject: [PATCH 827/966] Remove on-target testing It was unmaintained and untested, and the fear of breaking it was holding us back. Resolves #4934. Signed-off-by: Gilles Peskine --- ChangeLog.d/remove-greentea-support.txt | 3 + tests/Makefile | 39 +- tests/scripts/generate_test_code.py | 4 - tests/scripts/mbedtls_test.py | 382 -------------------- tests/suites/target_test.function | 449 ------------------------ 5 files changed, 4 insertions(+), 873 deletions(-) create mode 100644 ChangeLog.d/remove-greentea-support.txt delete mode 100755 tests/scripts/mbedtls_test.py delete mode 100644 tests/suites/target_test.function diff --git a/ChangeLog.d/remove-greentea-support.txt b/ChangeLog.d/remove-greentea-support.txt new file mode 100644 index 0000000000..af4df4baa1 --- /dev/null +++ b/ChangeLog.d/remove-greentea-support.txt @@ -0,0 +1,3 @@ +Removals + * Remove the partial support for running unit tests via Greentea on Mbed OS, + which had been unmaintained since 2018. diff --git a/tests/Makefile b/tests/Makefile index db642c7798..77a31720f0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -173,7 +173,7 @@ $(BINARIES): %$(EXEXT): %.c $(MBEDLIBS) $(TEST_OBJS_DEPS) $(MBEDTLS_TEST_OBJS) clean: ifndef WINDOWS - rm -rf $(BINARIES) *.c *.datax TESTS + rm -rf $(BINARIES) *.c *.datax rm -f src/*.o src/drivers/*.o src/libmbed* rm -f include/test/instrument_record_status.h else @@ -184,9 +184,6 @@ else if exist src/drivers/*.o del /Q /F src/drivers/*.o if exist src/libmbed* del /Q /F src/libmed* if exist include/test/instrument_record_status.h del /Q /F include/test/instrument_record_status.h -ifneq ($(wildcard TESTS/.*),) - rmdir /Q /S TESTS -endif endif neat: clean @@ -202,40 +199,6 @@ check: $(BINARIES) test: check -# Create separate targets for generating embedded tests. -EMBEDDED_TESTS := $(addprefix embedded_,$(APPS)) - -# Generate test code for target. - -.SECONDEXPANSION: -$(EMBEDDED_TESTS): embedded_%: suites/$$(firstword $$(subst ., ,$$*)).function suites/%.data scripts/generate_test_code.py suites/helpers.function suites/main_test.function suites/target_test.function - echo " Gen ./TESTS/mbedtls/$*/$*.c" - $(PYTHON) scripts/generate_test_code.py -f suites/$(firstword $(subst ., ,$*)).function \ - -d suites/$*.data \ - -t suites/main_test.function \ - -p suites/target_test.function \ - -s suites \ - --helpers-file suites/helpers.function \ - -o ./TESTS/mbedtls/$* - -generate-target-tests: $(EMBEDDED_TESTS) - -define copy_header_to_target -TESTS/mbedtls/$(1)/$(2): include/test/$(2) - echo " Copy ./$$@" -ifndef WINDOWS - mkdir -p $$(@D) - cp $$< $$@ -else - mkdir $$(@D) - copy $$< $$@ -endif - -endef -$(foreach app, $(APPS), $(foreach file, $(notdir $(wildcard include/test/*.h)), \ - $(eval $(call copy_header_to_target,$(app),$(file))))) -$(addprefix embedded_,$(filter test_suite_psa_%, $(APPS))): embedded_%: $(patsubst TESTS/mbedtls/%, include/test/%, $(wildcard include/test/*. include/test/*/*.h)) - ifdef RECORD_PSA_STATUS_COVERAGE_LOG include/test/instrument_record_status.h: ../include/psa/crypto.h Makefile echo " Gen $@" diff --git a/tests/scripts/generate_test_code.py b/tests/scripts/generate_test_code.py index 7382fb6ecb..f5750aacfa 100755 --- a/tests/scripts/generate_test_code.py +++ b/tests/scripts/generate_test_code.py @@ -106,10 +106,6 @@ Platform file: Platform file contains platform specific setup code and test case dispatch code. For example, host_test.function reads test data file from host's file system and dispatches tests. -In case of on-target target_test.function tests are not dispatched -on target. Target code is kept minimum and only test functions are -dispatched. Test case dispatch is done on the host using tools like -Greentea. Template file: --------- diff --git a/tests/scripts/mbedtls_test.py b/tests/scripts/mbedtls_test.py deleted file mode 100755 index 64f12bbb31..0000000000 --- a/tests/scripts/mbedtls_test.py +++ /dev/null @@ -1,382 +0,0 @@ -#!/usr/bin/env python3 - -# Greentea host test script for Mbed TLS on-target test suite testing. -# -# Copyright The Mbed TLS Contributors -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -""" -Mbed TLS on-target test suite tests are implemented as Greentea -tests. Greentea tests are implemented in two parts: target test and -host test. Target test is a C application that is built for the -target platform and executes on the target. Host test is a Python -class derived from mbed_host_tests.BaseHostTest. Target communicates -with the host over serial for the test data and sends back the result. - -Python tool mbedgt (Greentea) is responsible for flashing the test -binary on to the target and dynamically loading this host test module. - -Greentea documentation can be found here: -https://github.com/ARMmbed/greentea -""" - - -import re -import os -import binascii - -from mbed_host_tests import BaseHostTest, event_callback # type: ignore # pylint: disable=import-error - - -class TestDataParserError(Exception): - """Indicates error in test data, read from .data file.""" - pass - - -class TestDataParser: - """ - Parses test name, dependencies, test function name and test parameters - from the data file. - """ - - def __init__(self): - """ - Constructor - """ - self.tests = [] - - def parse(self, data_file): - """ - Data file parser. - - :param data_file: Data file path - """ - with open(data_file, 'r') as data_f: - self.__parse(data_f) - - @staticmethod - def __escaped_split(inp_str, split_char): - """ - Splits inp_str on split_char except when escaped. - - :param inp_str: String to split - :param split_char: Split character - :return: List of splits - """ - split_colon_fn = lambda x: re.sub(r'\\' + split_char, split_char, x) - if len(split_char) > 1: - raise ValueError('Expected split character. Found string!') - out = list(map(split_colon_fn, re.split(r'(?> x) & 0xff) for x in [24, 16, 8, 0]]) - return data_bytes - - def test_vector_to_bytes(self, function_id, dependencies, parameters): - """ - Converts test vector into a byte array that can be sent to the target. - - :param function_id: Test Function Identifier - :param dependencies: Dependency list - :param parameters: Test function input parameters - :return: Byte array and its length - """ - data_bytes = bytearray([len(dependencies)]) - if dependencies: - data_bytes += bytearray(dependencies) - data_bytes += bytearray([function_id, len(parameters)]) - for typ, param in parameters: - if typ in ('int', 'exp'): - i = int(param, 0) - data_bytes += b'I' if typ == 'int' else b'E' - self.align_32bit(data_bytes) - data_bytes += self.int32_to_big_endian_bytes(i) - elif typ == 'char*': - param = param.strip('"') - i = len(param) + 1 # + 1 for null termination - data_bytes += b'S' - self.align_32bit(data_bytes) - data_bytes += self.int32_to_big_endian_bytes(i) - data_bytes += bytearray(param, encoding='ascii') - data_bytes += b'\0' # Null terminate - elif typ == 'hex': - binary_data = self.hex_str_bytes(param) - data_bytes += b'H' - self.align_32bit(data_bytes) - i = len(binary_data) - data_bytes += self.int32_to_big_endian_bytes(i) - data_bytes += binary_data - length = self.int32_to_big_endian_bytes(len(data_bytes)) - return data_bytes, length - - def run_next_test(self): - """ - Fetch next test information and execute the test. - - """ - self.test_index += 1 - self.dep_index = 0 - if self.test_index < len(self.tests): - name, function_id, dependencies, args = self.tests[self.test_index] - self.run_test(name, function_id, dependencies, args) - else: - self.notify_complete(self.suite_passed) - - def run_test(self, name, function_id, dependencies, args): - """ - Execute the test on target by sending next test information. - - :param name: Test name - :param function_id: function identifier - :param dependencies: Dependencies list - :param args: test parameters - :return: - """ - self.log("Running: %s" % name) - - param_bytes, length = self.test_vector_to_bytes(function_id, - dependencies, args) - self.send_kv( - ''.join('{:02x}'.format(x) for x in length), - ''.join('{:02x}'.format(x) for x in param_bytes) - ) - - @staticmethod - def get_result(value): - """ - Converts result from string type to integer - :param value: Result code in string - :return: Integer result code. Value is from the test status - constants defined under the MbedTlsTest class. - """ - try: - return int(value) - except ValueError: - ValueError("Result should return error number. " - "Instead received %s" % value) - - @event_callback('GO') - def on_go(self, _key, _value, _timestamp): - """ - Sent by the target to start first test. - - :param _key: Event key - :param _value: Value. ignored - :param _timestamp: Timestamp ignored. - :return: - """ - self.run_next_test() - - @event_callback("R") - def on_result(self, _key, value, _timestamp): - """ - Handle result. Prints test start, finish required by Greentea - to detect test execution. - - :param _key: Event key - :param value: Value. ignored - :param _timestamp: Timestamp ignored. - :return: - """ - int_val = self.get_result(value) - name, _, _, _ = self.tests[self.test_index] - self.log('{{__testcase_start;%s}}' % name) - self.log('{{__testcase_finish;%s;%d;%d}}' % (name, int_val == 0, - int_val != 0)) - if int_val != 0: - self.suite_passed = False - self.run_next_test() - - @event_callback("F") - def on_failure(self, _key, value, _timestamp): - """ - Handles test execution failure. That means dependency not supported or - Test function not supported. Hence marking test as skipped. - - :param _key: Event key - :param value: Value. ignored - :param _timestamp: Timestamp ignored. - :return: - """ - int_val = self.get_result(value) - if int_val in self.error_str: - err = self.error_str[int_val] - else: - err = 'Unknown error' - # For skip status, do not write {{__testcase_finish;...}} - self.log("Error: %s" % err) - self.run_next_test() diff --git a/tests/suites/target_test.function b/tests/suites/target_test.function deleted file mode 100644 index 637a79d5ee..0000000000 --- a/tests/suites/target_test.function +++ /dev/null @@ -1,449 +0,0 @@ -#line 2 "suites/target_test.function" - -#include "greentea-client/test_env.h" - -/** - * \brief Increments pointer and asserts that it does not overflow. - * - * \param p Pointer to byte array - * \param start Pointer to start of byte array - * \param len Length of byte array - * \param step Increment size - * - */ -#define INCR_ASSERT(p, start, len, step) do \ -{ \ - TEST_HELPER_ASSERT( ( p ) >= ( start ) ); \ - TEST_HELPER_ASSERT( sizeof( *( p ) ) == sizeof( *( start ) ) ); \ - /* <= is checked to support use inside a loop where \ - pointer is incremented after reading data. */ \ - TEST_HELPER_ASSERT( (uint32_t)( ( ( p ) - ( start ) ) + ( step ) ) <= ( len ) );\ - ( p ) += ( step ); \ -} \ -while( 0 ) - - -/** - * \brief 4 byte align unsigned char pointer - * - * \param p Pointer to byte array - * \param start Pointer to start of byte array - * \param len Length of byte array - * - */ -#define ALIGN_32BIT(p, start, len) do \ -{ \ - uint32_t align = ( - (uintptr_t)( p ) ) % 4; \ - INCR_ASSERT( ( p ), ( start ), ( len ), align );\ -} \ -while( 0 ) - - -/** - * \brief Verify dependencies. Dependency identifiers are - * encoded in the buffer as 8 bit unsigned integers. - * - * \param count Number of dependencies. - * \param dep_p Pointer to buffer. - * - * \return DEPENDENCY_SUPPORTED if success else DEPENDENCY_NOT_SUPPORTED. - */ -int verify_dependencies( uint8_t count, uint8_t * dep_p ) -{ - uint8_t i; - for ( i = 0; i < count; i++ ) - { - if ( dep_check( (int)(dep_p[i]) ) != DEPENDENCY_SUPPORTED ) - return( DEPENDENCY_NOT_SUPPORTED ); - } - return( DEPENDENCY_SUPPORTED ); -} - -/** - * \brief Receives hex string on serial interface, and converts to a byte. - * - * \param none - * - * \return unsigned int8 - */ -uint8_t receive_byte() -{ - uint8_t byte; - uint8_t c[3]; - size_t len; - - c[0] = greentea_getc(); - c[1] = greentea_getc(); - c[2] = '\0'; - - TEST_HELPER_ASSERT( mbedtls_test_unhexify( &byte, sizeof( byte ), - c, &len ) == 0 ); - TEST_HELPER_ASSERT( len != 2 ); - - return( byte ); -} - -/** - * \brief Receives unsigned integer on serial interface. - * Integers are encoded in network order, and sent as hex ascii string. - * - * \param none - * - * \return unsigned int - */ -uint32_t receive_uint32() -{ - uint32_t value; - size_t len; - const uint8_t c_be[8] = { greentea_getc(), - greentea_getc(), - greentea_getc(), - greentea_getc(), - greentea_getc(), - greentea_getc(), - greentea_getc(), - greentea_getc() - }; - const uint8_t c[9] = { c_be[6], c_be[7], c_be[4], c_be[5], c_be[2], - c_be[3], c_be[0], c_be[1], '\0' }; - - TEST_HELPER_ASSERT( mbedtls_test_unhexify( (uint8_t*)&value, sizeof( value ), - c, &len ) == 0 ); - TEST_HELPER_ASSERT( len != 8 ); - - return( value ); -} - -/** - * \brief Parses out an unsigned 32 int value from the byte array. - * Integers are encoded in network order. - * - * \param p Pointer to byte array - * - * \return unsigned int - */ -uint32_t parse_uint32( uint8_t * p ) -{ - uint32_t value; - value = *p++ << 24; - value |= *p++ << 16; - value |= *p++ << 8; - value |= *p; - return( value ); -} - - -/** - * \brief Receives test data on serial as greentea key,value pair: - * {{;}} - * - * \param data_len Out pointer to hold received data length. - * - * \return Byte array. - */ -uint8_t * receive_data( uint32_t * data_len ) -{ - uint32_t i = 0, errors = 0; - char c; - uint8_t * data = NULL; - - /* Read opening braces */ - i = 0; - while ( i < 2 ) - { - c = greentea_getc(); - /* Ignore any prevous CR LF characters */ - if ( c == '\n' || c == '\r' ) - continue; - i++; - if ( c != '{' ) - return( NULL ); - } - - /* Read data length */ - *data_len = receive_uint32(); - data = (uint8_t *)malloc( *data_len ); - TEST_HELPER_ASSERT( data != NULL ); - - greentea_getc(); // read ';' received after key i.e. *data_len - - for( i = 0; i < *data_len; i++ ) - data[i] = receive_byte(); - - /* Read closing braces */ - for( i = 0; i < 2; i++ ) - { - c = greentea_getc(); - if ( c != '}' ) - { - errors++; - break; - } - } - - if ( errors ) - { - free( data ); - data = NULL; - *data_len = 0; - } - - return( data ); -} - -/** - * \brief Parse the received byte array and count the number of arguments - * to the test function passed as type hex. - * - * \param count Parameter count - * \param data Received Byte array - * \param data_len Byte array length - * - * \return count of hex params - */ -uint32_t find_hex_count( uint8_t count, uint8_t * data, uint32_t data_len ) -{ - uint32_t i = 0, sz = 0; - char c; - uint8_t * p = NULL; - uint32_t hex_count = 0; - - p = data; - - for( i = 0; i < count; i++ ) - { - c = (char)*p; - INCR_ASSERT( p, data, data_len, 1 ); - - /* Align p to 4 bytes for int, expression, string len or hex length */ - ALIGN_32BIT( p, data, data_len ); - - /* Network to host conversion */ - sz = (int32_t)parse_uint32( p ); - - INCR_ASSERT( p, data, data_len, sizeof( int32_t ) ); - - if ( c == 'H' || c == 'S' ) - { - INCR_ASSERT( p, data, data_len, sz ); - hex_count += ( c == 'H' )?1:0; - } - } - - return( hex_count ); -} - -/** - * \brief Parses received byte array for test parameters. - * - * \param count Parameter count - * \param data Received Byte array - * \param data_len Byte array length - * \param error Parsing error out variable. - * - * \return Array of parsed parameters allocated on heap. - * Note: Caller has the responsibility to delete - * the memory after use. - */ -void ** parse_parameters( uint8_t count, uint8_t * data, uint32_t data_len, - int * error ) -{ - uint32_t i = 0, hex_count = 0; - char c; - void ** params = NULL; - void ** cur = NULL; - uint8_t * p = NULL; - - hex_count = find_hex_count(count, data, data_len); - - params = (void **)malloc( sizeof( void *) * ( count + hex_count ) ); - TEST_HELPER_ASSERT( params != NULL ); - cur = params; - - p = data; - - /* Parameters */ - for( i = 0; i < count; i++ ) - { - c = (char)*p; - INCR_ASSERT( p, data, data_len, 1 ); - - /* Align p to 4 bytes for int, expression, string len or hex length */ - ALIGN_32BIT( p, data, data_len ); - - /* Network to host conversion */ - *( (int32_t *)p ) = (int32_t)parse_uint32( p ); - - switch( c ) - { - case 'E': - { - if ( get_expression( *( (int32_t *)p ), (int32_t *)p ) ) - { - *error = KEY_VALUE_MAPPING_NOT_FOUND; - goto exit; - } - } /* Intentional fall through */ - case 'I': - { - *cur++ = (void *)p; - INCR_ASSERT( p, data, data_len, sizeof( int32_t ) ); - } - break; - case 'H': /* Intentional fall through */ - case 'S': - { - uint32_t * sz = (uint32_t *)p; - INCR_ASSERT( p, data, data_len, sizeof( int32_t ) ); - *cur++ = (void *)p; - if ( c == 'H' ) - *cur++ = (void *)sz; - INCR_ASSERT( p, data, data_len, ( *sz ) ); - } - break; - default: - { - *error = DISPATCH_INVALID_TEST_DATA; - goto exit; - } - break; - } - } - -exit: - if ( *error ) - { - free( params ); - params = NULL; - } - - return( params ); -} - -/** - * \brief Sends greentea key and int value pair to host. - * - * \param key key string - * \param value integer value - * - * \return void - */ -void send_key_integer( char * key, int value ) -{ - char str[50]; - snprintf( str, sizeof( str ), "%d", value ); - greentea_send_kv( key, str ); -} - -/** - * \brief Sends test setup failure to the host. - * - * \param failure Test set failure - * - * \return void - */ -void send_failure( int failure ) -{ - send_key_integer( "F", failure ); -} - -/** - * \brief Sends test status to the host. - * - * \param status Test status (PASS=0/FAIL=!0) - * - * \return void - */ -void send_status( int status ) -{ - send_key_integer( "R", status ); -} - - -/** - * \brief Embedded implementation of execute_tests(). - * Ignores command line and received test data - * on serial. - * - * \param argc not used - * \param argv not used - * - * \return Program exit status. - */ -int execute_tests( int args, const char ** argv ) -{ - int ret = 0; - uint32_t data_len = 0; - uint8_t count = 0, function_id; - void ** params = NULL; - uint8_t * data = NULL, * p = NULL; - - GREENTEA_SETUP( 800, "mbedtls_test" ); - greentea_send_kv( "GO", " " ); - - while ( 1 ) - { - ret = 0; - mbedtls_test_info_reset( ); - data_len = 0; - - data = receive_data( &data_len ); - if ( data == NULL ) - continue; - p = data; - - do - { - /* Read dependency count */ - count = *p; - TEST_HELPER_ASSERT( count < data_len ); - INCR_ASSERT( p, data, data_len, sizeof( uint8_t ) ); - ret = verify_dependencies( count, p ); - if ( ret != DEPENDENCY_SUPPORTED ) - break; - - if ( count ) - INCR_ASSERT( p, data, data_len, count ); - - /* Read function id */ - function_id = *p; - INCR_ASSERT( p, data, data_len, sizeof( uint8_t ) ); - if ( ( ret = check_test( function_id ) ) != DISPATCH_TEST_SUCCESS ) - break; - - /* Read number of parameters */ - count = *p; - INCR_ASSERT( p, data, data_len, sizeof( uint8_t ) ); - - /* Parse parameters if present */ - if ( count ) - { - params = parse_parameters( count, p, data_len - ( p - data ), &ret ); - if ( ret ) - break; - } - - ret = dispatch_test( function_id, params ); - } - while ( 0 ); - - if ( data ) - { - free( data ); - data = NULL; - } - - if ( params ) - { - free( params ); - params = NULL; - } - - if ( ret ) - send_failure( ret ); - else - send_status( mbedtls_test_info.result ); - } - return( 0 ); -} - From f257a6e8f8c9b85ad2f42600bbac8c2518323607 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 27 Oct 2021 16:27:44 +0200 Subject: [PATCH 828/966] Add CCM*-no-tag tests for the cipher module. Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_cipher.aes.data | 312 +++++++++++++++++++ tests/suites/test_suite_cipher.aria.data | 312 +++++++++++++++++++ tests/suites/test_suite_cipher.camellia.data | 312 +++++++++++++++++++ tests/suites/test_suite_cipher.function | 23 +- 4 files changed, 954 insertions(+), 5 deletions(-) diff --git a/tests/suites/test_suite_cipher.aes.data b/tests/suites/test_suite_cipher.aes.data index c8fbca290b..bd5c2f68f8 100644 --- a/tests/suites/test_suite_cipher.aes.data +++ b/tests/suites/test_suite_cipher.aes.data @@ -790,6 +790,318 @@ AES-256 OFB - Encrypt and decrypt 32 bytes in multiple parts 1 depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:16:16:-1:16:16:16:16 +AES-128 CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:0:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:1:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:2:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:7:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:8:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:9:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:15:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:16:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:17:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:31:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:32:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:33:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:47:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:48:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:"AES-128-CCM*-NO-TAG":128:49:-1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:0:0:-1:0:0:0:0 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:1:0:-1:1:0:1:0 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:0:1:-1:0:1:0:1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:16:0:-1:16:0:16:0 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:0:16:-1:0:16:0:16 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:1:15:-1:1:15:1:15 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:15:1:-1:15:1:15:1 + +AES-128 CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:15:7:-1:15:7:15:7 + +AES-128-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:16:6:-1:16:6:16:6 + +AES-128-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:17:6:-1:17:6:17:6 + +AES-128-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:128:16:16:-1:16:16:16:16 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:0:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:1:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:2:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:7:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:8:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:9:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:15:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:16:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:17:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:31:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:32:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:33:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:47:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:48:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:"AES-192-CCM*-NO-TAG":192:49:-1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:0:0:-1:0:0:0:0 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:1:0:-1:1:0:1:0 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:0:1:-1:0:1:0:1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:16:0:-1:16:0:16:0 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:0:16:-1:0:16:0:16 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:1:15:-1:1:15:1:15 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:15:1:-1:15:1:15:1 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:15:7:-1:15:7:15:7 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:16:6:-1:16:6:16:6 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:17:6:-1:17:6:17:6 + +AES-192-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:192:16:16:-1:16:16:16:16 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:0:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:1:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:2:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:7:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:8:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:9:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:15:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:16:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:17:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:31:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:32:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:33:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:47:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:48:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:"AES-256-CCM*-NO-TAG":256:49:-1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:0:0:-1:0:0:0:0 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:1:0:-1:1:0:1:0 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:0:1:-1:0:1:0:1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:16:0:-1:16:0:16:0 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:0:16:-1:0:16:0:16 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:1:15:-1:1:15:1:15 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:15:1:-1:15:1:15:1 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:15:7:-1:15:7:15:7 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:16:6:-1:16:6:16:6 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:17:6:-1:17:6:17:6 + +AES-256-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:256:16:16:-1:16:16:16:16 + AES-128 XTS - Encrypt and decrypt 16 bytes depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:16:-1 diff --git a/tests/suites/test_suite_cipher.aria.data b/tests/suites/test_suite_cipher.aria.data index 2c50a21fc7..4b14bcc78b 100644 --- a/tests/suites/test_suite_cipher.aria.data +++ b/tests/suites/test_suite_cipher.aria.data @@ -1,3 +1,315 @@ Aria CBC Decrypt empty buffer depends_on:MBEDTLS_ARIA_C:MBEDTLS_CIPHER_MODE_CBC dec_empty_buf:MBEDTLS_CIPHER_ARIA_128_CBC:0:0 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:0:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:1:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:2:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:7:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:8:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:9:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:15:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:16:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:17:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:31:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:32:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:33:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:47:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:48:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:"ARIA-128-CCM*-NO-TAG":128:49:-1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:0:0:-1:0:0:0:0 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:1:0:-1:1:0:1:0 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:0:1:-1:0:1:0:1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:16:0:-1:16:0:16:0 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:0:16:-1:0:16:0:16 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:1:15:-1:1:15:1:15 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:15:1:-1:15:1:15:1 + +ARIA-128 CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:15:7:-1:15:7:15:7 + +ARIA-128-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:16:6:-1:16:6:16:6 + +ARIA-128-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:17:6:-1:17:6:17:6 + +ARIA-128-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:128:16:16:-1:16:16:16:16 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:0:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:1:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:2:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:7:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:8:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:9:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:15:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:16:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:17:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:31:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:32:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:33:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:47:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:48:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:"ARIA-192-CCM*-NO-TAG":192:49:-1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:0:0:-1:0:0:0:0 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:1:0:-1:1:0:1:0 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:0:1:-1:0:1:0:1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:16:0:-1:16:0:16:0 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:0:16:-1:0:16:0:16 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:1:15:-1:1:15:1:15 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:15:1:-1:15:1:15:1 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:15:7:-1:15:7:15:7 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:16:6:-1:16:6:16:6 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:17:6:-1:17:6:17:6 + +ARIA-192-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:192:16:16:-1:16:16:16:16 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:0:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:1:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:2:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:7:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:8:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:9:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:15:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:16:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:17:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:31:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:32:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:33:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:47:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:48:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:"ARIA-256-CCM*-NO-TAG":256:49:-1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:0:0:-1:0:0:0:0 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:1:0:-1:1:0:1:0 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:0:1:-1:0:1:0:1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:16:0:-1:16:0:16:0 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:0:16:-1:0:16:0:16 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:1:15:-1:1:15:1:15 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:15:1:-1:15:1:15:1 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:15:7:-1:15:7:15:7 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:16:6:-1:16:6:16:6 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:17:6:-1:17:6:17:6 + +ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:16:16:-1:16:16:16:16 diff --git a/tests/suites/test_suite_cipher.camellia.data b/tests/suites/test_suite_cipher.camellia.data index 3e7bffa45b..2c7a069ca2 100644 --- a/tests/suites/test_suite_cipher.camellia.data +++ b/tests/suites/test_suite_cipher.camellia.data @@ -765,3 +765,315 @@ enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CBC:256:17:6:-1:16:0:16:0 CAMELLIA Encrypt and decrypt 32 bytes in multiple parts 1 [#5] depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7 enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CBC:256:16:16:-1:16:16:0:32 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:0:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:1:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:2:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:7:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:8:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:9:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:15:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:16:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:17:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:31:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:32:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:33:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:47:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:48:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:"CAMELLIA-128-CCM*-NO-TAG":128:49:-1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:0:0:-1:0:0:0:0 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:1:0:-1:1:0:1:0 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:0:1:-1:0:1:0:1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:16:0:-1:16:0:16:0 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:0:16:-1:0:16:0:16 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:1:15:-1:1:15:1:15 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:15:1:-1:15:1:15:1 + +CAMELLIA-128 CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:15:7:-1:15:7:15:7 + +CAMELLIA-128-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:16:6:-1:16:6:16:6 + +CAMELLIA-128-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:17:6:-1:17:6:17:6 + +CAMELLIA-128-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:128:16:16:-1:16:16:16:16 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:0:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:1:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:2:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:7:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:8:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:9:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:15:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:16:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:17:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:31:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:32:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:33:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:47:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:48:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:"CAMELLIA-192-CCM*-NO-TAG":192:49:-1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:0:0:-1:0:0:0:0 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:1:0:-1:1:0:1:0 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:0:1:-1:0:1:0:1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:16:0:-1:16:0:16:0 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:0:16:-1:0:16:0:16 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:1:15:-1:1:15:1:15 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:15:1:-1:15:1:15:1 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:15:7:-1:15:7:15:7 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:16:6:-1:16:6:16:6 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:17:6:-1:17:6:17:6 + +CAMELLIA-192-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:192:16:16:-1:16:16:16:16 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:0:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:1:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:2:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:7:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:8:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:9:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:15:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:16:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:17:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:31:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:32:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:33:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:47:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:48:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:"CAMELLIA-256-CCM*-NO-TAG":256:49:-1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:0:0:-1:0:0:0:0 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:1:0:-1:1:0:1:0 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:0:1:-1:0:1:0:1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:16:0:-1:16:0:16:0 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:0:16:-1:0:16:0:16 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:1:15:-1:1:15:1:15 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:15:1:-1:15:1:15:1 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:15:7:-1:15:7:15:7 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:16:6:-1:16:6:16:6 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:17:6:-1:17:6:17:6 + +CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:16:16:-1:16:16:16:16 diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index c809d9a280..e496856e2e 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -343,7 +343,7 @@ exit: void enc_dec_buf( int cipher_id, char * cipher_string, int key_len, int length_val, int pad_mode ) { - size_t length = length_val, outlen, total_len, i, block_size; + size_t length = length_val, outlen, total_len, i, block_size, iv_len; unsigned char key[64]; unsigned char iv[16]; unsigned char ad[13]; @@ -401,8 +401,14 @@ void enc_dec_buf( int cipher_id, char * cipher_string, int key_len, memset( decbuf, 0, sizeof( decbuf ) ); memset( tag, 0, sizeof( tag ) ); - TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_dec, iv, sizeof( iv ) ) ); - TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_enc, iv, sizeof( iv ) ) ); + if( NULL != strstr( cipher_info->name, "CCM*-NO-TAG") ) + iv_len = 13; /* For CCM, IV length is expected to be between 7 and 13 bytes. + * For CCM*-NO-TAG, IV length must be exactly 13 bytes long. */ + else + iv_len = sizeof(iv); + + TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_dec, iv, iv_len ) ); + TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_enc, iv, iv_len ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) ); @@ -597,6 +603,7 @@ void enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_val, size_t second_length = second_length_val; size_t length = first_length + second_length; size_t block_size; + size_t iv_len; unsigned char key[32]; unsigned char iv[16]; @@ -641,8 +648,14 @@ void enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_val, (void) pad_mode; #endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ - TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_dec, iv, 16 ) ); - TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_enc, iv, 16 ) ); + if( NULL != strstr( cipher_info->name, "CCM*-NO-TAG") ) + iv_len = 13; /* For CCM, IV length is expected to be between 7 and 13 bytes. + * For CCM*-NO-TAG, IV length must be exactly 13 bytes long. */ + else + iv_len = sizeof(iv); + + TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_dec, iv, iv_len ) ); + TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_enc, iv, iv_len ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) ); From 2d5c72be0bd1e32bcf0fa06d23220002da554614 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 13 Sep 2021 07:30:09 +0000 Subject: [PATCH 829/966] TLS1.3: Add Encrypted Extensions Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 1 + library/ssl_tls13_client.c | 124 +++++++++++++++++++++++++++++++++++- library/ssl_tls13_generic.c | 33 ++++++++++ 3 files changed, 155 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index fa2429d07c..6bdb7acd18 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -486,6 +486,7 @@ #define MBEDTLS_SSL_HS_SERVER_HELLO 2 #define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3 #define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4 +#define MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION 8 // NEW IN TLS 1.3 #define MBEDTLS_SSL_HS_CERTIFICATE 11 #define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12 #define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13 diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 979db31449..686edfe3b9 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1395,11 +1395,125 @@ cleanup: } /* - * Handler for MBEDTLS_SSL_ENCRYPTED_EXTENSIONS + * + * EncryptedExtensions message + * + * The EncryptedExtensions message contains any extensions which + * should be protected, i.e., any which are not needed to establish + * the cryptographic context. */ -static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ) + +/* + * Overview + */ +static int ssl_tls1_3_read_encrypted_extensions( mbedtls_ssl_context *ssl ); + +/* Main entry point; orchestrates the other functions */ +static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl ); + +static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t buf_len ); +static int ssl_tls13_encrypted_extensions_postprocess( mbedtls_ssl_context *ssl ); + +/* + * Handler for MBEDTLS_SSL_ENCRYPTED_ENTENSIONS + */ +static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *buf; + size_t buf_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse encrypted extensions" ) ); + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_fetch_handshake_msg( ssl, + MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, + &buf, &buf_len ) ); + + /* Process the message contents */ + MBEDTLS_SSL_PROC_CHK( ssl_tls13_encrypted_extensions_parse( ssl, buf, buf_len ) ); + + mbedtls_ssl_tls13_add_hs_msg_to_checksum( + ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, buf, buf_len ); + + MBEDTLS_SSL_PROC_CHK( ssl_tls13_encrypted_extensions_postprocess( ssl ) ); + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse encrypted extensions" ) ); + return( ret ); + +} + +static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t buf_len ) +{ + int ret = 0; + size_t ext_len; + const unsigned char *ext; + + if( buf_len < 2 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension message too short" ) ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + ext_len = MBEDTLS_GET_UINT16_BE(buf, 0); + + buf += 2; /* skip extension length */ + ext = buf; + + /* Checking for an extension length that is too short */ + if( ext_len > 0 && ext_len < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension message too short" ) ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + /* Checking for an extension length that isn't aligned with the rest + * of the message */ + if( buf_len != 2 + ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension lengths misaligned" ) ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "encrypted extensions extensions", ext, ext_len ); + + while( ext_len ) + { + unsigned int ext_id = MBEDTLS_GET_UINT16_BE(ext, 0); + size_t ext_size = MBEDTLS_GET_UINT16_BE(ext, 2); + + if( ext_size + 4 > ext_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad encrypted extensions message" ) ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + /* TBD: The client MUST check EncryptedExtensions for the + * presence of any forbidden extensions and if any are found MUST abort + * the handshake with an "illegal_parameter" alert. + */ + ((void) ext_id); + + ext_len -= 4 + ext_size; + ext += 4 + ext_size; + + if( ext_len > 0 && ext_len < 4 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad encrypted extensions message" ) ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + } + + return( ret ); +} + +static int ssl_tls13_encrypted_extensions_postprocess( mbedtls_ssl_context *ssl ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_REQUEST ); return( 0 ); } @@ -1555,6 +1669,10 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) ret = ssl_tls1_3_handshake_wrapup( ssl ); break; + case MBEDTLS_SSL_ENCRYPTED_EXTENSIONS: + ret = ssl_tls13_encrypted_extensions_process( ssl ); + break; + default: MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index b3a4a09ddc..949fa74741 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -27,6 +27,39 @@ #include "mbedtls/debug.h" #include "ssl_misc.h" +#include + +int mbedtls_ssl_tls13_fetch_handshake_msg( mbedtls_ssl_context *ssl, + unsigned hs_type, + unsigned char **buf, + size_t *buflen ) +{ + int ret; + + if( ( ret = mbedtls_ssl_read_record( ssl, 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + goto cleanup; + } + + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE || + ssl->in_msg[0] != hs_type ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE, + MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); + ret = MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE; + goto cleanup; + } + + *buf = ssl->in_msg + 4; + *buflen = ssl->in_hslen - 4; + + +cleanup: + + return( ret ); +} int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, From c1fe000cfd8cca1d9b6994519bee84bdfa0bb608 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 16 Sep 2021 03:02:14 +0000 Subject: [PATCH 830/966] TLS1.3: Solve check name issue-macro definition Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 686edfe3b9..a27f7239dd 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1417,7 +1417,7 @@ static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl, static int ssl_tls13_encrypted_extensions_postprocess( mbedtls_ssl_context *ssl ); /* - * Handler for MBEDTLS_SSL_ENCRYPTED_ENTENSIONS + * Handler for MBEDTLS_SSL_ENCRYPTED_EXTENSIONS */ static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl ) { From e87e5924c9e8bf4bd6c08bb4ed375afd0d954acb Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Fri, 24 Sep 2021 07:35:32 +0000 Subject: [PATCH 831/966] Fix some issues such as naming mismatch based on comments. Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 25 ++++++++++--------------- library/ssl_tls13_generic.c | 32 -------------------------------- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index a27f7239dd..00c1835dd3 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1406,20 +1406,19 @@ cleanup: /* * Overview */ -static int ssl_tls1_3_read_encrypted_extensions( mbedtls_ssl_context *ssl ); /* Main entry point; orchestrates the other functions */ -static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl ); +static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ); -static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl, +static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t buf_len ); -static int ssl_tls13_encrypted_extensions_postprocess( mbedtls_ssl_context *ssl ); +static int ssl_tls1_3_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl ); /* * Handler for MBEDTLS_SSL_ENCRYPTED_EXTENSIONS */ -static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ) { int ret; unsigned char *buf; @@ -1427,17 +1426,17 @@ static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse encrypted extensions" ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_fetch_handshake_msg( ssl, + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, &buf, &buf_len ) ); /* Process the message contents */ - MBEDTLS_SSL_PROC_CHK( ssl_tls13_encrypted_extensions_parse( ssl, buf, buf_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_parse_encrypted_extensions( ssl, buf, buf_len ) ); - mbedtls_ssl_tls13_add_hs_msg_to_checksum( + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, buf, buf_len ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_encrypted_extensions_postprocess( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_postprocess_encrypted_extensions( ssl ) ); cleanup: @@ -1446,7 +1445,7 @@ cleanup: } -static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl, +static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t buf_len ) { @@ -1512,7 +1511,7 @@ static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl, return( ret ); } -static int ssl_tls13_encrypted_extensions_postprocess( mbedtls_ssl_context *ssl ) +static int ssl_tls1_3_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl ) { mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_REQUEST ); return( 0 ); @@ -1669,10 +1668,6 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) ret = ssl_tls1_3_handshake_wrapup( ssl ); break; - case MBEDTLS_SSL_ENCRYPTED_EXTENSIONS: - ret = ssl_tls13_encrypted_extensions_process( ssl ); - break; - default: MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) ); return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 949fa74741..70c2b02103 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -29,38 +29,6 @@ #include "ssl_misc.h" #include -int mbedtls_ssl_tls13_fetch_handshake_msg( mbedtls_ssl_context *ssl, - unsigned hs_type, - unsigned char **buf, - size_t *buflen ) -{ - int ret; - - if( ( ret = mbedtls_ssl_read_record( ssl, 0 ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); - goto cleanup; - } - - if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE || - ssl->in_msg[0] != hs_type ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE, - MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); - ret = MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE; - goto cleanup; - } - - *buf = ssl->in_msg + 4; - *buflen = ssl->in_hslen - 4; - - -cleanup: - - return( ret ); -} - int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, From 140f0459ed6f99d88b96d5451dc46c9abf0e1aa0 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Fri, 8 Oct 2021 08:05:53 +0000 Subject: [PATCH 832/966] Encrypted Extension: Align the code style of buffer pointer Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 45 ++++++++++++++++++++----------------- library/ssl_tls13_generic.c | 1 - 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 00c1835dd3..acdfa0542e 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1450,45 +1450,46 @@ static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, size_t buf_len ) { int ret = 0; - size_t ext_len; - const unsigned char *ext; + size_t p_ext_len; + const unsigned char *end = buf + buf_len; + const unsigned char *p = buf; - if( buf_len < 2 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension message too short" ) ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2); + p_ext_len = MBEDTLS_GET_UINT16_BE(buf, 0); - ext_len = MBEDTLS_GET_UINT16_BE(buf, 0); - - buf += 2; /* skip extension length */ - ext = buf; + p += 2; /* skip extension length */ /* Checking for an extension length that is too short */ - if( ext_len > 0 && ext_len < 4 ) + if( p_ext_len > 0 && p_ext_len < 4 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension message too short" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_ERR_SSL_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } /* Checking for an extension length that isn't aligned with the rest * of the message */ - if( buf_len != 2 + ext_len ) + if( buf_len != 2 + p_ext_len ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension lengths misaligned" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_ERR_SSL_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } - MBEDTLS_SSL_DEBUG_BUF( 3, "encrypted extensions extensions", ext, ext_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "encrypted extensions extensions", p, p_ext_len ); - while( ext_len ) + while( p_ext_len ) { - unsigned int ext_id = MBEDTLS_GET_UINT16_BE(ext, 0); - size_t ext_size = MBEDTLS_GET_UINT16_BE(ext, 2); + unsigned int ext_id = MBEDTLS_GET_UINT16_BE(p, 0); + size_t ext_size = MBEDTLS_GET_UINT16_BE(p, 2); - if( ext_size + 4 > ext_len ) + if( ext_size + 4 > p_ext_len ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad encrypted extensions message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_ERR_SSL_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } @@ -1498,12 +1499,14 @@ static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, */ ((void) ext_id); - ext_len -= 4 + ext_size; - ext += 4 + ext_size; + p_ext_len -= 4 + ext_size; + p += 4 + ext_size; - if( ext_len > 0 && ext_len < 4 ) + if( p_ext_len > 0 && p_ext_len < 4 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad encrypted extensions message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_ERR_SSL_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } } diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 70c2b02103..b3a4a09ddc 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -27,7 +27,6 @@ #include "mbedtls/debug.h" #include "ssl_misc.h" -#include int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, From 08da26c58f959ba4e93498d3ed626717b5ee1cdf Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Sat, 9 Oct 2021 10:12:11 +0000 Subject: [PATCH 833/966] Refine encrypted extensions parse function Change arguments of API. Send different messages base on extensions types. Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 83 +++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index acdfa0542e..13fb47079c 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1411,8 +1411,8 @@ cleanup: static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ); static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, - const unsigned char *buf, - size_t buf_len ); + const unsigned char *buf, + const unsigned char *end ); static int ssl_tls1_3_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl ); /* @@ -1431,7 +1431,7 @@ static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ) &buf, &buf_len ) ); /* Process the message contents */ - MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_parse_encrypted_extensions( ssl, buf, buf_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_parse_encrypted_extensions( ssl, buf, ( buf + buf_len ) ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, buf, buf_len ); @@ -1445,32 +1445,27 @@ cleanup: } +/* Parse EncryptedExtensions message + * struct { + * Extension extensions<0..2^16-1>; + * } EncryptedExtensions; + */ static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, - const unsigned char *buf, - size_t buf_len ) + const unsigned char *buf, + const unsigned char *end ) { int ret = 0; - size_t p_ext_len; - const unsigned char *end = buf + buf_len; + size_t extensions_len; const unsigned char *p = buf; - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2); - p_ext_len = MBEDTLS_GET_UINT16_BE(buf, 0); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); + extensions_len = MBEDTLS_GET_UINT16_BE(p, 0); - p += 2; /* skip extension length */ - - /* Checking for an extension length that is too short */ - if( p_ext_len > 0 && p_ext_len < 4 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension message too short" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ - MBEDTLS_ERR_SSL_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } + p += 2; /* Checking for an extension length that isn't aligned with the rest * of the message */ - if( buf_len != 2 + p_ext_len ) + if( p + extensions_len != end ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension lengths misaligned" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ @@ -1478,31 +1473,47 @@ static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } - MBEDTLS_SSL_DEBUG_BUF( 3, "encrypted extensions extensions", p, p_ext_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "encrypted extensions extensions", p, extensions_len ); - while( p_ext_len ) + while( p < end ) { - unsigned int ext_id = MBEDTLS_GET_UINT16_BE(p, 0); - size_t ext_size = MBEDTLS_GET_UINT16_BE(p, 2); + unsigned int extension_type; + size_t extension_data_len; - if( ext_size + 4 > p_ext_len ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad encrypted extensions message" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ - MBEDTLS_ERR_SSL_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } + /* + * struct { + * ExtensionType extension_type; (2 bytes) + * opaque extension_data<0..2^16-1>; + * } Extension; + */ + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 4 ); + extension_type = MBEDTLS_GET_UINT16_BE( p, 0 ); + extension_data_len = MBEDTLS_GET_UINT16_BE( p, 2 ); + p += 4; + + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, extension_data_len ); /* TBD: The client MUST check EncryptedExtensions for the * presence of any forbidden extensions and if any are found MUST abort - * the handshake with an "illegal_parameter" alert. + * the handshake with an "unsupported_extension" alert. */ - ((void) ext_id); + switch( extension_type ) + { - p_ext_len -= 4 + ext_size; - p += 4 + ext_size; + case MBEDTLS_TLS_EXT_SUPPORTED_GROUPS: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "found extensions supported groups" ) ); + break; - if( p_ext_len > 0 && p_ext_len < 4 ) + default: + MBEDTLS_SSL_DEBUG_MSG( 3, ( "unsupported extension found: %d ( ignoring )", extension_type) ); + break; + } + + extensions_len -= 4 + extension_data_len; + p += extension_data_len; + + /* Checking for an extension length that is too short */ + if( extensions_len > 0 && extensions_len < 4 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad encrypted extensions message" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ From 97799ac27bb095d1966aa0abce294cb076fa7706 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 11 Oct 2021 10:05:54 +0000 Subject: [PATCH 834/966] Encrypted Extensions: Align code style and some check logic Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 74 ++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 13fb47079c..f7f7eaabac 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1408,17 +1408,17 @@ cleanup: */ /* Main entry point; orchestrates the other functions */ -static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ); +static int ssl_tls13_process_encrypted_extensions( mbedtls_ssl_context *ssl ); -static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, - const unsigned char *buf, - const unsigned char *end ); -static int ssl_tls1_3_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl ); +static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ); +static int ssl_tls13_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl ); /* * Handler for MBEDTLS_SSL_ENCRYPTED_EXTENSIONS */ -static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ) +static int ssl_tls13_process_encrypted_extensions( mbedtls_ssl_context *ssl ) { int ret; unsigned char *buf; @@ -1431,12 +1431,13 @@ static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl ) &buf, &buf_len ) ); /* Process the message contents */ - MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_parse_encrypted_extensions( ssl, buf, ( buf + buf_len ) ) ); + MBEDTLS_SSL_PROC_CHK( + ssl_tls13_parse_encrypted_extensions( ssl, buf, ( buf + buf_len ) ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, buf, buf_len ); - MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_postprocess_encrypted_extensions( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_postprocess_encrypted_extensions( ssl ) ); cleanup: @@ -1447,33 +1448,22 @@ cleanup: /* Parse EncryptedExtensions message * struct { - * Extension extensions<0..2^16-1>; + * Extension extensions<0..2^16-1>; * } EncryptedExtensions; */ -static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, - const unsigned char *buf, - const unsigned char *end ) +static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ) { int ret = 0; size_t extensions_len; const unsigned char *p = buf; MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); - extensions_len = MBEDTLS_GET_UINT16_BE(p, 0); - + extensions_len = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; - /* Checking for an extension length that isn't aligned with the rest - * of the message */ - if( p + extensions_len != end ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension lengths misaligned" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ - MBEDTLS_ERR_SSL_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } - - MBEDTLS_SSL_DEBUG_BUF( 3, "encrypted extensions extensions", p, extensions_len ); + MBEDTLS_SSL_DEBUG_BUF( 3, "encrypted extensions", p, extensions_len ); while( p < end ) { @@ -1482,8 +1472,8 @@ static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, /* * struct { - * ExtensionType extension_type; (2 bytes) - * opaque extension_data<0..2^16-1>; + * ExtensionType extension_type; (2 bytes) + * opaque extension_data<0..2^16-1>; * } Extension; */ MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 4 ); @@ -1493,7 +1483,7 @@ static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, extension_data_len ); - /* TBD: The client MUST check EncryptedExtensions for the + /* The client MUST check EncryptedExtensions for the * presence of any forbidden extensions and if any are found MUST abort * the handshake with an "unsupported_extension" alert. */ @@ -1505,27 +1495,31 @@ static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl, break; default: - MBEDTLS_SSL_DEBUG_MSG( 3, ( "unsupported extension found: %d ( ignoring )", extension_type) ); + MBEDTLS_SSL_DEBUG_MSG( + 3, ( "unsupported extension found: %u ", extension_type) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT, \ + MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); + return ( MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); break; } - extensions_len -= 4 + extension_data_len; p += extension_data_len; + } - /* Checking for an extension length that is too short */ - if( extensions_len > 0 && extensions_len < 4 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad encrypted extensions message" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ - MBEDTLS_ERR_SSL_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_DECODE_ERROR ); - } + /* Check that we consumed all the message. */ + if( p != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension lengths misaligned" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } return( ret ); } -static int ssl_tls1_3_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl ) +static int ssl_tls13_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl ) { mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_REQUEST ); return( 0 ); @@ -1643,7 +1637,7 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) break; case MBEDTLS_SSL_ENCRYPTED_EXTENSIONS: - ret = ssl_tls1_3_process_encrypted_extensions( ssl ); + ret = ssl_tls13_process_encrypted_extensions( ssl ); break; case MBEDTLS_SSL_CERTIFICATE_REQUEST: From 8db25fffb48ca5c7c5a67d288451428e1652da8a Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 13 Oct 2021 05:56:18 +0000 Subject: [PATCH 835/966] Encrypted Extensions: Change extensions length check Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index f7f7eaabac..68f5ae568a 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1432,7 +1432,7 @@ static int ssl_tls13_process_encrypted_extensions( mbedtls_ssl_context *ssl ) /* Process the message contents */ MBEDTLS_SSL_PROC_CHK( - ssl_tls13_parse_encrypted_extensions( ssl, buf, ( buf + buf_len ) ) ); + ssl_tls13_parse_encrypted_extensions( ssl, buf, buf + buf_len ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, buf, buf_len ); @@ -1458,14 +1458,17 @@ static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, int ret = 0; size_t extensions_len; const unsigned char *p = buf; + const unsigned char *extensions_end; MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); extensions_len = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; MBEDTLS_SSL_DEBUG_BUF( 3, "encrypted extensions", p, extensions_len ); + extensions_end = p + extensions_len; + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, extensions_len ); - while( p < end ) + while( p < extensions_end ) { unsigned int extension_type; size_t extension_data_len; @@ -1476,12 +1479,12 @@ static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, * opaque extension_data<0..2^16-1>; * } Extension; */ - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 4 ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, extensions_end, 4 ); extension_type = MBEDTLS_GET_UINT16_BE( p, 0 ); extension_data_len = MBEDTLS_GET_UINT16_BE( p, 2 ); p += 4; - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, extension_data_len ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, extensions_end, extension_data_len ); /* The client MUST check EncryptedExtensions for the * presence of any forbidden extensions and if any are found MUST abort @@ -1501,18 +1504,17 @@ static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT, \ MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); return ( MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); - break; } p += extension_data_len; } /* Check that we consumed all the message. */ - if( p != end ) + if( p != extensions_end ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension lengths misaligned" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ - MBEDTLS_ERR_SSL_DECODE_ERROR ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, \ + MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } From 7b2d4efee8b8d35b783ddf3a3bb7c263f2c04da0 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 13 Oct 2021 10:19:02 +0000 Subject: [PATCH 836/966] Change the buffer boundary check and alert type Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 2 +- library/ssl_tls13_client.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 6bdb7acd18..288d9b3c5c 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -486,7 +486,7 @@ #define MBEDTLS_SSL_HS_SERVER_HELLO 2 #define MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST 3 #define MBEDTLS_SSL_HS_NEW_SESSION_TICKET 4 -#define MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION 8 // NEW IN TLS 1.3 +#define MBEDTLS_SSL_HS_ENCRYPTED_EXTENSIONS 8 // NEW IN TLS 1.3 #define MBEDTLS_SSL_HS_CERTIFICATE 11 #define MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE 12 #define MBEDTLS_SSL_HS_CERTIFICATE_REQUEST 13 diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 68f5ae568a..2c2d0f3afd 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1510,11 +1510,11 @@ static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, } /* Check that we consumed all the message. */ - if( p != extensions_end ) + if( p != end ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension lengths misaligned" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, \ - MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_ERR_SSL_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } From ab7f50d6389b9f6a6e2d60881d68c28f67126bf5 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 21 Oct 2021 06:23:29 +0000 Subject: [PATCH 837/966] Change macro names and add test script for extensions Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 4 ++-- tests/ssl-opt.sh | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 2c2d0f3afd..5ed01aade2 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1427,7 +1427,7 @@ static int ssl_tls13_process_encrypted_extensions( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse encrypted extensions" ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, - MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, + MBEDTLS_SSL_HS_ENCRYPTED_EXTENSIONS, &buf, &buf_len ) ); /* Process the message contents */ @@ -1435,7 +1435,7 @@ static int ssl_tls13_process_encrypted_extensions( mbedtls_ssl_context *ssl ) ssl_tls13_parse_encrypted_extensions( ssl, buf, buf + buf_len ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( - ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, buf, buf_len ); + ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSIONS, buf, buf_len ); MBEDTLS_SSL_PROC_CHK( ssl_tls13_postprocess_encrypted_extensions( ssl ) ); diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 8fbe67739b..f9bfec2e1e 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8808,7 +8808,7 @@ requires_openssl_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS1.3: Test client hello msg work - openssl" \ - "$O_NEXT_SRV -tls1_3 -msg" \ + "$O_NEXT_SRV -tls1_3 -msg -no_middlebox" \ "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3" \ 1 \ -c "SSL - The requested feature is not available" \ @@ -8828,13 +8828,14 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "<= ssl_tls1_3_process_server_hello" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "ECDH curve: x25519" \ - -c "=> ssl_tls1_3_process_server_hello" + -c "=> ssl_tls1_3_process_server_hello" \ + -c "<= parse encrypted extensions" requires_gnutls_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS1.3: Test client hello msg work - gnutls" \ - "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3 --debug=4" \ + "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:%DISABLE_TLS13_COMPAT_MODE --debug=4" \ "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3" \ 1 \ -c "SSL - The requested feature is not available" \ @@ -8854,8 +8855,8 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "<= ssl_tls1_3_process_server_hello" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "ECDH curve: x25519" \ - -c "=> ssl_tls1_3_process_server_hello" - + -c "=> ssl_tls1_3_process_server_hello" \ + -c "<= parse encrypted extensions" # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From 29287a46d2a6a24236a4062f4216f681ef0a8d9b Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 28 Oct 2021 10:26:13 +0800 Subject: [PATCH 838/966] fix wrong para name in doxygen comments Signed-off-by: Jerry Yu --- library/common.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/library/common.h b/library/common.h index 7c8d4bf478..a630fcc456 100644 --- a/library/common.h +++ b/library/common.h @@ -87,7 +87,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * big-endian order (MSB first). * * \param data Base address of the memory to get the four bytes from. - * \param offset Offset from \p base of the first and most significant + * \param offset Offset from \p data of the first and most significant * byte of the four bytes to build the 32 bits unsigned * integer from. */ @@ -107,7 +107,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param n 32 bits unsigned integer to put in memory. * \param data Base address of the memory where to put the 32 * bits unsigned integer in. - * \param offset Offset from \p base where to put the most significant + * \param offset Offset from \p data where to put the most significant * byte of the 32 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT32_BE @@ -125,7 +125,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * little-endian order (LSB first). * * \param data Base address of the memory to get the four bytes from. - * \param offset Offset from \p base of the first and least significant + * \param offset Offset from \p data of the first and least significant * byte of the four bytes to build the 32 bits unsigned * integer from. */ @@ -145,7 +145,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param n 32 bits unsigned integer to put in memory. * \param data Base address of the memory where to put the 32 * bits unsigned integer in. - * \param offset Offset from \p base where to put the least significant + * \param offset Offset from \p data where to put the least significant * byte of the 32 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT32_LE @@ -163,7 +163,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * little-endian order (LSB first). * * \param data Base address of the memory to get the two bytes from. - * \param offset Offset from \p base of the first and least significant + * \param offset Offset from \p data of the first and least significant * byte of the two bytes to build the 16 bits unsigned * integer from. */ @@ -181,7 +181,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param n 16 bits unsigned integer to put in memory. * \param data Base address of the memory where to put the 16 * bits unsigned integer in. - * \param offset Offset from \p base where to put the least significant + * \param offset Offset from \p data where to put the least significant * byte of the 16 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT16_LE @@ -197,7 +197,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * big-endian order (MSB first). * * \param data Base address of the memory to get the two bytes from. - * \param offset Offset from \p base of the first and most significant + * \param offset Offset from \p data of the first and most significant * byte of the two bytes to build the 16 bits unsigned * integer from. */ @@ -215,7 +215,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param n 16 bits unsigned integer to put in memory. * \param data Base address of the memory where to put the 16 * bits unsigned integer in. - * \param offset Offset from \p base where to put the most significant + * \param offset Offset from \p data where to put the most significant * byte of the 16 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT16_BE @@ -303,7 +303,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * big-endian order (MSB first). * * \param data Base address of the memory to get the eight bytes from. - * \param offset Offset from \p base of the first and most significant + * \param offset Offset from \p data of the first and most significant * byte of the eight bytes to build the 64 bits unsigned * integer from. */ @@ -327,7 +327,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param n 64 bits unsigned integer to put in memory. * \param data Base address of the memory where to put the 64 * bits unsigned integer in. - * \param offset Offset from \p base where to put the most significant + * \param offset Offset from \p data where to put the most significant * byte of the 64 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT64_BE @@ -349,7 +349,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * little-endian order (LSB first). * * \param data Base address of the memory to get the eight bytes from. - * \param offset Offset from \p base of the first and least significant + * \param offset Offset from \p data of the first and least significant * byte of the eight bytes to build the 64 bits unsigned * integer from. */ @@ -373,7 +373,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param n 64 bits unsigned integer to put in memory. * \param data Base address of the memory where to put the 64 * bits unsigned integer in. - * \param offset Offset from \p base where to put the least significant + * \param offset Offset from \p data where to put the least significant * byte of the 64 bits unsigned integer \p n. */ #ifndef MBEDTLS_PUT_UINT64_LE From 947571efff70d8a1b66501c2aa761bd702d538ee Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Wed, 29 Sep 2021 09:12:03 +0000 Subject: [PATCH 839/966] add tls1_3 read certificate Signed-off-by: Xiaofei Bai --- library/ssl_misc.h | 6 + library/ssl_tls13_client.c | 7 +- library/ssl_tls13_generic.c | 367 ++++++++++++++++++++++++++++++++++++ 3 files changed, 379 insertions(+), 1 deletion(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 66fb26c624..dbef6aa212 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1627,6 +1627,12 @@ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, unsigned char **buf, size_t *buflen ); + +/* + * Handler of TLS 1.3 server certificate message + */ +int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl ); + /* * Write TLS 1.3 handshake message tail */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 5ed01aade2..44c7b1ecc9 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1542,7 +1542,12 @@ static int ssl_tls1_3_process_certificate_request( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_process_server_certificate( mbedtls_ssl_context *ssl ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + int ret; + + ret = mbedtls_ssl_tls13_process_certificate( ssl ); + if( ret != 0) + return( ret ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_VERIFY ); return( 0 ); } diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index b3a4a09ddc..8cae7898bf 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -27,6 +27,10 @@ #include "mbedtls/debug.h" #include "ssl_misc.h" +#include +#include +#include + int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, @@ -215,6 +219,369 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ +/* + * + * STATE HANDLING: Incoming Certificate, client-side only currently. + * + */ + +/* + * Overview + */ + +/* Main state-handling entry point; orchestrates the other functions. */ +int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl ); + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +/* Parse certificate chain send by the server. */ +static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ); +/* Validate certificate chain sent by the server. */ +static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ); + +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +/* Update the state after handling the incoming certificate message. */ +static int ssl_tls13_process_certificate_postprocess( mbedtls_ssl_context *ssl ); + +/* + * Implementation + */ + +int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) ); + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + unsigned char *buf; + size_t buf_len; + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( + ssl, MBEDTLS_SSL_HS_CERTIFICATE, + &buf, &buf_len ) ); + + /* Parse the certificate chain sent by the peer. */ + MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_certificate( ssl, buf, buf + buf_len ) ); + /* Validate the certificate chain and set the verification results. */ + MBEDTLS_SSL_PROC_CHK( ssl_tls13_validate_certificate( ssl ) ); + + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_CERTIFICATE, + buf, buf_len ); + +#else + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + + /* Update state */ + MBEDTLS_SSL_PROC_CHK( ssl_tls13_process_certificate_postprocess( ssl ) ); + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate" ) ); + return( ret ); +} + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +#if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) +/* + * Structure of Certificate message: + * + * enum { + * X509(0), + * RawPublicKey(2), + * (255) + * } CertificateType; + * + * struct { + * select (certificate_type) { + * case RawPublicKey: + * * From RFC 7250 ASN.1_subjectPublicKeyInfo * + * opaque ASN1_subjectPublicKeyInfo<1..2^24-1>; + * case X509: + * opaque cert_data<1..2^24-1>; + * }; + * Extension extensions<0..2^16-1>; + * } CertificateEntry; + * + * struct { + * opaque certificate_request_context<0..2^8-1>; + * CertificateEntry certificate_list<0..2^24-1>; + * } Certificate; + * + */ +static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + size_t certificate_request_context_len = 0; + size_t certificate_list_len = 0; + const unsigned char *p = buf; + const unsigned char *certificate_list_end; + + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 4 ); + certificate_request_context_len = p[0]; + certificate_list_len = ( p[1] << 16 ) | ( p[2] << 8 ) | p[3]; + + /* In theory, the certificate list can be up to 2^24 Bytes, but we don't + * support anything beyond 2^16 = 64K. + */ + if( certificate_request_context_len != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + /* In case we tried to reuse a session but it failed */ + if( ssl->session_negotiate->peer_cert != NULL ) + { + mbedtls_x509_crt_free( ssl->session_negotiate->peer_cert ); + mbedtls_free( ssl->session_negotiate->peer_cert ); + } + + if( ( ssl->session_negotiate->peer_cert = + mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) ) ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc( %" MBEDTLS_PRINTF_SIZET " bytes ) failed", + sizeof( mbedtls_x509_crt ) ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR, + MBEDTLS_ERR_SSL_ALLOC_FAILED ); + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + } + + mbedtls_x509_crt_init( ssl->session_negotiate->peer_cert ); + + p += 4; + certificate_list_end = p + certificate_list_len; + while ( p < certificate_list_end ) + { + size_t cert_data_len, extensions_len; + + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 3 ); + cert_data_len = ( ( size_t )p[0] << 16 ) | + ( ( size_t )p[1] << 8 ) | + ( ( size_t )p[2] ); + p += 3; + + /* In theory, the CRT can be up to 2^24 Bytes, but we don't support + * anything beyond 2^16 = 64K. Otherwise as in the TLS 1.2 code, + * check that we have a minimum of 128 bytes of data, this is not + * clear why we need that though. + */ + if( ( cert_data_len < 128 ) || ( cert_data_len >= 0x10000 ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad Certificate message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, cert_data_len); + ret = mbedtls_x509_crt_parse_der( ssl->session_negotiate->peer_cert, + p, cert_data_len ); + + switch( ret ) + { + case 0: /*ok*/ + break; + case MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG + MBEDTLS_ERR_OID_NOT_FOUND: + /* Ignore certificate with an unknown algorithm: maybe a + prior certificate was already trusted. */ + break; + + case MBEDTLS_ERR_X509_ALLOC_FAILED: + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR, + MBEDTLS_ERR_X509_ALLOC_FAILED ); + MBEDTLS_SSL_DEBUG_RET( 1, " mbedtls_x509_crt_parse_der", ret ); + return( ret ); + + case MBEDTLS_ERR_X509_UNKNOWN_VERSION: + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_X509_UNKNOWN_VERSION ); + MBEDTLS_SSL_DEBUG_RET( 1, " mbedtls_x509_crt_parse_der", ret ); + return( ret ); + + default: + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_BAD_CERT, + ret ); + MBEDTLS_SSL_DEBUG_RET( 1, " mbedtls_x509_crt_parse_der", ret ); + return( ret ); + } + + p += cert_data_len; + + /* Certificate extensions length */ + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, 2 ); + extensions_len = MBEDTLS_GET_UINT16_BE( p, 0 ); + p += 2; + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, extensions_len); + p += extensions_len; + } + + /* Check that all the message is consumed. */ + if( p != end ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad Certificate message" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + MBEDTLS_SSL_DEBUG_CRT( 3, "peer certificate", ssl->session_negotiate->peer_cert ); + + return( ret ); +} +#else +static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ) +{ + ((void) ssl); + ((void) buf); + ((void) end); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} +#endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +#if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) +static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + mbedtls_x509_crt *ca_chain; + mbedtls_x509_crl *ca_crl; + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( ssl->handshake->sni_ca_chain != NULL ) + { + ca_chain = ssl->handshake->sni_ca_chain; + ca_crl = ssl->handshake->sni_ca_crl; + } + else +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + { + ca_chain = ssl->conf->ca_chain; + ca_crl = ssl->conf->ca_crl; + } + + /* + * Main check: verify certificate + */ + ret = mbedtls_x509_crt_verify_with_profile( + ssl->session_negotiate->peer_cert, + ca_chain, ca_crl, + ssl->conf->cert_profile, + ssl->hostname, + &ssl->session_negotiate->verify_result, + ssl->conf->f_vrfy, ssl->conf->p_vrfy ); + + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "x509_verify_cert", ret ); + } + + /* + * Secondary checks: always done, but change 'ret' only if it was 0 + */ + +#if defined(MBEDTLS_ECP_C) + { + const mbedtls_pk_context *pk = &ssl->session_negotiate->peer_cert->pk; + + /* If certificate uses an EC key, make sure the curve is OK */ + if( mbedtls_pk_can_do( pk, MBEDTLS_PK_ECKEY ) && + mbedtls_ssl_check_curve( ssl, mbedtls_pk_ec( *pk )->grp.id ) != 0 ) + { + ssl->session_negotiate->verify_result |= MBEDTLS_X509_BADCERT_BAD_KEY; + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate ( EC key curve )" ) ); + if( ret == 0 ) + ret = MBEDTLS_ERR_SSL_BAD_CERTIFICATE; + } + } +#endif /* MBEDTLS_ECP_C */ + + if( mbedtls_ssl_check_cert_usage( ssl->session_negotiate->peer_cert, + ssl->handshake->ciphersuite_info, + !ssl->conf->endpoint, + &ssl->session_negotiate->verify_result ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate ( usage extensions )" ) ); + if( ret == 0 ) + ret = MBEDTLS_ERR_SSL_BAD_CERTIFICATE; + } + + + if( ca_chain == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no CA chain" ) ); + ret = MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED; + } + + if( ret != 0 ) + { + /* The certificate may have been rejected for several reasons. + Pick one and send the corresponding alert. Which alert to send + may be a subject of debate in some cases. */ + if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_OTHER ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_CN_MISMATCH ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_BAD_CERT, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_KEY_USAGE ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_EXT_KEY_USAGE ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_NS_CERT_TYPE ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_BAD_PK ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_BAD_KEY ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_EXPIRED ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_REVOKED ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED, ret ); + else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_NOT_TRUSTED ) + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA, ret ); + else + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN, ret ); + } + +#if defined(MBEDTLS_DEBUG_C) + if( ssl->session_negotiate->verify_result != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "! Certificate verification flags %08x", + (unsigned int) ssl->session_negotiate->verify_result ) ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "Certificate verification flags clear" ) ); + } +#endif /* MBEDTLS_DEBUG_C */ + + return( ret ); +} +#else /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ +static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) +{ + ((void) ssl); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); +} +#endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +static int ssl_tls13_process_certificate_postprocess( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_VERIFY ); + return( 0 ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_TLS_C */ From 79595acf3f078b3ab7efea088ced5060391be0e9 Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Tue, 26 Oct 2021 07:16:45 +0000 Subject: [PATCH 840/966] Update based on review comments. Signed-off-by: Xiaofei Bai --- library/ssl_tls13_generic.c | 105 ++++++++++++++---------------------- 1 file changed, 40 insertions(+), 65 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 8cae7898bf..6f2c3ec178 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -225,65 +225,10 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, * */ -/* - * Overview - */ - -/* Main state-handling entry point; orchestrates the other functions. */ -int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl ); - -#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) -/* Parse certificate chain send by the server. */ -static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, - const unsigned char *buf, - const unsigned char *end ); -/* Validate certificate chain sent by the server. */ -static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ); - -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ - -/* Update the state after handling the incoming certificate message. */ -static int ssl_tls13_process_certificate_postprocess( mbedtls_ssl_context *ssl ); - /* * Implementation */ -int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl ) -{ - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) ); - -#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) - unsigned char *buf; - size_t buf_len; - - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( - ssl, MBEDTLS_SSL_HS_CERTIFICATE, - &buf, &buf_len ) ); - - /* Parse the certificate chain sent by the peer. */ - MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_certificate( ssl, buf, buf + buf_len ) ); - /* Validate the certificate chain and set the verification results. */ - MBEDTLS_SSL_PROC_CHK( ssl_tls13_validate_certificate( ssl ) ); - - mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_CERTIFICATE, - buf, buf_len ); - -#else - MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ - - /* Update state */ - MBEDTLS_SSL_PROC_CHK( ssl_tls13_process_certificate_postprocess( ssl ) ); - -cleanup: - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate" ) ); - return( ret ); -} - #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) /* @@ -312,6 +257,8 @@ cleanup: * } Certificate; * */ + +/* Parse certificate chain send by the server. */ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end ) @@ -325,11 +272,13 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 4 ); certificate_request_context_len = p[0]; certificate_list_len = ( p[1] << 16 ) | ( p[2] << 8 ) | p[3]; + p += 4; /* In theory, the certificate list can be up to 2^24 Bytes, but we don't * support anything beyond 2^16 = 64K. */ - if( certificate_request_context_len != 0 ) + if( ( certificate_request_context_len != 0 ) || + ( certificate_list_len >= 0x10000 ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, @@ -356,13 +305,12 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, mbedtls_x509_crt_init( ssl->session_negotiate->peer_cert ); - p += 4; certificate_list_end = p + certificate_list_len; - while ( p < certificate_list_end ) + while( p < certificate_list_end ) { size_t cert_data_len, extensions_len; - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 3 ); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, 3 ); cert_data_len = ( ( size_t )p[0] << 16 ) | ( ( size_t )p[1] << 8 ) | ( ( size_t )p[2] ); @@ -374,14 +322,14 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, * clear why we need that though. */ if( ( cert_data_len < 128 ) || ( cert_data_len >= 0x10000 ) ) - { + { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad Certificate message" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, MBEDTLS_ERR_SSL_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, cert_data_len); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, cert_data_len ); ret = mbedtls_x509_crt_parse_der( ssl->session_negotiate->peer_cert, p, cert_data_len ); @@ -419,7 +367,7 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, 2 ); extensions_len = MBEDTLS_GET_UINT16_BE( p, 0 ); p += 2; - MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, extensions_len); + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, extensions_len ); p += extensions_len; } @@ -451,6 +399,7 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) +/* Validate certificate chain sent by the server. */ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) { int ret = 0; @@ -576,10 +525,36 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ #endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ -static int ssl_tls13_process_certificate_postprocess( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl ) { - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_VERIFY ); - return( 0 ); + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) ); + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + unsigned char *buf; + size_t buf_len; + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( + ssl, MBEDTLS_SSL_HS_CERTIFICATE, + &buf, &buf_len ) ); + + /* Parse the certificate chain sent by the peer. */ + MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_certificate( ssl, buf, buf + buf_len ) ); + /* Validate the certificate chain and set the verification results. */ + MBEDTLS_SSL_PROC_CHK( ssl_tls13_validate_certificate( ssl ) ); + + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_CERTIFICATE, + buf, buf_len ); + +#else + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate" ) ); + return( ret ); } #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From 10aeec0685c878601cc65aee4fc424be9f65e823 Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Tue, 26 Oct 2021 09:50:08 +0000 Subject: [PATCH 841/966] Fix a build error Signed-off-by: Xiaofei Bai --- library/ssl_tls13_generic.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 6f2c3ec178..0157726afb 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -546,14 +546,13 @@ int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl ) mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_CERTIFICATE, buf, buf_len ); -#else - MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ - cleanup: MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate" ) ); +#else + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR; +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ return( ret ); } From ff45602c7438b9900c44519f4a9c54d8d30c7a39 Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Thu, 28 Oct 2021 06:50:17 +0000 Subject: [PATCH 842/966] Add local variable verify_result Signed-off-by: Xiaofei Bai --- library/ssl_tls13_generic.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 0157726afb..026c94c7e7 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -405,6 +405,7 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) int ret = 0; mbedtls_x509_crt *ca_chain; mbedtls_x509_crl *ca_crl; + uint32_t verify_result = 0; #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) if( ssl->handshake->sni_ca_chain != NULL ) @@ -427,7 +428,7 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) ca_chain, ca_crl, ssl->conf->cert_profile, ssl->hostname, - &ssl->session_negotiate->verify_result, + &verify_result, ssl->conf->f_vrfy, ssl->conf->p_vrfy ); if( ret != 0 ) @@ -447,7 +448,7 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) if( mbedtls_pk_can_do( pk, MBEDTLS_PK_ECKEY ) && mbedtls_ssl_check_curve( ssl, mbedtls_pk_ec( *pk )->grp.id ) != 0 ) { - ssl->session_negotiate->verify_result |= MBEDTLS_X509_BADCERT_BAD_KEY; + verify_result |= MBEDTLS_X509_BADCERT_BAD_KEY; MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate ( EC key curve )" ) ); if( ret == 0 ) @@ -459,7 +460,7 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) if( mbedtls_ssl_check_cert_usage( ssl->session_negotiate->peer_cert, ssl->handshake->ciphersuite_info, !ssl->conf->endpoint, - &ssl->session_negotiate->verify_result ) != 0 ) + &verify_result ) != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate ( usage extensions )" ) ); if( ret == 0 ) @@ -478,35 +479,31 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) /* The certificate may have been rejected for several reasons. Pick one and send the corresponding alert. Which alert to send may be a subject of debate in some cases. */ - if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_OTHER ) + if( verify_result & MBEDTLS_X509_BADCERT_OTHER ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_CN_MISMATCH ) + else if( verify_result & MBEDTLS_X509_BADCERT_CN_MISMATCH ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_BAD_CERT, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_KEY_USAGE ) + else if( ( verify_result & MBEDTLS_X509_BADCERT_KEY_USAGE ) || + ( verify_result & MBEDTLS_X509_BADCERT_EXT_KEY_USAGE ) || + ( verify_result & MBEDTLS_X509_BADCERT_NS_CERT_TYPE ) || + ( verify_result & MBEDTLS_X509_BADCERT_BAD_PK ) || + ( verify_result & MBEDTLS_X509_BADCERT_BAD_KEY ) ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_EXT_KEY_USAGE ) - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_NS_CERT_TYPE ) - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_BAD_PK ) - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_BAD_KEY ) - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_EXPIRED ) + else if( verify_result & MBEDTLS_X509_BADCERT_EXPIRED ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_REVOKED ) + else if( verify_result & MBEDTLS_X509_BADCERT_REVOKED ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED, ret ); - else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_NOT_TRUSTED ) + else if( verify_result & MBEDTLS_X509_BADCERT_NOT_TRUSTED ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA, ret ); else MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN, ret ); } #if defined(MBEDTLS_DEBUG_C) - if( ssl->session_negotiate->verify_result != 0 ) + if( verify_result != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "! Certificate verification flags %08x", - (unsigned int) ssl->session_negotiate->verify_result ) ); + verify_result ) ); } else { @@ -514,6 +511,7 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) } #endif /* MBEDTLS_DEBUG_C */ + ssl->session_negotiate->verify_result = verify_result; return( ret ); } #else /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ From 937ac673fae8a06143753ae4e1b1129fd0636af1 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 28 Oct 2021 17:39:28 +0800 Subject: [PATCH 843/966] Disable client cert for gnutls tests Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index f9bfec2e1e..70b9f4b7a0 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8763,6 +8763,7 @@ run_test "export keys functionality" \ # openssl feature tests: check if tls1.3 exists. requires_openssl_tls1_3 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS1.3: Test openssl tls1_3 feature" \ "$O_NEXT_SRV -tls1_3 -msg" \ "$O_NEXT_CLI -tls1_3 -msg" \ @@ -8774,8 +8775,9 @@ run_test "TLS1.3: Test openssl tls1_3 feature" \ requires_gnutls_tls1_3 requires_gnutls_next_no_ticket requires_gnutls_next_disable_tls13_compat +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL run_test "TLS1.3: Test gnutls tls1_3 feature" \ - "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE" \ + "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:+CIPHER-ALL:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE --disable-client-cert " \ "$G_NEXT_CLI localhost --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE -V" \ 0 \ -s "Version: TLS1.3" \ @@ -8832,10 +8834,12 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "<= parse encrypted extensions" requires_gnutls_tls1_3 +requires_gnutls_next_no_ticket +requires_gnutls_next_disable_tls13_compat requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS1.3: Test client hello msg work - gnutls" \ - "$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:%DISABLE_TLS13_COMPAT_MODE --debug=4" \ + "$G_NEXT_SRV --debug=4 --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:+CIPHER-ALL:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE --disable-client-cert" \ "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3" \ 1 \ -c "SSL - The requested feature is not available" \ From a93ac116c80e7955b6c0d8892e7dfeb9fd31bb84 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 27 Oct 2021 16:31:48 +0800 Subject: [PATCH 844/966] Remove certificate_request state Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 44c7b1ecc9..7be69fac3a 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1523,20 +1523,19 @@ static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, static int ssl_tls13_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl ) { - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_REQUEST ); - return( 0 ); -} - -/* - * Handler for MBEDTLS_SSL_CERTIFICATE_REQUEST - */ -static int ssl_tls1_3_process_certificate_request( mbedtls_ssl_context *ssl ) -{ - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_CERTIFICATE ); +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + if( mbedtls_ssl_tls1_3_some_psk_enabled( ssl ) ) + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_FINISHED ); + else + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_CERTIFICATE ); +#else + ((void) ssl); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_FINISHED ); +#endif return( 0 ); } +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /* * Handler for MBEDTLS_SSL_SERVER_CERTIFICATE */ @@ -1561,7 +1560,7 @@ static int ssl_tls1_3_process_certificate_verify( mbedtls_ssl_context *ssl ) mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_FINISHED ); return( 0 ); } - +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ /* * Handler for MBEDTLS_SSL_SERVER_FINISHED */ @@ -1647,10 +1646,7 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) ret = ssl_tls13_process_encrypted_extensions( ssl ); break; - case MBEDTLS_SSL_CERTIFICATE_REQUEST: - ret = ssl_tls1_3_process_certificate_request( ssl ); - break; - +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) case MBEDTLS_SSL_SERVER_CERTIFICATE: ret = ssl_tls1_3_process_server_certificate( ssl ); break; @@ -1658,6 +1654,7 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) case MBEDTLS_SSL_CERTIFICATE_VERIFY: ret = ssl_tls1_3_process_certificate_verify( ssl ); break; +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ case MBEDTLS_SSL_SERVER_FINISHED: ret = ssl_tls1_3_process_server_finished( ssl ); From 7aa71860221aaa27c5a7594bf9dbb8a3e2b199f2 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 28 Oct 2021 21:41:30 +0800 Subject: [PATCH 845/966] fix various issues Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 4 ++-- library/ssl_tls13_generic.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 7be69fac3a..49ca7f0b8b 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1501,7 +1501,7 @@ static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 3, ( "unsupported extension found: %u ", extension_type) ); MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT, \ + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT, MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); return ( MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION ); } @@ -1513,7 +1513,7 @@ static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, if( p != end ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension lengths misaligned" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, \ + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, MBEDTLS_ERR_SSL_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 026c94c7e7..598b2bc375 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -271,7 +271,7 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 4 ); certificate_request_context_len = p[0]; - certificate_list_len = ( p[1] << 16 ) | ( p[2] << 8 ) | p[3]; + certificate_list_len = MBEDTLS_GET_UINT24_BE( p, 0 ); p += 4; /* In theory, the certificate list can be up to 2^24 Bytes, but we don't From 83bb13101ab37dbe78135fade230b865d1105d22 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 28 Oct 2021 22:16:33 +0800 Subject: [PATCH 846/966] fix format warning Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 598b2bc375..18bb984178 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -503,7 +503,7 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) if( verify_result != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "! Certificate verification flags %08x", - verify_result ) ); + (unsigned int) verify_result ) ); } else { From 36b70b2a4e75855c1c1de6c0e2a011aa16a2f5f6 Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Tue, 19 Oct 2021 23:39:07 +0100 Subject: [PATCH 847/966] Change MBEDTLS_ECP_DP_MAX to 14 Signed-off-by: Brett Warren --- include/mbedtls/ecp.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/mbedtls/ecp.h b/include/mbedtls/ecp.h index b2a2e32564..5b26084d45 100644 --- a/include/mbedtls/ecp.h +++ b/include/mbedtls/ecp.h @@ -130,10 +130,8 @@ typedef enum /** * The number of supported curves, plus one for #MBEDTLS_ECP_DP_NONE. - * - * \note Montgomery curves are currently excluded. */ -#define MBEDTLS_ECP_DP_MAX 12 +#define MBEDTLS_ECP_DP_MAX 14 /* * Curve types From a706e5e317fca6812a96df78cc6305c3c45d16fd Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 28 Oct 2021 17:59:06 +0200 Subject: [PATCH 848/966] Add missing cipher mode translations for PSA Signed-off-by: Mateusz Starzyk --- include/mbedtls/psa_util.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/mbedtls/psa_util.h b/include/mbedtls/psa_util.h index 80bcd721c0..c54c035c37 100644 --- a/include/mbedtls/psa_util.h +++ b/include/mbedtls/psa_util.h @@ -51,6 +51,9 @@ static inline psa_key_type_t mbedtls_psa_translate_cipher_type( case MBEDTLS_CIPHER_AES_128_CCM: case MBEDTLS_CIPHER_AES_192_CCM: case MBEDTLS_CIPHER_AES_256_CCM: + case MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG: + case MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG: + case MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG: case MBEDTLS_CIPHER_AES_128_GCM: case MBEDTLS_CIPHER_AES_192_GCM: case MBEDTLS_CIPHER_AES_256_GCM: @@ -66,6 +69,9 @@ static inline psa_key_type_t mbedtls_psa_translate_cipher_type( /* case MBEDTLS_CIPHER_ARIA_128_CCM: case MBEDTLS_CIPHER_ARIA_192_CCM: case MBEDTLS_CIPHER_ARIA_256_CCM: + case MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG: + case MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG: + case MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG: case MBEDTLS_CIPHER_ARIA_128_GCM: case MBEDTLS_CIPHER_ARIA_192_GCM: case MBEDTLS_CIPHER_ARIA_256_GCM: @@ -90,6 +96,8 @@ static inline psa_algorithm_t mbedtls_psa_translate_cipher_mode( return( PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, taglen ) ); case MBEDTLS_MODE_CCM: return( PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, taglen ) ); + case MBEDTLS_MODE_CCM_STAR_NO_TAG: + return PSA_ALG_CCM_STAR_NO_TAG; case MBEDTLS_MODE_CBC: if( taglen == 0 ) return( PSA_ALG_CBC_NO_PADDING ); From 10fad74a1fee8c691948a5ccff7ae7624a1efe2e Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 28 Oct 2021 18:00:33 +0200 Subject: [PATCH 849/966] Extend CCM*-no-tag tests Signed-off-by: Mateusz Starzyk --- tests/suites/test_suite_cipher.aes.data | 48 ++++++++++++++++++++ tests/suites/test_suite_cipher.aria.data | 24 ++++++++++ tests/suites/test_suite_cipher.camellia.data | 24 ++++++++++ 3 files changed, 96 insertions(+) diff --git a/tests/suites/test_suite_cipher.aes.data b/tests/suites/test_suite_cipher.aes.data index bd5c2f68f8..8c2ba3c221 100644 --- a/tests/suites/test_suite_cipher.aes.data +++ b/tests/suites/test_suite_cipher.aes.data @@ -2206,6 +2206,54 @@ AES-256-ECB crypt Decrypt NIST KAT #4 PSA depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C test_vec_crypt:MBEDTLS_CIPHER_AES_256_ECB:MBEDTLS_DECRYPT:"0000000000000000000000000000000000000000000000000000000000000000":"":"5c9d844ed46f9885085e5d6a4f94c7d7":"014730f80ac625fe84f026c60bfd547d":0:1 +AES-128-CCM*-NO-TAG crypt Encrypt NIST VPT AES-128 #15 +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"7301c907b9d2aaac355c5416ff25c59b":"7304b65b6dab466273862c88b9":"484300aa3a506afcd313b49ead8d":"928ca58b0d373dc50c52afac787c":0:0 + +AES-128-CCM*-NO-TAG crypt Decrypt NIST DVPT AES-128 #15 +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"90929a4b0ac65b350ad1591611fe4829":"5a8aa485c316e9403aff859fbb":"4bfe4e35784f0a65b545477e5e2f4bae0e1e6fa717eaf2cb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697":0:0 + +AES-192-CCM*-NO-TAG crypt Encrypt NIST VTT AES-192 #1 +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"11fd45743d946e6d37341fec49947e8c70482494a8f07fcc":"c6aeebcb146cfafaae66f78aab":"ee7e6075ba52846de5d6254959a18affc4faf59c8ef63489":"137d9da59baf5cbfd46620c5f298fc766de10ac68e774edf":0:0 + +AES-192-CCM*-NO-TAG crypt Decrypt NIST DVPT AES-192 #15 +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"5a8aa485c316e9403aff859fbb":"a5b7d8cca2069908d1ed88e6a9fe2c9bede3131dad54671e":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697":0:0 + +AES-256-CCM*-NO-TAG crypt Encrypt NIST VADT AES-256 #1 +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886df3ba3e6da3a1389":"72a60f345a1978fb40f28a2fa4":"30d56ff2a25b83fee791110fcaea48e41db7c7f098a81000":"55f068c0bbba8b598013dd1841fd740fda2902322148ab5e":0:0 + +AES-256-CCM*-NO-TAG crypt Decrypt NIST DVPT AES-256 #13 +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"a544218dadd3c10583db49cf39":"63e00d30e4b08fd2a1cc8d70fab327b2368e77a93be4f412":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e":0:0 + +AES-128-CCM*-NO-TAG crypt Encrypt NIST VPT AES-128 #15 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"7301c907b9d2aaac355c5416ff25c59b":"7304b65b6dab466273862c88b9":"484300aa3a506afcd313b49ead8d":"928ca58b0d373dc50c52afac787c":0:1 + +AES-128-CCM*-NO-TAG crypt Decrypt NIST DVPT AES-128 #15 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"90929a4b0ac65b350ad1591611fe4829":"5a8aa485c316e9403aff859fbb":"4bfe4e35784f0a65b545477e5e2f4bae0e1e6fa717eaf2cb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697":0:1 + +AES-192-CCM*-NO-TAG crypt Encrypt NIST VTT AES-192 #1 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"11fd45743d946e6d37341fec49947e8c70482494a8f07fcc":"c6aeebcb146cfafaae66f78aab":"ee7e6075ba52846de5d6254959a18affc4faf59c8ef63489":"137d9da59baf5cbfd46620c5f298fc766de10ac68e774edf":0:1 + +AES-192-CCM*-NO-TAG crypt Decrypt NIST DVPT AES-192 #15 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"5a8aa485c316e9403aff859fbb":"a5b7d8cca2069908d1ed88e6a9fe2c9bede3131dad54671e":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697":0:1 + +AES-256-CCM*-NO-TAG crypt Encrypt NIST VADT AES-256 #1 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886df3ba3e6da3a1389":"72a60f345a1978fb40f28a2fa4":"30d56ff2a25b83fee791110fcaea48e41db7c7f098a81000":"55f068c0bbba8b598013dd1841fd740fda2902322148ab5e":0:1 + +AES-256-CCM*-NO-TAG crypt Decrypt NIST DVPT AES-256 #13 PSA +depends_on:MBEDTLS_USE_PSA_CRYPTO:MBEDTLS_AES_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"a544218dadd3c10583db49cf39":"63e00d30e4b08fd2a1cc8d70fab327b2368e77a93be4f412":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e":0:1 + Cipher Corner Case behaviours depends_on:MBEDTLS_AES_C cipher_special_behaviours: diff --git a/tests/suites/test_suite_cipher.aria.data b/tests/suites/test_suite_cipher.aria.data index 4b14bcc78b..c1e19909bc 100644 --- a/tests/suites/test_suite_cipher.aria.data +++ b/tests/suites/test_suite_cipher.aria.data @@ -313,3 +313,27 @@ enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:17:6:-1:17:6:1 ARIA-256-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C enc_dec_buf_multipart:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:256:16:16:-1:16:16:16:16 + +ARIA-128-CCM*-NO-TAG crypt Encrypt +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"6781f39fdf8d1c44165fc40ee2fb11f1d6e2ddc8c6512b":0:0 + +ARIA-128-CCM*-NO-TAG crypt Decrypt +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"6781f39fdf8d1c44165fc40ee2fb11f1d6e2ddc8c6512b":0:0 + +ARIA-192-CCM*-NO-TAG crypt Encrypt +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFC0C1C2C3C4C5C6C7":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"993df86214d98ae70582c784903702e349dd64ece488c2":0:0 + +ARIA-192-CCM*-NO-TAG crypt Decrypt +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFC0C1C2C3C4C5C6C7":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"993df86214d98ae70582c784903702e349dd64ece488c2":0:0 + +ARIA-256-CCM*-NO-TAG crypt Encrypt +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"5fdd984a6aa77c1d9a204c08f28172c4b4528bee27c41f":0:0 + +ARIA-256-CCM*-NO-TAG crypt Decrypt +depends_on:MBEDTLS_ARIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"5fdd984a6aa77c1d9a204c08f28172c4b4528bee27c41f":0:0 diff --git a/tests/suites/test_suite_cipher.camellia.data b/tests/suites/test_suite_cipher.camellia.data index 2c7a069ca2..31fe92286f 100644 --- a/tests/suites/test_suite_cipher.camellia.data +++ b/tests/suites/test_suite_cipher.camellia.data @@ -1077,3 +1077,27 @@ enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:17:6:-1:17 CAMELLIA-256-CCM*-NO-TAG - Encrypt and decrypt 32 bytes in multiple parts 1 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C enc_dec_buf_multipart:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:256:16:16:-1:16:16:16:16 + +CAMELLIA-128-CCM*-NO-TAG crypt Encrypt +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"BA737185E719310492F38A5F1251DA55FAFBC949848A0D":0:0 + +CAMELLIA-128-CCM*-NO-TAG crypt Decrypt +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"BA737185E719310492F38A5F1251DA55FAFBC949848A0D":0:0 + +CAMELLIA-192-CCM*-NO-TAG crypt Encrypt +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFC0C1C2C3C4C5C6C7":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"c3ceaa2a68fb31d8347a83950f25f3a7956b8a284a5b35":0:0 + +CAMELLIA-192-CCM*-NO-TAG crypt Decrypt +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFC0C1C2C3C4C5C6C7":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"c3ceaa2a68fb31d8347a83950f25f3a7956b8a284a5b35":0:0 + +CAMELLIA-256-CCM*-NO-TAG crypt Encrypt +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:MBEDTLS_ENCRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"933f749801d0e1262cd101831defd8366ab2a22e7c03cd":0:0 + +CAMELLIA-256-CCM*-NO-TAG crypt Decrypt +depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C +test_vec_crypt:MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG:MBEDTLS_DECRYPT:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"933f749801d0e1262cd101831defd8366ab2a22e7c03cd":0:0 From b640bf6c15c87d0c2dea1f27632052f39236842e Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 29 Oct 2021 10:05:32 +0800 Subject: [PATCH 850/966] fix CI build fail Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 18bb984178..9e643d478d 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -271,7 +271,7 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 4 ); certificate_request_context_len = p[0]; - certificate_list_len = MBEDTLS_GET_UINT24_BE( p, 0 ); + certificate_list_len = MBEDTLS_GET_UINT24_BE( p, 1 ); p += 4; /* In theory, the certificate list can be up to 2^24 Bytes, but we don't From d2674314a3a783cc4fb639512916eeacb4f9be0a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 29 Oct 2021 10:08:19 +0800 Subject: [PATCH 851/966] Restore certificate_request state Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 49ca7f0b8b..f1a31cab6b 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1527,7 +1527,7 @@ static int ssl_tls13_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl if( mbedtls_ssl_tls1_3_some_psk_enabled( ssl ) ) mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_FINISHED ); else - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_CERTIFICATE ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_REQUEST ); #else ((void) ssl); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_FINISHED ); @@ -1536,6 +1536,34 @@ static int ssl_tls13_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl } #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) +/* + * Handler for MBEDTLS_SSL_CERTIFICATE_REQUEST + */ +static int ssl_tls13_process_certificate_request( mbedtls_ssl_context *ssl ) +{ + int ret = mbedtls_ssl_read_record( ssl, 0 ); + + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) && + ( ssl->in_msg[0] == MBEDTLS_SSL_HS_CERTIFICATE_REQUEST ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "CertificateRequest not supported" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + + ssl->keep_current_message = 1; + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_CERTIFICATE ); + + return( 0 ); +} + /* * Handler for MBEDTLS_SSL_SERVER_CERTIFICATE */ @@ -1647,6 +1675,10 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) break; #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + case MBEDTLS_SSL_CERTIFICATE_REQUEST: + ret = ssl_tls13_process_certificate_request( ssl ); + break; + case MBEDTLS_SSL_SERVER_CERTIFICATE: ret = ssl_tls1_3_process_server_certificate( ssl ); break; From 1df3db04676851fc1e2d3d3f252a9c9ed19c4430 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 29 Oct 2021 10:18:43 +0800 Subject: [PATCH 852/966] Add certificate success check Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 70b9f4b7a0..993021013c 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8831,6 +8831,7 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" \ + -c "Certificate verification flags clear" \ -c "<= parse encrypted extensions" requires_gnutls_tls1_3 @@ -8860,6 +8861,7 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" \ + -c "Certificate verification flags clear" \ -c "<= parse encrypted extensions" # Test heap memory usage after handshake From f93cbd267443e27e9b5e3a53742fb0f20cf6a5ea Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Fri, 29 Oct 2021 02:39:30 +0000 Subject: [PATCH 853/966] fix some format issues Signed-off-by: Xiaofei Bai --- library/ssl_tls13_client.c | 2 +- library/ssl_tls13_generic.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index f1a31cab6b..0fb09c4ced 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1572,7 +1572,7 @@ static int ssl_tls1_3_process_server_certificate( mbedtls_ssl_context *ssl ) int ret; ret = mbedtls_ssl_tls13_process_certificate( ssl ); - if( ret != 0) + if( ret != 0 ) return( ret ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_VERIFY ); diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 9e643d478d..c8601ce17e 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -311,9 +311,7 @@ static int ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, size_t cert_data_len, extensions_len; MBEDTLS_SSL_CHK_BUF_READ_PTR( p, certificate_list_end, 3 ); - cert_data_len = ( ( size_t )p[0] << 16 ) | - ( ( size_t )p[1] << 8 ) | - ( ( size_t )p[2] ); + cert_data_len = MBEDTLS_GET_UINT24_BE( p, 0 ); p += 3; /* In theory, the CRT can be up to 2^24 Bytes, but we don't support @@ -483,11 +481,11 @@ static int ssl_tls13_validate_certificate( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED, ret ); else if( verify_result & MBEDTLS_X509_BADCERT_CN_MISMATCH ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_BAD_CERT, ret ); - else if( ( verify_result & MBEDTLS_X509_BADCERT_KEY_USAGE ) || - ( verify_result & MBEDTLS_X509_BADCERT_EXT_KEY_USAGE ) || - ( verify_result & MBEDTLS_X509_BADCERT_NS_CERT_TYPE ) || - ( verify_result & MBEDTLS_X509_BADCERT_BAD_PK ) || - ( verify_result & MBEDTLS_X509_BADCERT_BAD_KEY ) ) + else if( verify_result & ( MBEDTLS_X509_BADCERT_KEY_USAGE | + MBEDTLS_X509_BADCERT_EXT_KEY_USAGE | + MBEDTLS_X509_BADCERT_NS_CERT_TYPE | + MBEDTLS_X509_BADCERT_BAD_PK | + MBEDTLS_X509_BADCERT_BAD_KEY ) ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, ret ); else if( verify_result & MBEDTLS_X509_BADCERT_EXPIRED ) MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED, ret ); From ca9236b0c56ac290e9f2c8da15330914dbd8bdaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Mon, 25 Oct 2021 19:29:07 +0200 Subject: [PATCH 854/966] Make the changes easier to backport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code replaced in this patch was not compatible with the development_2.x branch. Signed-off-by: Bence Szépkúti --- tests/scripts/all.sh | 12 +++++++++--- tests/scripts/test_psa_compliance.py | 5 ++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 68163559a8..d86a9f773b 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2758,15 +2758,21 @@ component_test_zeroize () { component_test_psa_compliance () { msg "build: make, default config (out-of-box), libmbedcrypto.a only" - make library/libmbedcrypto.a + make -C library libmbedcrypto.a msg "unit test: test_psa_compliance.py" ./tests/scripts/test_psa_compliance.py } support_test_psa_compliance () { - local ver=($(cmake --version | sed 's/cmake version //; y/./ /; q')) - [ "${ver[0]}" -eq 3 ] && [ "${ver[1]}" -ge 10 ] + ver="$(cmake --version)" + ver="${ver#cmake version }" + ver_major="${ver%%.*}" + + ver="${ver#*.}" + ver_minor="${ver%%.*}" + + [ "$ver_major" -eq 3 ] && [ "$ver_minor" -ge 10 ] } component_check_python_files () { diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 07fa76e60f..d6fe8c4407 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -16,9 +16,8 @@ PSA_ARCH_TESTS_REF = 'crypto1.0-3.0' def main(): mbedtls_dir = os.getcwd() - mbedcrypto_lib = 'library/libmbedcrypto.a' - if not os.path.exists(mbedcrypto_lib): - subprocess.check_call(['make', mbedcrypto_lib]) + if not os.path.exists('library/libmbedcrypto.a'): + subprocess.check_call(['make', '-C', 'library', 'libmbedcrypto.a']) psa_arch_tests_dir = 'psa-arch-tests' try: From e0edc8407b7df1467036b9b8706e37e99e6dfc22 Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Tue, 17 Aug 2021 09:53:13 +0100 Subject: [PATCH 855/966] Add mbedtls_ssl_conf_groups to API mbedtls_ssl_conf_groups allows supported groups for key sharing to be configured via their IANA NamedGroup ID. This is added in anticipation of PQC and Hybrid key sharing algorithms being integrated into Mbed TLS. mbedtls_ssl_conf_curves is deprecated in favor of mbedtls_ssl_conf_groups. handshake_init has been modified to translate and copy curves configured via conf_curves into a heap allocatied array of NamedGroup IDs. This allows the refactoring of code interacting with conf_curve related variables (such as curve_list) to use NamedGroup IDs while retaining the deprecated API. Signed-off-by: Brett Warren --- include/mbedtls/ssl.h | 83 ++++++++++++++++++++++----- library/ssl_misc.h | 42 +++++++++++--- library/ssl_tls.c | 127 +++++++++++++++++++++++++++++++++--------- 3 files changed, 206 insertions(+), 46 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index fa2429d07c..323ffa90bf 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -21,6 +21,7 @@ */ #ifndef MBEDTLS_SSL_H #define MBEDTLS_SSL_H +#include "mbedtls/platform_util.h" #include "mbedtls/private_access.h" #include "mbedtls/build_info.h" @@ -187,18 +188,28 @@ * } NamedGroup; * */ + /* Elliptic Curve Groups (ECDHE) */ -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP256R1 0x0017 -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP384R1 0x0018 -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP521R1 0x0019 -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_X25519 0x001D -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_X448 0x001E +#define MBEDTLS_SSL_IANA_TLS_GROUP_NONE 0 +#define MBEDTLS_SSL_IANA_TLS_GROUP_SECP192K1 0x0012 +#define MBEDTLS_SSL_IANA_TLS_GROUP_SECP192R1 0x0013 +#define MBEDTLS_SSL_IANA_TLS_GROUP_SECP224K1 0x0014 +#define MBEDTLS_SSL_IANA_TLS_GROUP_SECP224R1 0x0015 +#define MBEDTLS_SSL_IANA_TLS_GROUP_SECP256K1 0x0016 +#define MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1 0x0017 +#define MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1 0x0018 +#define MBEDTLS_SSL_IANA_TLS_GROUP_SECP521R1 0x0019 +#define MBEDTLS_SSL_IANA_TLS_GROUP_BP256R1 0x001A +#define MBEDTLS_SSL_IANA_TLS_GROUP_BP384R1 0x001B +#define MBEDTLS_SSL_IANA_TLS_GROUP_BP512R1 0x001C +#define MBEDTLS_SSL_IANA_TLS_GROUP_X25519 0x001D +#define MBEDTLS_SSL_IANA_TLS_GROUP_X448 0x001E /* Finite Field Groups (DHE) */ -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE2048 0x0100 -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE3072 0x0101 -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE4096 0x0102 -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE6144 0x0103 -#define MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE8192 0x0104 +#define MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE2048 0x0100 +#define MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE3072 0x0101 +#define MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE4096 0x0102 +#define MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE6144 0x0103 +#define MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE8192 0x0104 /* * TLS 1.3 Key Exchange Modes @@ -1282,10 +1293,12 @@ struct mbedtls_ssl_config #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif -#if defined(MBEDTLS_ECP_C) +#if defined(MBEDTLS_ECP_C) && !defined(MBEDTLS_DEPRECATED_REMOVED) const mbedtls_ecp_group_id *MBEDTLS_PRIVATE(curve_list); /*!< allowed curves */ #endif + const uint16_t *MBEDTLS_PRIVATE(group_list); /*!< allowed IANA NamedGroups */ + #if defined(MBEDTLS_DHM_C) mbedtls_mpi MBEDTLS_PRIVATE(dhm_P); /*!< prime modulus for DHM */ mbedtls_mpi MBEDTLS_PRIVATE(dhm_G); /*!< generator for DHM */ @@ -3142,6 +3155,7 @@ void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf, #endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */ #if defined(MBEDTLS_ECP_C) +#if !defined(MBEDTLS_DEPRECATED_REMOVED) /** * \brief Set the allowed curves in order of preference. * @@ -3155,6 +3169,8 @@ void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf, * Both sides: limits the set of curves accepted for use in * ECDHE and in the peer's end-entity certificate. * + * \deprecated Superseeded by mbedtls_ssl_conf_groups(). + * * \note This has no influence on which curves are allowed inside the * certificate chains, see \c mbedtls_ssl_conf_cert_profile() * for that. For the end-entity certificate however, the key @@ -3181,10 +3197,51 @@ void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf, * \param curves Ordered list of allowed curves, * terminated by MBEDTLS_ECP_DP_NONE. */ -void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf, - const mbedtls_ecp_group_id *curves ); +void MBEDTLS_DEPRECATED mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf, + const mbedtls_ecp_group_id *curves ); +#endif /* MBEDTLS_DEPRECATED_REMOVED */ #endif /* MBEDTLS_ECP_C */ +/** + * \brief Set the allowed groups in order of preference. + * + * On server: This only affects the choice of key agreement mechanism + * + * On client: this affects the list of groups offered for any + * use. The server can override our preference order. + * + * Both sides: limits the set of groups accepted for use in + * key sharing. + * + * \note This function replaces the deprecated mbedtls_ssl_conf_curves(), + * which only allows ECP curves to be configured. + * + * \note The most recent invocation of either mbedtls_ssl_conf_curves() + * or mbedtls_ssl_conf_groups() nullifies all previous invocations + * of both. + * + * \note This list should be ordered by decreasing preference + * (preferred group first). + * + * \note When this function is not called, a default list is used, + * consisting of all supported curves at 255 bits and above, + * and all supported finite fields at 2048 bits and above. + * The order favors groups with the lowest resource usage. + * + * \note New minor versions of Mbed TLS will not remove items + * from the default list unless serious security concerns require it. + * New minor versions of Mbed TLS may change the order in + * keeping with the general principle of favoring the lowest + * resource usage. + * + * \param conf SSL configuration + * \param groups List of allowed groups ordered by preference, terminated by 0. + * Must contain valid IANA NamedGroup IDs (provided via either an integer + * or using MBEDTLS_TLS13_NAMED_GROUP_XXX macros). + */ +void mbedtls_ssl_conf_groups( mbedtls_ssl_config *conf, + const uint16_t *groups ); + #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) /** * \brief Set the allowed hashes for signatures during the handshake. diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 9041c51d2c..56a5718a6a 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -520,6 +520,11 @@ struct mbedtls_ssl_handshake_params int tls1_3_kex_modes; /*!< key exchange modes for TLS 1.3 */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) + const uint16_t *group_list; + unsigned char group_list_heap_allocated; +#endif + #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) mbedtls_ssl_sig_hash_set_t hash_algs; /*!< Set of suitable sig-hash pairs */ @@ -1565,17 +1570,17 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf */ static inline int mbedtls_ssl_tls13_named_group_is_ecdhe( uint16_t named_group ) { - return( named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP256R1 || - named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP384R1 || - named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_SECP521R1 || - named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_X25519 || - named_group == MBEDTLS_SSL_TLS13_NAMED_GROUP_X448 ); + return( named_group == MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1 || + named_group == MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1 || + named_group == MBEDTLS_SSL_IANA_TLS_GROUP_SECP521R1 || + named_group == MBEDTLS_SSL_IANA_TLS_GROUP_X25519 || + named_group == MBEDTLS_SSL_IANA_TLS_GROUP_X448 ); } static inline int mbedtls_ssl_tls13_named_group_is_dhe( uint16_t named_group ) { - return( named_group >= MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE2048 && - named_group <= MBEDTLS_SSL_TLS13_NAMED_GROUP_FFDHE8192 ); + return( named_group >= MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE2048 && + named_group <= MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE8192 ); } static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl, @@ -1638,4 +1643,27 @@ int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl, size_t dst_len, size_t *olen ); +/* + * Return supported groups. + * + * In future, invocations can be changed to ssl->conf->group_list + * when mbedtls_ssl_conf_curves() is deleted. + * + * ssl->handshake->group_list is either a translation of curve_list to IANA TLS group + * identifiers when mbedtls_ssl_conf_curves() has been used, or a pointer to + * ssl->conf->group_list when mbedtls_ssl_conf_groups() has been more recently invoked. + * + */ +static inline const void *mbedtls_ssl_get_groups( const mbedtls_ssl_context *ssl ) +{ + #if defined(MBEDTLS_DEPRECATED_REMOVED) || !defined(MBEDTLS_ECP_C) + return( ssl->conf->group_list ); + #else + if( ( ssl->handshake != NULL ) && ( ssl->handshake->group_list != NULL ) ) + return( ssl->handshake->group_list ); + else + return( ssl->conf->group_list ); + #endif +} + #endif /* ssl_misc.h */ diff --git a/library/ssl_tls.c b/library/ssl_tls.c index c5079508ee..d604f38cee 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3073,6 +3073,52 @@ static int ssl_handshake_init( mbedtls_ssl_context *ssl ) } #endif +/* + * curve_list is translated to IANA TLS group identifiers here because + * mbedtls_ssl_conf_curves returns void and so can't return + * any error codes. + */ +#if defined(MBEDTLS_ECP_C) +#if !defined(MBEDTLS_DEPRECATED_REMOVED) + /* Heap allocate and translate curve_list from internal to IANA group ids */ + if ( ssl->conf->curve_list != NULL ) + { + size_t length; + const mbedtls_ecp_group_id *curve_list = ssl->conf->curve_list; + + for( length = 0; ( curve_list[length] != MBEDTLS_ECP_DP_NONE ) && + ( length < MBEDTLS_ECP_DP_MAX ); length++ ) {} + + /* Leave room for zero termination */ + uint16_t *group_list = mbedtls_calloc( length + 1, sizeof(uint16_t) ); + if ( group_list == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + for( size_t i = 0; i < length; i++ ) + { + const mbedtls_ecp_curve_info *info = + mbedtls_ecp_curve_info_from_grp_id( curve_list[i] ); + if ( info == NULL ) + { + mbedtls_free( group_list ); + return( MBEDTLS_ERR_SSL_BAD_CONFIG ); + } + group_list[i] = info->tls_id; + } + + group_list[length] = 0; + + ssl->handshake->group_list = group_list; + ssl->handshake->group_list_heap_allocated = 1; + } + else + { + ssl->handshake->group_list = ssl->conf->group_list; + ssl->handshake->group_list_heap_allocated = 0; + } +#endif /* MBEDTLS_DEPRECATED_REMOVED */ +#endif /* MBEDTLS_ECP_C */ + return( 0 ); } @@ -3928,16 +3974,36 @@ void mbedtls_ssl_conf_sig_algs( mbedtls_ssl_config *conf, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #if defined(MBEDTLS_ECP_C) +#if !defined(MBEDTLS_DEPRECATED_REMOVED) /* * Set the allowed elliptic curves + * + * mbedtls_ssl_setup() takes the provided list + * and translates it to a list of IANA TLS group identifiers, + * stored in ssl->handshake->group_list. + * */ void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf, const mbedtls_ecp_group_id *curve_list ) { conf->curve_list = curve_list; + conf->group_list = NULL; } +#endif /* MBEDTLS_DEPRECATED_REMOVED */ #endif /* MBEDTLS_ECP_C */ +/* + * Set the allowed groups + */ +void mbedtls_ssl_conf_groups( mbedtls_ssl_config *conf, + const uint16_t *group_list ) +{ +#if defined(MBEDTLS_ECP_C) && !defined(MBEDTLS_DEPRECATED_REMOVED) + conf->curve_list = NULL; +#endif + conf->group_list = group_list; +} + #if defined(MBEDTLS_X509_CRT_PARSE_C) int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname ) { @@ -5379,6 +5445,14 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ) if( handshake == NULL ) return; +#if defined(MBEDTLS_ECP_C) +#if !defined(MBEDTLS_DEPRECATED_REMOVED) + if ( ssl->handshake->group_list_heap_allocated ) + mbedtls_free( (void*) handshake->group_list ); + handshake->group_list = NULL; +#endif /* MBEDTLS_DEPRECATED_REMOVED */ +#endif /* MBEDTLS_ECP_C */ + #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) if( ssl->conf->f_async_cancel != NULL && handshake->async_in_progress != 0 ) { @@ -6233,41 +6307,39 @@ static int ssl_preset_default_hashes[] = { }; #endif -#if defined(MBEDTLS_ECP_C) /* The selection should be the same as mbedtls_x509_crt_profile_default in * x509_crt.c, plus Montgomery curves for ECDHE. Here, the order matters: * curves with a lower resource usage come first. * See the documentation of mbedtls_ssl_conf_curves() for what we promise * about this list. */ -static mbedtls_ecp_group_id ssl_preset_default_curves[] = { +static uint16_t ssl_preset_default_groups[] = { #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - MBEDTLS_ECP_DP_CURVE25519, + MBEDTLS_SSL_IANA_TLS_GROUP_X25519, #endif #if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) - MBEDTLS_ECP_DP_SECP256R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1, #endif #if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) - MBEDTLS_ECP_DP_SECP384R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1, #endif #if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) - MBEDTLS_ECP_DP_CURVE448, + MBEDTLS_SSL_IANA_TLS_GROUP_X448, #endif #if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) - MBEDTLS_ECP_DP_SECP521R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP521R1, #endif #if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) - MBEDTLS_ECP_DP_BP256R1, + MBEDTLS_SSL_IANA_TLS_GROUP_BP256R1, #endif #if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) - MBEDTLS_ECP_DP_BP384R1, + MBEDTLS_SSL_IANA_TLS_GROUP_BP384R1, #endif #if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) - MBEDTLS_ECP_DP_BP512R1, + MBEDTLS_SSL_IANA_TLS_GROUP_BP512R1, #endif - MBEDTLS_ECP_DP_NONE + MBEDTLS_SSL_IANA_TLS_GROUP_NONE }; -#endif static int ssl_preset_suiteb_ciphersuites[] = { MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, @@ -6314,17 +6386,15 @@ static uint16_t ssl_preset_suiteb_sig_algs[] = { #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif -#if defined(MBEDTLS_ECP_C) -static mbedtls_ecp_group_id ssl_preset_suiteb_curves[] = { +static uint16_t ssl_preset_suiteb_groups[] = { #if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) - MBEDTLS_ECP_DP_SECP256R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1, #endif #if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) - MBEDTLS_ECP_DP_SECP384R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1, #endif - MBEDTLS_ECP_DP_NONE + MBEDTLS_SSL_IANA_TLS_GROUP_NONE }; -#endif /* * Load default in mbedtls_ssl_config @@ -6438,9 +6508,10 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif -#if defined(MBEDTLS_ECP_C) - conf->curve_list = ssl_preset_suiteb_curves; +#if defined(MBEDTLS_ECP_C) && !defined(MBEDTLS_DEPRECATED_REMOVED) + conf->curve_list = NULL; #endif + conf->group_list = ssl_preset_suiteb_groups; break; /* @@ -6475,9 +6546,10 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ -#if defined(MBEDTLS_ECP_C) - conf->curve_list = ssl_preset_default_curves; +#if defined(MBEDTLS_ECP_C) && !defined(MBEDTLS_DEPRECATED_REMOVED) + conf->curve_list = NULL; #endif + conf->group_list = ssl_preset_default_groups; #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C) conf->dhm_min_bitlen = 1024; @@ -6701,14 +6773,17 @@ unsigned char mbedtls_ssl_hash_from_md_alg( int md ) */ int mbedtls_ssl_check_curve( const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id grp_id ) { - const mbedtls_ecp_group_id *gid; + const uint16_t *group_list = mbedtls_ssl_get_groups( ssl ); - if( ssl->conf->curve_list == NULL ) + if( group_list == NULL ) return( -1 ); + uint16_t tls_id = mbedtls_ecp_curve_info_from_grp_id(grp_id)->tls_id; - for( gid = ssl->conf->curve_list; *gid != MBEDTLS_ECP_DP_NONE; gid++ ) - if( *gid == grp_id ) + for( ; *group_list != 0; group_list++ ) + { + if( *group_list == tls_id ) return( 0 ); + } return( -1 ); } From fed825a9aaabf9f66066ce2a71f44404e2f69a39 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Tue, 26 Oct 2021 14:32:10 +0200 Subject: [PATCH 856/966] ssl_client2, ssl_server2: add check for psa memory leaks Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_client2.c | 13 +++++++++++++ programs/ssl/ssl_server2.c | 12 ++++++++++++ tests/include/test/psa_crypto_helpers.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index f872e60fc3..130f3f98ef 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -21,6 +21,11 @@ #include "ssl_test_lib.h" +#if defined(MBEDTLS_USE_PSA_CRYPTO) +#define SKIP_LIBRARY_HEADERS +#include "test/psa_crypto_helpers.h" +#endif + #if defined(MBEDTLS_SSL_TEST_IMPOSSIBLE) int main( void ) { @@ -3059,7 +3064,15 @@ exit: #endif #if defined(MBEDTLS_USE_PSA_CRYPTO) + mbedtls_psa_crypto_free( ); + const char* message = mbedtls_test_helper_is_psa_leaking(); + if( message ) + { + if( ret == 0 ) + ret = 1; + mbedtls_printf( "PSA memory leak detected: %s\n", message); + } #endif #if defined(MBEDTLS_TEST_HOOKS) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index c0f3196748..d20d1faa10 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -65,6 +65,11 @@ int main( void ) #include #endif +#if defined(MBEDTLS_USE_PSA_CRYPTO) +#define SKIP_LIBRARY_HEADERS +#include "test/psa_crypto_helpers.h" +#endif + /* Size of memory to be allocated for the heap, when using the library's memory * management and MBEDTLS_MEMORY_BUFFER_ALLOC_C is enabled. */ #define MEMORY_HEAP_SIZE 120000 @@ -4027,6 +4032,13 @@ exit: #if defined(MBEDTLS_USE_PSA_CRYPTO) mbedtls_psa_crypto_free( ); + const char* message = mbedtls_test_helper_is_psa_leaking(); + if( message ) + { + if( ret == 0 ) + ret = 1; + mbedtls_printf( "PSA memory leak detected: %s\n", message); + } #endif #if defined(MBEDTLS_TEST_HOOKS) diff --git a/tests/include/test/psa_crypto_helpers.h b/tests/include/test/psa_crypto_helpers.h index 8a8c37e008..8e7d425a93 100644 --- a/tests/include/test/psa_crypto_helpers.h +++ b/tests/include/test/psa_crypto_helpers.h @@ -28,7 +28,9 @@ #include "test/psa_helpers.h" #include +#if !defined(SKIP_LIBRARY_HEADERS) #include +#endif #if defined(MBEDTLS_USE_PSA_CRYPTO) #include "mbedtls/psa_util.h" From 0bbb39786dc41e3e503c7b80b4db1ca9f52f06bb Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sun, 19 Sep 2021 20:27:17 +0800 Subject: [PATCH 857/966] tls13: add labels add client and server cv magic words Signed-off-by: Jerry Yu --- library/ssl_tls13_keys.h | 45 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 384f433b59..165b58a2d4 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -22,25 +22,27 @@ /* This requires MBEDTLS_SSL_TLS1_3_LABEL( idx, name, string ) to be defined at * the point of use. See e.g. the definition of mbedtls_ssl_tls1_3_labels_union * below. */ -#define MBEDTLS_SSL_TLS1_3_LABEL_LIST \ - MBEDTLS_SSL_TLS1_3_LABEL( finished , "finished" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( resumption , "resumption" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( traffic_upd , "traffic upd" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( exporter , "exporter" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( key , "key" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( iv , "iv" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( c_hs_traffic, "c hs traffic" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( c_ap_traffic, "c ap traffic" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( c_e_traffic , "c e traffic" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( s_hs_traffic, "s hs traffic" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( s_ap_traffic, "s ap traffic" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( s_e_traffic , "s e traffic" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( e_exp_master, "e exp master" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( res_master , "res master" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( exp_master , "exp master" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( ext_binder , "ext binder" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( res_binder , "res binder" ) \ - MBEDTLS_SSL_TLS1_3_LABEL( derived , "derived" ) +#define MBEDTLS_SSL_TLS1_3_LABEL_LIST \ + MBEDTLS_SSL_TLS1_3_LABEL( finished , "finished" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( resumption , "resumption" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( traffic_upd , "traffic upd" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( exporter , "exporter" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( key , "key" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( iv , "iv" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( c_hs_traffic, "c hs traffic" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( c_ap_traffic, "c ap traffic" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( c_e_traffic , "c e traffic" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( s_hs_traffic, "s hs traffic" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( s_ap_traffic, "s ap traffic" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( s_e_traffic , "s e traffic" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( e_exp_master, "e exp master" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( res_master , "res master" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( exp_master , "exp master" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( ext_binder , "ext binder" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( res_binder , "res binder" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( derived , "derived" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( client_cv , "TLS 1.3, client CertificateVerify" ) \ + MBEDTLS_SSL_TLS1_3_LABEL( server_cv , "TLS 1.3, server CertificateVerify" ) #define MBEDTLS_SSL_TLS1_3_LABEL( name, string ) \ const unsigned char name [ sizeof(string) - 1 ]; @@ -57,9 +59,12 @@ struct mbedtls_ssl_tls1_3_labels_struct extern const struct mbedtls_ssl_tls1_3_labels_struct mbedtls_ssl_tls1_3_labels; +#define MBEDTLS_SSL_TLS1_3_LBL_LEN( LABEL ) \ + sizeof(mbedtls_ssl_tls1_3_labels.LABEL) + #define MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN( LABEL ) \ mbedtls_ssl_tls1_3_labels.LABEL, \ - sizeof(mbedtls_ssl_tls1_3_labels.LABEL) + MBEDTLS_SSL_TLS1_3_LBL_LEN( LABEL ) #define MBEDTLS_SSL_TLS1_3_KEY_SCHEDULE_MAX_LABEL_LEN \ sizeof( union mbedtls_ssl_tls1_3_labels_union ) From 30b071cb66766efa5b367772a14f375248b64f54 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sun, 12 Sep 2021 20:16:03 +0800 Subject: [PATCH 858/966] tls13:Add certificate verify Signed-off-by: Jerry Yu --- library/ssl_misc.h | 5 + library/ssl_tls13_client.c | 7 +- library/ssl_tls13_generic.c | 375 +++++++++++++++++++++++++++++++++++- 3 files changed, 382 insertions(+), 5 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index dbef6aa212..56633464b2 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1633,6 +1633,11 @@ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, */ int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl ); +/* + * Generic handler of Certificate Verify + */ +int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ); + /* * Write TLS 1.3 handshake message tail */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 0fb09c4ced..6e16c07ba7 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1584,7 +1584,12 @@ static int ssl_tls1_3_process_server_certificate( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_process_certificate_verify( mbedtls_ssl_context *ssl ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + int ret; + + ret = mbedtls_ssl_tls13_process_certificate_verify( ssl ); + if( ret != 0 ) + return( ret ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_SERVER_FINISHED ); return( 0 ); } diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index c8601ce17e..e484b79663 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -23,14 +23,15 @@ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +#include + #include "mbedtls/error.h" #include "mbedtls/debug.h" +#include "mbedtls/oid.h" +#include "mbedtls/platform.h" #include "ssl_misc.h" -#include -#include -#include - +#include "ssl_tls13_keys.h" int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type, @@ -217,8 +218,374 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, return( 0 ); } +/* + * The ssl_tls13_create_verify_structure() creates the verify structure. + * As input, it requires the transcript hash. + * + * The caller has to ensure that the buffer has size at least + * SSL_VERIFY_STRUCT_MAX_SIZE bytes. + */ +static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, + size_t transcript_hash_len, + unsigned char *verify_buffer, + size_t *verify_buffer_len, + int from ) +{ + size_t idx = 0; + + /* RFC 8446, Section 4.4.3: + * + * The digital signature [in the CertificateVerify message] is then + * computed over the concatenation of: + * - A string that consists of octet 32 (0x20) repeated 64 times + * - The context string + * - A single 0 byte which serves as the separator + * - The content to be signed + */ + uint8_t const verify_padding_val = 0x20; + size_t const verify_padding_len = 64; + + memset( verify_buffer + idx, verify_padding_val, verify_padding_len ); + idx += verify_padding_len; + + if( from == MBEDTLS_SSL_IS_CLIENT ) + { + memcpy( verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN( client_cv ) ); + idx += MBEDTLS_SSL_TLS1_3_LBL_LEN( client_cv ); + } + else + { /* from == MBEDTLS_SSL_IS_SERVER */ + memcpy( verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN( server_cv ) ); + idx += MBEDTLS_SSL_TLS1_3_LBL_LEN( server_cv ); + } + + verify_buffer[idx++] = 0x0; + + memcpy( verify_buffer + idx, transcript_hash, transcript_hash_len ); + idx += transcript_hash_len; + + *verify_buffer_len = idx; +} + #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ +/* + * STATE HANDLING: Read CertificateVerify + */ +/* Macro to express the length of the verify structure length. + * + * The structure is computed per TLS 1.3 specification as: + * - 64 bytes of octet 32, + * - 33 bytes for the context string + * (which is either "TLS 1.3, client CertificateVerify" + * or "TLS 1.3, server CertificateVerify"), + * - 1 byte for the octet 0x0, which servers as a separator, + * - 32 or 48 bytes for the Transcript-Hash(Handshake Context, Certificate) + * (depending on the size of the transcript_hash) + * + * This results in a total size of + * - 130 bytes for a SHA256-based transcript hash, or + * (64 + 33 + 1 + 32 bytes) + * - 146 bytes for a SHA384-based transcript hash. + * (64 + 33 + 1 + 48 bytes) + * + */ +#define SSL_VERIFY_STRUCT_MAX_SIZE ( 64 + \ + 33 + \ + 1 + \ + MBEDTLS_MD_MAX_SIZE \ + ) +/* Coordinate: Check whether a certificate verify message is expected. + * Returns a negative value on failure, and otherwise + * - SSL_CERTIFICATE_VERIFY_SKIP + * - SSL_CERTIFICATE_VERIFY_READ + * to indicate if the CertificateVerify message should be present or not. + */ +#define SSL_CERTIFICATE_VERIFY_SKIP 0 +#define SSL_CERTIFICATE_VERIFY_READ 1 +static int ssl_tls13_process_certificate_verify_coordinate( + mbedtls_ssl_context *ssl ) +{ + if( mbedtls_ssl_tls1_3_some_psk_enabled( ssl ) ) + return( SSL_CERTIFICATE_VERIFY_SKIP ); + +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + if( ssl->session_negotiate->peer_cert == NULL ) + return( SSL_CERTIFICATE_VERIFY_SKIP ); + return( SSL_CERTIFICATE_VERIFY_READ ); +#else + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ +} + +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) +static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end, + const unsigned char *verify_buffer, + size_t verify_buffer_len ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + const unsigned char *p = buf; + uint16_t algorithm; + const uint16_t *tls13_sig_alg = ssl->conf->tls13_sig_algs; + size_t signature_len; + mbedtls_pk_type_t sig_alg; + mbedtls_md_type_t md_alg; + unsigned char verify_hash[MBEDTLS_TLS1_3_MD_MAX_SIZE]; + size_t verify_hash_len; + + /* + * struct { + * SignatureScheme algorithm; + * opaque signature<0..2^16-1>; + * } CertificateVerify; + */ + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); + algorithm = MBEDTLS_GET_UINT16_BE( p, 0 ); + p += 2; + + /* RFC 8446 section 4.4.3 + * + * If the CertificateVerify message is sent by a server, the signature algorithm + * MUST be one offered in the client's "signature_algorithms" extension unless + * no valid certificate chain can be produced without unsupported algorithms + * + * RFC 8446 section 4.4.2.2 + * + * If the client cannot construct an acceptable chain using the provided + * certificates and decides to abort the handshake, then it MUST abort the handshake + * with an appropriate certificate-related alert (by default, "unsupported_certificate"). + * + * Check if algorithm in offered signature algorithms. Send `unsupported_certificate` + * alert message on failure. + */ + while( 1 ) + { + /* Found algorithm in offered signature algorithms */ + if( *tls13_sig_alg == algorithm ) + break; + + if( *tls13_sig_alg == MBEDTLS_TLS13_SIG_NONE ) + { + /* End of offered signature algorithms list */ + MBEDTLS_SSL_DEBUG_MSG( 1, + ( "signature algorithm(%04x) not in offered" + "signature algorithms ", + ( unsigned int ) algorithm ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; + } + + tls13_sig_alg++; + } + + /* We currently only support ECDSA-based signatures */ + switch( algorithm ) + { + case MBEDTLS_TLS13_SIG_ECDSA_SECP256R1_SHA256: + md_alg = MBEDTLS_MD_SHA256; + sig_alg = MBEDTLS_PK_ECDSA; + break; + case MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384: + md_alg = MBEDTLS_MD_SHA384; + sig_alg = MBEDTLS_PK_ECDSA; + break; + case MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512: + md_alg = MBEDTLS_MD_SHA512; + sig_alg = MBEDTLS_PK_ECDSA; + break; + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Certificate Verify: Unknown signature algorithm." ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "Certificate Verify: Signature algorithm ( %04x )", + ( unsigned int ) algorithm ) ); + + /* + * Check the certificate's key type matches the signature alg + */ + if( !mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, sig_alg ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "signature algorithm doesn't match cert key" ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); + signature_len = MBEDTLS_GET_UINT16_BE( p, 0 ); + p += 2; + MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, signature_len ); + + /* Hash verify buffer with indicated hash function */ + switch( md_alg ) + { +#if defined(MBEDTLS_SHA256_C) + case MBEDTLS_MD_SHA256: + verify_hash_len = 32; + if( ( ret = mbedtls_sha256( verify_buffer, + verify_buffer_len, + verify_hash, + 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha256", ret ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + break; +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA384_C) + case MBEDTLS_MD_SHA384: + verify_hash_len = 48; + if( ( ret = mbedtls_sha512( verify_buffer, + verify_buffer_len, + verify_hash, + 1 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha384", ret ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + break; +#endif /* MBEDTLS_SHA384_C */ + +#if defined(MBEDTLS_SHA512_C) + case MBEDTLS_MD_SHA512: + verify_hash_len = 64; + if( ( ret = mbedtls_sha512( verify_buffer, + verify_buffer_len, + verify_hash, + 0 ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha512", ret ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + break; +#endif /* MBEDTLS_SHA512_C */ + + default: + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Certificate Verify: Unknown signature algorithm." ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "verify hash", verify_hash, verify_hash_len ); + + if( ( ret = mbedtls_pk_verify_ext( sig_alg, NULL, + &ssl->session_negotiate->peer_cert->pk, + md_alg, verify_hash, verify_hash_len, + buf, signature_len ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify_ext", ret ); + + /* RFC 8446 section 4.4.3 + * + * If the verification fails, the receiver MUST terminate the handshake + * with a "decrypt_error" alert. + */ + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR, ret ); + + return( ret ); + } + + return( ret ); +} +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + +int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + /* Coordination step */ + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) ); + + MBEDTLS_SSL_PROC_CHK_NEG( ssl_tls13_process_certificate_verify_coordinate( ssl ) ); + +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) // TBD: double-check + if( ret == SSL_CERTIFICATE_VERIFY_READ ) + { + unsigned char verify_buffer[SSL_VERIFY_STRUCT_MAX_SIZE]; + size_t verify_buffer_len; + unsigned char transcript[MBEDTLS_TLS1_3_MD_MAX_SIZE]; + size_t transcript_len; + unsigned char *buf; + size_t buf_len; + + /* Need to calculate the hash of the transcript first + * before reading the message since otherwise it gets + * included in the transcript + */ + ret = mbedtls_ssl_get_handshake_transcript( ssl, + ssl->handshake->ciphersuite_info->mac, + transcript, sizeof( transcript ), + &transcript_len ); + if( ret != 0 ) + { + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR, + MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_BUF( 3, "handshake hash", transcript, transcript_len ); + + /* Create verify structure */ + ssl_tls13_create_verify_structure( transcript, + transcript_len, + verify_buffer, + &verify_buffer_len, + !ssl->conf->endpoint ); + + MBEDTLS_SSL_PROC_CHK( + mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, + MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, &buf, &buf_len ) ); + + /* Process the message contents */ + MBEDTLS_SSL_PROC_CHK( + ssl_tls13_process_certificate_verify_parse( ssl, + buf, buf + buf_len, verify_buffer, verify_buffer_len ) ); + + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, + MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, buf, buf_len ); + } + else +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + if( ret == SSL_CERTIFICATE_VERIFY_SKIP ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate verify" ) ); + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate verify" ) ); + return( ret ); +} + /* * * STATE HANDLING: Incoming Certificate, client-side only currently. From 26c2d118027ec9a930ffb83da860c2b129fa32ea Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 25 Oct 2021 12:42:58 +0800 Subject: [PATCH 859/966] Fix various issues Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index e484b79663..db99d9de49 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -231,7 +231,7 @@ static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, size_t *verify_buffer_len, int from ) { - size_t idx = 0; + size_t idx; /* RFC 8446, Section 4.4.3: * @@ -245,8 +245,8 @@ static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, uint8_t const verify_padding_val = 0x20; size_t const verify_padding_len = 64; - memset( verify_buffer + idx, verify_padding_val, verify_padding_len ); - idx += verify_padding_len; + memset( verify_buffer, verify_padding_val, verify_padding_len ); + idx = verify_padding_len; if( from == MBEDTLS_SSL_IS_CLIENT ) { @@ -290,10 +290,10 @@ static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, * (64 + 33 + 1 + 48 bytes) * */ -#define SSL_VERIFY_STRUCT_MAX_SIZE ( 64 + \ - 33 + \ - 1 + \ - MBEDTLS_MD_MAX_SIZE \ +#define SSL_VERIFY_STRUCT_MAX_SIZE ( 64 + \ + 33 + \ + 1 + \ + MBEDTLS_TLS1_3_MD_MAX_SIZE \ ) /* Coordinate: Check whether a certificate verify message is expected. * Returns a negative value on failure, and otherwise @@ -530,6 +530,10 @@ int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ) unsigned char *buf; size_t buf_len; + MBEDTLS_SSL_PROC_CHK( + mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, + MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, &buf, &buf_len ) ); + /* Need to calculate the hash of the transcript first * before reading the message since otherwise it gets * included in the transcript @@ -555,10 +559,6 @@ int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ) &verify_buffer_len, !ssl->conf->endpoint ); - MBEDTLS_SSL_PROC_CHK( - mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, - MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, &buf, &buf_len ) ); - /* Process the message contents */ MBEDTLS_SSL_PROC_CHK( ssl_tls13_process_certificate_verify_parse( ssl, From 133690cceff604a5836e271fb0a5e8055a1884d7 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 25 Oct 2021 14:01:13 +0800 Subject: [PATCH 860/966] Refactor hash computation Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 45 ++++++++++--------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index db99d9de49..24275e5c54 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -432,51 +432,21 @@ static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_SHA256_C) case MBEDTLS_MD_SHA256: verify_hash_len = 32; - if( ( ret = mbedtls_sha256( verify_buffer, - verify_buffer_len, - verify_hash, - 0 ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha256", ret ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - } + ret = mbedtls_sha256( verify_buffer, verify_buffer_len, verify_hash, 0 ); break; #endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA384_C) case MBEDTLS_MD_SHA384: verify_hash_len = 48; - if( ( ret = mbedtls_sha512( verify_buffer, - verify_buffer_len, - verify_hash, - 1 ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha384", ret ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - } + ret = mbedtls_sha512( verify_buffer, verify_buffer_len, verify_hash, 1 ); break; #endif /* MBEDTLS_SHA384_C */ #if defined(MBEDTLS_SHA512_C) case MBEDTLS_MD_SHA512: verify_hash_len = 64; - if( ( ret = mbedtls_sha512( verify_buffer, - verify_buffer_len, - verify_hash, - 0 ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha512", ret ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - } + ret = mbedtls_sha512( verify_buffer, verify_buffer_len, verify_hash, 0 ); break; #endif /* MBEDTLS_SHA512_C */ @@ -488,6 +458,15 @@ static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); } + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "hash computation error", ret ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + MBEDTLS_SSL_DEBUG_BUF( 3, "verify hash", verify_hash, verify_hash_len ); if( ( ret = mbedtls_pk_verify_ext( sig_alg, NULL, From 982d9e5db2e5dbd414dbe400d3bfdb1721a47525 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 14 Oct 2021 15:59:37 +0800 Subject: [PATCH 861/966] Add ssl_tls13_sig_alg_is_offered To keep consistent with cipher_suite check Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 24275e5c54..66c6678ec3 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -320,6 +320,18 @@ static int ssl_tls13_process_certificate_verify_coordinate( } #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) +static int ssl_tls13_sig_alg_is_offered( mbedtls_ssl_context *ssl, uint16_t sig_alg ) +{ + const uint16_t *tls13_sig_alg = ssl->conf->tls13_sig_algs; + + for( ; *tls13_sig_alg !=MBEDTLS_TLS13_SIG_NONE ; tls13_sig_alg++ ) + { + if( *tls13_sig_alg == sig_alg ) + return 1; + } + return 0; +} + static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end, @@ -329,7 +341,6 @@ static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const unsigned char *p = buf; uint16_t algorithm; - const uint16_t *tls13_sig_alg = ssl->conf->tls13_sig_algs; size_t signature_len; mbedtls_pk_type_t sig_alg; mbedtls_md_type_t md_alg; @@ -361,26 +372,16 @@ static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, * Check if algorithm in offered signature algorithms. Send `unsupported_certificate` * alert message on failure. */ - while( 1 ) + if( ssl_tls13_sig_alg_is_offered( ssl, algorithm ) == 0 ) { - /* Found algorithm in offered signature algorithms */ - if( *tls13_sig_alg == algorithm ) - break; - - if( *tls13_sig_alg == MBEDTLS_TLS13_SIG_NONE ) - { - /* End of offered signature algorithms list */ - MBEDTLS_SSL_DEBUG_MSG( 1, - ( "signature algorithm(%04x) not in offered" - "signature algorithms ", - ( unsigned int ) algorithm ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; - } - - tls13_sig_alg++; + /* algorithm not in offered signature algorithms list */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Received signature algorithm(%04x) is not " + "offered.", + ( unsigned int ) algorithm ) ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; } /* We currently only support ECDSA-based signatures */ From da8cdf2fa969573039115003bfce08fb5b170c7d Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 25 Oct 2021 15:06:49 +0800 Subject: [PATCH 862/966] Remove certificate_verify_coordinate Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 134 ++++++++++++++---------------------- 1 file changed, 53 insertions(+), 81 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 66c6678ec3..2a8695a475 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -295,29 +295,7 @@ static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, 1 + \ MBEDTLS_TLS1_3_MD_MAX_SIZE \ ) -/* Coordinate: Check whether a certificate verify message is expected. - * Returns a negative value on failure, and otherwise - * - SSL_CERTIFICATE_VERIFY_SKIP - * - SSL_CERTIFICATE_VERIFY_READ - * to indicate if the CertificateVerify message should be present or not. - */ -#define SSL_CERTIFICATE_VERIFY_SKIP 0 -#define SSL_CERTIFICATE_VERIFY_READ 1 -static int ssl_tls13_process_certificate_verify_coordinate( - mbedtls_ssl_context *ssl ) -{ - if( mbedtls_ssl_tls1_3_some_psk_enabled( ssl ) ) - return( SSL_CERTIFICATE_VERIFY_SKIP ); -#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) - if( ssl->session_negotiate->peer_cert == NULL ) - return( SSL_CERTIFICATE_VERIFY_SKIP ); - return( SSL_CERTIFICATE_VERIFY_READ ); -#else - MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); -#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ -} #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) static int ssl_tls13_sig_alg_is_offered( mbedtls_ssl_context *ssl, uint16_t sig_alg ) @@ -493,77 +471,71 @@ static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ) { - int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - /* Coordination step */ +#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + unsigned char verify_buffer[SSL_VERIFY_STRUCT_MAX_SIZE]; + size_t verify_buffer_len; + unsigned char transcript[MBEDTLS_TLS1_3_MD_MAX_SIZE]; + size_t transcript_len; + unsigned char *buf; + size_t buf_len; + + if( mbedtls_ssl_tls1_3_some_psk_enabled( ssl ) ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + if( ssl->session_negotiate->peer_cert == NULL ) + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) ); - MBEDTLS_SSL_PROC_CHK_NEG( ssl_tls13_process_certificate_verify_coordinate( ssl ) ); + MBEDTLS_SSL_PROC_CHK( + mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, + MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, &buf, &buf_len ) ); -#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) // TBD: double-check - if( ret == SSL_CERTIFICATE_VERIFY_READ ) + /* Need to calculate the hash of the transcript first + * before reading the message since otherwise it gets + * included in the transcript + */ + ret = mbedtls_ssl_get_handshake_transcript( ssl, + ssl->handshake->ciphersuite_info->mac, + transcript, sizeof( transcript ), + &transcript_len ); + if( ret != 0 ) { - unsigned char verify_buffer[SSL_VERIFY_STRUCT_MAX_SIZE]; - size_t verify_buffer_len; - unsigned char transcript[MBEDTLS_TLS1_3_MD_MAX_SIZE]; - size_t transcript_len; - unsigned char *buf; - size_t buf_len; - - MBEDTLS_SSL_PROC_CHK( - mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, - MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, &buf, &buf_len ) ); - - /* Need to calculate the hash of the transcript first - * before reading the message since otherwise it gets - * included in the transcript - */ - ret = mbedtls_ssl_get_handshake_transcript( ssl, - ssl->handshake->ciphersuite_info->mac, - transcript, sizeof( transcript ), - &transcript_len ); - if( ret != 0 ) - { - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR, - MBEDTLS_ERR_SSL_INTERNAL_ERROR ); - return( ret ); - } - - MBEDTLS_SSL_DEBUG_BUF( 3, "handshake hash", transcript, transcript_len ); - - /* Create verify structure */ - ssl_tls13_create_verify_structure( transcript, - transcript_len, - verify_buffer, - &verify_buffer_len, - !ssl->conf->endpoint ); - - /* Process the message contents */ - MBEDTLS_SSL_PROC_CHK( - ssl_tls13_process_certificate_verify_parse( ssl, - buf, buf + buf_len, verify_buffer, verify_buffer_len ) ); - - mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, - MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, buf, buf_len ); - } - else -#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ - if( ret == SSL_CERTIFICATE_VERIFY_SKIP ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate verify" ) ); - } - else - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR, + MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + return( ret ); } + MBEDTLS_SSL_DEBUG_BUF( 3, "handshake hash", transcript, transcript_len ); + + /* Create verify structure */ + ssl_tls13_create_verify_structure( transcript, + transcript_len, + verify_buffer, + &verify_buffer_len, + !ssl->conf->endpoint ); + + /* Process the message contents */ + MBEDTLS_SSL_PROC_CHK( + ssl_tls13_process_certificate_verify_parse( ssl, + buf, buf + buf_len, verify_buffer, verify_buffer_len ) ); + + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, + MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, buf, buf_len ); cleanup: MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate verify" ) ); return( ret ); +#else + ((void) ssl); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ } /* From 0b32c502a407a107800786043ea2ad35227e3f16 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 28 Oct 2021 13:41:59 +0800 Subject: [PATCH 863/966] fix various issues Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 138 ++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 77 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 2a8695a475..d42e463a93 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -218,57 +218,6 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, return( 0 ); } -/* - * The ssl_tls13_create_verify_structure() creates the verify structure. - * As input, it requires the transcript hash. - * - * The caller has to ensure that the buffer has size at least - * SSL_VERIFY_STRUCT_MAX_SIZE bytes. - */ -static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, - size_t transcript_hash_len, - unsigned char *verify_buffer, - size_t *verify_buffer_len, - int from ) -{ - size_t idx; - - /* RFC 8446, Section 4.4.3: - * - * The digital signature [in the CertificateVerify message] is then - * computed over the concatenation of: - * - A string that consists of octet 32 (0x20) repeated 64 times - * - The context string - * - A single 0 byte which serves as the separator - * - The content to be signed - */ - uint8_t const verify_padding_val = 0x20; - size_t const verify_padding_len = 64; - - memset( verify_buffer, verify_padding_val, verify_padding_len ); - idx = verify_padding_len; - - if( from == MBEDTLS_SSL_IS_CLIENT ) - { - memcpy( verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN( client_cv ) ); - idx += MBEDTLS_SSL_TLS1_3_LBL_LEN( client_cv ); - } - else - { /* from == MBEDTLS_SSL_IS_SERVER */ - memcpy( verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN( server_cv ) ); - idx += MBEDTLS_SSL_TLS1_3_LBL_LEN( server_cv ); - } - - verify_buffer[idx++] = 0x0; - - memcpy( verify_buffer + idx, transcript_hash, transcript_hash_len ); - idx += transcript_hash_len; - - *verify_buffer_len = idx; -} - -#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ - /* * STATE HANDLING: Read CertificateVerify */ @@ -296,8 +245,52 @@ static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, MBEDTLS_TLS1_3_MD_MAX_SIZE \ ) +/* + * The ssl_tls13_create_verify_structure() creates the verify structure. + * As input, it requires the transcript hash. + * + * The caller has to ensure that the buffer has size at least + * SSL_VERIFY_STRUCT_MAX_SIZE bytes. + */ +static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, + size_t transcript_hash_len, + unsigned char *verify_buffer, + size_t *verify_buffer_len, + int from ) +{ + size_t idx; + + /* RFC 8446, Section 4.4.3: + * + * The digital signature [in the CertificateVerify message] is then + * computed over the concatenation of: + * - A string that consists of octet 32 (0x20) repeated 64 times + * - The context string + * - A single 0 byte which serves as the separator + * - The content to be signed + */ + memset( verify_buffer, 0x20, 64 ); + idx = 64; + + if( from == MBEDTLS_SSL_IS_CLIENT ) + { + memcpy( verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN( client_cv ) ); + idx += MBEDTLS_SSL_TLS1_3_LBL_LEN( client_cv ); + } + else + { /* from == MBEDTLS_SSL_IS_SERVER */ + memcpy( verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN( server_cv ) ); + idx += MBEDTLS_SSL_TLS1_3_LBL_LEN( server_cv ); + } + + verify_buffer[idx++] = 0x0; + + memcpy( verify_buffer + idx, transcript_hash, transcript_hash_len ); + idx += transcript_hash_len; + + *verify_buffer_len = idx; +} -#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) static int ssl_tls13_sig_alg_is_offered( mbedtls_ssl_context *ssl, uint16_t sig_alg ) { const uint16_t *tls13_sig_alg = ssl->conf->tls13_sig_algs; @@ -310,7 +303,7 @@ static int ssl_tls13_sig_alg_is_offered( mbedtls_ssl_context *ssl, uint16_t sig_ return 0; } -static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, +static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end, const unsigned char *verify_buffer, @@ -350,7 +343,7 @@ static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, * Check if algorithm in offered signature algorithms. Send `unsupported_certificate` * alert message on failure. */ - if( ssl_tls13_sig_alg_is_offered( ssl, algorithm ) == 0 ) + if( ! ssl_tls13_sig_alg_is_offered( ssl, algorithm ) ) { /* algorithm not in offered signature algorithms list */ MBEDTLS_SSL_DEBUG_MSG( 1, ( "Received signature algorithm(%04x) is not " @@ -429,12 +422,9 @@ static int ssl_tls13_process_certificate_verify_parse( mbedtls_ssl_context *ssl, break; #endif /* MBEDTLS_SHA512_C */ - default: - MBEDTLS_SSL_DEBUG_MSG( 1, ( "Certificate Verify: Unknown signature algorithm." ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + default: + ret = MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; + break; } if( ret != 0 ) @@ -481,13 +471,6 @@ int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ) unsigned char *buf; size_t buf_len; - if( mbedtls_ssl_tls1_3_some_psk_enabled( ssl ) ) - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); - - if( ssl->session_negotiate->peer_cert == NULL ) - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) ); MBEDTLS_SSL_PROC_CHK( @@ -495,9 +478,9 @@ int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, &buf, &buf_len ) ); /* Need to calculate the hash of the transcript first - * before reading the message since otherwise it gets - * included in the transcript - */ + * before reading the message since otherwise it gets + * included in the transcript + */ ret = mbedtls_ssl_get_handshake_transcript( ssl, ssl->handshake->ciphersuite_info->mac, transcript, sizeof( transcript ), @@ -514,15 +497,16 @@ int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ) /* Create verify structure */ ssl_tls13_create_verify_structure( transcript, - transcript_len, - verify_buffer, - &verify_buffer_len, - !ssl->conf->endpoint ); + transcript_len, + verify_buffer, + &verify_buffer_len, + ( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) ? + MBEDTLS_SSL_IS_SERVER : + MBEDTLS_SSL_IS_CLIENT ); /* Process the message contents */ - MBEDTLS_SSL_PROC_CHK( - ssl_tls13_process_certificate_verify_parse( ssl, - buf, buf + buf_len, verify_buffer, verify_buffer_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_certificate_verify( ssl, buf, + buf + buf_len, verify_buffer, verify_buffer_len ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_CERTIFICATE_VERIFY, buf, buf_len ); From d0fc585b7e686c4837c5b9cb5e26f00c68d16aa6 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 29 Oct 2021 11:09:06 +0800 Subject: [PATCH 864/966] fix various issues Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index d42e463a93..c83c98b186 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -221,14 +221,14 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, /* * STATE HANDLING: Read CertificateVerify */ -/* Macro to express the length of the verify structure length. +/* Macro to express the maximum length of the verify structure. * * The structure is computed per TLS 1.3 specification as: * - 64 bytes of octet 32, * - 33 bytes for the context string * (which is either "TLS 1.3, client CertificateVerify" * or "TLS 1.3, server CertificateVerify"), - * - 1 byte for the octet 0x0, which servers as a separator, + * - 1 byte for the octet 0x0, which serves as a separator, * - 32 or 48 bytes for the Transcript-Hash(Handshake Context, Certificate) * (depending on the size of the transcript_hash) * @@ -252,7 +252,7 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl, * The caller has to ensure that the buffer has size at least * SSL_VERIFY_STRUCT_MAX_SIZE bytes. */ -static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, +static void ssl_tls13_create_verify_structure( const unsigned char *transcript_hash, size_t transcript_hash_len, unsigned char *verify_buffer, size_t *verify_buffer_len, @@ -291,23 +291,24 @@ static void ssl_tls13_create_verify_structure( unsigned char *transcript_hash, *verify_buffer_len = idx; } -static int ssl_tls13_sig_alg_is_offered( mbedtls_ssl_context *ssl, uint16_t sig_alg ) +static int ssl_tls13_sig_alg_is_offered( const mbedtls_ssl_context *ssl, + uint16_t sig_alg ) { const uint16_t *tls13_sig_alg = ssl->conf->tls13_sig_algs; - for( ; *tls13_sig_alg !=MBEDTLS_TLS13_SIG_NONE ; tls13_sig_alg++ ) + for( ; *tls13_sig_alg != MBEDTLS_TLS13_SIG_NONE ; tls13_sig_alg++ ) { if( *tls13_sig_alg == sig_alg ) - return 1; + return( 1 ); } - return 0; + return( 0 ); } static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, - const unsigned char *buf, - const unsigned char *end, - const unsigned char *verify_buffer, - size_t verify_buffer_len ) + const unsigned char *buf, + const unsigned char *end, + const unsigned char *verify_buffer, + size_t verify_buffer_len ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const unsigned char *p = buf; @@ -315,7 +316,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, size_t signature_len; mbedtls_pk_type_t sig_alg; mbedtls_md_type_t md_alg; - unsigned char verify_hash[MBEDTLS_TLS1_3_MD_MAX_SIZE]; + unsigned char verify_hash[MBEDTLS_MD_MAX_SIZE]; size_t verify_hash_len; /* @@ -340,7 +341,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, * certificates and decides to abort the handshake, then it MUST abort the handshake * with an appropriate certificate-related alert (by default, "unsupported_certificate"). * - * Check if algorithm in offered signature algorithms. Send `unsupported_certificate` + * Check if algorithm is an offered signature algorithm. Send `unsupported_certificate` * alert message on failure. */ if( ! ssl_tls13_sig_alg_is_offered( ssl, algorithm ) ) @@ -352,7 +353,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); } /* We currently only support ECDSA-based signatures */ @@ -441,7 +442,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, if( ( ret = mbedtls_pk_verify_ext( sig_alg, NULL, &ssl->session_negotiate->peer_cert->pk, md_alg, verify_hash, verify_hash_len, - buf, signature_len ) ) != 0 ) + p, signature_len ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify_ext", ret ); @@ -455,7 +456,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, return( ret ); } - return( ret ); + return( 0 ); } #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ From daac3593318e57390baa7ba77e312e2ce963bab2 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 29 Oct 2021 20:01:42 +0800 Subject: [PATCH 865/966] Change check condition order Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 993021013c..d43f43dbac 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8831,8 +8831,8 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" \ - -c "Certificate verification flags clear" \ - -c "<= parse encrypted extensions" + -c "<= parse encrypted extensions" \ + -c "Certificate verification flags clear" requires_gnutls_tls1_3 requires_gnutls_next_no_ticket @@ -8861,8 +8861,8 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" \ - -c "Certificate verification flags clear" \ - -c "<= parse encrypted extensions" + -c "<= parse encrypted extensions" \ + -c "Certificate verification flags clear" # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From 6f87f2521c8da36e68b074c92774e30aa20fca44 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 29 Oct 2021 20:12:51 +0800 Subject: [PATCH 866/966] Refactor ssl_tls13_parse_certificate_verify Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 48 ++++++++++++++----------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index c83c98b186..45692d8771 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -341,8 +341,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, * certificates and decides to abort the handshake, then it MUST abort the handshake * with an appropriate certificate-related alert (by default, "unsupported_certificate"). * - * Check if algorithm is an offered signature algorithm. Send `unsupported_certificate` - * alert message on failure. + * Check if algorithm is an offered signature algorithm. */ if( ! ssl_tls13_sig_alg_is_offered( ssl, algorithm ) ) { @@ -350,10 +349,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 1, ( "Received signature algorithm(%04x) is not " "offered.", ( unsigned int ) algorithm ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + goto error; } /* We currently only support ECDSA-based signatures */ @@ -373,10 +369,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, break; default: MBEDTLS_SSL_DEBUG_MSG( 1, ( "Certificate Verify: Unknown signature algorithm." ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + goto error; } MBEDTLS_SSL_DEBUG_MSG( 3, ( "Certificate Verify: Signature algorithm ( %04x )", @@ -388,10 +381,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, if( !mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, sig_alg ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "signature algorithm doesn't match cert key" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + goto error; } MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, 2 ); @@ -431,10 +421,7 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "hash computation error", ret ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + goto error; } MBEDTLS_SSL_DEBUG_BUF( 3, "verify hash", verify_hash, verify_hash_len ); @@ -442,21 +429,22 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, if( ( ret = mbedtls_pk_verify_ext( sig_alg, NULL, &ssl->session_negotiate->peer_cert->pk, md_alg, verify_hash, verify_hash_len, - p, signature_len ) ) != 0 ) + p, signature_len ) ) == 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify_ext", ret ); - - /* RFC 8446 section 4.4.3 - * - * If the verification fails, the receiver MUST terminate the handshake - * with a "decrypt_error" alert. - */ - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR, ret ); - - return( ret ); + return( 0 ); } + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify_ext", ret ); + +error: + /* RFC 8446 section 4.4.3 + * + * If the verification fails, the receiver MUST terminate the handshake + * with a "decrypt_error" alert. + */ + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - return( 0 ); } #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ From 7f813d5d88e4ba3f9127d65ff0280a40816fd781 Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Wed, 20 Oct 2021 23:08:38 +0100 Subject: [PATCH 867/966] add group api tests Signed-off-by: Brett Warren --- tests/suites/test_suite_ssl.data | 6 +++ tests/suites/test_suite_ssl.function | 69 ++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/tests/suites/test_suite_ssl.data b/tests/suites/test_suite_ssl.data index 25eefb3ab9..9dabb51c21 100644 --- a/tests/suites/test_suite_ssl.data +++ b/tests/suites/test_suite_ssl.data @@ -6229,3 +6229,9 @@ ssl_cf_memcpy_offset:0:255:32 # we could get this with 255-bytes plaintext and untruncated SHA-384 Constant-flow memcpy from offset: large ssl_cf_memcpy_offset:100:339:48 + +Test configuration of groups for DHE through mbedtls_ssl_conf_curves() +conf_curve: + +Test configuration of groups for DHE through mbedtls_ssl_conf_groups() +conf_group: diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 69d2e0066c..75eda1dcd2 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -4881,3 +4881,72 @@ exit: } /* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_ECP_C:!MBEDTLS_DEPRECATED_REMOVED:!MBEDTLS_DEPRECATED_WARNING:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_ECP_DP_SECP256R1_ENABLED */ +void conf_curve() +{ + + mbedtls_ecp_group_id curve_list[] = { MBEDTLS_ECP_DP_SECP192R1, + MBEDTLS_ECP_DP_SECP224R1, + MBEDTLS_ECP_DP_SECP256R1, + MBEDTLS_ECP_DP_NONE }; + mbedtls_ecp_group_id iana_tls_group_list[] = { MBEDTLS_SSL_IANA_TLS_GROUP_SECP192R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP224R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1, + MBEDTLS_SSL_IANA_TLS_GROUP_NONE }; + + mbedtls_ssl_config conf; + mbedtls_ssl_config_init( &conf ); + + mbedtls_ssl_conf_max_version( &conf, 3, 3 ); + mbedtls_ssl_conf_min_version( &conf, 3, 3 ); + mbedtls_ssl_conf_curves( &conf, curve_list ); + + mbedtls_ssl_context ssl; + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_setup( &ssl, &conf ); + + TEST_ASSERT( ssl.handshake != NULL && ssl.handshake->group_list != NULL ); + TEST_ASSERT( ssl.conf != NULL && ssl.conf->group_list == NULL ); + + TEST_EQUAL( ssl.handshake->group_list[ARRAY_LENGTH( iana_tls_group_list ) - 1], MBEDTLS_SSL_IANA_TLS_GROUP_NONE ); + + for( size_t i = 0; i < ARRAY_LENGTH( iana_tls_group_list ); i++ ) + TEST_EQUAL( iana_tls_group_list[i], ssl.handshake->group_list[i] ); + + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_DEPRECATED_REMOVED */ +void conf_group() +{ + uint16_t iana_tls_group_list[] = { MBEDTLS_SSL_IANA_TLS_GROUP_SECP192R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP224R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1, + MBEDTLS_SSL_IANA_TLS_GROUP_NONE }; + + mbedtls_ssl_config conf; + mbedtls_ssl_config_init( &conf ); + + mbedtls_ssl_conf_max_version( &conf, 3, 3 ); + mbedtls_ssl_conf_min_version( &conf, 3, 3 ); + + mbedtls_ssl_conf_groups( &conf, iana_tls_group_list ); + + mbedtls_ssl_context ssl; + mbedtls_ssl_init( &ssl ); + mbedtls_ssl_setup( &ssl, &conf ); + + TEST_ASSERT( ssl.conf != NULL && ssl.conf->group_list != NULL ); + + TEST_EQUAL( ssl.conf->group_list[ARRAY_LENGTH( iana_tls_group_list ) - 1], MBEDTLS_SSL_IANA_TLS_GROUP_NONE ); + + for( size_t i = 0; i < ARRAY_LENGTH( iana_tls_group_list ); i++ ) + TEST_EQUAL( iana_tls_group_list[i], ssl.conf->group_list[i] ); + + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); +} +/* END_CASE */ From 01f3dae3f30d4c016ed7b1b5cb251d5e5abaceb5 Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Tue, 17 Aug 2021 13:50:51 +0100 Subject: [PATCH 868/966] Refactor elliptic curve extension for NamedGroups The refactoring is needed for the group api to work properly. Code is modified to use mbedtls_get_supported_groups instead of direct access so that both deprecated and new api are useable. Signed-off-by: Brett Warren --- library/ssl_cli.c | 32 ++++++++++++-------------------- library/ssl_srv.c | 8 +++++--- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 9120aa2f75..9fc8041262 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -309,27 +309,32 @@ static int ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl, unsigned char *elliptic_curve_list = p + 6; size_t elliptic_curve_len = 0; const mbedtls_ecp_curve_info *info; - const mbedtls_ecp_group_id *grp_id; - + const uint16_t *group_list = mbedtls_ssl_get_groups( ssl ); *olen = 0; + /* Check there is room for header */ + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported_elliptic_curves extension" ) ); - if( ssl->conf->curve_list == NULL ) + if( group_list == NULL ) return( MBEDTLS_ERR_SSL_BAD_CONFIG ); - for( grp_id = ssl->conf->curve_list; - *grp_id != MBEDTLS_ECP_DP_NONE; - grp_id++ ) + for( ; *group_list != 0; group_list++ ) { - info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); + info = mbedtls_ecp_curve_info_from_tls_id( *group_list ); if( info == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid curve in ssl configuration" ) ); return( MBEDTLS_ERR_SSL_BAD_CONFIG ); } + + /* Check there is room for another curve */ + MBEDTLS_SSL_CHK_BUF_PTR( elliptic_curve_list, end, elliptic_curve_len + 2 ); + + MBEDTLS_PUT_UINT16_BE( *group_list, elliptic_curve_list, elliptic_curve_len ); elliptic_curve_len += 2; if( elliptic_curve_len > MBEDTLS_SSL_MAX_CURVE_LIST_LEN ) @@ -344,19 +349,6 @@ static int ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl, if( elliptic_curve_len == 0 ) return( MBEDTLS_ERR_SSL_BAD_CONFIG ); - MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 + elliptic_curve_len ); - - elliptic_curve_len = 0; - - for( grp_id = ssl->conf->curve_list; - *grp_id != MBEDTLS_ECP_DP_NONE; - grp_id++ ) - { - info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); - elliptic_curve_list[elliptic_curve_len++] = MBEDTLS_BYTE_1( info->tls_id ); - elliptic_curve_list[elliptic_curve_len++] = MBEDTLS_BYTE_0( info->tls_id ); - } - MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES, p, 0 ); p += 2; diff --git a/library/ssl_srv.c b/library/ssl_srv.c index e27fdff5e3..881b1fd695 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -3036,14 +3036,16 @@ static int ssl_prepare_server_key_exchange( mbedtls_ssl_context *ssl, * } ServerECDHParams; */ const mbedtls_ecp_curve_info **curve = NULL; - const mbedtls_ecp_group_id *gid; + const uint16_t *group_list = mbedtls_ssl_get_groups( ssl ); int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; size_t len = 0; /* Match our preference list against the offered curves */ - for( gid = ssl->conf->curve_list; *gid != MBEDTLS_ECP_DP_NONE; gid++ ) + if( group_list == NULL ) + return( MBEDTLS_ERR_SSL_BAD_CONFIG ); + for( ; *group_list != 0; group_list++ ) for( curve = ssl->handshake->curves; *curve != NULL; curve++ ) - if( (*curve)->grp_id == *gid ) + if( (*curve)->tls_id == *group_list ) goto curve_matching_done; curve_matching_done: From 25386b7652570098093af149160c19b08cdfa14d Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Tue, 17 Aug 2021 09:32:04 +0100 Subject: [PATCH 869/966] Refactor ssl_{server2,client2} for NamedGroup IDs Signed-off-by: Brett Warren --- programs/ssl/ssl_client2.c | 10 +++++----- programs/ssl/ssl_server2.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index a02d977ec9..19e74be876 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -678,7 +678,7 @@ int main( int argc, char *argv[] ) #endif #if defined(MBEDTLS_ECP_C) - mbedtls_ecp_group_id curve_list[CURVE_LIST_SIZE]; + uint16_t group_list[CURVE_LIST_SIZE]; const mbedtls_ecp_curve_info *curve_cur; #endif #if defined(MBEDTLS_SSL_DTLS_SRTP) @@ -1452,7 +1452,7 @@ int main( int argc, char *argv[] ) if( strcmp( p, "none" ) == 0 ) { - curve_list[0] = MBEDTLS_ECP_DP_NONE; + group_list[0] = 0; } else if( strcmp( p, "default" ) != 0 ) { @@ -1469,7 +1469,7 @@ int main( int argc, char *argv[] ) if( ( curve_cur = mbedtls_ecp_curve_info_from_name( q ) ) != NULL ) { - curve_list[i++] = curve_cur->grp_id; + group_list[i++] = curve_cur->tls_id; } else { @@ -1495,7 +1495,7 @@ int main( int argc, char *argv[] ) goto exit; } - curve_list[i] = MBEDTLS_ECP_DP_NONE; + group_list[i] = 0; } } #endif /* MBEDTLS_ECP_C */ @@ -1889,7 +1889,7 @@ int main( int argc, char *argv[] ) if( opt.curves != NULL && strcmp( opt.curves, "default" ) != 0 ) { - mbedtls_ssl_conf_curves( &conf, curve_list ); + mbedtls_ssl_conf_groups( &conf, group_list ); } #endif diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 40a6902294..dd28ef3309 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1326,7 +1326,7 @@ int main( int argc, char *argv[] ) sni_entry *sni_info = NULL; #endif #if defined(MBEDTLS_ECP_C) - mbedtls_ecp_group_id curve_list[CURVE_LIST_SIZE]; + uint16_t group_list[CURVE_LIST_SIZE]; const mbedtls_ecp_curve_info * curve_cur; #endif #if defined(MBEDTLS_SSL_ALPN) @@ -2177,7 +2177,7 @@ int main( int argc, char *argv[] ) if( strcmp( p, "none" ) == 0 ) { - curve_list[0] = MBEDTLS_ECP_DP_NONE; + group_list[0] = 0; } else if( strcmp( p, "default" ) != 0 ) { @@ -2194,7 +2194,7 @@ int main( int argc, char *argv[] ) if( ( curve_cur = mbedtls_ecp_curve_info_from_name( q ) ) != NULL ) { - curve_list[i++] = curve_cur->grp_id; + group_list[i++] = curve_cur->tls_id; } else { @@ -2220,7 +2220,7 @@ int main( int argc, char *argv[] ) goto exit; } - curve_list[i] = MBEDTLS_ECP_DP_NONE; + group_list[i] = 0; } } #endif /* MBEDTLS_ECP_C */ @@ -2857,7 +2857,7 @@ int main( int argc, char *argv[] ) if( opt.curves != NULL && strcmp( opt.curves, "default" ) != 0 ) { - mbedtls_ssl_conf_curves( &conf, curve_list ); + mbedtls_ssl_conf_groups( &conf, group_list ); } #endif From 14efd33a6cca867eabaf1e356cd8366345571612 Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Wed, 6 Oct 2021 09:32:11 +0100 Subject: [PATCH 870/966] Convert TLS1.3 functions to get_supported_groups Signed-off-by: Brett Warren --- library/ssl_tls13_client.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 633bb8da2e..8fe2232ec5 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -117,36 +117,35 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, * 'elliptic_curves' and only contained elliptic curve groups. */ static int ssl_tls13_write_named_group_list_ecdhe( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) + unsigned char *buf, + unsigned char *end, + size_t *olen ) { unsigned char *p = buf; *olen = 0; - if( ssl->conf->curve_list == NULL ) + const uint16_t *group_list = mbedtls_ssl_get_groups( ssl ); + + if( group_list == NULL ) return( MBEDTLS_ERR_SSL_BAD_CONFIG ); - for ( const mbedtls_ecp_group_id *grp_id = ssl->conf->curve_list; - *grp_id != MBEDTLS_ECP_DP_NONE; - grp_id++ ) + for ( ; *group_list != 0; group_list++ ) { const mbedtls_ecp_curve_info *info; - info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); + info = mbedtls_ecp_curve_info_from_tls_id( *group_list ); if( info == NULL ) continue; - if( !mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) + if( !mbedtls_ssl_tls13_named_group_is_ecdhe( *group_list ) ) continue; MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2); - MBEDTLS_PUT_UINT16_BE( info->tls_id, p, 0 ); + MBEDTLS_PUT_UINT16_BE( *group_list, p, 0 ); p += 2; MBEDTLS_SSL_DEBUG_MSG( 3, ( "NamedGroup: %s ( %x )", - mbedtls_ecp_curve_info_from_tls_id( info->tls_id )->name, - info->tls_id ) ); + info->name, *group_list ) ); } *olen = p - buf; @@ -301,20 +300,19 @@ static int ssl_tls13_get_default_group_id( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_ECDH_C) + const uint16_t *group_list = mbedtls_ssl_get_groups( ssl ); /* Pick first available ECDHE group compatible with TLS 1.3 */ - if( ssl->conf->curve_list == NULL ) + if( group_list == NULL ) return( MBEDTLS_ERR_SSL_BAD_CONFIG ); - for ( const mbedtls_ecp_group_id *grp_id = ssl->conf->curve_list; - *grp_id != MBEDTLS_ECP_DP_NONE; - grp_id++ ) + for ( ; *group_list != 0; group_list++ ) { const mbedtls_ecp_curve_info *info; - info = mbedtls_ecp_curve_info_from_grp_id( *grp_id ); + info = mbedtls_ecp_curve_info_from_tls_id( *group_list ); if( info != NULL && - mbedtls_ssl_tls13_named_group_is_ecdhe( info->tls_id ) ) + mbedtls_ssl_tls13_named_group_is_ecdhe( *group_list ) ) { - *group_id = info->tls_id; + *group_id = *group_list; return( 0 ); } } From 834886d2112b54dca7781d2da1a239434bd43f2c Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sat, 30 Oct 2021 13:26:15 +0800 Subject: [PATCH 871/966] Add certificate verify check Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index d43f43dbac..037dfa5188 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8832,7 +8832,8 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" \ -c "<= parse encrypted extensions" \ - -c "Certificate verification flags clear" + -c "Certificate verification flags clear" \ + -c "<= parse certificate verify" requires_gnutls_tls1_3 requires_gnutls_next_no_ticket @@ -8862,7 +8863,8 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" \ -c "<= parse encrypted extensions" \ - -c "Certificate verification flags clear" + -c "Certificate verification flags clear" \ + -c "<= parse certificate verify" # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From 47413c2c8f5ad766874e279445a1e567ed9935e3 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 29 Oct 2021 17:19:41 +0800 Subject: [PATCH 872/966] fix wrong version header for tls1.3 Signed-off-by: Jerry Yu --- library/ssl_msg.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 3795c65475..40eb57e223 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2560,9 +2560,15 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) #endif /* Skip writing the record content type to after the encryption, * as it may change when using the CID extension. */ - - mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, - ssl->conf->transport, ssl->out_hdr + 1 ); + int minor_ver = ssl->minor_ver; +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + /* TLS 1.3 still uses the TLS 1.3 version identifier + * for backwards compatibility. */ + if( minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) + minor_ver = MBEDTLS_SSL_MINOR_VERSION_3; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + mbedtls_ssl_write_version( ssl->major_ver, minor_ver, + ssl->conf->transport, ssl->out_hdr + 1 ); memcpy( ssl->out_ctr, ssl->cur_out_ctr, MBEDTLS_SSL_SEQUENCE_NUMBER_LEN ); MBEDTLS_PUT_UINT16_BE( len, ssl->out_len, 0); @@ -2577,7 +2583,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) rec.data_offset = ssl->out_msg - rec.buf; memcpy( &rec.ctr[0], ssl->out_ctr, sizeof( rec.ctr ) ); - mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, + mbedtls_ssl_write_version( ssl->major_ver, minor_ver, ssl->conf->transport, rec.ver ); rec.type = ssl->out_msgtype; @@ -5619,6 +5625,7 @@ static void ssl_buffering_free_slot( mbedtls_ssl_context *ssl, void mbedtls_ssl_write_version( int major, int minor, int transport, unsigned char ver[2] ) { + #if defined(MBEDTLS_SSL_PROTO_DTLS) if( transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { From ba9c727e94a6d26fd9c93c10759872310bd5e6f1 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sat, 30 Oct 2021 11:54:10 +0800 Subject: [PATCH 873/966] fix memory leak issue Signed-off-by: Jerry Yu --- library/ssl_tls.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index c5079508ee..1929d8b3ee 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5477,8 +5477,15 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ) psa_destroy_key( handshake->ecdh_psa_privkey ); #endif /* MBEDTLS_ECDH_C && MBEDTLS_USE_PSA_CRYPTO */ - mbedtls_platform_zeroize( handshake, - sizeof( mbedtls_ssl_handshake_params ) ); +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + mbedtls_ssl_transform_free(handshake->transform_handshake); + mbedtls_ssl_transform_free(handshake->transform_earlydata); + mbedtls_free( handshake->transform_earlydata ); + mbedtls_free( handshake->transform_handshake ); + handshake->transform_earlydata = NULL; + handshake->transform_handshake = NULL; +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH) /* If the buffers are too big - reallocate. Because of the way Mbed TLS @@ -5489,12 +5496,9 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ) mbedtls_ssl_get_output_buflen( ssl ) ); #endif -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - mbedtls_free( handshake->transform_earlydata ); - mbedtls_free( handshake->transform_handshake ); - handshake->transform_earlydata = NULL; - handshake->transform_handshake = NULL; -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* mbedtls_platform_zeroize MUST be last one in this function */ + mbedtls_platform_zeroize( handshake, + sizeof( mbedtls_ssl_handshake_params ) ); } void mbedtls_ssl_session_free( mbedtls_ssl_session *session ) From 7bc26b8c2ad82a3f1050ed9af4abb92580a18154 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Tue, 2 Nov 2021 10:50:44 +0100 Subject: [PATCH 874/966] generate_psa_tests.py: add key generation result to test case argument list, add comments Signed-off-by: Przemyslaw Stekiel --- scripts/mbedtls_dev/test_case.py | 8 -------- tests/scripts/generate_psa_tests.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/scripts/mbedtls_dev/test_case.py b/scripts/mbedtls_dev/test_case.py index 11117fcdd7..8ec2115461 100644 --- a/scripts/mbedtls_dev/test_case.py +++ b/scripts/mbedtls_dev/test_case.py @@ -42,7 +42,6 @@ class TestCase: self.dependencies = [] #type: List[str] self.function = None #type: Optional[str] self.arguments = [] #type: List[str] - self.result = '' #type: str def add_comment(self, *lines: str) -> None: self.comments += lines @@ -59,9 +58,6 @@ class TestCase: def set_arguments(self, arguments: List[str]) -> None: self.arguments = arguments - def set_result(self, result: str) -> None: - self.result = result - def check_completeness(self) -> None: if self.description is None: raise MissingDescription @@ -86,10 +82,6 @@ class TestCase: if self.dependencies: out.write('depends_on:' + ':'.join(self.dependencies) + '\n') out.write(self.function + ':' + ':'.join(self.arguments)) - if self.result: - out.write(':' + self.result + '\n') - else: - out.write('\n') def write_data_file(filename: str, test_cases: Iterable[TestCase], diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index a850ea7cbf..7c16778969 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -203,7 +203,8 @@ class NotSupported: # supported or not depending on implementation capabilities, # only generate the test case once. continue - # Public key cannot be generated + # For public key we expect that key generation fails with + # INVALID_ARGUMENT. It is handled by KeyGenerate class. if not kt.name.endswith('_PUBLIC_KEY'): yield test_case_for_key_type_not_supported( 'generate', kt.expression, bits, @@ -246,8 +247,7 @@ def test_case_for_key_generation( .format(short_key_type, bits)) tc.set_dependencies(dependencies) tc.set_function('generate_key') - tc.set_arguments([key_type] + list(args)) - tc.set_result(result) + tc.set_arguments([key_type] + list(args) + [result]) return tc @@ -260,11 +260,8 @@ class KeyGenerate: ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR', 'PSA_KEY_TYPE_ECC_PUBLIC_KEY') - RSA_KEY_TYPES = ('PSA_KEY_TYPE_RSA_KEY_PAIR', - 'PSA_KEY_TYPE_RSA_PUBLIC_KEY') - + @staticmethod def test_cases_for_key_type_key_generation( - self, kt: crypto_knowledge.KeyType ) -> Iterator[test_case.TestCase]: """Return test cases exercising key generation. @@ -279,11 +276,14 @@ class KeyGenerate: import_dependencies += [psa_want_symbol(sym) for i, sym in enumerate(kt.params)] if kt.name.endswith('_PUBLIC_KEY'): + # The library checks whether the key type is a public key generically, + # before it reaches a point where it needs support for the specific key + # type, so it returns INVALID_ARGUMENT for unsupported public key types. generate_dependencies = [] result = 'PSA_ERROR_INVALID_ARGUMENT' else: generate_dependencies = import_dependencies - if kt.name in self.RSA_KEY_TYPES: + if kt.name == 'PSA_KEY_TYPE_RSA_KEY_PAIR': generate_dependencies.append("MBEDTLS_GENPRIME") for bits in kt.sizes_to_test(): yield test_case_for_key_generation( From e3fcb5087aa07094959ae9dd992267fd0834855c Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Tue, 2 Nov 2021 10:52:53 +0100 Subject: [PATCH 875/966] Adapt generate_key() test code to mbedTLS standards Signed-off-by: Przemyslaw Stekiel --- ...est_suite_psa_crypto_generate_key.function | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_generate_key.function b/tests/suites/test_suite_psa_crypto_generate_key.function index d30c0e4876..dbe9a0ecf9 100644 --- a/tests/suites/test_suite_psa_crypto_generate_key.function +++ b/tests/suites/test_suite_psa_crypto_generate_key.function @@ -13,41 +13,36 @@ */ /* BEGIN_CASE */ -void generate_key( int key_type, int bits, int result) +void generate_key( int key_type_arg, int bits_arg, int expected_status_arg) { psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; mbedtls_svc_key_id_t key_id = INVALID_KEY_ID; // key lifetiem, usage flags, algorithm are irrelevant for this test - psa_key_lifetime_t _key_life_time = (psa_key_lifetime_t) 0; - psa_key_usage_t _key_usage_flags = (psa_key_usage_t) 0; - psa_algorithm_t _key_algorithm = (psa_algorithm_t) 0; - psa_key_type_t _key_type = (psa_key_type_t) key_type; - size_t _key_bits = (size_t) bits; - psa_status_t _result = (psa_status_t) result; + psa_key_type_t key_type = key_type_arg; + size_t bits = bits_arg; + psa_status_t expected_status = expected_status_arg; PSA_ASSERT( psa_crypto_init( ) ); - psa_set_key_lifetime( &attributes, _key_life_time ); - psa_set_key_usage_flags( &attributes, _key_usage_flags ); - psa_set_key_algorithm( &attributes, _key_algorithm ); - psa_set_key_type( &attributes, _key_type ); - psa_set_key_bits( &attributes, _key_bits ); + psa_set_key_type( &attributes, key_type ); + psa_set_key_bits( &attributes, bits ); TEST_EQUAL( psa_generate_key( &attributes, &key_id ), - _result ); + expected_status ); // Verify attributes of the created key on success - if (_result == PSA_SUCCESS) + if ( expected_status == PSA_SUCCESS ) { - psa_key_attributes_t key_attributes = PSA_KEY_ATTRIBUTES_INIT; - PSA_ASSERT( psa_get_key_attributes( key_id, &key_attributes ) ); - TEST_EQUAL( psa_get_key_lifetime( &key_attributes ), 0 ); - TEST_EQUAL( psa_get_key_usage_flags( &key_attributes ), 0 ); - TEST_EQUAL( psa_get_key_algorithm( &key_attributes ), 0 ); - TEST_EQUAL( psa_get_key_type( &key_attributes ), _key_type ); - TEST_EQUAL( psa_get_key_bits( &key_attributes ), _key_bits ); + psa_reset_key_attributes(&attributes); + PSA_ASSERT( psa_get_key_attributes( key_id, &attributes ) ); + TEST_EQUAL( psa_get_key_lifetime( &attributes ), PSA_KEY_LIFETIME_VOLATILE ); + TEST_EQUAL( psa_get_key_usage_flags( &attributes ), 0 ); + TEST_EQUAL( psa_get_key_algorithm( &attributes ), 0 ); + TEST_EQUAL( psa_get_key_type( &attributes ), key_type ); + TEST_EQUAL( psa_get_key_bits( &attributes ), bits ); } exit: + psa_reset_key_attributes(&attributes); psa_destroy_key( key_id ); PSA_DONE( ); } From d2ea2c0df3399a55d96274d34b85aa41a775bf10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Mon, 25 Oct 2021 20:58:14 +0200 Subject: [PATCH 876/966] Indicate errors interleaved with test suite output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Indicate whether a success or failure is unexpected, or expected and ignored as they happen. Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index d6fe8c4407..aa0a480e5c 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -52,7 +52,7 @@ def main(): proc = subprocess.Popen(['./psa-arch-tests-crypto'], bufsize=1, stdout=subprocess.PIPE, universal_newlines=True) - test_re = re.compile('^TEST(?:: ([0-9]*)| RESULT: FAILED)') + test_re = re.compile('^TEST(?:: ([0-9]*)| RESULT: (FAILED|PASSED))') test = -1 unexpected_successes = set(EXPECTED_FAILURES) expected_failures = [] @@ -63,12 +63,16 @@ def main(): if match is not None: if match.group(1) is not None: test = int(match.group(1)) - else: + elif match.group(2) == 'FAILED': try: unexpected_successes.remove(test) expected_failures.append(test) + print('Expected failure, ignoring') except KeyError: unexpected_failures.append(test) + print('ERROR: Unexpected failure') + elif test in unexpected_successes: + print('ERROR: Unexpected success') proc.wait() print() From c2bac00530bb010015090fa9c38885ca1d41f1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Mon, 25 Oct 2021 20:58:14 +0200 Subject: [PATCH 877/966] Use print(end='') to silence double newline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index aa0a480e5c..ca9387954e 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -58,7 +58,7 @@ def main(): expected_failures = [] unexpected_failures = [] for line in proc.stdout: - print(line[:-1]) + print(line, end='') match = test_re.match(line) if match is not None: if match.group(1) is not None: From 83aa604ce5d6b3de956de2a116b8fa1c6caefc22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Fri, 29 Oct 2021 12:06:19 +0200 Subject: [PATCH 878/966] Simplify regex and use named capture groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index ca9387954e..dfd23938a2 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -52,7 +52,10 @@ def main(): proc = subprocess.Popen(['./psa-arch-tests-crypto'], bufsize=1, stdout=subprocess.PIPE, universal_newlines=True) - test_re = re.compile('^TEST(?:: ([0-9]*)| RESULT: (FAILED|PASSED))') + test_re = re.compile( + '^TEST: (?P[0-9]*)|' + '^TEST RESULT: (?PFAILED|PASSED)' + ) test = -1 unexpected_successes = set(EXPECTED_FAILURES) expected_failures = [] @@ -61,9 +64,11 @@ def main(): print(line, end='') match = test_re.match(line) if match is not None: - if match.group(1) is not None: - test = int(match.group(1)) - elif match.group(2) == 'FAILED': + groupdict = match.groupdict() + test_num = groupdict['test_num'] + if test_num is not None: + test = int(test_num) + elif groupdict['test_result'] == 'FAILED': try: unexpected_successes.remove(test) expected_failures.append(test) From 449781fda774db94b3b0366002047817e774f683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 2 Nov 2021 13:41:14 +0100 Subject: [PATCH 879/966] Fix pylint errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index dfd23938a2..41003d80da 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -1,5 +1,11 @@ #!/usr/bin/env python3 -#pylint: disable=missing-module-docstring +"""Run the PSA Cryto API compliance test suite. +Clone the repo and check out the commit specified by PSA_ARCH_TEST_REPO and PSA_ARCH_TEST_REF, +then complie and run the test suite. +Known defects in either the test suite or mbedtls - identified by their test number - are ignored, +while unexpected failures AND successes are reported as errors, +to help keep the list of known defects as up to date as possible. +""" import os import re import shutil @@ -90,8 +96,8 @@ def main(): if unexpected_successes or unexpected_failures: if unexpected_successes: print('Unexpected successes encountered.') - #pylint: disable=line-too-long - print('Please remove the corresponding tests from EXPECTED_FAILURES in tests/scripts/compliance_test.py') + print('Please remove the corresponding tests from ' + 'EXPECTED_FAILURES in tests/scripts/compliance_test.py') print() print('FAILED') sys.exit(1) From 386f5820aae5c9acdb1b55d2c7680f00e569e540 Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Tue, 2 Nov 2021 16:51:24 +0100 Subject: [PATCH 880/966] Add a missing psa_crypto test suite test name Signed-off-by: Andrzej Kurek --- tests/suites/test_suite_psa_crypto.data | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 9c204957a0..caac146f4a 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -1911,6 +1911,7 @@ PSA symmetric encrypt: AES-CBC-nopad, input too short depends_on:PSA_WANT_ALG_CBC_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_encrypt_fail:PSA_ALG_CBC_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"6bc1bee223":PSA_ERROR_INVALID_ARGUMENT +PSA symmetric encrypt: AES-ECB, 0 bytes, good depends_on:PSA_WANT_ALG_ECB_NO_PADDING:PSA_WANT_KEY_TYPE_AES cipher_encrypt_alg_without_iv:PSA_ALG_ECB_NO_PADDING:PSA_KEY_TYPE_AES:"2b7e151628aed2a6abf7158809cf4f3c":"":"" From 01ef723bbab53fa3004e7d7c1f7fb011e9c482cc Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 3 Nov 2021 00:53:05 +0100 Subject: [PATCH 881/966] DT_NEEDED for shared builds in makefile The makefile build specifies -L. -lmbedx509 -lmbedcrypto flags first, and only then object files referencing symbols from those libraries. In this order the linker will not add the linked libraries to the DT_NEEDED section because they are not referenced yet (at least that happens for me on ubuntu 20.04 with the default gnu compiler tools). By first specifying the object files and then the linked libraries, we do end up with libmbedx509 and libmbedcrypto in the DT_NEEDED sections. This way running dlopen(...) on libmedtls.so just works. Note that the CMake build does this by default. Signed-off-by: Harmen Stoppels --- README.md | 2 +- library/Makefile | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e6924cbe1d..c8d94500e2 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ There are currently three active build systems used within Mbed TLS releases: The main systems used for development are CMake and GNU Make. Those systems are always complete and up-to-date. The others should reflect all changes present in the CMake and Make build system, although features may not be ported there automatically. -The Make and CMake build systems create three libraries: libmbedcrypto, libmbedx509, and libmbedtls. Note that libmbedtls depends on libmbedx509 and libmbedcrypto, and libmbedx509 depends on libmbedcrypto. As a result, some linkers will expect flags to be in a specific order, for example the GNU linker wants `-lmbedtls -lmbedx509 -lmbedcrypto`. Also, when loading shared libraries using dlopen(), you'll need to load libmbedcrypto first, then libmbedx509, before you can load libmbedtls. +The Make and CMake build systems create three libraries: libmbedcrypto, libmbedx509, and libmbedtls. Note that libmbedtls depends on libmbedx509 and libmbedcrypto, and libmbedx509 depends on libmbedcrypto. As a result, some linkers will expect flags to be in a specific order, for example the GNU linker wants `-lmbedtls -lmbedx509 -lmbedcrypto`. ### Tool versions diff --git a/library/Makefile b/library/Makefile index 13cd7db0c6..cbe6031ff8 100644 --- a/library/Makefile +++ b/library/Makefile @@ -199,7 +199,7 @@ endif libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so echo " LD $@" - $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS) + $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_TLS) -L. -lmbedcrypto -lmbedx509$(LOCAL_LDFLAGS) $(LDFLAGS) libmbedtls.so: libmbedtls.$(SOEXT_TLS) echo " LN $@ -> $<" @@ -207,7 +207,7 @@ libmbedtls.so: libmbedtls.$(SOEXT_TLS) libmbedtls.dylib: $(OBJS_TLS) libmbedx509.dylib echo " LD $@" - $(CC) -dynamiclib -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS) + $(CC) -dynamiclib -o $@ $(OBJS_TLS) -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll echo " LD $@" @@ -226,7 +226,7 @@ endif libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so echo " LD $@" - $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509) + $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_X509) -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) libmbedx509.so: libmbedx509.$(SOEXT_X509) echo " LN $@ -> $<" @@ -234,7 +234,7 @@ libmbedx509.so: libmbedx509.$(SOEXT_X509) libmbedx509.dylib: $(OBJS_X509) libmbedcrypto.dylib echo " LD $@" - $(CC) -dynamiclib -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509) + $(CC) -dynamiclib -o $@ $(OBJS_X509) -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll echo " LD $@" @@ -253,7 +253,7 @@ endif libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) echo " LD $@" - $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO) + $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_CRYPTO) $(LOCAL_LDFLAGS) $(LDFLAGS) libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO) echo " LN $@ -> $<" @@ -261,7 +261,7 @@ libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO) libmbedcrypto.dylib: $(OBJS_CRYPTO) echo " LD $@" - $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO) + $(CC) -dynamiclib -o $@ $(OBJS_CRYPTO) $(LOCAL_LDFLAGS) $(LDFLAGS) libmbedcrypto.dll: $(OBJS_CRYPTO) echo " LD $@" From ccd738b85381b7cf42a5ec356a8249ce6755859b Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Wed, 3 Nov 2021 07:12:31 +0000 Subject: [PATCH 882/966] Add git rev-parse options Signed-off-by: Xiaofei Bai --- scripts/code_size_compare.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/code_size_compare.py b/scripts/code_size_compare.py index 898aaf9f38..85393d031c 100755 --- a/scripts/code_size_compare.py +++ b/scripts/code_size_compare.py @@ -58,8 +58,8 @@ class CodeSizeComparison: @staticmethod def validate_revision(revision): - result = subprocess.run(["git", "rev-parse", "--verify", revision], - check=False, stdout=subprocess.PIPE) + result = subprocess.check_output(["git", "rev-parse", "--verify", + revision + "^{commit}"], shell=False) return result def _create_git_worktree(self, revision): @@ -208,15 +208,11 @@ def main(): parser.exit() validate_res = CodeSizeComparison.validate_revision(comp_args.old_rev) - if validate_res.returncode != 0: - sys.exit(validate_res.returncode) - old_revision = validate_res.stdout.decode().replace("\n", "") + old_revision = validate_res.decode().replace("\n", "") if comp_args.new_rev is not None: validate_res = CodeSizeComparison.validate_revision(comp_args.new_rev) - if validate_res.returncode != 0: - sys.exit(validate_res.returncode) - new_revision = validate_res.stdout.decode().replace("\n", "") + new_revision = validate_res.decode().replace("\n", "") else: new_revision = "current" From bbb22bbd9e42e76f5899fd14d57413a6512fcf55 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 3 Nov 2021 09:06:09 +0100 Subject: [PATCH 883/966] ssl_client2/ssl_server2: Move is_psa_leaking() before mbedtls_psa_crypto_free() (and rng_free()) Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_client2.c | 29 +++++++++++++++++------------ programs/ssl/ssl_server2.c | 32 +++++++++++++++++++------------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 130f3f98ef..deecbad3e9 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -3050,6 +3050,23 @@ exit: #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED && MBEDTLS_USE_PSA_CRYPTO */ +#if defined(MBEDTLS_USE_PSA_CRYPTO) + const char* message = mbedtls_test_helper_is_psa_leaking(); + if( message ) + { + if( ret == 0 ) + ret = 1; + mbedtls_printf( "PSA memory leak detected: %s\n", message); + } +#endif /* MBEDTLS_USE_PSA_CRYPTO */ + + /* For builds with MBEDTLS_TEST_USE_PSA_CRYPTO_RNG psa crypto + * resources are freed by rng_free(). */ +#if defined(MBEDTLS_USE_PSA_CRYPTO) && \ + !defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG) + mbedtls_psa_crypto_free( ); +#endif + mbedtls_ssl_session_free( &saved_session ); mbedtls_ssl_free( &ssl ); mbedtls_ssl_config_free( &conf ); @@ -3063,18 +3080,6 @@ exit: mbedtls_free( context_buf ); #endif -#if defined(MBEDTLS_USE_PSA_CRYPTO) - - mbedtls_psa_crypto_free( ); - const char* message = mbedtls_test_helper_is_psa_leaking(); - if( message ) - { - if( ret == 0 ) - ret = 1; - mbedtls_printf( "PSA memory leak detected: %s\n", message); - } -#endif - #if defined(MBEDTLS_TEST_HOOKS) if( test_hooks_failure_detected( ) ) { diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index d20d1faa10..f95c151843 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -4008,10 +4008,6 @@ exit: #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED && MBEDTLS_USE_PSA_CRYPTO */ - mbedtls_ssl_free( &ssl ); - mbedtls_ssl_config_free( &conf ); - rng_free( &rng ); - #if defined(MBEDTLS_SSL_CACHE_C) mbedtls_ssl_cache_free( &cache ); #endif @@ -4022,16 +4018,7 @@ exit: mbedtls_ssl_cookie_free( &cookie_ctx ); #endif - mbedtls_free( buf ); - -#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) - if( context_buf != NULL ) - mbedtls_platform_zeroize( context_buf, context_buf_len ); - mbedtls_free( context_buf ); -#endif - #if defined(MBEDTLS_USE_PSA_CRYPTO) - mbedtls_psa_crypto_free( ); const char* message = mbedtls_test_helper_is_psa_leaking(); if( message ) { @@ -4041,6 +4028,25 @@ exit: } #endif + /* For builds with MBEDTLS_TEST_USE_PSA_CRYPTO_RNG psa crypto + * resources are freed by rng_free(). */ +#if defined(MBEDTLS_USE_PSA_CRYPTO) && \ + !defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG) + mbedtls_psa_crypto_free( ); +#endif + + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + rng_free( &rng ); + + mbedtls_free( buf ); + +#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) + if( context_buf != NULL ) + mbedtls_platform_zeroize( context_buf, context_buf_len ); + mbedtls_free( context_buf ); +#endif + #if defined(MBEDTLS_TEST_HOOKS) /* Let test hooks detect errors such as resource leaks. * Don't do it in query_config mode, because some test code prints From 53de2622f3667bb812de0fe17d8988bfa6da6a27 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 3 Nov 2021 09:35:35 +0100 Subject: [PATCH 884/966] Move psa_crypto_slot_management.h out from psa_crypto_helpers.h Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_client2.c | 1 - programs/ssl/ssl_server2.c | 1 - tests/include/test/psa_crypto_helpers.h | 3 --- tests/src/psa_crypto_helpers.c | 1 + tests/src/psa_exercise_key.c | 1 + 5 files changed, 2 insertions(+), 5 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index deecbad3e9..62bba1380b 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -22,7 +22,6 @@ #include "ssl_test_lib.h" #if defined(MBEDTLS_USE_PSA_CRYPTO) -#define SKIP_LIBRARY_HEADERS #include "test/psa_crypto_helpers.h" #endif diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index f95c151843..6a4a033aa9 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -66,7 +66,6 @@ int main( void ) #endif #if defined(MBEDTLS_USE_PSA_CRYPTO) -#define SKIP_LIBRARY_HEADERS #include "test/psa_crypto_helpers.h" #endif diff --git a/tests/include/test/psa_crypto_helpers.h b/tests/include/test/psa_crypto_helpers.h index 8e7d425a93..f5622e2d2d 100644 --- a/tests/include/test/psa_crypto_helpers.h +++ b/tests/include/test/psa_crypto_helpers.h @@ -28,9 +28,6 @@ #include "test/psa_helpers.h" #include -#if !defined(SKIP_LIBRARY_HEADERS) -#include -#endif #if defined(MBEDTLS_USE_PSA_CRYPTO) #include "mbedtls/psa_util.h" diff --git a/tests/src/psa_crypto_helpers.c b/tests/src/psa_crypto_helpers.c index d9d841abd5..299b6d125d 100644 --- a/tests/src/psa_crypto_helpers.c +++ b/tests/src/psa_crypto_helpers.c @@ -22,6 +22,7 @@ #include #include +#include #include #if defined(MBEDTLS_PSA_CRYPTO_C) diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index 923d2c136a..29e673ae76 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -29,6 +29,7 @@ #include #include +#include #include #if defined(MBEDTLS_PSA_CRYPTO_SE_C) From 34b5f5634407a7b9ce5c3a36fb853276caed2985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 2 Nov 2021 13:48:39 +0100 Subject: [PATCH 885/966] Make main() suitable to being called from python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't call sys.exit(), and don't clobber the working directory. Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 146 ++++++++++++++------------- 1 file changed, 75 insertions(+), 71 deletions(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 41003d80da..7d7192f063 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -18,7 +18,7 @@ EXPECTED_FAILURES = { PSA_ARCH_TESTS_REPO = 'https://github.com/ronald-cron-arm/psa-arch-tests.git' PSA_ARCH_TESTS_REF = 'crypto1.0-3.0' -#pylint: disable=too-many-statements +#pylint: disable=too-many-branches,too-many-statements def main(): mbedtls_dir = os.getcwd() @@ -30,81 +30,85 @@ def main(): os.mkdir(psa_arch_tests_dir) except FileExistsError: pass - os.chdir(psa_arch_tests_dir) - - subprocess.check_call(['git', 'init']) - subprocess.check_call(['git', 'fetch', PSA_ARCH_TESTS_REPO, PSA_ARCH_TESTS_REF]) - subprocess.check_call(['git', 'checkout', 'FETCH_HEAD']) - - build_dir = 'api-tests/build' try: - shutil.rmtree(build_dir) - except FileNotFoundError: - pass - os.mkdir(build_dir) - os.chdir(build_dir) + os.chdir(psa_arch_tests_dir) - #pylint: disable=bad-continuation - subprocess.check_call([ - 'cmake', '..', '-GUnix Makefiles', - '-DTARGET=tgt_dev_apis_stdc', - '-DTOOLCHAIN=HOST_GCC', - '-DSUITE=CRYPTO', - '-DPSA_CRYPTO_LIB_FILENAME={}/library/libmbedcrypto.a'.format(mbedtls_dir), - '-DPSA_INCLUDE_PATHS={}/include'.format(mbedtls_dir) - ]) - subprocess.check_call(['cmake', '--build', '.']) + subprocess.check_call(['git', 'init']) + subprocess.check_call(['git', 'fetch', PSA_ARCH_TESTS_REPO, PSA_ARCH_TESTS_REF]) + subprocess.check_call(['git', 'checkout', 'FETCH_HEAD']) - proc = subprocess.Popen(['./psa-arch-tests-crypto'], - bufsize=1, stdout=subprocess.PIPE, universal_newlines=True) + build_dir = 'api-tests/build' + try: + shutil.rmtree(build_dir) + except FileNotFoundError: + pass + os.mkdir(build_dir) + os.chdir(build_dir) - test_re = re.compile( - '^TEST: (?P[0-9]*)|' - '^TEST RESULT: (?PFAILED|PASSED)' - ) - test = -1 - unexpected_successes = set(EXPECTED_FAILURES) - expected_failures = [] - unexpected_failures = [] - for line in proc.stdout: - print(line, end='') - match = test_re.match(line) - if match is not None: - groupdict = match.groupdict() - test_num = groupdict['test_num'] - if test_num is not None: - test = int(test_num) - elif groupdict['test_result'] == 'FAILED': - try: - unexpected_successes.remove(test) - expected_failures.append(test) - print('Expected failure, ignoring') - except KeyError: - unexpected_failures.append(test) - print('ERROR: Unexpected failure') - elif test in unexpected_successes: - print('ERROR: Unexpected success') - proc.wait() + #pylint: disable=bad-continuation + subprocess.check_call([ + 'cmake', '..', + '-GUnix Makefiles', + '-DTARGET=tgt_dev_apis_stdc', + '-DTOOLCHAIN=HOST_GCC', + '-DSUITE=CRYPTO', + '-DPSA_CRYPTO_LIB_FILENAME={}/library/libmbedcrypto.a'.format(mbedtls_dir), + '-DPSA_INCLUDE_PATHS={}/include'.format(mbedtls_dir) + ]) + subprocess.check_call(['cmake', '--build', '.']) - print() - print('***** test_psa_compliance.py report ******') - print() - print('Expected failures:', ', '.join(str(i) for i in expected_failures)) - print('Unexpected failures:', ', '.join(str(i) for i in unexpected_failures)) - print('Unexpected successes:', ', '.join(str(i) for i in sorted(unexpected_successes))) - print() - if unexpected_successes or unexpected_failures: - if unexpected_successes: - print('Unexpected successes encountered.') - print('Please remove the corresponding tests from ' - 'EXPECTED_FAILURES in tests/scripts/compliance_test.py') - print() - print('FAILED') - sys.exit(1) - else: + proc = subprocess.Popen(['./psa-arch-tests-crypto'], + bufsize=1, stdout=subprocess.PIPE, universal_newlines=True) + + test_re = re.compile( + '^TEST: (?P[0-9]*)|' + '^TEST RESULT: (?PFAILED|PASSED)' + ) + test = -1 + unexpected_successes = set(EXPECTED_FAILURES) + expected_failures = [] + unexpected_failures = [] + for line in proc.stdout: + print(line, end='') + match = test_re.match(line) + if match is not None: + groupdict = match.groupdict() + test_num = groupdict['test_num'] + if test_num is not None: + test = int(test_num) + elif groupdict['test_result'] == 'FAILED': + try: + unexpected_successes.remove(test) + expected_failures.append(test) + print('Expected failure, ignoring') + except KeyError: + unexpected_failures.append(test) + print('ERROR: Unexpected failure') + elif test in unexpected_successes: + print('ERROR: Unexpected success') + proc.wait() + + print() + print('***** test_psa_compliance.py report ******') + print() + print('Expected failures:', ', '.join(str(i) for i in expected_failures)) + print('Unexpected failures:', ', '.join(str(i) for i in unexpected_failures)) + print('Unexpected successes:', ', '.join(str(i) for i in sorted(unexpected_successes))) + print() + if unexpected_successes or unexpected_failures: + if unexpected_successes: + print('Unexpected successes encountered.') + print('Please remove the corresponding tests from ' + 'EXPECTED_FAILURES in tests/scripts/compliance_test.py') + print() + print('FAILED') + return 1 + else: + shutil.rmtree(psa_arch_tests_dir) + print('SUCCESS') + return 0 + finally: os.chdir(mbedtls_dir) - shutil.rmtree(psa_arch_tests_dir) - print('SUCCESS') if __name__ == '__main__': - main() + sys.exit(main()) From 67fb3149c01dd5e121980f1de8061124288eb8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 2 Nov 2021 14:01:08 +0100 Subject: [PATCH 886/966] Add licence header to script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 7d7192f063..d94f6c2422 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -6,6 +6,22 @@ Known defects in either the test suite or mbedtls - identified by their test num while unexpected failures AND successes are reported as errors, to help keep the list of known defects as up to date as possible. """ + +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import re import shutil From c63d1605ab69f8aff97cf9c8678bbfdfd6f8fe00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 2 Nov 2021 14:06:40 +0100 Subject: [PATCH 887/966] Make directory creation code more compact MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index d94f6c2422..33207c014b 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -42,10 +42,7 @@ def main(): subprocess.check_call(['make', '-C', 'library', 'libmbedcrypto.a']) psa_arch_tests_dir = 'psa-arch-tests' - try: - os.mkdir(psa_arch_tests_dir) - except FileExistsError: - pass + os.makedirs(psa_arch_tests_dir, exist_ok=True) try: os.chdir(psa_arch_tests_dir) From b3818412bcb043503bfe287de0e1135502a33448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Wed, 3 Nov 2021 11:32:51 +0100 Subject: [PATCH 888/966] Keep local clone around even if the test succeeds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- .gitignore | 3 +++ tests/scripts/test_psa_compliance.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0792920a8b..e86092c45f 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,9 @@ massif-* # Generated documentation: /apidoc +# PSA Crypto compliance test repo, cloned by test_psa_complaince.py +/psa-arch-tests + # Editor navigation files: /GPATH /GRTAGS diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 33207c014b..2f67f08c88 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Run the PSA Cryto API compliance test suite. Clone the repo and check out the commit specified by PSA_ARCH_TEST_REPO and PSA_ARCH_TEST_REF, -then complie and run the test suite. +then complie and run the test suite. The clone is stored at /psa-arch-tests. Known defects in either the test suite or mbedtls - identified by their test number - are ignored, while unexpected failures AND successes are reported as errors, to help keep the list of known defects as up to date as possible. @@ -46,6 +46,7 @@ def main(): try: os.chdir(psa_arch_tests_dir) + # Reuse existing local clone subprocess.check_call(['git', 'init']) subprocess.check_call(['git', 'fetch', PSA_ARCH_TESTS_REPO, PSA_ARCH_TESTS_REF]) subprocess.check_call(['git', 'checkout', 'FETCH_HEAD']) @@ -117,7 +118,6 @@ def main(): print('FAILED') return 1 else: - shutil.rmtree(psa_arch_tests_dir) print('SUCCESS') return 0 finally: From ef0d02ed317c431a9eaa3ec8c3ba58cf8952d673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Wed, 3 Nov 2021 11:36:09 +0100 Subject: [PATCH 889/966] Explain why support_test_psa_compliance is needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- tests/scripts/all.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index d86a9f773b..449b213ff7 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2765,6 +2765,7 @@ component_test_psa_compliance () { } support_test_psa_compliance () { + # psa-compliance-tests only supports CMake >= 3.10.0 ver="$(cmake --version)" ver="${ver#cmake version }" ver_major="${ver%%.*}" From 505712338ea7ac8661026c2acd8f8ccb310c7e01 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 3 Nov 2021 14:19:52 +0100 Subject: [PATCH 890/966] ssl_client2: move memory leak check before rng_free() Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_client2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 62bba1380b..4360fd3438 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -3049,6 +3049,10 @@ exit: #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED && MBEDTLS_USE_PSA_CRYPTO */ + mbedtls_ssl_session_free( &saved_session ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + #if defined(MBEDTLS_USE_PSA_CRYPTO) const char* message = mbedtls_test_helper_is_psa_leaking(); if( message ) @@ -3066,9 +3070,6 @@ exit: mbedtls_psa_crypto_free( ); #endif - mbedtls_ssl_session_free( &saved_session ); - mbedtls_ssl_free( &ssl ); - mbedtls_ssl_config_free( &conf ); rng_free( &rng ); if( session_data != NULL ) mbedtls_platform_zeroize( session_data, session_data_len ); From e6d3edaf327ec3097ad18f442df42b0369d90556 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 26 Aug 2021 11:46:14 +0200 Subject: [PATCH 891/966] Add missing PSA_ALG_IS_SIGN_HASH macro. Signed-off-by: Mateusz Starzyk --- include/psa/crypto.h | 8 ++++++-- include/psa/crypto_values.h | 15 +++++++++++++++ library/psa_crypto.c | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/psa/crypto.h b/include/psa/crypto.h index 5d9854a7ba..ee4b54cbf9 100644 --- a/include/psa/crypto.h +++ b/include/psa/crypto.h @@ -2990,7 +2990,9 @@ psa_status_t psa_verify_message( mbedtls_svc_key_id_t key, * \param key Identifier of the key to use for the operation. * It must be an asymmetric key pair. The key must * allow the usage #PSA_KEY_USAGE_SIGN_HASH. - * \param alg A signature algorithm that is compatible with + * \param alg A signature algorithm (PSA_ALG_XXX + * value such that #PSA_ALG_IS_SIGN_HASH(\p alg) + * is true), that is compatible with * the type of \p key. * \param[in] hash The hash or message to sign. * \param hash_length Size of the \p hash buffer in bytes. @@ -3043,7 +3045,9 @@ psa_status_t psa_sign_hash(mbedtls_svc_key_id_t key, * must be a public key or an asymmetric key pair. The * key must allow the usage * #PSA_KEY_USAGE_VERIFY_HASH. - * \param alg A signature algorithm that is compatible with + * \param alg A signature algorithm (PSA_ALG_XXX + * value such that #PSA_ALG_IS_SIGN_HASH(\p alg) + * is true), that is compatible with * the type of \p key. * \param[in] hash The hash or message whose signature is to be * verified. diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index 621b872fc8..526b4549d2 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -1621,6 +1621,21 @@ #define PSA_ALG_IS_SIGN_MESSAGE(alg) \ (PSA_ALG_IS_HASH_AND_SIGN(alg) || (alg) == PSA_ALG_PURE_EDDSA ) +/** Whether the specified algorithm is a signature algorithm that can be used + * with psa_sign_hash() and psa_verify_hash(). + * + * \param alg An algorithm identifier (value of type psa_algorithm_t). + * + * \return 1 if alg is a signature algorithm that can be used to sign a + * hash. 0 if alg is a signature algorithm that can only be used + * to sign a message. 0 if alg is not a signature algorithm. + * This macro can return either 0 or 1 if alg is not a + * supported algorithm identifier. + */ +#define PSA_ALG_IS_SIGN_HASH(alg) \ + (PSA_ALG_IS_HASH_AND_SIGN(alg) || (alg) == PSA_ALG_ED25519PH || \ + (alg) == PSA_ALG_ED448PH) + /** Get the hash used by a hash-and-sign signature algorithm. * * A hash-and-sign algorithm is a signature algorithm which is diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 3670071a5d..84b85667cc 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2652,7 +2652,7 @@ static psa_status_t psa_sign_verify_check_alg( int input_is_message, } else { - if( ! PSA_ALG_IS_HASH_AND_SIGN( alg ) ) + if( ! PSA_ALG_IS_SIGN_HASH( alg ) ) return( PSA_ERROR_INVALID_ARGUMENT ); } From 359b5ab6eaa5ff6fcfee6e88cc445db129bc37af Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 26 Aug 2021 12:52:56 +0200 Subject: [PATCH 892/966] Add missing PSA_ALG_NONE macro. Signed-off-by: Mateusz Starzyk --- include/psa/crypto_values.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index 526b4549d2..9ce8b68780 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -847,6 +847,9 @@ (PSA_ALG_IS_KEY_DERIVATION(alg) && \ (alg) & PSA_ALG_KEY_DERIVATION_STRETCHING_FLAG) +/** An invalid algorithm identifier value. */ +#define PSA_ALG_NONE ((psa_algorithm_t)0) + #define PSA_ALG_HASH_MASK ((psa_algorithm_t)0x000000ff) /** MD5 */ #define PSA_ALG_MD5 ((psa_algorithm_t)0x02000003) From 7d262dd1ee62e62942928428846470c12f5de93d Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 26 Aug 2021 13:28:46 +0200 Subject: [PATCH 893/966] Add missing PSA_HASH_BLOCK_LENGTH macro. Signed-off-by: Mateusz Starzyk --- include/psa/crypto_sizes.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/psa/crypto_sizes.h b/include/psa/crypto_sizes.h index 4c67f10afa..5f230e0f0f 100644 --- a/include/psa/crypto_sizes.h +++ b/include/psa/crypto_sizes.h @@ -79,6 +79,38 @@ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 64 : \ 0) +/** The input block size of a hash algorithm, in bytes. + * + * Hash algorithms process their input data in blocks. Hash operations will + * retain any partial blocks until they have enough input to fill the block or + * until the operation is finished. + * This affects the output from psa_hash_suspend(). + * + * \param alg A hash algorithm (\c PSA_ALG_XXX value such that + * PSA_ALG_IS_HASH(\p alg) is true). + * + * \return The block size in bytes for the specified hash algorithm. + * If the hash algorithm is not recognized, return 0. + * An implementation can return either 0 or the correct size for a + * hash algorithm that it recognizes, but does not support. + */ +#define PSA_HASH_BLOCK_LENGTH(alg) \ + ( \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 64 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 64 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 64 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 64 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 64 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 128 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 128 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 128 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 128 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 144 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 136 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 104 : \ + PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 72 : \ + 0) + /** \def PSA_HASH_MAX_SIZE * * Maximum size of a hash. From c5c5b9361102de706ae66b054408e93f89b95121 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 26 Aug 2021 13:32:30 +0200 Subject: [PATCH 894/966] Add missing PSA_KEY_ID_NULL macro. Signed-off-by: Mateusz Starzyk --- include/psa/crypto_values.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index 9ce8b68780..252c29590d 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -2150,6 +2150,9 @@ #define PSA_KEY_LOCATION_VENDOR_FLAG ((psa_key_location_t)0x800000) +/** The null key identifier. + */ +#define PSA_KEY_ID_NULL ((psa_key_id_t)0) /** The minimum value for a key identifier chosen by the application. */ #define PSA_KEY_ID_USER_MIN ((psa_key_id_t)0x00000001) From 5bc9bf7584f7bb1d3ef35f854803a1fb1ac84563 Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Thu, 26 Aug 2021 14:29:02 +0200 Subject: [PATCH 895/966] Add changelog entry for new PSA Crypto API macros. Signed-off-by: Mateusz Starzyk --- ChangeLog.d/psa_crypto_api_macros.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ChangeLog.d/psa_crypto_api_macros.txt diff --git a/ChangeLog.d/psa_crypto_api_macros.txt b/ChangeLog.d/psa_crypto_api_macros.txt new file mode 100644 index 0000000000..c695ff5c95 --- /dev/null +++ b/ChangeLog.d/psa_crypto_api_macros.txt @@ -0,0 +1,3 @@ +Features + * Add missing PSA macros declared by PSA Crypto API 1.0.0: + PSA_ALG_IS_SIGN_HASH, PSA_ALG_NONE, PSA_HASH_BLOCK_LENGTH, PSA_KEY_ID_NULL From e7be73d5794f26c15920adbb53d3f6f31be17a22 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 22 Sep 2021 14:44:28 +0200 Subject: [PATCH 896/966] Use the new macro PSA_HASH_BLOCK_LENGTH Replace an equivalent internal function. Signed-off-by: Gilles Peskine --- library/psa_crypto_mac.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/library/psa_crypto_mac.c b/library/psa_crypto_mac.c index 2c079d434f..7e0a8325df 100644 --- a/library/psa_crypto_mac.c +++ b/library/psa_crypto_mac.c @@ -42,29 +42,6 @@ #endif #if defined(BUILTIN_ALG_HMAC) -static size_t psa_get_hash_block_size( psa_algorithm_t alg ) -{ - switch( alg ) - { - case PSA_ALG_MD5: - return( 64 ); - case PSA_ALG_RIPEMD160: - return( 64 ); - case PSA_ALG_SHA_1: - return( 64 ); - case PSA_ALG_SHA_224: - return( 64 ); - case PSA_ALG_SHA_256: - return( 64 ); - case PSA_ALG_SHA_384: - return( 128 ); - case PSA_ALG_SHA_512: - return( 128 ); - default: - return( 0 ); - } -} - static psa_status_t psa_hmac_abort_internal( mbedtls_psa_hmac_operation_t *hmac ) { @@ -81,7 +58,7 @@ static psa_status_t psa_hmac_setup_internal( uint8_t ipad[PSA_HMAC_MAX_HASH_BLOCK_SIZE]; size_t i; size_t hash_size = PSA_HASH_LENGTH( hash_alg ); - size_t block_size = psa_get_hash_block_size( hash_alg ); + size_t block_size = PSA_HASH_BLOCK_LENGTH( hash_alg ); psa_status_t status; hmac->alg = hash_alg; @@ -153,7 +130,7 @@ static psa_status_t psa_hmac_finish_internal( uint8_t tmp[MBEDTLS_MD_MAX_SIZE]; psa_algorithm_t hash_alg = hmac->alg; size_t hash_size = 0; - size_t block_size = psa_get_hash_block_size( hash_alg ); + size_t block_size = PSA_HASH_BLOCK_LENGTH( hash_alg ); psa_status_t status; status = psa_hash_finish( &hmac->hash_ctx, tmp, sizeof( tmp ), &hash_size ); From c1ec49eb13d0b0769ce610dcf1248282bb5ed43a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 22 Sep 2021 14:47:26 +0200 Subject: [PATCH 897/966] Test PSA_HASH_BLOCK_LENGTH Only tested for algorithms for which we support HMAC, since that's all we use PSA_HASH_BLOCK_LENGTH for at the moment. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto_metadata.function | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index ab9b2f879a..d868f5903d 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -353,6 +353,7 @@ void hmac_algorithm( int alg_arg, TEST_ASSERT( PSA_ALG_IS_HASH( hash_alg ) ); TEST_EQUAL( PSA_ALG_HMAC( hash_alg ), alg ); + TEST_ASSERT( block_size == PSA_HASH_BLOCK_LENGTH( alg ) ); TEST_ASSERT( block_size <= PSA_HMAC_MAX_HASH_BLOCK_SIZE ); test_mac_algorithm( alg_arg, ALG_IS_HMAC, length, From f7b4137e69e494c9e40b4620f7567775bf44bab3 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 22 Sep 2021 16:15:05 +0200 Subject: [PATCH 898/966] Untangle PSA_ALG_IS_HASH_AND_SIGN and PSA_ALG_IS_SIGN_HASH The current definition of PSA_ALG_IS_HASH_AND_SIGN includes PSA_ALG_RSA_PKCS1V15_SIGN_RAW and PSA_ALG_ECDSA_ANY, which don't strictly follow the hash-and-sign paradigm: the algorithm does not encode a hash algorithm that is applied prior to the signature step. The definition in fact encompasses what can be used with psa_sign_hash/psa_verify_hash, so it's the correct definition for PSA_ALG_IS_SIGN_HASH. Therefore this commit moves definition of PSA_ALG_IS_HASH_AND_SIGN to PSA_ALG_IS_SIGN_HASH, and replace the definition of PSA_ALG_IS_HASH_AND_SIGN by a correct one (based on PSA_ALG_IS_SIGN_HASH, excluding the algorithms where the pre-signature step isn't to apply the hash encoded in the algorithm). In the definition of PSA_ALG_SIGN_GET_HASH, keep the condition for a nonzero output to be PSA_ALG_IS_HASH_AND_SIGN. Everywhere else in the code base (definition of PSA_ALG_IS_SIGN_MESSAGE, and every use of PSA_ALG_IS_HASH_AND_SIGN outside of crypto_values.h), we meant PSA_ALG_IS_SIGN_HASH where we wrote PSA_ALG_IS_HASH_AND_SIGN, so do a global replacement. ``` git grep -l IS_HASH_AND_SIGN ':!include/psa/crypto_values.h' | xargs perl -i -pe 's/ALG_IS_HASH_AND_SIGN/ALG_IS_SIGN_HASH/g' ``` Signed-off-by: Gilles Peskine --- include/psa/crypto_values.h | 34 ++++++++++++++----- library/psa_crypto.c | 12 +++---- tests/src/psa_exercise_key.c | 4 +-- tests/suites/test_suite_psa_crypto.function | 2 +- .../test_suite_psa_crypto_metadata.data | 18 +++++----- .../test_suite_psa_crypto_metadata.function | 6 ++-- 6 files changed, 47 insertions(+), 29 deletions(-) diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index 252c29590d..cb40d4e442 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -1597,7 +1597,20 @@ * Hash-and-sign algorithms are asymmetric (public-key) signature algorithms * structured in two parts: first the calculation of a hash in a way that * does not depend on the key, then the calculation of a signature from the - * hash value and the key. + * hash value and the key. Hash-and-sign algorithms encode the hash + * used for the hashing step, and you can call #PSA_ALG_SIGN_GET_HASH + * to extract this algorithm. + * + * Thus, for a hash-and-sign algorithm, + * `psa_sign_message(key, alg, input, ...)` is equivalent to + * ``` + * psa_hash_compute(PSA_ALG_SIGN_GET_HASH(alg), input, ..., hash, ...); + * psa_sign_hash(key, alg, hash, ..., signature, ...); + * ``` + * Most usefully, separating the hash from the signature allows the hash + * to be calculated in multiple steps with psa_hash_setup(), psa_hash_update() + * and psa_hash_finish(). Likewise psa_verify_message() is equivalent to + * calculating the hash and then calling psa_verify_hash(). * * \param alg An algorithm identifier (value of type #psa_algorithm_t). * @@ -1606,9 +1619,8 @@ * algorithm identifier. */ #define PSA_ALG_IS_HASH_AND_SIGN(alg) \ - (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \ - PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_HASH_EDDSA(alg) || \ - PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg)) + (PSA_ALG_IS_SIGN_HASH(alg) && \ + ((alg) & PSA_ALG_HASH_MASK) != 0) /** Whether the specified algorithm is a signature algorithm that can be used * with psa_sign_message() and psa_verify_message(). @@ -1622,11 +1634,17 @@ * supported algorithm identifier. */ #define PSA_ALG_IS_SIGN_MESSAGE(alg) \ - (PSA_ALG_IS_HASH_AND_SIGN(alg) || (alg) == PSA_ALG_PURE_EDDSA ) + (PSA_ALG_IS_SIGN_HASH(alg) || (alg) == PSA_ALG_PURE_EDDSA ) /** Whether the specified algorithm is a signature algorithm that can be used * with psa_sign_hash() and psa_verify_hash(). * + * This encompasses all strict hash-and-sign algorithms categorized by + * PSA_ALG_IS_HASH_AND_SIGN(), as well as algorithms that follow the + * paradigm more loosely: + * - #PSA_ALG_RSA_PKCS1V15_SIGN_RAW (expects its input to be an encoded hash) + * - #PSA_ALG_ECDSA_ANY (doesn't specify what kind of hash the input is) + * * \param alg An algorithm identifier (value of type psa_algorithm_t). * * \return 1 if alg is a signature algorithm that can be used to sign a @@ -1636,8 +1654,9 @@ * supported algorithm identifier. */ #define PSA_ALG_IS_SIGN_HASH(alg) \ - (PSA_ALG_IS_HASH_AND_SIGN(alg) || (alg) == PSA_ALG_ED25519PH || \ - (alg) == PSA_ALG_ED448PH) + (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \ + PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_HASH_EDDSA(alg) || \ + PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg)) /** Get the hash used by a hash-and-sign signature algorithm. * @@ -1659,7 +1678,6 @@ */ #define PSA_ALG_SIGN_GET_HASH(alg) \ (PSA_ALG_IS_HASH_AND_SIGN(alg) ? \ - ((alg) & PSA_ALG_HASH_MASK) == 0 ? /*"raw" algorithm*/ 0 : \ ((alg) & PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : \ 0) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 84b85667cc..c4bcddcb1a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -623,8 +623,8 @@ static psa_algorithm_t psa_key_policy_algorithm_intersection( return( alg1 ); /* If the policies are from the same hash-and-sign family, check * if one is a wildcard. If so the other has the specific algorithm. */ - if( PSA_ALG_IS_HASH_AND_SIGN( alg1 ) && - PSA_ALG_IS_HASH_AND_SIGN( alg2 ) && + if( PSA_ALG_IS_SIGN_HASH( alg1 ) && + PSA_ALG_IS_SIGN_HASH( alg2 ) && ( alg1 & ~PSA_ALG_HASH_MASK ) == ( alg2 & ~PSA_ALG_HASH_MASK ) ) { if( PSA_ALG_SIGN_GET_HASH( alg1 ) == PSA_ALG_ANY_HASH ) @@ -726,7 +726,7 @@ static int psa_key_algorithm_permits( psa_key_type_t key_type, /* If policy_alg is a hash-and-sign with a wildcard for the hash, * and requested_alg is the same hash-and-sign family with any hash, * then requested_alg is compliant with policy_alg. */ - if( PSA_ALG_IS_HASH_AND_SIGN( requested_alg ) && + if( PSA_ALG_IS_SIGN_HASH( requested_alg ) && PSA_ALG_SIGN_GET_HASH( policy_alg ) == PSA_ALG_ANY_HASH ) { return( ( policy_alg & ~PSA_ALG_HASH_MASK ) == @@ -2644,7 +2644,7 @@ static psa_status_t psa_sign_verify_check_alg( int input_is_message, if( ! PSA_ALG_IS_SIGN_MESSAGE( alg ) ) return( PSA_ERROR_INVALID_ARGUMENT ); - if ( PSA_ALG_IS_HASH_AND_SIGN( alg ) ) + if ( PSA_ALG_IS_SIGN_HASH( alg ) ) { if( ! PSA_ALG_IS_HASH( PSA_ALG_SIGN_GET_HASH( alg ) ) ) return( PSA_ERROR_INVALID_ARGUMENT ); @@ -2802,7 +2802,7 @@ psa_status_t psa_sign_message_builtin( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if ( PSA_ALG_IS_HASH_AND_SIGN( alg ) ) + if ( PSA_ALG_IS_SIGN_HASH( alg ) ) { size_t hash_length; uint8_t hash[PSA_HASH_MAX_SIZE]; @@ -2849,7 +2849,7 @@ psa_status_t psa_verify_message_builtin( { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if ( PSA_ALG_IS_HASH_AND_SIGN( alg ) ) + if ( PSA_ALG_IS_SIGN_HASH( alg ) ) { size_t hash_length; uint8_t hash[PSA_HASH_MAX_SIZE]; diff --git a/tests/src/psa_exercise_key.c b/tests/src/psa_exercise_key.c index 923d2c136a..91bac678ef 100644 --- a/tests/src/psa_exercise_key.c +++ b/tests/src/psa_exercise_key.c @@ -306,7 +306,7 @@ static int exercise_signature_key( mbedtls_svc_key_id_t key, psa_algorithm_t hash_alg = PSA_ALG_SIGN_GET_HASH( alg ); /* If the policy allows signing with any hash, just pick one. */ - if( PSA_ALG_IS_HASH_AND_SIGN( alg ) && hash_alg == PSA_ALG_ANY_HASH ) + if( PSA_ALG_IS_SIGN_HASH( alg ) && hash_alg == PSA_ALG_ANY_HASH ) { #if defined(KNOWN_SUPPORTED_HASH_ALG) hash_alg = KNOWN_SUPPORTED_HASH_ALG; @@ -925,7 +925,7 @@ psa_key_usage_t mbedtls_test_psa_usage_to_exercise( psa_key_type_t type, { if( PSA_ALG_IS_MAC( alg ) || PSA_ALG_IS_SIGN( alg ) ) { - if( PSA_ALG_IS_HASH_AND_SIGN( alg ) ) + if( PSA_ALG_IS_SIGN_HASH( alg ) ) { if( PSA_ALG_SIGN_GET_HASH( alg ) ) return( PSA_KEY_TYPE_IS_PUBLIC_KEY( type ) ? diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 591c2960de..01a06989df 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -1422,7 +1422,7 @@ void asymmetric_signature_key_policy( int policy_usage_arg, else TEST_EQUAL( status, PSA_ERROR_NOT_PERMITTED ); - if( PSA_ALG_IS_HASH_AND_SIGN( exercise_alg ) && + if( PSA_ALG_IS_SIGN_HASH( exercise_alg ) && PSA_ALG_IS_HASH( PSA_ALG_SIGN_GET_HASH( exercise_alg ) ) ) { status = psa_sign_message( key, exercise_alg, diff --git a/tests/suites/test_suite_psa_crypto_metadata.data b/tests/suites/test_suite_psa_crypto_metadata.data index ad806c77cc..d6758fabae 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.data +++ b/tests/suites/test_suite_psa_crypto_metadata.data @@ -196,31 +196,31 @@ aead_algorithm:PSA_ALG_CHACHA20_POLY1305:0:16:PSA_KEY_TYPE_CHACHA20:256 Asymmetric signature: RSA PKCS#1 v1.5 raw depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN -asymmetric_signature_algorithm:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:ALG_IS_RSA_PKCS1V15_SIGN | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:ALG_IS_RSA_PKCS1V15_SIGN | ALG_IS_SIGN_HASH Asymmetric signature: RSA PKCS#1 v1.5 SHA-256 depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_RSA_PKCS1V15_SIGN( PSA_ALG_SHA_256 ):ALG_IS_RSA_PKCS1V15_SIGN | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_RSA_PKCS1V15_SIGN( PSA_ALG_SHA_256 ):ALG_IS_RSA_PKCS1V15_SIGN | ALG_IS_SIGN_HASH Asymmetric signature: RSA PSS SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_RSA_PSS( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_STANDARD_SALT | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_RSA_PSS( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_STANDARD_SALT | ALG_IS_SIGN_HASH Asymmetric signature: RSA PSS-any-salt SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_ANY_SALT | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_ANY_SALT | ALG_IS_SIGN_HASH Asymmetric signature: randomized ECDSA (no hashing) depends_on:PSA_WANT_ALG_ECDSA -asymmetric_signature_algorithm:PSA_ALG_ECDSA_ANY:ALG_IS_ECDSA | ALG_IS_RANDOMIZED_ECDSA | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_ECDSA_ANY:ALG_IS_ECDSA | ALG_IS_RANDOMIZED_ECDSA | ALG_IS_SIGN_HASH Asymmetric signature: SHA-256 + randomized ECDSA depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_ECDSA( PSA_ALG_SHA_256 ):ALG_IS_ECDSA | ALG_IS_RANDOMIZED_ECDSA | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_ECDSA( PSA_ALG_SHA_256 ):ALG_IS_ECDSA | ALG_IS_RANDOMIZED_ECDSA | ALG_IS_SIGN_HASH Asymmetric signature: SHA-256 + deterministic ECDSA using SHA-256 depends_on:PSA_WANT_ALG_DETERMINISTIC_ECDSA:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 ):ALG_IS_ECDSA | ALG_IS_DETERMINISTIC_ECDSA | ALG_ECDSA_IS_DETERMINISTIC | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 ):ALG_IS_ECDSA | ALG_IS_DETERMINISTIC_ECDSA | ALG_ECDSA_IS_DETERMINISTIC | ALG_IS_SIGN_HASH Asymmetric signature: pure EdDSA depends_on:PSA_WANT_ALG_EDDSA @@ -228,11 +228,11 @@ asymmetric_signature_algorithm:PSA_ALG_PURE_EDDSA:0 Asymmetric signature: Ed25519ph depends_on:PSA_WANT_ALG_EDDSA -asymmetric_signature_algorithm:PSA_ALG_ED25519PH:ALG_IS_HASH_EDDSA | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_ED25519PH:ALG_IS_HASH_EDDSA | ALG_IS_SIGN_HASH Asymmetric signature: Ed448ph depends_on:PSA_WANT_ALG_EDDSA -asymmetric_signature_algorithm:PSA_ALG_ED448PH:ALG_IS_HASH_EDDSA | ALG_IS_HASH_AND_SIGN +asymmetric_signature_algorithm:PSA_ALG_ED448PH:ALG_IS_HASH_EDDSA | ALG_IS_SIGN_HASH Asymmetric signature: RSA PKCS#1 v1.5 with wildcard hash depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index d868f5903d..e64dc39477 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -33,7 +33,7 @@ #define ALG_IS_DETERMINISTIC_ECDSA ( 1u << 14 ) #define ALG_IS_RANDOMIZED_ECDSA ( 1u << 15 ) #define ALG_IS_HASH_EDDSA ( 1u << 16 ) -#define ALG_IS_HASH_AND_SIGN ( 1u << 17 ) +#define ALG_IS_SIGN_HASH ( 1u << 17 ) #define ALG_IS_RSA_OAEP ( 1u << 18 ) #define ALG_IS_HKDF ( 1u << 19 ) #define ALG_IS_FFDH ( 1u << 20 ) @@ -114,7 +114,7 @@ void algorithm_classification( psa_algorithm_t alg, unsigned flags ) TEST_CLASSIFICATION_MACRO( ALG_IS_DETERMINISTIC_ECDSA, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_RANDOMIZED_ECDSA, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_HASH_EDDSA, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_HASH_AND_SIGN, alg, flags ); + TEST_CLASSIFICATION_MACRO( ALG_IS_SIGN_HASH, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_RSA_OAEP, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_HKDF, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_WILDCARD, alg, flags ); @@ -490,7 +490,7 @@ void asymmetric_signature_algorithm( int alg_arg, int classification_flags ) /* BEGIN_CASE */ void asymmetric_signature_wildcard( int alg_arg, int classification_flags ) { - classification_flags |= ALG_IS_HASH_AND_SIGN | ALG_IS_WILDCARD; + classification_flags |= ALG_IS_SIGN_HASH | ALG_IS_WILDCARD; test_asymmetric_signature_algorithm( alg_arg, classification_flags ); /* Any failure of this test function comes from * asymmetric_signature_algorithm. Pacify -Werror=unused-label. */ From f2fe31ab4e39bc633d8c35703bb4c2ca47127f57 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 22 Sep 2021 16:42:02 +0200 Subject: [PATCH 899/966] Reorder macro definitions Definition before mention Signed-off-by: Gilles Peskine --- include/psa/crypto_values.h | 72 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index cb40d4e442..f0d76fb557 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -1592,6 +1592,42 @@ * file. */ #define PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg) 0 +/** Whether the specified algorithm is a signature algorithm that can be used + * with psa_sign_hash() and psa_verify_hash(). + * + * This encompasses all strict hash-and-sign algorithms categorized by + * PSA_ALG_IS_HASH_AND_SIGN(), as well as algorithms that follow the + * paradigm more loosely: + * - #PSA_ALG_RSA_PKCS1V15_SIGN_RAW (expects its input to be an encoded hash) + * - #PSA_ALG_ECDSA_ANY (doesn't specify what kind of hash the input is) + * + * \param alg An algorithm identifier (value of type psa_algorithm_t). + * + * \return 1 if alg is a signature algorithm that can be used to sign a + * hash. 0 if alg is a signature algorithm that can only be used + * to sign a message. 0 if alg is not a signature algorithm. + * This macro can return either 0 or 1 if alg is not a + * supported algorithm identifier. + */ +#define PSA_ALG_IS_SIGN_HASH(alg) \ + (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \ + PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_HASH_EDDSA(alg) || \ + PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg)) + +/** Whether the specified algorithm is a signature algorithm that can be used + * with psa_sign_message() and psa_verify_message(). + * + * \param alg An algorithm identifier (value of type #psa_algorithm_t). + * + * \return 1 if alg is a signature algorithm that can be used to sign a + * message. 0 if \p alg is a signature algorithm that can only be used + * to sign an already-calculated hash. 0 if \p alg is not a signature + * algorithm. This macro can return either 0 or 1 if \p alg is not a + * supported algorithm identifier. + */ +#define PSA_ALG_IS_SIGN_MESSAGE(alg) \ + (PSA_ALG_IS_SIGN_HASH(alg) || (alg) == PSA_ALG_PURE_EDDSA ) + /** Whether the specified algorithm is a hash-and-sign algorithm. * * Hash-and-sign algorithms are asymmetric (public-key) signature algorithms @@ -1622,42 +1658,6 @@ (PSA_ALG_IS_SIGN_HASH(alg) && \ ((alg) & PSA_ALG_HASH_MASK) != 0) -/** Whether the specified algorithm is a signature algorithm that can be used - * with psa_sign_message() and psa_verify_message(). - * - * \param alg An algorithm identifier (value of type #psa_algorithm_t). - * - * \return 1 if alg is a signature algorithm that can be used to sign a - * message. 0 if \p alg is a signature algorithm that can only be used - * to sign an already-calculated hash. 0 if \p alg is not a signature - * algorithm. This macro can return either 0 or 1 if \p alg is not a - * supported algorithm identifier. - */ -#define PSA_ALG_IS_SIGN_MESSAGE(alg) \ - (PSA_ALG_IS_SIGN_HASH(alg) || (alg) == PSA_ALG_PURE_EDDSA ) - -/** Whether the specified algorithm is a signature algorithm that can be used - * with psa_sign_hash() and psa_verify_hash(). - * - * This encompasses all strict hash-and-sign algorithms categorized by - * PSA_ALG_IS_HASH_AND_SIGN(), as well as algorithms that follow the - * paradigm more loosely: - * - #PSA_ALG_RSA_PKCS1V15_SIGN_RAW (expects its input to be an encoded hash) - * - #PSA_ALG_ECDSA_ANY (doesn't specify what kind of hash the input is) - * - * \param alg An algorithm identifier (value of type psa_algorithm_t). - * - * \return 1 if alg is a signature algorithm that can be used to sign a - * hash. 0 if alg is a signature algorithm that can only be used - * to sign a message. 0 if alg is not a signature algorithm. - * This macro can return either 0 or 1 if alg is not a - * supported algorithm identifier. - */ -#define PSA_ALG_IS_SIGN_HASH(alg) \ - (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \ - PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_HASH_EDDSA(alg) || \ - PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg)) - /** Get the hash used by a hash-and-sign signature algorithm. * * A hash-and-sign algorithm is a signature algorithm which is From 4977e9fe64ab468be1fa8ae3059820116c36235b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 22 Sep 2021 18:12:31 +0200 Subject: [PATCH 900/966] Add PSA_ALG_IS_HASH_AND_SIGN to the metadata tests The status of signature wildcards with respect to PSA_ALG_IS_HASH_AND_SIGN is unclear in the specification. A wildcard is usually instantiated with a specific hash, making the implementation hash-and-sign, but it could also be instantiated with a non-hash-and-sign algorithm. For the time being, go with what's currently implemented, which is that they are considered hash-and-sign. Signed-off-by: Gilles Peskine --- .../test_suite_psa_crypto_metadata.data | 14 +++++----- .../test_suite_psa_crypto_metadata.function | 28 +++++++++++-------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_metadata.data b/tests/suites/test_suite_psa_crypto_metadata.data index d6758fabae..83763c55d9 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.data +++ b/tests/suites/test_suite_psa_crypto_metadata.data @@ -200,15 +200,15 @@ asymmetric_signature_algorithm:PSA_ALG_RSA_PKCS1V15_SIGN_RAW:ALG_IS_RSA_PKCS1V15 Asymmetric signature: RSA PKCS#1 v1.5 SHA-256 depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_RSA_PKCS1V15_SIGN( PSA_ALG_SHA_256 ):ALG_IS_RSA_PKCS1V15_SIGN | ALG_IS_SIGN_HASH +asymmetric_signature_algorithm:PSA_ALG_RSA_PKCS1V15_SIGN( PSA_ALG_SHA_256 ):ALG_IS_RSA_PKCS1V15_SIGN | ALG_IS_SIGN_HASH | ALG_IS_HASH_AND_SIGN Asymmetric signature: RSA PSS SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_RSA_PSS( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_STANDARD_SALT | ALG_IS_SIGN_HASH +asymmetric_signature_algorithm:PSA_ALG_RSA_PSS( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_STANDARD_SALT | ALG_IS_SIGN_HASH | ALG_IS_HASH_AND_SIGN Asymmetric signature: RSA PSS-any-salt SHA-256 depends_on:PSA_WANT_ALG_RSA_PSS:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_ANY_SALT | ALG_IS_SIGN_HASH +asymmetric_signature_algorithm:PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ):ALG_IS_RSA_PSS | ALG_IS_RSA_PSS_ANY_SALT | ALG_IS_SIGN_HASH | ALG_IS_HASH_AND_SIGN Asymmetric signature: randomized ECDSA (no hashing) depends_on:PSA_WANT_ALG_ECDSA @@ -216,11 +216,11 @@ asymmetric_signature_algorithm:PSA_ALG_ECDSA_ANY:ALG_IS_ECDSA | ALG_IS_RANDOMIZE Asymmetric signature: SHA-256 + randomized ECDSA depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_ECDSA( PSA_ALG_SHA_256 ):ALG_IS_ECDSA | ALG_IS_RANDOMIZED_ECDSA | ALG_IS_SIGN_HASH +asymmetric_signature_algorithm:PSA_ALG_ECDSA( PSA_ALG_SHA_256 ):ALG_IS_ECDSA | ALG_IS_RANDOMIZED_ECDSA | ALG_IS_SIGN_HASH | ALG_IS_HASH_AND_SIGN Asymmetric signature: SHA-256 + deterministic ECDSA using SHA-256 depends_on:PSA_WANT_ALG_DETERMINISTIC_ECDSA:PSA_WANT_ALG_SHA_256 -asymmetric_signature_algorithm:PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 ):ALG_IS_ECDSA | ALG_IS_DETERMINISTIC_ECDSA | ALG_ECDSA_IS_DETERMINISTIC | ALG_IS_SIGN_HASH +asymmetric_signature_algorithm:PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 ):ALG_IS_ECDSA | ALG_IS_DETERMINISTIC_ECDSA | ALG_ECDSA_IS_DETERMINISTIC | ALG_IS_SIGN_HASH | ALG_IS_HASH_AND_SIGN Asymmetric signature: pure EdDSA depends_on:PSA_WANT_ALG_EDDSA @@ -228,11 +228,11 @@ asymmetric_signature_algorithm:PSA_ALG_PURE_EDDSA:0 Asymmetric signature: Ed25519ph depends_on:PSA_WANT_ALG_EDDSA -asymmetric_signature_algorithm:PSA_ALG_ED25519PH:ALG_IS_HASH_EDDSA | ALG_IS_SIGN_HASH +asymmetric_signature_algorithm:PSA_ALG_ED25519PH:ALG_IS_HASH_EDDSA | ALG_IS_SIGN_HASH | ALG_IS_HASH_AND_SIGN Asymmetric signature: Ed448ph depends_on:PSA_WANT_ALG_EDDSA -asymmetric_signature_algorithm:PSA_ALG_ED448PH:ALG_IS_HASH_EDDSA | ALG_IS_SIGN_HASH +asymmetric_signature_algorithm:PSA_ALG_ED448PH:ALG_IS_HASH_EDDSA | ALG_IS_SIGN_HASH | ALG_IS_HASH_AND_SIGN Asymmetric signature: RSA PKCS#1 v1.5 with wildcard hash depends_on:PSA_WANT_ALG_RSA_PKCS1V15_SIGN diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index e64dc39477..0f2fcec590 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -33,16 +33,17 @@ #define ALG_IS_DETERMINISTIC_ECDSA ( 1u << 14 ) #define ALG_IS_RANDOMIZED_ECDSA ( 1u << 15 ) #define ALG_IS_HASH_EDDSA ( 1u << 16 ) -#define ALG_IS_SIGN_HASH ( 1u << 17 ) -#define ALG_IS_RSA_OAEP ( 1u << 18 ) -#define ALG_IS_HKDF ( 1u << 19 ) -#define ALG_IS_FFDH ( 1u << 20 ) -#define ALG_IS_ECDH ( 1u << 21 ) -#define ALG_IS_WILDCARD ( 1u << 22 ) -#define ALG_IS_RAW_KEY_AGREEMENT ( 1u << 23 ) -#define ALG_IS_AEAD_ON_BLOCK_CIPHER ( 1u << 24 ) -#define ALG_IS_TLS12_PRF ( 1u << 25 ) -#define ALG_IS_TLS12_PSK_TO_MS ( 1u << 26 ) +#define ALG_IS_SIGN_HASH ( 1u << 17 ) +#define ALG_IS_HASH_AND_SIGN ( 1u << 18 ) +#define ALG_IS_RSA_OAEP ( 1u << 19 ) +#define ALG_IS_HKDF ( 1u << 20 ) +#define ALG_IS_FFDH ( 1u << 21 ) +#define ALG_IS_ECDH ( 1u << 22 ) +#define ALG_IS_WILDCARD ( 1u << 23 ) +#define ALG_IS_RAW_KEY_AGREEMENT ( 1u << 24 ) +#define ALG_IS_AEAD_ON_BLOCK_CIPHER ( 1u << 25 ) +#define ALG_IS_TLS12_PRF ( 1u << 26 ) +#define ALG_IS_TLS12_PSK_TO_MS ( 1u << 27 ) /* Flags for key type classification macros. There is a flag for every * key type classification macro PSA_KEY_TYPE_IS_xxx except for some that @@ -51,7 +52,7 @@ #define KEY_TYPE_IS_VENDOR_DEFINED ( 1u << 0 ) #define KEY_TYPE_IS_UNSTRUCTURED ( 1u << 1 ) #define KEY_TYPE_IS_PUBLIC_KEY ( 1u << 2 ) -#define KEY_TYPE_IS_KEY_PAIR ( 1u << 3 ) +#define KEY_TYPE_IS_KEY_PAIR ( 1u << 3 ) #define KEY_TYPE_IS_RSA ( 1u << 4 ) #define KEY_TYPE_IS_DSA ( 1u << 5 ) #define KEY_TYPE_IS_ECC ( 1u << 6 ) @@ -115,6 +116,7 @@ void algorithm_classification( psa_algorithm_t alg, unsigned flags ) TEST_CLASSIFICATION_MACRO( ALG_IS_RANDOMIZED_ECDSA, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_HASH_EDDSA, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_SIGN_HASH, alg, flags ); + TEST_CLASSIFICATION_MACRO( ALG_IS_HASH_AND_SIGN, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_RSA_OAEP, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_HKDF, alg, flags ); TEST_CLASSIFICATION_MACRO( ALG_IS_WILDCARD, alg, flags ); @@ -490,7 +492,9 @@ void asymmetric_signature_algorithm( int alg_arg, int classification_flags ) /* BEGIN_CASE */ void asymmetric_signature_wildcard( int alg_arg, int classification_flags ) { - classification_flags |= ALG_IS_SIGN_HASH | ALG_IS_WILDCARD; + classification_flags |= ALG_IS_WILDCARD; + classification_flags |= ALG_IS_SIGN_HASH; + classification_flags |= ALG_IS_HASH_AND_SIGN; test_asymmetric_signature_algorithm( alg_arg, classification_flags ); /* Any failure of this test function comes from * asymmetric_signature_algorithm. Pacify -Werror=unused-label. */ From c323d4585fd51b7c75c959c2289d6ab9efa14183 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 15 Oct 2021 21:38:35 +0200 Subject: [PATCH 901/966] Note the change to PSA_ALG_IS_HASH_AND_SIGN in the changelog Signed-off-by: Gilles Peskine --- ChangeLog.d/psa_crypto_api_macros.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.d/psa_crypto_api_macros.txt b/ChangeLog.d/psa_crypto_api_macros.txt index c695ff5c95..ff53e33c2d 100644 --- a/ChangeLog.d/psa_crypto_api_macros.txt +++ b/ChangeLog.d/psa_crypto_api_macros.txt @@ -1,3 +1,11 @@ Features * Add missing PSA macros declared by PSA Crypto API 1.0.0: - PSA_ALG_IS_SIGN_HASH, PSA_ALG_NONE, PSA_HASH_BLOCK_LENGTH, PSA_KEY_ID_NULL + PSA_ALG_IS_SIGN_HASH, PSA_ALG_NONE, PSA_HASH_BLOCK_LENGTH, PSA_KEY_ID_NULL. + +Bugfix + * The existing predicate macro name PSA_ALG_IS_HASH_AND_SIGN is now reserved + for algorithm values that fully encode the hashing step, as per the PSA + Crypto API specification. This excludes PSA_ALG_RSA_PKCS1V15_SIGN_RAW and + PSA_ALG_ECDSA_ANY. The new predicate macro PSA_ALG_IS_SIGN_HASH covers + all algorithms that can be used with psa_{sign,verify}_hash(), including + these two. From a4256c1b2dc90fd144c154b746ff9d718bd33f35 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 3 Nov 2021 14:18:08 +0100 Subject: [PATCH 902/966] Ensure that all flags are actually tested At least twice, we added a classification flag but forgot to test it in the relevant test functions. Add some protection so that this doesn't happen again. In each classification category, put a macro xxx_FLAG_MASK_PLUS_ONE at the end. In the corresponding test function, keep track of the flags that are tested, and check that their mask is xxx_FLAG_MASK_PLUS_ONE - 1 which is all the bits of the previous flags set. Now, if we add a flag without testing it, the test TEST_EQUAL( classification_flags_tested, xxx_FLAG_MASK_PLUS_ONE - 1 ) will fail. It will also fail if we make the set of flag numbers non-consecutive, which is ok. This reveals that three algorithm flags had been added but not tested (in two separate occasions). Also, one key type flag that is no longer used by the library was still defined but not tested, which is not a test gap but is inconsistent. It's for DSA, which is relevant to the PSA encoding even if Mbed TLS doesn't implement it, so keep the flag and do test it. Signed-off-by: Gilles Peskine --- .../test_suite_psa_crypto_metadata.function | 112 +++++++++++------- 1 file changed, 69 insertions(+), 43 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index 0f2fcec590..f02adf3a74 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -44,6 +44,7 @@ #define ALG_IS_AEAD_ON_BLOCK_CIPHER ( 1u << 25 ) #define ALG_IS_TLS12_PRF ( 1u << 26 ) #define ALG_IS_TLS12_PSK_TO_MS ( 1u << 27 ) +#define ALG_FLAG_MASK_PLUS_ONE ( 1u << 28 ) /* must be last! */ /* Flags for key type classification macros. There is a flag for every * key type classification macro PSA_KEY_TYPE_IS_xxx except for some that @@ -57,21 +58,38 @@ #define KEY_TYPE_IS_DSA ( 1u << 5 ) #define KEY_TYPE_IS_ECC ( 1u << 6 ) #define KEY_TYPE_IS_DH ( 1u << 7 ) +#define KEY_TYPE_FLAG_MASK_PLUS_ONE ( 1u << 8 ) /* must be last! */ /* Flags for lifetime classification macros. There is a flag for every * lifetime classification macro PSA_KEY_LIFETIME_IS_xxx. The name of the * flag is the name of the classification macro without the PSA_ prefix. */ #define KEY_LIFETIME_IS_VOLATILE ( 1u << 0 ) #define KEY_LIFETIME_IS_READ_ONLY ( 1u << 1 ) +#define KEY_LIFETIME_FLAG_MASK_PLUS_ONE ( 1u << 2 ) /* must be last! */ -#define TEST_CLASSIFICATION_MACRO( flag, alg, flags ) \ - do \ - { \ - if( ( flags ) & ( flag ) ) \ - TEST_ASSERT( PSA_##flag( alg ) ); \ - else \ - TEST_ASSERT( ! PSA_##flag( alg ) ); \ - } \ +/* Check that in the value of flags, the bit flag (which should be a macro + * expanding to a number of the form 1 << k) is set if and only if + * PSA_##flag(alg) is true. + * + * Only perform this check if cond is true. Typically cond is 1, but it can + * be different if the value of the flag bit is only specified under specific + * conditions. + * + * Unconditionally mask flag into the ambient variable + * classification_flags_tested. + */ +#define TEST_CLASSIFICATION_MACRO( cond, flag, alg, flags ) \ + do \ + { \ + if( cond ) \ + { \ + if( ( flags ) & ( flag ) ) \ + TEST_ASSERT( PSA_##flag( alg ) ); \ + else \ + TEST_ASSERT( ! PSA_##flag( alg ) ); \ + } \ + classification_flags_tested |= ( flag ); \ + } \ while( 0 ) /* Check the parity of value. @@ -98,45 +116,50 @@ int has_even_parity( uint32_t value ) void algorithm_classification( psa_algorithm_t alg, unsigned flags ) { - TEST_CLASSIFICATION_MACRO( ALG_IS_VENDOR_DEFINED, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_HMAC, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_BLOCK_CIPHER_MAC, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_STREAM_CIPHER, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_RSA_PKCS1V15_SIGN, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_RSA_PSS, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_DSA, alg, flags ); - if ( PSA_ALG_IS_DSA( alg ) ) - TEST_CLASSIFICATION_MACRO( ALG_DSA_IS_DETERMINISTIC, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_DETERMINISTIC_DSA, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_RANDOMIZED_DSA, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_ECDSA, alg, flags ); - if ( PSA_ALG_IS_ECDSA( alg ) ) - TEST_CLASSIFICATION_MACRO( ALG_ECDSA_IS_DETERMINISTIC, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_DETERMINISTIC_ECDSA, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_RANDOMIZED_ECDSA, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_HASH_EDDSA, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_SIGN_HASH, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_HASH_AND_SIGN, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_RSA_OAEP, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_HKDF, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_WILDCARD, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_ECDH, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_FFDH, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_RAW_KEY_AGREEMENT, alg, flags ); - TEST_CLASSIFICATION_MACRO( ALG_IS_AEAD_ON_BLOCK_CIPHER, alg, flags ); + unsigned classification_flags_tested = 0; + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_VENDOR_DEFINED, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_HMAC, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_BLOCK_CIPHER_MAC, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_STREAM_CIPHER, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RSA_PKCS1V15_SIGN, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RSA_PSS, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_DSA, alg, flags ); + TEST_CLASSIFICATION_MACRO( PSA_ALG_IS_DSA( alg ), + ALG_DSA_IS_DETERMINISTIC, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_DETERMINISTIC_DSA, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RANDOMIZED_DSA, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_ECDSA, alg, flags ); + TEST_CLASSIFICATION_MACRO( PSA_ALG_IS_ECDSA( alg ), + ALG_ECDSA_IS_DETERMINISTIC, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_DETERMINISTIC_ECDSA, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RANDOMIZED_ECDSA, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_HASH_EDDSA, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_SIGN_HASH, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_HASH_AND_SIGN, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RSA_OAEP, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_HKDF, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_WILDCARD, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_ECDH, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_FFDH, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RAW_KEY_AGREEMENT, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_AEAD_ON_BLOCK_CIPHER, alg, flags ); + TEST_EQUAL( classification_flags_tested, ALG_FLAG_MASK_PLUS_ONE - 1 ); exit: ; } void key_type_classification( psa_key_type_t type, unsigned flags ) { + unsigned classification_flags_tested = 0; + /* Macros tested based on the test case parameter */ - TEST_CLASSIFICATION_MACRO( KEY_TYPE_IS_VENDOR_DEFINED, type, flags ); - TEST_CLASSIFICATION_MACRO( KEY_TYPE_IS_UNSTRUCTURED, type, flags ); - TEST_CLASSIFICATION_MACRO( KEY_TYPE_IS_PUBLIC_KEY, type, flags ); - TEST_CLASSIFICATION_MACRO( KEY_TYPE_IS_KEY_PAIR, type, flags ); - TEST_CLASSIFICATION_MACRO( KEY_TYPE_IS_RSA, type, flags ); - TEST_CLASSIFICATION_MACRO( KEY_TYPE_IS_ECC, type, flags ); - TEST_CLASSIFICATION_MACRO( KEY_TYPE_IS_DH, type, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_VENDOR_DEFINED, type, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_UNSTRUCTURED, type, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_PUBLIC_KEY, type, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_KEY_PAIR, type, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_RSA, type, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_ECC, type, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_DH, type, flags ); + TEST_EQUAL( classification_flags_tested, KEY_TYPE_FLAG_MASK_PLUS_ONE - 1 ); /* Macros with derived semantics */ TEST_EQUAL( PSA_KEY_TYPE_IS_ASYMMETRIC( type ), @@ -698,9 +721,12 @@ void lifetime( int lifetime_arg, int classification_flags, psa_key_persistence_t persistence = persistence_arg; psa_key_location_t location = location_arg; unsigned flags = classification_flags; + unsigned classification_flags_tested = 0; - TEST_CLASSIFICATION_MACRO( KEY_LIFETIME_IS_VOLATILE, lifetime, flags ); - TEST_CLASSIFICATION_MACRO( KEY_LIFETIME_IS_READ_ONLY, lifetime, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_LIFETIME_IS_VOLATILE, lifetime, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_LIFETIME_IS_READ_ONLY, lifetime, flags ); + TEST_EQUAL( classification_flags_tested, + KEY_LIFETIME_FLAG_MASK_PLUS_ONE - 1 ); TEST_EQUAL( PSA_KEY_LIFETIME_GET_PERSISTENCE( lifetime ), persistence ); TEST_EQUAL( PSA_KEY_LIFETIME_GET_LOCATION( lifetime ), location ); From 4db2624bfe2bd47b87be2d53747db8d59c1dc58f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 3 Nov 2021 13:56:47 +0100 Subject: [PATCH 903/966] Fix test bug: some classification flags were not tested Signed-off-by: Gilles Peskine --- tests/suites/test_suite_psa_crypto_metadata.function | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index f02adf3a74..092780c4db 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -123,6 +123,8 @@ void algorithm_classification( psa_algorithm_t alg, unsigned flags ) TEST_CLASSIFICATION_MACRO( 1, ALG_IS_STREAM_CIPHER, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RSA_PKCS1V15_SIGN, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RSA_PSS, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RSA_PSS_ANY_SALT, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RSA_PSS_STANDARD_SALT, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_DSA, alg, flags ); TEST_CLASSIFICATION_MACRO( PSA_ALG_IS_DSA( alg ), ALG_DSA_IS_DETERMINISTIC, alg, flags ); @@ -143,6 +145,8 @@ void algorithm_classification( psa_algorithm_t alg, unsigned flags ) TEST_CLASSIFICATION_MACRO( 1, ALG_IS_FFDH, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RAW_KEY_AGREEMENT, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_AEAD_ON_BLOCK_CIPHER, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_TLS12_PRF, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_TLS12_PSK_TO_MS, alg, flags ); TEST_EQUAL( classification_flags_tested, ALG_FLAG_MASK_PLUS_ONE - 1 ); exit: ; } @@ -157,6 +161,7 @@ void key_type_classification( psa_key_type_t type, unsigned flags ) TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_PUBLIC_KEY, type, flags ); TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_KEY_PAIR, type, flags ); TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_RSA, type, flags ); + TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_DSA, type, flags ); TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_ECC, type, flags ); TEST_CLASSIFICATION_MACRO( 1, KEY_TYPE_IS_DH, type, flags ); TEST_EQUAL( classification_flags_tested, KEY_TYPE_FLAG_MASK_PLUS_ONE - 1 ); From f4ecf305fe783cffac73f2373b79ad32cefc3925 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 3 Nov 2021 18:27:22 +0100 Subject: [PATCH 904/966] Fix copypasta in #endif comment Signed-off-by: Gilles Peskine --- library/base64_invasive.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/base64_invasive.h b/library/base64_invasive.h index 9e264719d4..ed5f7cb824 100644 --- a/library/base64_invasive.h +++ b/library/base64_invasive.h @@ -52,4 +52,4 @@ unsigned char mbedtls_base64_enc_char( unsigned char val ); signed char mbedtls_base64_dec_value( unsigned char c ); #endif /* MBEDTLS_TEST_HOOKS */ -#endif /* MBEDTLS_SSL_INVASIVE_H */ +#endif /* MBEDTLS_BASE64_INVASIVE_H */ From 70842950fdf8b4dd36ee3e0a18cd432443355d3d Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 4 Nov 2021 13:09:02 +0100 Subject: [PATCH 905/966] Restore the whitespace Signed-off-by: Harmen Stoppels --- library/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Makefile b/library/Makefile index cbe6031ff8..6b02f77c18 100644 --- a/library/Makefile +++ b/library/Makefile @@ -199,7 +199,7 @@ endif libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so echo " LD $@" - $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_TLS) -L. -lmbedcrypto -lmbedx509$(LOCAL_LDFLAGS) $(LDFLAGS) + $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_TLS) -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) libmbedtls.so: libmbedtls.$(SOEXT_TLS) echo " LN $@ -> $<" From 9e9aa5d2ebd4ffbeb6ac46d070dc389665e71e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Thu, 4 Nov 2021 16:39:48 +0100 Subject: [PATCH 906/966] Fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e86092c45f..26986d60c1 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,7 @@ massif-* # Generated documentation: /apidoc -# PSA Crypto compliance test repo, cloned by test_psa_complaince.py +# PSA Crypto compliance test repo, cloned by test_psa_compliance.py /psa-arch-tests # Editor navigation files: From fcb4fb71e3888edf257f86d92e394abac4be81b6 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 4 Nov 2021 17:33:51 +0100 Subject: [PATCH 907/966] Reorder linker flags Signed-off-by: Harmen Stoppels --- library/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Makefile b/library/Makefile index 6b02f77c18..01e85cf5b3 100644 --- a/library/Makefile +++ b/library/Makefile @@ -199,7 +199,7 @@ endif libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so echo " LD $@" - $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_TLS) -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) + $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_TLS) -L. -lmbedx509 -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) libmbedtls.so: libmbedtls.$(SOEXT_TLS) echo " LN $@ -> $<" @@ -207,11 +207,11 @@ libmbedtls.so: libmbedtls.$(SOEXT_TLS) libmbedtls.dylib: $(OBJS_TLS) libmbedx509.dylib echo " LD $@" - $(CC) -dynamiclib -o $@ $(OBJS_TLS) -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) + $(CC) -dynamiclib -o $@ $(OBJS_TLS) -L. -lmbedx509 -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll echo " LD $@" - $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -lmbedx509 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) + $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedx509 -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) # x509 libmbedx509.a: $(OBJS_X509) From 5398c10b897de8f4f29aa897484621b76748bea4 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 5 Nov 2021 13:32:38 +0800 Subject: [PATCH 908/966] Add return value check for cerificate verify Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 1 + tests/ssl-opt.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 45692d8771..75b11c93af 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -503,6 +503,7 @@ int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl ) cleanup: MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate verify" ) ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_process_certificate_verify", ret ); return( ret ); #else ((void) ssl); diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 037dfa5188..0e78356bc9 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8833,7 +8833,9 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "=> ssl_tls1_3_process_server_hello" \ -c "<= parse encrypted extensions" \ -c "Certificate verification flags clear" \ - -c "<= parse certificate verify" + -c "=> parse certificate verify" \ + -c "<= parse certificate verify" \ + -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" requires_gnutls_tls1_3 requires_gnutls_next_no_ticket @@ -8864,7 +8866,9 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "=> ssl_tls1_3_process_server_hello" \ -c "<= parse encrypted extensions" \ -c "Certificate verification flags clear" \ - -c "<= parse certificate verify" + -c "=> parse certificate verify" \ + -c "<= parse certificate verify" \ + -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From 3e636161eccd98c4d51cef4631bf2ae6a7c26170 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 5 Nov 2021 09:12:09 +0100 Subject: [PATCH 909/966] Add changelog Signed-off-by: Harmen Stoppels --- ChangeLog.d/fix-needed-shared-libraries-linux.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ChangeLog.d/fix-needed-shared-libraries-linux.txt diff --git a/ChangeLog.d/fix-needed-shared-libraries-linux.txt b/ChangeLog.d/fix-needed-shared-libraries-linux.txt new file mode 100644 index 0000000000..74ad3bc753 --- /dev/null +++ b/ChangeLog.d/fix-needed-shared-libraries-linux.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix issue in Makefile on Linux with SHARED=1, that caused shared libraries + not to list other shared libraries they need. From 15a56813a28814cc4132188dd233a8c11b2794de Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Fri, 5 Nov 2021 10:52:12 +0000 Subject: [PATCH 910/966] TLS1.3 Add hostname extention Signed-off-by: Xiaofei Bai --- library/ssl_cli.c | 9 +++++++++ library/ssl_misc.h | 7 +++++++ library/ssl_tls13_client.c | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 9fc8041262..f070b0fade 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -156,6 +156,15 @@ static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl, return( 0 ); } + +int mbedtls_ssl_write_hostname_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + const unsigned char *end, + size_t *olen ) +{ + return ssl_write_hostname_ext( ssl, buf, end, olen ); +} + #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ #if defined(MBEDTLS_SSL_RENEGOTIATION) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index c7d966bf2c..87347bf263 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1037,6 +1037,13 @@ void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl, void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl, mbedtls_ssl_transform *transform ); +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) +int mbedtls_ssl_write_hostname_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + const unsigned char *end, + size_t *olen ); +#endif + int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 9c8848454f..511f4cd289 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -798,6 +798,14 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + /* Write server name extention */ + ret = mbedtls_ssl_write_hostname_ext( ssl, p, end, &output_len ); + if( ret != 0 ) + return( ret ); + p += output_len; +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + /* Add more extensions here */ /* Write the length of the list of extensions. */ From 1ca80f7ca5fe9cc93849ee0cb1d7aa91baec6759 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 8 Nov 2021 10:30:54 +0800 Subject: [PATCH 911/966] fix comment issue Signed-off-by: Jerry Yu --- library/ssl_msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index 40eb57e223..fc3ecc8824 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -2562,8 +2562,8 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) * as it may change when using the CID extension. */ int minor_ver = ssl->minor_ver; #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - /* TLS 1.3 still uses the TLS 1.3 version identifier - * for backwards compatibility. */ + /* TLS 1.3 still uses the TLS 1.2 version identifier + * for backwards compatibility. */ if( minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) minor_ver = MBEDTLS_SSL_MINOR_VERSION_3; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From a1a568c2f6fa5f87889d972b92867c7517f88f5b Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 9 Nov 2021 10:17:21 +0800 Subject: [PATCH 912/966] fix various issues Signed-off-by: Jerry Yu --- library/ssl_msg.c | 1 - library/ssl_tls.c | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/library/ssl_msg.c b/library/ssl_msg.c index fc3ecc8824..3c7700bab3 100644 --- a/library/ssl_msg.c +++ b/library/ssl_msg.c @@ -5625,7 +5625,6 @@ static void ssl_buffering_free_slot( mbedtls_ssl_context *ssl, void mbedtls_ssl_write_version( int major, int minor, int transport, unsigned char ver[2] ) { - #if defined(MBEDTLS_SSL_PROTO_DTLS) if( transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 1929d8b3ee..d91f2312cf 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5478,12 +5478,10 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_ECDH_C && MBEDTLS_USE_PSA_CRYPTO */ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - mbedtls_ssl_transform_free(handshake->transform_handshake); - mbedtls_ssl_transform_free(handshake->transform_earlydata); + mbedtls_ssl_transform_free( handshake->transform_handshake ); + mbedtls_ssl_transform_free( handshake->transform_earlydata ); mbedtls_free( handshake->transform_earlydata ); mbedtls_free( handshake->transform_handshake ); - handshake->transform_earlydata = NULL; - handshake->transform_handshake = NULL; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ From 58afdba88727babbd9ebea002d60cc1fda7a72fd Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Tue, 9 Nov 2021 03:10:05 +0000 Subject: [PATCH 913/966] Fix typo and remove wrapper Signed-off-by: Xiaofei Bai --- library/ssl_cli.c | 17 ++++------------- library/ssl_tls13_client.c | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index f070b0fade..d871dba66b 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -89,10 +89,10 @@ static int ssl_conf_has_static_raw_psk( mbedtls_ssl_config const *conf ) #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */ #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) -static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - const unsigned char *end, - size_t *olen ) +int mbedtls_ssl_write_hostname_ext( mbedtls_ssl_context *ssl, + unsigned char *buf, + const unsigned char *end, + size_t *olen ) { unsigned char *p = buf; size_t hostname_len; @@ -156,15 +156,6 @@ static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl, return( 0 ); } - -int mbedtls_ssl_write_hostname_ext( mbedtls_ssl_context *ssl, - unsigned char *buf, - const unsigned char *end, - size_t *olen ) -{ - return ssl_write_hostname_ext( ssl, buf, end, olen ); -} - #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ #if defined(MBEDTLS_SSL_RENEGOTIATION) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 511f4cd289..5abb18c6c6 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -799,7 +799,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) - /* Write server name extention */ + /* Write server name extension */ ret = mbedtls_ssl_write_hostname_ext( ssl, p, end, &output_len ); if( ret != 0 ) return( ret ); From 6f435f07d2bac2fdcfafb5daec05e197f9aba309 Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Tue, 9 Nov 2021 04:08:32 +0000 Subject: [PATCH 914/966] Fix compile error Signed-off-by: Xiaofei Bai --- library/ssl_cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index d871dba66b..f3327b26c6 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -1168,10 +1168,10 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) - if( ( ret = ssl_write_hostname_ext( ssl, p + 2 + ext_len, + if( ( ret = mbedtls_ssl_write_hostname_ext( ssl, p + 2 + ext_len, end, &olen ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "ssl_write_hostname_ext", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_hostname_ext", ret ); return( ret ); } ext_len += olen; From f36e1677b12622da38864af4fc44936db33a7aba Mon Sep 17 00:00:00 2001 From: Xiaofei Bai Date: Tue, 9 Nov 2021 09:28:25 +0000 Subject: [PATCH 915/966] Fix alignment Signed-off-by: Xiaofei Bai --- library/ssl_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index f3327b26c6..8c5c0242be 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -1169,7 +1169,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) if( ( ret = mbedtls_ssl_write_hostname_ext( ssl, p + 2 + ext_len, - end, &olen ) ) != 0 ) + end, &olen ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_hostname_ext", ret ); return( ret ); From 729c24481933d2aead531a6f63fc274630c8b7fb Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Tue, 9 Nov 2021 14:40:12 +0100 Subject: [PATCH 916/966] test_case.py: add new line between test cases Signed-off-by: Przemyslaw Stekiel --- scripts/mbedtls_dev/test_case.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mbedtls_dev/test_case.py b/scripts/mbedtls_dev/test_case.py index 8ec2115461..6a46e4209b 100644 --- a/scripts/mbedtls_dev/test_case.py +++ b/scripts/mbedtls_dev/test_case.py @@ -81,7 +81,7 @@ class TestCase: out.write(self.description + '\n') if self.dependencies: out.write('depends_on:' + ':'.join(self.dependencies) + '\n') - out.write(self.function + ':' + ':'.join(self.arguments)) + out.write(self.function + ':' + ':'.join(self.arguments) + '\n') def write_data_file(filename: str, test_cases: Iterable[TestCase], From e2855c32b5d121efe4863782b6694761a600a848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 9 Nov 2021 17:33:57 +0100 Subject: [PATCH 917/966] Move to an updated fork of psa-arch-tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new fork was rebased on top of the upstream master, removing the need for most of the downstream patches we carried. On the other hand, the new fork includes a couple of fixes to problems that were not addressed by the original fork, or were introduced with the new version of psa-arch-tests. Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 2f67f08c88..58cb8f1a90 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -29,10 +29,18 @@ import subprocess import sys EXPECTED_FAILURES = { - 216, 221, 224, 225, 248, 249, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263 + 221, 224, 225, 252, 253, 254, 255, 256, 257, 258, 259, 261, 262, 263 } -PSA_ARCH_TESTS_REPO = 'https://github.com/ronald-cron-arm/psa-arch-tests.git' -PSA_ARCH_TESTS_REF = 'crypto1.0-3.0' + +# We currently use a fork of ARM-software/psa-arch-tests, with a couple of downstream patches +# that allow it to build with MbedTLS 3, and fixes a couple of issues in the compliance test suite. +# These fixes allow the tests numbered 216, 248 and 249 to complete successfully. +# +# Once all the fixes are upstreamed, this fork should be replaced with an upstream commit/tag. +# +# Web URL: https://github.com/bensze01/psa-arch-tests/tree/fixes-for-mbedtls-3 +PSA_ARCH_TESTS_REPO = 'https://github.com/bensze01/psa-arch-tests.git' +PSA_ARCH_TESTS_REF = 'fixes-for-mbedtls-3' #pylint: disable=too-many-branches,too-many-statements def main(): From cb288713264175dfab7987b67f1578b40803ca76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 9 Nov 2021 21:30:43 +0100 Subject: [PATCH 918/966] Document the values in EXPECTED_FAILURES MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Including the issues where the corresponding defects are tracked. Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 58cb8f1a90..31e3fce774 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -28,8 +28,28 @@ import shutil import subprocess import sys +# PSA Compliance tests we expect to fail due to known defects in Mbed TLS (or the test suite) +# The test numbers correspond to the numbers used by the console output of the test suite. +# Test number 2xx corresponds to the files in the folder +# psa-arch-tests/api-tests/dev_apis/crypto/test_c0xx EXPECTED_FAILURES = { - 221, 224, 225, 252, 253, 254, 255, 256, 257, 258, 259, 261, 262, 263 + # psa_key_derivation_output_key() returns PSA_ERROR_NOT_PERMITTED instead of + # PSA_ERROR_BAD_STATE when called after the operation was aborted. + # - Tracked in issue #5143 + 221, + + # psa_aead_[encrypt/decrypt]() returns PSA_ERROR_NOT_SUPPORTED instead of + # PSA_ERROR_INVALID_ARGUMENT when called with an invalid nonce. + # - Tracked in issue #5144 + 224, 225, + + # Multipart CCM is not supported. + # - Tracked in issue #3721 + 252, 253, 254, 255, 256, 257, 258, 259, 261, + + # psa_hash_suspend() and psa_hash_resume() are not supported. + # - Tracked in issue #3274 + 262, 263 } # We currently use a fork of ARM-software/psa-arch-tests, with a couple of downstream patches From b376eac5aca9b82659bc46f723c458bed02607ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 9 Nov 2021 22:13:46 +0100 Subject: [PATCH 919/966] Track upstreaming task in an issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 31e3fce774..2f6358132d 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -57,6 +57,7 @@ EXPECTED_FAILURES = { # These fixes allow the tests numbered 216, 248 and 249 to complete successfully. # # Once all the fixes are upstreamed, this fork should be replaced with an upstream commit/tag. +# - Tracked in issue #5145 # # Web URL: https://github.com/bensze01/psa-arch-tests/tree/fixes-for-mbedtls-3 PSA_ARCH_TESTS_REPO = 'https://github.com/bensze01/psa-arch-tests.git' From aa5f5c1f5d1256955a690f04613e03683467a875 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Sat, 18 Sep 2021 06:20:25 +0000 Subject: [PATCH 920/966] TLS1.3: Add server finish processing in client side Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 12 ++- library/ssl_misc.h | 103 +++++++++++++++++++ library/ssl_tls13_generic.c | 153 ++++++++++++++++++++++++++++ library/ssl_tls13_keys.c | 194 ++++++++++++++++++++++++++++++++++++ library/ssl_tls13_keys.h | 61 ++++++++++++ 5 files changed, 522 insertions(+), 1 deletion(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 5d04a115fa..3e10181253 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -39,7 +39,6 @@ #if defined(MBEDTLS_DHM_C) #include "mbedtls/dhm.h" #endif - /* Adding guard for MBEDTLS_ECDSA_C to ensure no compile errors due * to guards also being in ssl_srv.c and ssl_cli.c. There is a gap * in functionality that access to ecdh_ctx structure is needed for @@ -637,6 +636,7 @@ typedef enum MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET, MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT, #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + MBEDTLS_SSL_END_OF_EARLY_DATA, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS, MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY, #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ @@ -1050,6 +1050,14 @@ typedef void mbedtls_ssl_async_cancel_t( mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED && !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ +typedef struct +{ + unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; + unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; +} mbedtls_ssl_tls1_3_application_secrets; + #if defined(MBEDTLS_SSL_DTLS_SRTP) #define MBEDTLS_TLS_SRTP_MAX_MKI_LENGTH 255 @@ -1114,6 +1122,8 @@ struct mbedtls_ssl_session * to be studied whether one of them can be removed. */ unsigned char MBEDTLS_PRIVATE(minor_ver); /*!< The TLS version used in the session. */ + mbedtls_ssl_tls1_3_application_secrets MBEDTLS_PRIVATE(app_secrets); + #if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) mbedtls_x509_crt *MBEDTLS_PRIVATE(peer_cert); /*!< peer X.509 cert chain */ diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 23d5970d91..ae6cbfab5b 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -719,6 +719,104 @@ struct mbedtls_ssl_handshake_params * but can be overwritten by the HRR. */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + /* + * State-local variables used during the processing + * of a specific handshake state. + */ + union + { + /* Outgoing Finished message */ + struct + { + uint8_t preparation_done; + + /* Buffer holding digest of the handshake up to + * but excluding the outgoing finished message. */ + unsigned char digest[MBEDTLS_MD_MAX_SIZE]; + size_t digest_len; + } finished_out; + + /* Incoming Finished message */ + struct + { + /* Buffer holding digest of the handshake up to but + * excluding the peer's incoming finished message. */ + unsigned char digest[MBEDTLS_MD_MAX_SIZE]; + size_t digest_len; + } finished_in; + +#if defined(MBEDTLS_SSL_CLI_C) + + /* Client, incoming ServerKeyExchange */ + struct + { + uint8_t preparation_done; + } srv_key_exchange; + + /* Client, incoming ServerHello */ + struct + { +#if defined(MBEDTLS_SSL_RENEGOTIATION) + int renego_info_seen; +#else + int dummy; +#endif + } srv_hello_in; + + /* Client, outgoing ClientKeyExchange */ + struct + { + uint8_t preparation_done; + } cli_key_exch_out; + + /* Client, outgoing Certificate Verify */ + struct + { + uint8_t preparation_done; + } crt_vrfy_out; + + /* Client, outgoing ClientHello */ + struct + { + uint8_t preparation_done; + } cli_hello_out; + +#endif /* MBEDTLS_SSL_CLI_C */ + +#if defined(MBEDTLS_SSL_SRV_C) + + /* Server, outgoing ClientKeyExchange */ + struct + { + uint8_t preparation_done; + } cli_key_exch_in; + + /* Server, outgoing ClientKeyExchange */ + struct + { + uint8_t preparation_done; + } encrypted_extensions_out; + +#endif /* MBEDTLS_SSL_SRV_C */ + + /* Incoming CertificateVerify */ + struct + { + unsigned char verify_buffer[ 64 + 33 + 1 + MBEDTLS_MD_MAX_SIZE ]; + size_t verify_buffer_len; + } certificate_verify_in; + + /* Outgoing CertificateVerify */ + struct + { + unsigned char handshake_hash[ MBEDTLS_MD_MAX_SIZE ]; + size_t handshake_hash_len; + } certificate_verify_out; + + } state_local; + + /* End of state-local variables. */ + mbedtls_ssl_ciphersuite_t const *ciphersuite_info; size_t pmslen; /*!< premaster length */ @@ -1162,6 +1260,11 @@ static inline int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_read_certificate_process(mbedtls_ssl_context *ssl); +int mbedtls_ssl_write_certificate_process(mbedtls_ssl_context *ssl); +int mbedtls_ssl_tls1_3_finished_in_process( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls1_3_finished_out_process( mbedtls_ssl_context *ssl ); + int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 75b11c93af..c9bf78e6a7 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -845,6 +845,159 @@ cleanup: return( ret ); } +/* + * + * STATE HANDLING: Incoming Finished + * Overview + */ + +/* Main entry point: orchestrates the other functions */ +int mbedtls_ssl_tls1_3_finished_in_process( mbedtls_ssl_context* ssl ); + +static int ssl_finished_in_preprocess( mbedtls_ssl_context* ssl ); +static int ssl_finished_in_postprocess( mbedtls_ssl_context* ssl ); +static int ssl_finished_in_parse( mbedtls_ssl_context* ssl, + const unsigned char* buf, + size_t buflen ); + +/* + * Implementation + */ + +int mbedtls_ssl_tls1_3_finished_in_process( mbedtls_ssl_context* ssl ) +{ + int ret = 0; + unsigned char *buf; + size_t buflen; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished" ) ); + + /* Preprocessing step: Compute handshake digest */ + MBEDTLS_SSL_PROC_CHK( ssl_finished_in_preprocess( ssl ) ); + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, + MBEDTLS_SSL_HS_FINISHED, + &buf, &buflen ) ); + MBEDTLS_SSL_PROC_CHK( ssl_finished_in_parse( ssl, buf, buflen ) ); + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( + ssl, MBEDTLS_SSL_HS_FINISHED, buf, buflen ); + MBEDTLS_SSL_PROC_CHK( ssl_finished_in_postprocess( ssl ) ); + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse finished" ) ); + return( ret ); +} + +static int ssl_finished_in_preprocess( mbedtls_ssl_context* ssl ) +{ + int ret; + + ret = mbedtls_ssl_tls1_3_calc_finished( ssl, + ssl->handshake->state_local.finished_in.digest, + sizeof( ssl->handshake->state_local.finished_in.digest ), + &ssl->handshake->state_local.finished_in.digest_len, + ssl->conf->endpoint ^ 1 ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_calc_finished", ret ); + return( ret ); + } + + return( 0 ); +} + +static int ssl_finished_in_parse( mbedtls_ssl_context* ssl, + const unsigned char* buf, + size_t buflen ) +{ + /* Structural validation */ + if( buflen != ssl->handshake->state_local.finished_in.digest_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_ERR_SSL_DECODE_ERROR ); + return( MBEDTLS_ERR_SSL_DECODE_ERROR ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "Hash (self-computed):", + ssl->handshake->state_local.finished_in.digest, + ssl->handshake->state_local.finished_in.digest_len ); + MBEDTLS_SSL_DEBUG_BUF( 4, "Hash (received message):", buf, + ssl->handshake->state_local.finished_in.digest_len ); + + /* Semantic validation */ + if( mbedtls_ssl_safer_memcmp( buf, + ssl->handshake->state_local.finished_in.digest, + ssl->handshake->state_local.finished_in.digest_len ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); + + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + return( 0 ); +} + +static int ssl_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + mbedtls_ssl_key_set traffic_keys; + mbedtls_ssl_transform *transform_application; + + ret = mbedtls_ssl_tls1_3_key_schedule_stage_application( ssl ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, + "mbedtls_ssl_tls1_3_key_schedule_stage_application", ret ); + return( ret ); + } + + ret = mbedtls_ssl_tls1_3_generate_application_keys( + ssl, &traffic_keys ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, + "mbedtls_ssl_tls1_3_generate_application_keys", ret ); + return( ret ); + } + + transform_application = + mbedtls_calloc( 1, sizeof( mbedtls_ssl_transform ) ); + if( transform_application == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + + ret = mbedtls_ssl_tls13_populate_transform( + transform_application, + ssl->conf->endpoint, + ssl->session_negotiate->ciphersuite, + &traffic_keys, + ssl ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_populate_transform", ret ); + return( ret ); + } + + ssl->transform_application = transform_application; + + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_END_OF_EARLY_DATA ); + return( 0 ); +} + +static int ssl_finished_in_postprocess( mbedtls_ssl_context* ssl ) +{ + + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + { + return( ssl_finished_in_postprocess_cli( ssl ) ); + } + + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_TLS_C */ diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 96f5310797..010d6352da 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -564,6 +564,36 @@ int mbedtls_ssl_tls1_3_derive_resumption_master_secret( return( 0 ); } +int mbedtls_ssl_tls1_3_key_schedule_stage_application( + mbedtls_ssl_context *ssl ) +{ + int ret = 0; + mbedtls_md_type_t const md_type = ssl->handshake->ciphersuite_info->mac; +#if defined(MBEDTLS_DEBUG_C) + mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); + size_t const md_size = mbedtls_md_get_size( md_info ); +#endif /* MBEDTLS_DEBUG_C */ + + /* + * Compute MasterSecret + */ + + ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, + ssl->handshake->tls1_3_master_secrets.handshake, + NULL, 0, + ssl->handshake->tls1_3_master_secrets.app ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_evolve_secret", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "Master secret", + ssl->handshake->tls1_3_master_secrets.app, md_size ); + + return( 0 ); +} + static int ssl_tls1_3_calc_finished_core( mbedtls_md_type_t md_type, unsigned char const *base_key, unsigned char const *transcript, @@ -614,6 +644,54 @@ exit: return( ret ); } +int mbedtls_ssl_tls1_3_calc_finished( mbedtls_ssl_context* ssl, + unsigned char* dst, + size_t dst_len, + size_t *actual_len, + int from ) +{ + int ret; + + unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; + size_t transcript_len; + + unsigned char const *base_key = NULL; + + mbedtls_md_type_t const md_type = ssl->handshake->ciphersuite_info->mac; + const mbedtls_md_info_t* const md = mbedtls_md_info_from_type( md_type ); + size_t const md_size = mbedtls_md_get_size( md ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls1_3_calc_finished" ) ); + + if( dst_len < md_size ) + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + + ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type, + transcript, sizeof( transcript ), + &transcript_len ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_get_handshake_transcript", ret ); + return( ret ); + } + MBEDTLS_SSL_DEBUG_BUF( 4, "handshake hash", transcript, transcript_len ); + + if( from == MBEDTLS_SSL_IS_CLIENT ) + base_key = ssl->handshake->tls1_3_hs_secrets.client_handshake_traffic_secret; + else + base_key = ssl->handshake->tls1_3_hs_secrets.server_handshake_traffic_secret; + + ret = ssl_tls1_3_calc_finished_core( md_type, base_key, transcript, dst ); + if( ret != 0 ) + return( ret ); + *actual_len = md_size; + + MBEDTLS_SSL_DEBUG_BUF( 3, "verify_data for finished message", dst, md_size ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls1_3_calc_finished" ) ); + return( 0 ); +} + int mbedtls_ssl_tls1_3_create_psk_binder( mbedtls_ssl_context *ssl, const mbedtls_md_type_t md_type, unsigned char const *psk, size_t psk_len, @@ -1028,4 +1106,120 @@ int mbedtls_ssl_tls13_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) return( 0 ); } +/* Generate application traffic keys since any records following a 1-RTT Finished message + * MUST be encrypted under the application traffic key. + */ +int mbedtls_ssl_tls1_3_generate_application_keys( + mbedtls_ssl_context *ssl, + mbedtls_ssl_key_set *traffic_keys ) +{ + int ret = 0; + + /* Address at which to store the application secrets */ + mbedtls_ssl_tls1_3_application_secrets * const app_secrets = + &ssl->session_negotiate->app_secrets; + + /* Holding the transcript up to and including the ServerFinished */ + unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; + size_t transcript_len; + + /* Variables relating to the hash for the chosen ciphersuite. */ + mbedtls_md_type_t md_type; + mbedtls_md_info_t const *md_info; + size_t md_size; + + /* Variables relating to the cipher for the chosen ciphersuite. */ + mbedtls_cipher_info_t const *cipher_info; + size_t keylen, ivlen; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> derive application traffic keys" ) ); + + /* Extract basic information about hash and ciphersuite */ + + cipher_info = mbedtls_cipher_info_from_type( + ssl->handshake->ciphersuite_info->cipher ); + keylen = cipher_info->key_bitlen / 8; + ivlen = cipher_info->iv_size; + + md_type = ssl->handshake->ciphersuite_info->mac; + md_info = mbedtls_md_info_from_type( md_type ); + md_size = mbedtls_md_get_size( md_info ); + + /* Compute current handshake transcript. It's the caller's responsiblity + * to call this at the right time, that is, after the ServerFinished. */ + + ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type, + transcript, sizeof( transcript ), + &transcript_len ); + if( ret != 0 ) + return( ret ); + + /* Compute application secrets from master secret and transcript hash. */ + + ret = mbedtls_ssl_tls1_3_derive_application_secrets( md_type, + ssl->handshake->tls1_3_master_secrets.app, + transcript, transcript_len, + app_secrets ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, + "mbedtls_ssl_tls1_3_derive_application_secrets", ret ); + return( ret ); + } + + /* Derive first epoch of IV + Key for application traffic. */ + + ret = mbedtls_ssl_tls1_3_make_traffic_keys( md_type, + app_secrets->client_application_traffic_secret_N, + app_secrets->server_application_traffic_secret_N, + md_size, keylen, ivlen, traffic_keys ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_make_traffic_keys", ret ); + return( ret ); + } + + MBEDTLS_SSL_DEBUG_BUF( 4, "Client application traffic secret", + app_secrets->client_application_traffic_secret_N, + md_size ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "Server application traffic secret", + app_secrets->server_application_traffic_secret_N, + md_size ); + + /* + * Export client/server application traffic secret 0 + */ +#if defined(MBEDTLS_SSL_EXPORT_KEYS) + if( ssl->f_export_keys != NULL ) + { + ssl->f_export_keys( ssl->p_export_keys, + MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_APPLICATION_TRAFFIC_SECRET, + app_secrets->client_application_traffic_secret_N, md_size, + ssl->handshake->randbytes + 32, + ssl->handshake->randbytes, + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + + ssl->f_export_keys( ssl->p_export_keys, + MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_APPLICATION_TRAFFIC_SECRET, + app_secrets->server_application_traffic_secret_N, md_size, + ssl->handshake->randbytes + 32, + ssl->handshake->randbytes, + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + } +#endif /* MBEDTLS_SSL_EXPORT_KEYS */ + + MBEDTLS_SSL_DEBUG_BUF( 4, "client application_write_key:", + traffic_keys->client_write_key, keylen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "server application write key", + traffic_keys->server_write_key, keylen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "client application write IV", + traffic_keys->client_write_iv, ivlen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "server application write IV", + traffic_keys->server_write_iv, ivlen ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= derive application traffic keys" ) ); + return( 0 ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 165b58a2d4..78bfc2a3d6 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -570,4 +570,65 @@ int mbedtls_ssl_tls13_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ); int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, mbedtls_ssl_key_set *traffic_keys ); +/** + * \brief Transition into application stage of TLS 1.3 key schedule. + * + * The TLS 1.3 key schedule can be viewed as a simple state machine + * with states Initial -> Early -> Handshake -> Application, and + * this function represents the Handshake -> Application transition. + * + * In the handshake stage, mbedtls_ssl_tls1_3_generate_application_keys() + * can be used to derive the handshake traffic keys. + * + * \param ssl The SSL context to operate on. This must be in key schedule + * stage \c Handshake. + * + * \returns \c 0 on success. + * \returns A negative error code on failure. + */ +int mbedtls_ssl_tls1_3_key_schedule_stage_application( + mbedtls_ssl_context *ssl ); + +/** + * \brief Compute TLS 1.3 application traffic keys. + * + * \param ssl The SSL context to operate on. This must be in + * key schedule stage \c Application, see + * mbedtls_ssl_tls1_3_key_schedule_stage_application(). + * \param traffic_keys The address at which to store the application traffic key + * keys. This must be writable but may be uninitialized. + * + * \returns \c 0 on success. + * \returns A negative error code on failure. + */ +int mbedtls_ssl_tls1_3_generate_application_keys( + mbedtls_ssl_context* ssl, mbedtls_ssl_key_set *traffic_keys ); + +/** + * \brief Calculate content of TLS 1.3 Finished message. + * + * \param ssl The SSL context to operate on. This must be in + * key schedule stage \c Handshake, see + * mbedtls_ssl_tls1_3_key_schedule_stage_application(). + * \param dst The address at which to write the Finished content. + * \param dst_len The size of \p dst in bytes. + * \param actual_len The address at which to store the amount of data + * actually written to \p dst upon success. + * \param from The endpoint the Finished message originates from: + * - #MBEDTLS_SSL_IS_CLIENT for the Client's Finished message + * - #MBEDTLS_SSL_IS_SERVER for the Server's Finished message + * + * \note Both client and server call this function twice, once to + * generate their own Finished message, and once to verify the + * peer's Finished message. + + * \returns \c 0 on success. + * \returns A negative error code on failure. + */ +int mbedtls_ssl_tls1_3_calc_finished( mbedtls_ssl_context *ssl, + unsigned char *dst, + size_t dst_len, + size_t *actual_len, + int from ); + #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From 4cab0240c77b97e94840f07fd1b904073ef6a695 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 12 Oct 2021 08:43:37 +0000 Subject: [PATCH 921/966] Change coding style Signed-off-by: XiaokangQian --- library/ssl_misc.h | 21 +++------------------ library/ssl_tls13_client.c | 4 +--- library/ssl_tls13_generic.c | 30 +++++++++++++++--------------- library/ssl_tls13_keys.c | 24 +++++++++++++++++------- library/ssl_tls13_keys.h | 6 +++--- 5 files changed, 39 insertions(+), 46 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index ae6cbfab5b..3b0d61b35c 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -783,22 +783,6 @@ struct mbedtls_ssl_handshake_params #endif /* MBEDTLS_SSL_CLI_C */ -#if defined(MBEDTLS_SSL_SRV_C) - - /* Server, outgoing ClientKeyExchange */ - struct - { - uint8_t preparation_done; - } cli_key_exch_in; - - /* Server, outgoing ClientKeyExchange */ - struct - { - uint8_t preparation_done; - } encrypted_extensions_out; - -#endif /* MBEDTLS_SSL_SRV_C */ - /* Incoming CertificateVerify */ struct { @@ -1262,8 +1246,9 @@ int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); int mbedtls_ssl_read_certificate_process(mbedtls_ssl_context *ssl); int mbedtls_ssl_write_certificate_process(mbedtls_ssl_context *ssl); -int mbedtls_ssl_tls1_3_finished_in_process( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls1_3_finished_out_process( mbedtls_ssl_context *ssl ); + +int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_finished_out_process( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index e36e28d9d7..2bde4a8252 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1605,9 +1605,7 @@ static int ssl_tls1_3_process_certificate_verify( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE ); - return( 0 ); + return ( mbedtls_ssl_tls13_finished_in_process( ssl ) ); } /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index c9bf78e6a7..87bc12ce24 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -852,11 +852,11 @@ cleanup: */ /* Main entry point: orchestrates the other functions */ -int mbedtls_ssl_tls1_3_finished_in_process( mbedtls_ssl_context* ssl ); +int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context* ssl ); -static int ssl_finished_in_preprocess( mbedtls_ssl_context* ssl ); -static int ssl_finished_in_postprocess( mbedtls_ssl_context* ssl ); -static int ssl_finished_in_parse( mbedtls_ssl_context* ssl, +static int ssl_tls13_finished_in_preprocess( mbedtls_ssl_context* ssl ); +static int ssl_tls13_finished_in_postprocess( mbedtls_ssl_context* ssl ); +static int ssl_tls13_finished_in_parse( mbedtls_ssl_context* ssl, const unsigned char* buf, size_t buflen ); @@ -864,7 +864,7 @@ static int ssl_finished_in_parse( mbedtls_ssl_context* ssl, * Implementation */ -int mbedtls_ssl_tls1_3_finished_in_process( mbedtls_ssl_context* ssl ) +int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context* ssl ) { int ret = 0; unsigned char *buf; @@ -873,15 +873,15 @@ int mbedtls_ssl_tls1_3_finished_in_process( mbedtls_ssl_context* ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished" ) ); /* Preprocessing step: Compute handshake digest */ - MBEDTLS_SSL_PROC_CHK( ssl_finished_in_preprocess( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finished_in_preprocess( ssl ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, MBEDTLS_SSL_HS_FINISHED, &buf, &buflen ) ); - MBEDTLS_SSL_PROC_CHK( ssl_finished_in_parse( ssl, buf, buflen ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finished_in_parse( ssl, buf, buflen ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, buf, buflen ); - MBEDTLS_SSL_PROC_CHK( ssl_finished_in_postprocess( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finished_in_postprocess( ssl ) ); cleanup: @@ -889,7 +889,7 @@ cleanup: return( ret ); } -static int ssl_finished_in_preprocess( mbedtls_ssl_context* ssl ) +static int ssl_tls13_finished_in_preprocess( mbedtls_ssl_context* ssl ) { int ret; @@ -907,7 +907,7 @@ static int ssl_finished_in_preprocess( mbedtls_ssl_context* ssl ) return( 0 ); } -static int ssl_finished_in_parse( mbedtls_ssl_context* ssl, +static int ssl_tls13_finished_in_parse( mbedtls_ssl_context* ssl, const unsigned char* buf, size_t buflen ) { @@ -941,17 +941,17 @@ static int ssl_finished_in_parse( mbedtls_ssl_context* ssl, return( 0 ); } -static int ssl_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) +static int ssl_tls13_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) { int ret = 0; mbedtls_ssl_key_set traffic_keys; mbedtls_ssl_transform *transform_application; - ret = mbedtls_ssl_tls1_3_key_schedule_stage_application( ssl ); + ret = mbedtls_ssl_tls13_key_schedule_stage_application( ssl ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, - "mbedtls_ssl_tls1_3_key_schedule_stage_application", ret ); + "mbedtls_ssl_tls13_key_schedule_stage_application", ret ); return( ret ); } @@ -987,12 +987,12 @@ static int ssl_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) return( 0 ); } -static int ssl_finished_in_postprocess( mbedtls_ssl_context* ssl ) +static int ssl_tls13_finished_in_postprocess( mbedtls_ssl_context* ssl ) { if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { - return( ssl_finished_in_postprocess_cli( ssl ) ); + return( ssl_tls13_finished_in_postprocess_cli( ssl ) ); } return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 010d6352da..ddbeb626ea 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -564,7 +564,7 @@ int mbedtls_ssl_tls1_3_derive_resumption_master_secret( return( 0 ); } -int mbedtls_ssl_tls1_3_key_schedule_stage_application( +int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ) { int ret = 0; @@ -577,7 +577,6 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_application( /* * Compute MasterSecret */ - ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, ssl->handshake->tls1_3_master_secrets.handshake, NULL, 0, @@ -687,7 +686,6 @@ int mbedtls_ssl_tls1_3_calc_finished( mbedtls_ssl_context* ssl, *actual_len = md_size; MBEDTLS_SSL_DEBUG_BUF( 3, "verify_data for finished message", dst, md_size ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls1_3_calc_finished" ) ); return( 0 ); } @@ -1152,7 +1150,7 @@ int mbedtls_ssl_tls1_3_generate_application_keys( transcript, sizeof( transcript ), &transcript_len ); if( ret != 0 ) - return( ret ); + goto cleanup; /* Compute application secrets from master secret and transcript hash. */ @@ -1164,7 +1162,7 @@ int mbedtls_ssl_tls1_3_generate_application_keys( { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_derive_application_secrets", ret ); - return( ret ); + goto cleanup; } /* Derive first epoch of IV + Key for application traffic. */ @@ -1176,7 +1174,7 @@ int mbedtls_ssl_tls1_3_generate_application_keys( if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_make_traffic_keys", ret ); - return( ret ); + goto cleanup; } MBEDTLS_SSL_DEBUG_BUF( 4, "Client application traffic secret", @@ -1219,7 +1217,19 @@ int mbedtls_ssl_tls1_3_generate_application_keys( traffic_keys->server_write_iv, ivlen ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= derive application traffic keys" ) ); - return( 0 ); + + cleanup: + + mbedtls_platform_zeroize( transcript, sizeof(transcript) ); + mbedtls_platform_zeroize( traffic_keys->client_write_key, + sizeof(traffic_keys->client_write_key) ); + mbedtls_platform_zeroize( traffic_keys->server_write_key, + sizeof(traffic_keys->server_write_key) ); + mbedtls_platform_zeroize( traffic_keys->client_write_iv, + sizeof(traffic_keys->client_write_iv) ); + mbedtls_platform_zeroize( traffic_keys->server_write_iv, + sizeof(traffic_keys->server_write_iv) ); + return( ret ); } #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 78bfc2a3d6..31a5029b42 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -586,7 +586,7 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls1_3_key_schedule_stage_application( +int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ); /** @@ -594,7 +594,7 @@ int mbedtls_ssl_tls1_3_key_schedule_stage_application( * * \param ssl The SSL context to operate on. This must be in * key schedule stage \c Application, see - * mbedtls_ssl_tls1_3_key_schedule_stage_application(). + * mbedtls_ssl_tls13_key_schedule_stage_application(). * \param traffic_keys The address at which to store the application traffic key * keys. This must be writable but may be uninitialized. * @@ -609,7 +609,7 @@ int mbedtls_ssl_tls1_3_generate_application_keys( * * \param ssl The SSL context to operate on. This must be in * key schedule stage \c Handshake, see - * mbedtls_ssl_tls1_3_key_schedule_stage_application(). + * mbedtls_ssl_tls13_key_schedule_stage_application(). * \param dst The address at which to write the Finished content. * \param dst_len The size of \p dst in bytes. * \param actual_len The address at which to store the amount of data From a763498490601288b651f3f3843d06cd17a1693a Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Fri, 22 Oct 2021 06:32:32 +0000 Subject: [PATCH 922/966] Change code based on commetns Focus on the code style, naming rule,etc. Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 9 +++++++-- library/ssl_tls13_generic.c | 8 ++++---- library/ssl_tls13_keys.c | 16 ++++++++-------- library/ssl_tls13_keys.h | 6 +++--- tests/suites/test_suite_ssl.function | 4 ++-- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 3e10181253..b88351f90e 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -39,6 +39,7 @@ #if defined(MBEDTLS_DHM_C) #include "mbedtls/dhm.h" #endif + /* Adding guard for MBEDTLS_ECDSA_C to ensure no compile errors due * to guards also being in ssl_srv.c and ssl_cli.c. There is a gap * in functionality that access to ecdh_ctx structure is needed for @@ -1050,13 +1051,15 @@ typedef void mbedtls_ssl_async_cancel_t( mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED && !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) typedef struct { unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_application_secrets; +} mbedtls_ssl_tls13_application_secrets; +#endif #if defined(MBEDTLS_SSL_DTLS_SRTP) @@ -1122,7 +1125,9 @@ struct mbedtls_ssl_session * to be studied whether one of them can be removed. */ unsigned char MBEDTLS_PRIVATE(minor_ver); /*!< The TLS version used in the session. */ - mbedtls_ssl_tls1_3_application_secrets MBEDTLS_PRIVATE(app_secrets); +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + mbedtls_ssl_tls13_application_secrets MBEDTLS_PRIVATE(app_secrets); +#endif #if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 87bc12ce24..1d41cd3d39 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -870,7 +870,7 @@ int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context* ssl ) unsigned char *buf; size_t buflen; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server finished_in_process" ) ); /* Preprocessing step: Compute handshake digest */ MBEDTLS_SSL_PROC_CHK( ssl_tls13_finished_in_preprocess( ssl ) ); @@ -885,7 +885,7 @@ int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context* ssl ) cleanup: - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse finished" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse server finished_in_process" ) ); return( ret ); } @@ -893,14 +893,14 @@ static int ssl_tls13_finished_in_preprocess( mbedtls_ssl_context* ssl ) { int ret; - ret = mbedtls_ssl_tls1_3_calc_finished( ssl, + ret = mbedtls_ssl_tls1_3_calculate_expected_finished( ssl, ssl->handshake->state_local.finished_in.digest, sizeof( ssl->handshake->state_local.finished_in.digest ), &ssl->handshake->state_local.finished_in.digest_len, ssl->conf->endpoint ^ 1 ); if( ret != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_calc_finished", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_calculate_expected_finished", ret ); return( ret ); } diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index ddbeb626ea..85026f5384 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -469,7 +469,7 @@ int mbedtls_ssl_tls1_3_derive_application_secrets( mbedtls_md_type_t md_type, unsigned char const *application_secret, unsigned char const *transcript, size_t transcript_len, - mbedtls_ssl_tls1_3_application_secrets *derived ) + mbedtls_ssl_tls13_application_secrets *derived ) { int ret; mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); @@ -539,7 +539,7 @@ int mbedtls_ssl_tls1_3_derive_resumption_master_secret( mbedtls_md_type_t md_type, unsigned char const *application_secret, unsigned char const *transcript, size_t transcript_len, - mbedtls_ssl_tls1_3_application_secrets *derived ) + mbedtls_ssl_tls13_application_secrets *derived ) { int ret; mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); @@ -643,13 +643,13 @@ exit: return( ret ); } -int mbedtls_ssl_tls1_3_calc_finished( mbedtls_ssl_context* ssl, +int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context* ssl, unsigned char* dst, size_t dst_len, size_t *actual_len, int from ) { - int ret; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; size_t transcript_len; @@ -660,7 +660,7 @@ int mbedtls_ssl_tls1_3_calc_finished( mbedtls_ssl_context* ssl, const mbedtls_md_info_t* const md = mbedtls_md_info_from_type( md_type ); size_t const md_size = mbedtls_md_get_size( md ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls1_3_calc_finished" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls1_3_calculate_expected_finished" ) ); if( dst_len < md_size ) return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); @@ -686,7 +686,7 @@ int mbedtls_ssl_tls1_3_calc_finished( mbedtls_ssl_context* ssl, *actual_len = md_size; MBEDTLS_SSL_DEBUG_BUF( 3, "verify_data for finished message", dst, md_size ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls1_3_calc_finished" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls1_3_calculate_expected_finished" ) ); return( 0 ); } @@ -1111,10 +1111,10 @@ int mbedtls_ssl_tls1_3_generate_application_keys( mbedtls_ssl_context *ssl, mbedtls_ssl_key_set *traffic_keys ) { - int ret = 0; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; /* Address at which to store the application secrets */ - mbedtls_ssl_tls1_3_application_secrets * const app_secrets = + mbedtls_ssl_tls13_application_secrets * const app_secrets = &ssl->session_negotiate->app_secrets; /* Holding the transcript up to and including the ServerFinished */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 31a5029b42..2509cffd59 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -344,7 +344,7 @@ int mbedtls_ssl_tls1_3_derive_application_secrets( mbedtls_md_type_t md_type, unsigned char const *master_secret, unsigned char const *transcript, size_t transcript_len, - mbedtls_ssl_tls1_3_application_secrets *derived ); + mbedtls_ssl_tls13_application_secrets *derived ); /** * \brief Derive TLS 1.3 resumption master secret from the master secret. @@ -374,7 +374,7 @@ int mbedtls_ssl_tls1_3_derive_resumption_master_secret( mbedtls_md_type_t md_type, unsigned char const *application_secret, unsigned char const *transcript, size_t transcript_len, - mbedtls_ssl_tls1_3_application_secrets *derived ); + mbedtls_ssl_tls13_application_secrets *derived ); /** * \brief Compute the next secret in the TLS 1.3 key schedule @@ -625,7 +625,7 @@ int mbedtls_ssl_tls1_3_generate_application_keys( * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls1_3_calc_finished( mbedtls_ssl_context *ssl, +int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context *ssl, unsigned char *dst, size_t dst_len, size_t *actual_len, diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 75eda1dcd2..6d262cee26 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -3862,7 +3862,7 @@ void ssl_tls1_3_derive_application_secrets( int hash_alg, data_t *server_expected, data_t *exporter_expected ) { - mbedtls_ssl_tls1_3_application_secrets secrets; + mbedtls_ssl_tls13_application_secrets secrets; /* Double-check that we've passed sane parameters. */ mbedtls_md_type_t md_type = (mbedtls_md_type_t) hash_alg; @@ -3894,7 +3894,7 @@ void ssl_tls1_3_derive_resumption_secrets( int hash_alg, data_t *transcript, data_t *resumption_expected ) { - mbedtls_ssl_tls1_3_application_secrets secrets; + mbedtls_ssl_tls13_application_secrets secrets; /* Double-check that we've passed sane parameters. */ mbedtls_md_type_t md_type = (mbedtls_md_type_t) hash_alg; From 46c6fc74f19b5d742d4704013509a40bb2d7e01d Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Fri, 22 Oct 2021 10:20:28 +0000 Subject: [PATCH 923/966] Fix compile issue about MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL Signed-off-by: XiaokangQian --- library/ssl_tls13_keys.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 2509cffd59..1e6fff58bf 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -19,6 +19,7 @@ #if !defined(MBEDTLS_SSL_TLS1_3_KEYS_H) #define MBEDTLS_SSL_TLS1_3_KEYS_H +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) /* This requires MBEDTLS_SSL_TLS1_3_LABEL( idx, name, string ) to be defined at * the point of use. See e.g. the definition of mbedtls_ssl_tls1_3_labels_union * below. */ @@ -631,4 +632,5 @@ int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context *ssl, size_t *actual_len, int from ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From 7c91705e21b9a39116c7bf0c4ef6e1a357cd7751 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 25 Oct 2021 06:17:12 +0000 Subject: [PATCH 924/966] Remove support for MBEDTLS_SSL_EXPORT_KEYS Signed-off-by: XiaokangQian --- library/ssl_tls13_keys.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 85026f5384..54a9275284 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -1185,28 +1185,6 @@ int mbedtls_ssl_tls1_3_generate_application_keys( app_secrets->server_application_traffic_secret_N, md_size ); - /* - * Export client/server application traffic secret 0 - */ -#if defined(MBEDTLS_SSL_EXPORT_KEYS) - if( ssl->f_export_keys != NULL ) - { - ssl->f_export_keys( ssl->p_export_keys, - MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_APPLICATION_TRAFFIC_SECRET, - app_secrets->client_application_traffic_secret_N, md_size, - ssl->handshake->randbytes + 32, - ssl->handshake->randbytes, - MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); - - ssl->f_export_keys( ssl->p_export_keys, - MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_APPLICATION_TRAFFIC_SECRET, - app_secrets->server_application_traffic_secret_N, md_size, - ssl->handshake->randbytes + 32, - ssl->handshake->randbytes, - MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); - } -#endif /* MBEDTLS_SSL_EXPORT_KEYS */ - MBEDTLS_SSL_DEBUG_BUF( 4, "client application_write_key:", traffic_keys->client_write_key, keylen ); MBEDTLS_SSL_DEBUG_BUF( 4, "server application write key", From f13c56032f32f7a7e1a68de0d271e500a338bfac Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 26 Oct 2021 10:22:25 +0000 Subject: [PATCH 925/966] Revert some changes about tls13 and macros There is one PR #4988 to change it in the future Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 8 ++------ library/ssl_tls13_keys.c | 6 +++--- library/ssl_tls13_keys.h | 6 ++---- tests/suites/test_suite_ssl.function | 4 ++-- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index b88351f90e..ed6a445c22 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1051,15 +1051,13 @@ typedef void mbedtls_ssl_async_cancel_t( mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED && !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) typedef struct { unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; -} mbedtls_ssl_tls13_application_secrets; -#endif +} mbedtls_ssl_tls1_3_application_secrets; #if defined(MBEDTLS_SSL_DTLS_SRTP) @@ -1125,9 +1123,7 @@ struct mbedtls_ssl_session * to be studied whether one of them can be removed. */ unsigned char MBEDTLS_PRIVATE(minor_ver); /*!< The TLS version used in the session. */ -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - mbedtls_ssl_tls13_application_secrets MBEDTLS_PRIVATE(app_secrets); -#endif + mbedtls_ssl_tls1_3_application_secrets MBEDTLS_PRIVATE(app_secrets); #if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 54a9275284..2127393fc9 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -469,7 +469,7 @@ int mbedtls_ssl_tls1_3_derive_application_secrets( mbedtls_md_type_t md_type, unsigned char const *application_secret, unsigned char const *transcript, size_t transcript_len, - mbedtls_ssl_tls13_application_secrets *derived ) + mbedtls_ssl_tls1_3_application_secrets *derived ) { int ret; mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); @@ -539,7 +539,7 @@ int mbedtls_ssl_tls1_3_derive_resumption_master_secret( mbedtls_md_type_t md_type, unsigned char const *application_secret, unsigned char const *transcript, size_t transcript_len, - mbedtls_ssl_tls13_application_secrets *derived ) + mbedtls_ssl_tls1_3_application_secrets *derived ) { int ret; mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); @@ -1114,7 +1114,7 @@ int mbedtls_ssl_tls1_3_generate_application_keys( int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; /* Address at which to store the application secrets */ - mbedtls_ssl_tls13_application_secrets * const app_secrets = + mbedtls_ssl_tls1_3_application_secrets * const app_secrets = &ssl->session_negotiate->app_secrets; /* Holding the transcript up to and including the ServerFinished */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 1e6fff58bf..e96cfc10c2 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -19,7 +19,6 @@ #if !defined(MBEDTLS_SSL_TLS1_3_KEYS_H) #define MBEDTLS_SSL_TLS1_3_KEYS_H -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) /* This requires MBEDTLS_SSL_TLS1_3_LABEL( idx, name, string ) to be defined at * the point of use. See e.g. the definition of mbedtls_ssl_tls1_3_labels_union * below. */ @@ -345,7 +344,7 @@ int mbedtls_ssl_tls1_3_derive_application_secrets( mbedtls_md_type_t md_type, unsigned char const *master_secret, unsigned char const *transcript, size_t transcript_len, - mbedtls_ssl_tls13_application_secrets *derived ); + mbedtls_ssl_tls1_3_application_secrets *derived ); /** * \brief Derive TLS 1.3 resumption master secret from the master secret. @@ -375,7 +374,7 @@ int mbedtls_ssl_tls1_3_derive_resumption_master_secret( mbedtls_md_type_t md_type, unsigned char const *application_secret, unsigned char const *transcript, size_t transcript_len, - mbedtls_ssl_tls13_application_secrets *derived ); + mbedtls_ssl_tls1_3_application_secrets *derived ); /** * \brief Compute the next secret in the TLS 1.3 key schedule @@ -632,5 +631,4 @@ int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context *ssl, size_t *actual_len, int from ); -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 6d262cee26..75eda1dcd2 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -3862,7 +3862,7 @@ void ssl_tls1_3_derive_application_secrets( int hash_alg, data_t *server_expected, data_t *exporter_expected ) { - mbedtls_ssl_tls13_application_secrets secrets; + mbedtls_ssl_tls1_3_application_secrets secrets; /* Double-check that we've passed sane parameters. */ mbedtls_md_type_t md_type = (mbedtls_md_type_t) hash_alg; @@ -3894,7 +3894,7 @@ void ssl_tls1_3_derive_resumption_secrets( int hash_alg, data_t *transcript, data_t *resumption_expected ) { - mbedtls_ssl_tls13_application_secrets secrets; + mbedtls_ssl_tls1_3_application_secrets secrets; /* Double-check that we've passed sane parameters. */ mbedtls_md_type_t md_type = (mbedtls_md_type_t) hash_alg; From f26f6ade0c650dded604bd3350460593cb2ae77f Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 28 Oct 2021 05:50:31 +0000 Subject: [PATCH 926/966] Rebase and solve conflicts Remove the double definition and change name Signed-off-by: XiaokangQian --- library/ssl_misc.h | 8 -------- library/ssl_tls13_keys.c | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 3b0d61b35c..7044769a2a 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -522,14 +522,6 @@ typedef struct unsigned char server_handshake_traffic_secret[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; } mbedtls_ssl_tls1_3_handshake_secrets; -typedef struct -{ - unsigned char client_application_traffic_secret_N[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; - unsigned char server_application_traffic_secret_N[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; - unsigned char exporter_master_secret [ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; - unsigned char resumption_master_secret [ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; -} mbedtls_ssl_tls1_3_application_secrets; - /* * This structure contains the parameters only needed during handshake. */ diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 2127393fc9..5bd3e47196 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -676,9 +676,9 @@ int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context* ssl, MBEDTLS_SSL_DEBUG_BUF( 4, "handshake hash", transcript, transcript_len ); if( from == MBEDTLS_SSL_IS_CLIENT ) - base_key = ssl->handshake->tls1_3_hs_secrets.client_handshake_traffic_secret; + base_key = ssl->handshake->tls13_hs_secrets.client_handshake_traffic_secret; else - base_key = ssl->handshake->tls1_3_hs_secrets.server_handshake_traffic_secret; + base_key = ssl->handshake->tls13_hs_secrets.server_handshake_traffic_secret; ret = ssl_tls1_3_calc_finished_core( md_type, base_key, transcript, dst ); if( ret != 0 ) From 61bdbbc18b4da3cd20cdf7bc8b80031d4240513b Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 28 Oct 2021 08:03:38 +0000 Subject: [PATCH 927/966] Add cleanup in functions for secure reason Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 24 +++++++++++++++++++----- library/ssl_tls13_keys.c | 20 ++++++++------------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 1d41cd3d39..dd550f7721 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -952,7 +952,7 @@ static int ssl_tls13_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_key_schedule_stage_application", ret ); - return( ret ); + goto cleanup; } ret = mbedtls_ssl_tls1_3_generate_application_keys( @@ -961,13 +961,16 @@ static int ssl_tls13_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_generate_application_keys", ret ); - return( ret ); + goto cleanup; } transform_application = mbedtls_calloc( 1, sizeof( mbedtls_ssl_transform ) ); if( transform_application == NULL ) - return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + { + ret = MBEDTLS_ERR_SSL_ALLOC_FAILED; + goto cleanup; + } ret = mbedtls_ssl_tls13_populate_transform( transform_application, @@ -978,13 +981,24 @@ static int ssl_tls13_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_populate_transform", ret ); - return( ret ); + goto cleanup; } ssl->transform_application = transform_application; mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_END_OF_EARLY_DATA ); - return( 0 ); + +cleanup: + + mbedtls_platform_zeroize( &traffic_keys, sizeof(mbedtls_ssl_key_set) ); + if( ret != 0) + { + mbedtls_free( transform_application ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } + return( ret ); } static int ssl_tls13_finished_in_postprocess( mbedtls_ssl_context* ssl ) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 5bd3e47196..34d8a19df2 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -567,7 +567,7 @@ int mbedtls_ssl_tls1_3_derive_resumption_master_secret( int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ) { - int ret = 0; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; mbedtls_md_type_t const md_type = ssl->handshake->ciphersuite_info->mac; #if defined(MBEDTLS_DEBUG_C) mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); @@ -671,7 +671,7 @@ int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context* ssl, if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_get_handshake_transcript", ret ); - return( ret ); + goto exit; } MBEDTLS_SSL_DEBUG_BUF( 4, "handshake hash", transcript, transcript_len ); @@ -682,12 +682,16 @@ int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context* ssl, ret = ssl_tls1_3_calc_finished_core( md_type, base_key, transcript, dst ); if( ret != 0 ) - return( ret ); + goto exit; *actual_len = md_size; MBEDTLS_SSL_DEBUG_BUF( 3, "verify_data for finished message", dst, md_size ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls1_3_calculate_expected_finished" ) ); - return( 0 ); + +exit: + + mbedtls_platform_zeroize( transcript, sizeof( transcript) ); + return( ret ); } int mbedtls_ssl_tls1_3_create_psk_binder( mbedtls_ssl_context *ssl, @@ -1199,14 +1203,6 @@ int mbedtls_ssl_tls1_3_generate_application_keys( cleanup: mbedtls_platform_zeroize( transcript, sizeof(transcript) ); - mbedtls_platform_zeroize( traffic_keys->client_write_key, - sizeof(traffic_keys->client_write_key) ); - mbedtls_platform_zeroize( traffic_keys->server_write_key, - sizeof(traffic_keys->server_write_key) ); - mbedtls_platform_zeroize( traffic_keys->client_write_iv, - sizeof(traffic_keys->client_write_iv) ); - mbedtls_platform_zeroize( traffic_keys->server_write_iv, - sizeof(traffic_keys->server_write_iv) ); return( ret ); } From 1aef02ee20a1271aae8cad561193060211f41269 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 28 Oct 2021 09:54:34 +0000 Subject: [PATCH 928/966] Fix initialized issues and remove useless code Fix the variable not inialized issue, remove the client certificate related code, remove early data related code. Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 1 - library/ssl_tls13_client.c | 28 ---------------------------- library/ssl_tls13_generic.c | 18 +++++++++--------- 3 files changed, 9 insertions(+), 38 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index ed6a445c22..508a5e34ad 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -637,7 +637,6 @@ typedef enum MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET, MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT, #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - MBEDTLS_SSL_END_OF_EARLY_DATA, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS, MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY, #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 2bde4a8252..5dba0f0c40 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1608,26 +1608,6 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) return ( mbedtls_ssl_tls13_finished_in_process( ssl ) ); } -/* - * Handler for MBEDTLS_SSL_CLIENT_CERTIFICATE - */ -static int ssl_tls1_3_write_client_certificate( mbedtls_ssl_context *ssl ) -{ - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY ); - return( 0 ); -} - -/* - * Handler for MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY - */ -static int ssl_tls1_3_write_client_certificate_verify( mbedtls_ssl_context *ssl ) -{ - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_FINISHED ); - return( 0 ); -} - /* * Handler for MBEDTLS_SSL_CLIENT_FINISHED */ @@ -1701,14 +1681,6 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) ret = ssl_tls1_3_process_server_finished( ssl ); break; - case MBEDTLS_SSL_CLIENT_CERTIFICATE: - ret = ssl_tls1_3_write_client_certificate( ssl ); - break; - - case MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY: - ret = ssl_tls1_3_write_client_certificate_verify( ssl ); - break; - case MBEDTLS_SSL_CLIENT_FINISHED: ret = ssl_tls1_3_write_client_finished( ssl ); break; diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index dd550f7721..f379485854 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -945,7 +945,7 @@ static int ssl_tls13_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) { int ret = 0; mbedtls_ssl_key_set traffic_keys; - mbedtls_ssl_transform *transform_application; + mbedtls_ssl_transform *transform_application = NULL; ret = mbedtls_ssl_tls13_key_schedule_stage_application( ssl ); if( ret != 0 ) @@ -986,18 +986,18 @@ static int ssl_tls13_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) ssl->transform_application = transform_application; - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_END_OF_EARLY_DATA ); + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_FINISHED ); cleanup: mbedtls_platform_zeroize( &traffic_keys, sizeof(mbedtls_ssl_key_set) ); - if( ret != 0) - { - mbedtls_free( transform_application ); - MBEDTLS_SSL_PEND_FATAL_ALERT( - MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); - } + if( ret != 0) + { + mbedtls_free( transform_application ); + MBEDTLS_SSL_PEND_FATAL_ALERT( + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE, + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + } return( ret ); } From 8903bd97b0eea085f09670f227946eef07420176 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 3 Nov 2021 05:56:49 +0000 Subject: [PATCH 929/966] Change some naming style issues and remove useless code Signed-off-by: XiaokangQian --- library/ssl_misc.h | 21 ++------------------- library/ssl_tls13_client.c | 2 +- library/ssl_tls13_generic.c | 35 ++++++++++++++++------------------- library/ssl_tls13_keys.h | 8 ++++---- 4 files changed, 23 insertions(+), 43 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 7044769a2a..6b9bc599de 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -775,20 +775,6 @@ struct mbedtls_ssl_handshake_params #endif /* MBEDTLS_SSL_CLI_C */ - /* Incoming CertificateVerify */ - struct - { - unsigned char verify_buffer[ 64 + 33 + 1 + MBEDTLS_MD_MAX_SIZE ]; - size_t verify_buffer_len; - } certificate_verify_in; - - /* Outgoing CertificateVerify */ - struct - { - unsigned char handshake_hash[ MBEDTLS_MD_MAX_SIZE ]; - size_t handshake_hash_len; - } certificate_verify_out; - } state_local; /* End of state-local variables. */ @@ -1236,11 +1222,8 @@ static inline int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_read_certificate_process(mbedtls_ssl_context *ssl); -int mbedtls_ssl_write_certificate_process(mbedtls_ssl_context *ssl); - -int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls13_finished_out_process( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_process_finished_in( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_process_finished_out( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 5dba0f0c40..8644db9587 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1605,7 +1605,7 @@ static int ssl_tls1_3_process_certificate_verify( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) { - return ( mbedtls_ssl_tls13_finished_in_process( ssl ) ); + return ( mbedtls_ssl_tls13_process_finished_in( ssl ) ); } /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index f379485854..b2e5ad0619 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -851,20 +851,17 @@ cleanup: * Overview */ -/* Main entry point: orchestrates the other functions */ -int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context* ssl ); - -static int ssl_tls13_finished_in_preprocess( mbedtls_ssl_context* ssl ); -static int ssl_tls13_finished_in_postprocess( mbedtls_ssl_context* ssl ); -static int ssl_tls13_finished_in_parse( mbedtls_ssl_context* ssl, - const unsigned char* buf, - size_t buflen ); +static int ssl_tls13_preprocess_finished_in( mbedtls_ssl_context *ssl ); +static int ssl_tls13_postprocess_finished_in( mbedtls_ssl_context *ssl ); +static int ssl_tls13_parse_finished_in( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t buflen ); /* * Implementation */ -int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context* ssl ) +int mbedtls_ssl_tls13_process_finished_in( mbedtls_ssl_context *ssl ) { int ret = 0; unsigned char *buf; @@ -873,15 +870,15 @@ int mbedtls_ssl_tls13_finished_in_process( mbedtls_ssl_context* ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server finished_in_process" ) ); /* Preprocessing step: Compute handshake digest */ - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finished_in_preprocess( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_preprocess_finished_in( ssl ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, MBEDTLS_SSL_HS_FINISHED, &buf, &buflen ) ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finished_in_parse( ssl, buf, buflen ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_finished_in( ssl, buf, buflen ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, buf, buflen ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finished_in_postprocess( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_postprocess_finished_in( ssl ) ); cleanup: @@ -889,7 +886,7 @@ cleanup: return( ret ); } -static int ssl_tls13_finished_in_preprocess( mbedtls_ssl_context* ssl ) +static int ssl_tls13_preprocess_finished_in( mbedtls_ssl_context *ssl ) { int ret; @@ -907,9 +904,9 @@ static int ssl_tls13_finished_in_preprocess( mbedtls_ssl_context* ssl ) return( 0 ); } -static int ssl_tls13_finished_in_parse( mbedtls_ssl_context* ssl, - const unsigned char* buf, - size_t buflen ) +static int ssl_tls13_parse_finished_in( mbedtls_ssl_context *ssl, + const unsigned char *buf, + size_t buflen ) { /* Structural validation */ if( buflen != ssl->handshake->state_local.finished_in.digest_len ) @@ -941,7 +938,7 @@ static int ssl_tls13_finished_in_parse( mbedtls_ssl_context* ssl, return( 0 ); } -static int ssl_tls13_finished_in_postprocess_cli( mbedtls_ssl_context *ssl ) +static int ssl_tls13_postprocess_finished_in_cli( mbedtls_ssl_context *ssl ) { int ret = 0; mbedtls_ssl_key_set traffic_keys; @@ -1001,12 +998,12 @@ cleanup: return( ret ); } -static int ssl_tls13_finished_in_postprocess( mbedtls_ssl_context* ssl ) +static int ssl_tls13_postprocess_finished_in( mbedtls_ssl_context* ssl ) { if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { - return( ssl_tls13_finished_in_postprocess_cli( ssl ) ); + return( ssl_tls13_postprocess_finished_in_cli( ssl ) ); } return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index e96cfc10c2..fbc6e83c89 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -626,9 +626,9 @@ int mbedtls_ssl_tls1_3_generate_application_keys( * \returns A negative error code on failure. */ int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context *ssl, - unsigned char *dst, - size_t dst_len, - size_t *actual_len, - int from ); + unsigned char *dst, + size_t dst_len, + size_t *actual_len, + int from ); #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From ac0385c08f76108c733b8677af8473e51a2f8648 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 3 Nov 2021 06:40:11 +0000 Subject: [PATCH 930/966] Change code based on comments Move set_state function into client Add back export_key callback function in generate application keys Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 9 ++++++++- library/ssl_tls13_generic.c | 2 -- library/ssl_tls13_keys.c | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 8644db9587..c30d5627df 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1605,7 +1605,14 @@ static int ssl_tls1_3_process_certificate_verify( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) { - return ( mbedtls_ssl_tls13_process_finished_in( ssl ) ); + int ret; + + ret = mbedtls_ssl_tls13_process_finished_in( ssl ); + if( ret != 0 ) + return( ret ); + + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_FINISHED ); + return( 0 ); } /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index b2e5ad0619..9754395f7a 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -983,8 +983,6 @@ static int ssl_tls13_postprocess_finished_in_cli( mbedtls_ssl_context *ssl ) ssl->transform_application = transform_application; - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_FINISHED ); - cleanup: mbedtls_platform_zeroize( &traffic_keys, sizeof(mbedtls_ssl_key_set) ); diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 34d8a19df2..b97a70f29f 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -1189,6 +1189,26 @@ int mbedtls_ssl_tls1_3_generate_application_keys( app_secrets->server_application_traffic_secret_N, md_size ); + /* + * Export client/server application traffic secret 0 + */ + if( ssl->f_export_keys != NULL ) + { + ssl->f_export_keys( ssl->p_export_keys, + MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_APPLICATION_TRAFFIC_SECRET, + app_secrets->client_application_traffic_secret_N, md_size, + ssl->handshake->randbytes + 32, + ssl->handshake->randbytes, + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + + ssl->f_export_keys( ssl->p_export_keys, + MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_APPLICATION_TRAFFIC_SECRET, + app_secrets->server_application_traffic_secret_N, md_size, + ssl->handshake->randbytes + 32, + ssl->handshake->randbytes, + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + } + MBEDTLS_SSL_DEBUG_BUF( 4, "client application_write_key:", traffic_keys->client_write_key, keylen ); MBEDTLS_SSL_DEBUG_BUF( 4, "server application write key", From b51f8841c42864e39b7eba4f7e68c52c751ed26a Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 4 Nov 2021 03:02:47 +0000 Subject: [PATCH 931/966] Change comments for export_keys callback Signed-off-by: XiaokangQian --- library/ssl_tls13_keys.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index b97a70f29f..1f0dd8a841 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -1199,14 +1199,16 @@ int mbedtls_ssl_tls1_3_generate_application_keys( app_secrets->client_application_traffic_secret_N, md_size, ssl->handshake->randbytes + 32, ssl->handshake->randbytes, - MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: this should be replaced by + a new constant for TLS 1.3! */ ); ssl->f_export_keys( ssl->p_export_keys, MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_APPLICATION_TRAFFIC_SECRET, app_secrets->server_application_traffic_secret_N, md_size, ssl->handshake->randbytes + 32, ssl->handshake->randbytes, - MBEDTLS_SSL_TLS_PRF_NONE /* TODO: FIX! */ ); + MBEDTLS_SSL_TLS_PRF_NONE /* TODO: this should be replaced by + a new constant for TLS 1.3! */ ); } MBEDTLS_SSL_DEBUG_BUF( 4, "client application_write_key:", From 44c38f7e3669694d3fc8785a6442f8664a477039 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Fri, 5 Nov 2021 06:49:27 +0000 Subject: [PATCH 932/966] Chande debug message in finished and rename finalize functions Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 9754395f7a..27cef72871 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -852,7 +852,7 @@ cleanup: */ static int ssl_tls13_preprocess_finished_in( mbedtls_ssl_context *ssl ); -static int ssl_tls13_postprocess_finished_in( mbedtls_ssl_context *ssl ); +static int ssl_tls13_finalize_finished_in( mbedtls_ssl_context *ssl ); static int ssl_tls13_parse_finished_in( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t buflen ); @@ -867,7 +867,7 @@ int mbedtls_ssl_tls13_process_finished_in( mbedtls_ssl_context *ssl ) unsigned char *buf; size_t buflen; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server finished_in_process" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished_in" ) ); /* Preprocessing step: Compute handshake digest */ MBEDTLS_SSL_PROC_CHK( ssl_tls13_preprocess_finished_in( ssl ) ); @@ -878,11 +878,11 @@ int mbedtls_ssl_tls13_process_finished_in( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_finished_in( ssl, buf, buflen ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, buf, buflen ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_postprocess_finished_in( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_finished_in( ssl ) ); cleanup: - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse server finished_in_process" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse finished_in" ) ); return( ret ); } @@ -938,7 +938,7 @@ static int ssl_tls13_parse_finished_in( mbedtls_ssl_context *ssl, return( 0 ); } -static int ssl_tls13_postprocess_finished_in_cli( mbedtls_ssl_context *ssl ) +static int ssl_tls13_finalize_finished_in_cli( mbedtls_ssl_context *ssl ) { int ret = 0; mbedtls_ssl_key_set traffic_keys; @@ -996,12 +996,12 @@ cleanup: return( ret ); } -static int ssl_tls13_postprocess_finished_in( mbedtls_ssl_context* ssl ) +static int ssl_tls13_finalize_finished_in( mbedtls_ssl_context* ssl ) { if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { - return( ssl_tls13_postprocess_finished_in_cli( ssl ) ); + return( ssl_tls13_finalize_finished_in_cli( ssl ) ); } return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); From c5c39d5800d38add9e5eee30e44c41b338edce31 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 9 Nov 2021 11:55:10 +0000 Subject: [PATCH 933/966] Change code for styles and comments .etc Remove useless code in union. Rename functions and parameters. Move definitions into othe files. Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 10 ++-- library/ssl_misc.h | 46 ++----------------- library/ssl_tls13_client.c | 2 +- library/ssl_tls13_generic.c | 92 +++++++++++++++++-------------------- library/ssl_tls13_keys.c | 6 +-- library/ssl_tls13_keys.h | 9 ++-- 6 files changed, 61 insertions(+), 104 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 508a5e34ad..fba8f8f846 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -605,6 +605,8 @@ union mbedtls_ssl_premaster_secret #define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret ) +#define MBEDTLS_TLS1_3_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE + /* Length in number of bytes of the TLS sequence number */ #define MBEDTLS_SSL_SEQUENCE_NUMBER_LEN 8 @@ -1052,10 +1054,10 @@ typedef void mbedtls_ssl_async_cancel_t( mbedtls_ssl_context *ssl ); typedef struct { - unsigned char client_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char server_application_traffic_secret_N[ MBEDTLS_MD_MAX_SIZE ]; - unsigned char exporter_master_secret [ MBEDTLS_MD_MAX_SIZE ]; - unsigned char resumption_master_secret [ MBEDTLS_MD_MAX_SIZE ]; + unsigned char client_application_traffic_secret_N[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char server_application_traffic_secret_N[ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char exporter_master_secret [ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; + unsigned char resumption_master_secret [ MBEDTLS_TLS1_3_MD_MAX_SIZE ]; } mbedtls_ssl_tls1_3_application_secrets; #if defined(MBEDTLS_SSL_DTLS_SRTP) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 6b9bc599de..89a5d4313f 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -307,8 +307,6 @@ + ( MBEDTLS_SSL_CID_OUT_LEN_MAX ) ) #endif -#define MBEDTLS_TLS1_3_MD_MAX_SIZE MBEDTLS_MD_MAX_SIZE - #define MBEDTLS_CLIENT_HELLO_RANDOM_LEN 32 #define MBEDTLS_SERVER_HELLO_RANDOM_LEN 32 @@ -724,7 +722,7 @@ struct mbedtls_ssl_handshake_params /* Buffer holding digest of the handshake up to * but excluding the outgoing finished message. */ - unsigned char digest[MBEDTLS_MD_MAX_SIZE]; + unsigned char digest[MBEDTLS_TLS1_3_MD_MAX_SIZE]; size_t digest_len; } finished_out; @@ -733,48 +731,10 @@ struct mbedtls_ssl_handshake_params { /* Buffer holding digest of the handshake up to but * excluding the peer's incoming finished message. */ - unsigned char digest[MBEDTLS_MD_MAX_SIZE]; + unsigned char digest[MBEDTLS_TLS1_3_MD_MAX_SIZE]; size_t digest_len; } finished_in; -#if defined(MBEDTLS_SSL_CLI_C) - - /* Client, incoming ServerKeyExchange */ - struct - { - uint8_t preparation_done; - } srv_key_exchange; - - /* Client, incoming ServerHello */ - struct - { -#if defined(MBEDTLS_SSL_RENEGOTIATION) - int renego_info_seen; -#else - int dummy; -#endif - } srv_hello_in; - - /* Client, outgoing ClientKeyExchange */ - struct - { - uint8_t preparation_done; - } cli_key_exch_out; - - /* Client, outgoing Certificate Verify */ - struct - { - uint8_t preparation_done; - } crt_vrfy_out; - - /* Client, outgoing ClientHello */ - struct - { - uint8_t preparation_done; - } cli_hello_out; - -#endif /* MBEDTLS_SSL_CLI_C */ - } state_local; /* End of state-local variables. */ @@ -1222,7 +1182,7 @@ static inline int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls13_process_finished_in( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ); int mbedtls_ssl_tls13_process_finished_out( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index c30d5627df..6deab2a8c7 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1607,7 +1607,7 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) { int ret; - ret = mbedtls_ssl_tls13_process_finished_in( ssl ); + ret = mbedtls_ssl_tls13_process_finished_message( ssl ); if( ret != 0 ) return( ret ); diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 27cef72871..83f7202242 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -847,69 +847,37 @@ cleanup: /* * - * STATE HANDLING: Incoming Finished - * Overview + * STATE HANDLING: Incoming Finished message. */ - -static int ssl_tls13_preprocess_finished_in( mbedtls_ssl_context *ssl ); -static int ssl_tls13_finalize_finished_in( mbedtls_ssl_context *ssl ); -static int ssl_tls13_parse_finished_in( mbedtls_ssl_context *ssl, - const unsigned char *buf, - size_t buflen ); - /* * Implementation */ -int mbedtls_ssl_tls13_process_finished_in( mbedtls_ssl_context *ssl ) -{ - int ret = 0; - unsigned char *buf; - size_t buflen; - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished_in" ) ); - - /* Preprocessing step: Compute handshake digest */ - MBEDTLS_SSL_PROC_CHK( ssl_tls13_preprocess_finished_in( ssl ) ); - - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, - MBEDTLS_SSL_HS_FINISHED, - &buf, &buflen ) ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_finished_in( ssl, buf, buflen ) ); - mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( - ssl, MBEDTLS_SSL_HS_FINISHED, buf, buflen ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_finished_in( ssl ) ); - -cleanup: - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse finished_in" ) ); - return( ret ); -} - -static int ssl_tls13_preprocess_finished_in( mbedtls_ssl_context *ssl ) +static int ssl_tls13_prepare_finished_in( mbedtls_ssl_context *ssl ) { int ret; - ret = mbedtls_ssl_tls1_3_calculate_expected_finished( ssl, + ret = mbedtls_ssl_tls13_calculate_verify_data( ssl, ssl->handshake->state_local.finished_in.digest, sizeof( ssl->handshake->state_local.finished_in.digest ), &ssl->handshake->state_local.finished_in.digest_len, - ssl->conf->endpoint ^ 1 ); + ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ? + MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT ); if( ret != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_calculate_expected_finished", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_calculate_verify_data", ret ); return( ret ); } return( 0 ); } -static int ssl_tls13_parse_finished_in( mbedtls_ssl_context *ssl, - const unsigned char *buf, - size_t buflen ) +static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, + const unsigned char *buf, + const unsigned char *end ) { /* Structural validation */ - if( buflen != ssl->handshake->state_local.finished_in.digest_len ) + if( (size_t)( end - buf ) != ssl->handshake->state_local.finished_in.digest_len ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); @@ -918,10 +886,10 @@ static int ssl_tls13_parse_finished_in( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } - MBEDTLS_SSL_DEBUG_BUF( 4, "Hash (self-computed):", + MBEDTLS_SSL_DEBUG_BUF( 4, "verify_data (self-computed):", ssl->handshake->state_local.finished_in.digest, ssl->handshake->state_local.finished_in.digest_len ); - MBEDTLS_SSL_DEBUG_BUF( 4, "Hash (received message):", buf, + MBEDTLS_SSL_DEBUG_BUF( 4, "verify_data (received message):", buf, ssl->handshake->state_local.finished_in.digest_len ); /* Semantic validation */ @@ -938,7 +906,7 @@ static int ssl_tls13_parse_finished_in( mbedtls_ssl_context *ssl, return( 0 ); } -static int ssl_tls13_finalize_finished_in_cli( mbedtls_ssl_context *ssl ) +static int ssl_tls13_finalize_server_finished_message( mbedtls_ssl_context *ssl ) { int ret = 0; mbedtls_ssl_key_set traffic_keys; @@ -985,8 +953,8 @@ static int ssl_tls13_finalize_finished_in_cli( mbedtls_ssl_context *ssl ) cleanup: - mbedtls_platform_zeroize( &traffic_keys, sizeof(mbedtls_ssl_key_set) ); - if( ret != 0) + mbedtls_platform_zeroize( &traffic_keys, sizeof( mbedtls_ssl_key_set ) ); + if( ret != 0 ) { mbedtls_free( transform_application ); MBEDTLS_SSL_PEND_FATAL_ALERT( @@ -996,17 +964,43 @@ cleanup: return( ret ); } -static int ssl_tls13_finalize_finished_in( mbedtls_ssl_context* ssl ) +static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context* ssl ) { if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { - return( ssl_tls13_finalize_finished_in_cli( ssl ) ); + return( ssl_tls13_finalize_server_finished_message( ssl ) ); } return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } +int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + unsigned char *buf; + size_t buflen; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished_in" ) ); + + /* Preprocessing step: Compute handshake digest */ + MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_finished_in( ssl ) ); + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, + MBEDTLS_SSL_HS_FINISHED, + &buf, &buflen ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_finished_message( ssl, buf, buf + buflen ) ); + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( + ssl, MBEDTLS_SSL_HS_FINISHED, buf, buflen ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_finished_message( ssl ) ); + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse finished_in" ) ); + return( ret ); +} + + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_TLS_C */ diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 1f0dd8a841..8f089f580b 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -643,7 +643,7 @@ exit: return( ret ); } -int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context* ssl, +int mbedtls_ssl_tls13_calculate_verify_data( mbedtls_ssl_context* ssl, unsigned char* dst, size_t dst_len, size_t *actual_len, @@ -660,7 +660,7 @@ int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context* ssl, const mbedtls_md_info_t* const md = mbedtls_md_info_from_type( md_type ); size_t const md_size = mbedtls_md_get_size( md ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls1_3_calculate_expected_finished" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_tls13_calculate_verify_data" ) ); if( dst_len < md_size ) return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); @@ -686,7 +686,7 @@ int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context* ssl, *actual_len = md_size; MBEDTLS_SSL_DEBUG_BUF( 3, "verify_data for finished message", dst, md_size ); - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls1_3_calculate_expected_finished" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_tls13_calculate_verify_data" ) ); exit: diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index fbc6e83c89..c5c3a34162 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -605,16 +605,17 @@ int mbedtls_ssl_tls1_3_generate_application_keys( mbedtls_ssl_context* ssl, mbedtls_ssl_key_set *traffic_keys ); /** - * \brief Calculate content of TLS 1.3 Finished message. + * \brief Calculate the verify_data value for the client or server TLS 1.3 + * Finished message. * * \param ssl The SSL context to operate on. This must be in * key schedule stage \c Handshake, see * mbedtls_ssl_tls13_key_schedule_stage_application(). - * \param dst The address at which to write the Finished content. + * \param dst The address at which to write the verify_data value. * \param dst_len The size of \p dst in bytes. * \param actual_len The address at which to store the amount of data * actually written to \p dst upon success. - * \param from The endpoint the Finished message originates from: + * \param from The message to calculate the `verify_data` for: * - #MBEDTLS_SSL_IS_CLIENT for the Client's Finished message * - #MBEDTLS_SSL_IS_SERVER for the Server's Finished message * @@ -625,7 +626,7 @@ int mbedtls_ssl_tls1_3_generate_application_keys( * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls1_3_calculate_expected_finished( mbedtls_ssl_context *ssl, +int mbedtls_ssl_tls13_calculate_verify_data( mbedtls_ssl_context *ssl, unsigned char *dst, size_t dst_len, size_t *actual_len, From aaa0e197a81ea8fe8b8a9364987019603b81f519 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 10 Nov 2021 03:07:04 +0000 Subject: [PATCH 934/966] Change the alignment and names of functions and a macro Signed-off-by: XiaokangQian --- library/ssl_misc.h | 1 - library/ssl_tls13_generic.c | 12 ++++++------ library/ssl_tls13_keys.c | 10 +++++----- library/ssl_tls13_keys.h | 10 +++++----- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 89a5d4313f..c0a370e06b 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1183,7 +1183,6 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls13_process_finished_out( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 83f7202242..9be6948cb2 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -853,7 +853,7 @@ cleanup: * Implementation */ -static int ssl_tls13_prepare_finished_in( mbedtls_ssl_context *ssl ) +static int ssl_tls13_preprocess_finished_message( mbedtls_ssl_context *ssl ) { int ret; @@ -906,7 +906,7 @@ static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, return( 0 ); } -static int ssl_tls13_finalize_server_finished_message( mbedtls_ssl_context *ssl ) +static int ssl_tls13_postprocess_server_finished_message( mbedtls_ssl_context *ssl ) { int ret = 0; mbedtls_ssl_key_set traffic_keys; @@ -964,12 +964,12 @@ cleanup: return( ret ); } -static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context* ssl ) +static int ssl_tls13_postprocess_finished_message( mbedtls_ssl_context* ssl ) { if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { - return( ssl_tls13_finalize_server_finished_message( ssl ) ); + return( ssl_tls13_postprocess_server_finished_message( ssl ) ); } return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); @@ -984,7 +984,7 @@ int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished_in" ) ); /* Preprocessing step: Compute handshake digest */ - MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_finished_in( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_preprocess_finished_message( ssl ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl, MBEDTLS_SSL_HS_FINISHED, @@ -992,7 +992,7 @@ int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_finished_message( ssl, buf, buf + buflen ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, buf, buflen ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_finished_message( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_postprocess_finished_message( ssl ) ); cleanup: diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 8f089f580b..fbbf096c98 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -644,14 +644,14 @@ exit: } int mbedtls_ssl_tls13_calculate_verify_data( mbedtls_ssl_context* ssl, - unsigned char* dst, - size_t dst_len, - size_t *actual_len, - int from ) + unsigned char* dst, + size_t dst_len, + size_t *actual_len, + int from ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; + unsigned char transcript[MBEDTLS_TLS1_3_MD_MAX_SIZE]; size_t transcript_len; unsigned char const *base_key = NULL; diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index c5c3a34162..53dbe732e8 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -615,7 +615,7 @@ int mbedtls_ssl_tls1_3_generate_application_keys( * \param dst_len The size of \p dst in bytes. * \param actual_len The address at which to store the amount of data * actually written to \p dst upon success. - * \param from The message to calculate the `verify_data` for: + * \param which The message to calculate the `verify_data` for: * - #MBEDTLS_SSL_IS_CLIENT for the Client's Finished message * - #MBEDTLS_SSL_IS_SERVER for the Server's Finished message * @@ -627,9 +627,9 @@ int mbedtls_ssl_tls1_3_generate_application_keys( * \returns A negative error code on failure. */ int mbedtls_ssl_tls13_calculate_verify_data( mbedtls_ssl_context *ssl, - unsigned char *dst, - size_t dst_len, - size_t *actual_len, - int from ); + unsigned char *dst, + size_t dst_len, + size_t *actual_len, + int which ); #endif /* MBEDTLS_SSL_TLS1_3_KEYS_H */ From 57b2aff8a8bc32a5bf81087321f95f2c1e235e3d Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 10 Nov 2021 03:12:11 +0000 Subject: [PATCH 935/966] Align the union size Signed-off-by: XiaokangQian --- library/ssl_misc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index c0a370e06b..362117fd9a 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -729,6 +729,8 @@ struct mbedtls_ssl_handshake_params /* Incoming Finished message */ struct { + uint8_t preparation_done; + /* Buffer holding digest of the handshake up to but * excluding the peer's incoming finished message. */ unsigned char digest[MBEDTLS_TLS1_3_MD_MAX_SIZE]; From d0aa3e930764be11c659729de019cef51ee152eb Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 10 Nov 2021 06:17:40 +0000 Subject: [PATCH 936/966] Inprove code base on review comments Change debug messag for server finished. Change name of generate_application_keys. Remove the client vertificate tests from ssl-opt.sh. Add test strings for server finished in ssl-opt.sh. Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 8 ++++---- library/ssl_tls13_keys.c | 2 +- library/ssl_tls13_keys.h | 4 ++-- tests/ssl-opt.sh | 11 +++++------ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 9be6948cb2..91b4bdfecc 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -920,12 +920,12 @@ static int ssl_tls13_postprocess_server_finished_message( mbedtls_ssl_context *s goto cleanup; } - ret = mbedtls_ssl_tls1_3_generate_application_keys( + ret = mbedtls_ssl_tls13_generate_application_keys( ssl, &traffic_keys ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, - "mbedtls_ssl_tls1_3_generate_application_keys", ret ); + "mbedtls_ssl_tls13_generate_application_keys", ret ); goto cleanup; } @@ -981,7 +981,7 @@ int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ) unsigned char *buf; size_t buflen; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished_in" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished message" ) ); /* Preprocessing step: Compute handshake digest */ MBEDTLS_SSL_PROC_CHK( ssl_tls13_preprocess_finished_message( ssl ) ); @@ -996,7 +996,7 @@ int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ) cleanup: - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse finished_in" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse finished message" ) ); return( ret ); } diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index fbbf096c98..c035504bf0 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -1111,7 +1111,7 @@ int mbedtls_ssl_tls13_key_schedule_stage_handshake( mbedtls_ssl_context *ssl ) /* Generate application traffic keys since any records following a 1-RTT Finished message * MUST be encrypted under the application traffic key. */ -int mbedtls_ssl_tls1_3_generate_application_keys( +int mbedtls_ssl_tls13_generate_application_keys( mbedtls_ssl_context *ssl, mbedtls_ssl_key_set *traffic_keys ) { diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 53dbe732e8..7ea018339e 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -577,7 +577,7 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, * with states Initial -> Early -> Handshake -> Application, and * this function represents the Handshake -> Application transition. * - * In the handshake stage, mbedtls_ssl_tls1_3_generate_application_keys() + * In the handshake stage, mbedtls_ssl_tls13_generate_application_keys() * can be used to derive the handshake traffic keys. * * \param ssl The SSL context to operate on. This must be in key schedule @@ -601,7 +601,7 @@ int mbedtls_ssl_tls13_key_schedule_stage_application( * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls1_3_generate_application_keys( +int mbedtls_ssl_tls13_generate_application_keys( mbedtls_ssl_context* ssl, mbedtls_ssl_key_set *traffic_keys ); /** diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 0e78356bc9..997bdee639 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8820,9 +8820,7 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "tls1_3 client state: 19" \ -c "tls1_3 client state: 5" \ -c "tls1_3 client state: 3" \ - -c "tls1_3 client state: 9" \ -c "tls1_3 client state: 13" \ - -c "tls1_3 client state: 7" \ -c "tls1_3 client state: 20" \ -c "tls1_3 client state: 11" \ -c "tls1_3 client state: 14" \ @@ -8835,7 +8833,8 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "Certificate verification flags clear" \ -c "=> parse certificate verify" \ -c "<= parse certificate verify" \ - -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" + -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ + -c "<= parse finished message" requires_gnutls_tls1_3 requires_gnutls_next_no_ticket @@ -8853,9 +8852,7 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "tls1_3 client state: 19" \ -c "tls1_3 client state: 5" \ -c "tls1_3 client state: 3" \ - -c "tls1_3 client state: 9" \ -c "tls1_3 client state: 13" \ - -c "tls1_3 client state: 7" \ -c "tls1_3 client state: 20" \ -c "tls1_3 client state: 11" \ -c "tls1_3 client state: 14" \ @@ -8868,7 +8865,9 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "Certificate verification flags clear" \ -c "=> parse certificate verify" \ -c "<= parse certificate verify" \ - -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" + -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ + -c "<= parse finished message" + # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From d6914e3196909a00fe0ade7af64c0a921ebd0b96 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Wed, 10 Nov 2021 10:46:11 +0100 Subject: [PATCH 937/966] ssl_client2/ssl_server2: Rework ordering of cleanup Signed-off-by: Przemyslaw Stekiel --- programs/ssl/ssl_client2.c | 25 ++++++++------- programs/ssl/ssl_server2.c | 64 ++++++++++++++++++++------------------ 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 4360fd3438..01459c08ed 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -3019,6 +3019,19 @@ exit: mbedtls_net_free( &server_fd ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + mbedtls_ssl_session_free( &saved_session ); + + if( session_data != NULL ) + mbedtls_platform_zeroize( session_data, session_data_len ); + mbedtls_free( session_data ); +#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) + if( context_buf != NULL ) + mbedtls_platform_zeroize( context_buf, context_buf_len ); + mbedtls_free( context_buf ); +#endif + #if defined(MBEDTLS_X509_CRT_PARSE_C) mbedtls_x509_crt_free( &clicert ); mbedtls_x509_crt_free( &cacert ); @@ -3049,10 +3062,6 @@ exit: #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED && MBEDTLS_USE_PSA_CRYPTO */ - mbedtls_ssl_session_free( &saved_session ); - mbedtls_ssl_free( &ssl ); - mbedtls_ssl_config_free( &conf ); - #if defined(MBEDTLS_USE_PSA_CRYPTO) const char* message = mbedtls_test_helper_is_psa_leaking(); if( message ) @@ -3071,14 +3080,6 @@ exit: #endif rng_free( &rng ); - if( session_data != NULL ) - mbedtls_platform_zeroize( session_data, session_data_len ); - mbedtls_free( session_data ); -#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) - if( context_buf != NULL ) - mbedtls_platform_zeroize( context_buf, context_buf_len ); - mbedtls_free( context_buf ); -#endif #if defined(MBEDTLS_TEST_HOOKS) if( test_hooks_failure_detected( ) ) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 6a4a033aa9..6f5d118d62 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -3951,9 +3951,35 @@ exit: mbedtls_net_free( &client_fd ); mbedtls_net_free( &listen_fd ); -#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) - mbedtls_dhm_free( &dhm ); + mbedtls_ssl_free( &ssl ); + mbedtls_ssl_config_free( &conf ); + +#if defined(MBEDTLS_SSL_CACHE_C) + mbedtls_ssl_cache_free( &cache ); #endif +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + mbedtls_ssl_ticket_free( &ticket_ctx ); +#endif +#if defined(MBEDTLS_SSL_COOKIE_C) + mbedtls_ssl_cookie_free( &cookie_ctx ); +#endif + +#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) + if( context_buf != NULL ) + mbedtls_platform_zeroize( context_buf, context_buf_len ); + mbedtls_free( context_buf ); +#endif + +#if defined(SNI_OPTION) + sni_free( sni_info ); +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) + ret = psk_free( psk_info ); + if( ( ret != 0 ) && ( opt.query_config_mode == DFL_QUERY_CONFIG_MODE ) ) + mbedtls_printf( "Failed to list of opaque PSKs - error was %d\n", ret ); +#endif + #if defined(MBEDTLS_X509_CRT_PARSE_C) mbedtls_x509_crt_free( &cacert ); mbedtls_x509_crt_free( &srvcert ); @@ -3965,6 +3991,11 @@ exit: psa_destroy_key( key_slot2 ); #endif #endif + +#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) + mbedtls_dhm_free( &dhm ); +#endif + #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) for( i = 0; (size_t) i < ssl_async_keys.slots_used; i++ ) { @@ -3976,17 +4007,6 @@ exit: } } #endif -#if defined(SNI_OPTION) - sni_free( sni_info ); -#endif -#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) - ret = psk_free( psk_info ); - if( ( ret != 0 ) && ( opt.query_config_mode == DFL_QUERY_CONFIG_MODE ) ) - mbedtls_printf( "Failed to list of opaque PSKs - error was %d\n", ret ); -#endif -#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) - mbedtls_dhm_free( &dhm ); -#endif #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) && \ defined(MBEDTLS_USE_PSA_CRYPTO) @@ -4007,16 +4027,6 @@ exit: #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED && MBEDTLS_USE_PSA_CRYPTO */ -#if defined(MBEDTLS_SSL_CACHE_C) - mbedtls_ssl_cache_free( &cache ); -#endif -#if defined(MBEDTLS_SSL_SESSION_TICKETS) - mbedtls_ssl_ticket_free( &ticket_ctx ); -#endif -#if defined(MBEDTLS_SSL_COOKIE_C) - mbedtls_ssl_cookie_free( &cookie_ctx ); -#endif - #if defined(MBEDTLS_USE_PSA_CRYPTO) const char* message = mbedtls_test_helper_is_psa_leaking(); if( message ) @@ -4034,18 +4044,10 @@ exit: mbedtls_psa_crypto_free( ); #endif - mbedtls_ssl_free( &ssl ); - mbedtls_ssl_config_free( &conf ); rng_free( &rng ); mbedtls_free( buf ); -#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) - if( context_buf != NULL ) - mbedtls_platform_zeroize( context_buf, context_buf_len ); - mbedtls_free( context_buf ); -#endif - #if defined(MBEDTLS_TEST_HOOKS) /* Let test hooks detect errors such as resource leaks. * Don't do it in query_config mode, because some test code prints From 0eedd36557b43174519dd88c44b5a98f9ee76e7f Mon Sep 17 00:00:00 2001 From: Tom Cosgrove Date: Wed, 10 Nov 2021 11:15:46 +0000 Subject: [PATCH 938/966] Serialise builds of the .a files on Windows This is a workaround for an issue with mkstemp() in older MinGW releases that causes simultaneous creation of .a files in the same directory to fail. Fixes #5146 Signed-off-by: Tom Cosgrove --- library/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/Makefile b/library/Makefile index 01e85cf5b3..15c9a8b153 100644 --- a/library/Makefile +++ b/library/Makefile @@ -186,6 +186,14 @@ static: libmbedcrypto.a libmbedx509.a libmbedtls.a shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT) +# Windows builds under Mingw can fail if make tries to create archives in the same +# directory at the same time - see https://bugs.launchpad.net/gcc-arm-embedded/+bug/1848002. +# This forces builds of the .a files to be serialised. +ifdef WINDOWS +libmbedtls.a: | libmbedx509.a +libmbedx509.a: | libmbedcrypto.a +endif + # tls libmbedtls.a: $(OBJS_TLS) echo " AR $@" From d6d234f69879d0038214724b8b14c7b52a38c551 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 11 Nov 2021 02:22:12 +0000 Subject: [PATCH 939/966] Solve the ABI_API check issue for mbedtls_ssl_session Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index fba8f8f846..89cc0513e7 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1124,7 +1124,9 @@ struct mbedtls_ssl_session * to be studied whether one of them can be removed. */ unsigned char MBEDTLS_PRIVATE(minor_ver); /*!< The TLS version used in the session. */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) mbedtls_ssl_tls1_3_application_secrets MBEDTLS_PRIVATE(app_secrets); +#endif #if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) From 33062847764d9dd4c13cc7990fc3ba0b207cd097 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 11 Nov 2021 03:37:45 +0000 Subject: [PATCH 940/966] Change code base on comments Remove client certificate verify in tests. Change the layout of structure to fix abi_api check issues. Add comments of Finished. Align with the coding styles. Signed-off-by: XiaokangQian --- include/mbedtls/ssl.h | 8 ++++---- library/ssl_tls13_generic.c | 32 ++++++++++++++++++++------------ library/ssl_tls13_keys.c | 30 ++++++++++++++++-------------- tests/ssl-opt.sh | 4 ++-- 4 files changed, 42 insertions(+), 32 deletions(-) diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 89cc0513e7..45e05447be 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1124,10 +1124,6 @@ struct mbedtls_ssl_session * to be studied whether one of them can be removed. */ unsigned char MBEDTLS_PRIVATE(minor_ver); /*!< The TLS version used in the session. */ -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - mbedtls_ssl_tls1_3_application_secrets MBEDTLS_PRIVATE(app_secrets); -#endif - #if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) mbedtls_x509_crt *MBEDTLS_PRIVATE(peer_cert); /*!< peer X.509 cert chain */ @@ -1154,6 +1150,10 @@ struct mbedtls_ssl_session #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) int MBEDTLS_PRIVATE(encrypt_then_mac); /*!< flag for EtM activation */ #endif + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + mbedtls_ssl_tls1_3_application_secrets MBEDTLS_PRIVATE(app_secrets); +#endif }; /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 91b4bdfecc..e989d71770 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -876,8 +876,17 @@ static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, const unsigned char *buf, const unsigned char *end ) { + /* + * struct { + * opaque verify_data[Hash.length]; + * } Finished; + */ + const unsigned char *expected_verify_data = + ssl->handshake->state_local.finished_in.digest; + size_t expected_verify_data_len = + ssl->handshake->state_local.finished_in.digest_len; /* Structural validation */ - if( (size_t)( end - buf ) != ssl->handshake->state_local.finished_in.digest_len ) + if( (size_t)( end - buf ) != expected_verify_data_len ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); @@ -887,19 +896,19 @@ static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, } MBEDTLS_SSL_DEBUG_BUF( 4, "verify_data (self-computed):", - ssl->handshake->state_local.finished_in.digest, - ssl->handshake->state_local.finished_in.digest_len ); + expected_verify_data, + expected_verify_data_len ); MBEDTLS_SSL_DEBUG_BUF( 4, "verify_data (received message):", buf, - ssl->handshake->state_local.finished_in.digest_len ); + expected_verify_data_len ); /* Semantic validation */ if( mbedtls_ssl_safer_memcmp( buf, - ssl->handshake->state_local.finished_in.digest, - ssl->handshake->state_local.finished_in.digest_len ) != 0 ) + expected_verify_data, + expected_verify_data_len ) != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); - MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, + MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR, MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); } @@ -908,7 +917,7 @@ static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, static int ssl_tls13_postprocess_server_finished_message( mbedtls_ssl_context *ssl ) { - int ret = 0; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; mbedtls_ssl_key_set traffic_keys; mbedtls_ssl_transform *transform_application = NULL; @@ -920,8 +929,7 @@ static int ssl_tls13_postprocess_server_finished_message( mbedtls_ssl_context *s goto cleanup; } - ret = mbedtls_ssl_tls13_generate_application_keys( - ssl, &traffic_keys ); + ret = mbedtls_ssl_tls13_generate_application_keys( ssl, &traffic_keys ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, @@ -953,7 +961,7 @@ static int ssl_tls13_postprocess_server_finished_message( mbedtls_ssl_context *s cleanup: - mbedtls_platform_zeroize( &traffic_keys, sizeof( mbedtls_ssl_key_set ) ); + mbedtls_platform_zeroize( &traffic_keys, sizeof( traffic_keys ) ); if( ret != 0 ) { mbedtls_free( transform_application ); @@ -977,7 +985,7 @@ static int ssl_tls13_postprocess_finished_message( mbedtls_ssl_context* ssl ) int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ) { - int ret = 0; + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; unsigned char *buf; size_t buflen; diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index c035504bf0..a030b65d30 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -568,7 +568,8 @@ int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - mbedtls_md_type_t const md_type = ssl->handshake->ciphersuite_info->mac; + mbedtls_ssl_handshake_params *handshake = ssl->handshake; + mbedtls_md_type_t const md_type = handshake->ciphersuite_info->mac; #if defined(MBEDTLS_DEBUG_C) mbedtls_md_info_t const * const md_info = mbedtls_md_info_from_type( md_type ); size_t const md_size = mbedtls_md_get_size( md_info ); @@ -578,9 +579,9 @@ int mbedtls_ssl_tls13_key_schedule_stage_application( * Compute MasterSecret */ ret = mbedtls_ssl_tls1_3_evolve_secret( md_type, - ssl->handshake->tls1_3_master_secrets.handshake, + handshake->tls1_3_master_secrets.handshake, NULL, 0, - ssl->handshake->tls1_3_master_secrets.app ); + handshake->tls1_3_master_secrets.app ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls1_3_evolve_secret", ret ); @@ -588,7 +589,7 @@ int mbedtls_ssl_tls13_key_schedule_stage_application( } MBEDTLS_SSL_DEBUG_BUF( 4, "Master secret", - ssl->handshake->tls1_3_master_secrets.app, md_size ); + handshake->tls1_3_master_secrets.app, md_size ); return( 0 ); } @@ -690,7 +691,7 @@ int mbedtls_ssl_tls13_calculate_verify_data( mbedtls_ssl_context* ssl, exit: - mbedtls_platform_zeroize( transcript, sizeof( transcript) ); + mbedtls_platform_zeroize( transcript, sizeof( transcript ) ); return( ret ); } @@ -1116,13 +1117,14 @@ int mbedtls_ssl_tls13_generate_application_keys( mbedtls_ssl_key_set *traffic_keys ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + mbedtls_ssl_handshake_params *handshake = ssl->handshake; /* Address at which to store the application secrets */ mbedtls_ssl_tls1_3_application_secrets * const app_secrets = &ssl->session_negotiate->app_secrets; /* Holding the transcript up to and including the ServerFinished */ - unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; + unsigned char transcript[MBEDTLS_TLS1_3_MD_MAX_SIZE]; size_t transcript_len; /* Variables relating to the hash for the chosen ciphersuite. */ @@ -1139,11 +1141,11 @@ int mbedtls_ssl_tls13_generate_application_keys( /* Extract basic information about hash and ciphersuite */ cipher_info = mbedtls_cipher_info_from_type( - ssl->handshake->ciphersuite_info->cipher ); + handshake->ciphersuite_info->cipher ); keylen = cipher_info->key_bitlen / 8; ivlen = cipher_info->iv_size; - md_type = ssl->handshake->ciphersuite_info->mac; + md_type = handshake->ciphersuite_info->mac; md_info = mbedtls_md_info_from_type( md_type ); md_size = mbedtls_md_get_size( md_info ); @@ -1159,7 +1161,7 @@ int mbedtls_ssl_tls13_generate_application_keys( /* Compute application secrets from master secret and transcript hash. */ ret = mbedtls_ssl_tls1_3_derive_application_secrets( md_type, - ssl->handshake->tls1_3_master_secrets.app, + handshake->tls1_3_master_secrets.app, transcript, transcript_len, app_secrets ); if( ret != 0 ) @@ -1197,16 +1199,16 @@ int mbedtls_ssl_tls13_generate_application_keys( ssl->f_export_keys( ssl->p_export_keys, MBEDTLS_SSL_KEY_EXPORT_TLS13_CLIENT_APPLICATION_TRAFFIC_SECRET, app_secrets->client_application_traffic_secret_N, md_size, - ssl->handshake->randbytes + 32, - ssl->handshake->randbytes, + handshake->randbytes + 32, + handshake->randbytes, MBEDTLS_SSL_TLS_PRF_NONE /* TODO: this should be replaced by a new constant for TLS 1.3! */ ); ssl->f_export_keys( ssl->p_export_keys, MBEDTLS_SSL_KEY_EXPORT_TLS13_SERVER_APPLICATION_TRAFFIC_SECRET, app_secrets->server_application_traffic_secret_N, md_size, - ssl->handshake->randbytes + 32, - ssl->handshake->randbytes, + handshake->randbytes + 32, + handshake->randbytes, MBEDTLS_SSL_TLS_PRF_NONE /* TODO: this should be replaced by a new constant for TLS 1.3! */ ); } @@ -1224,7 +1226,7 @@ int mbedtls_ssl_tls13_generate_application_keys( cleanup: - mbedtls_platform_zeroize( transcript, sizeof(transcript) ); + mbedtls_platform_zeroize( transcript, sizeof( transcript ) ); return( ret ); } diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 997bdee639..43759c59e4 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8820,8 +8820,8 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "tls1_3 client state: 19" \ -c "tls1_3 client state: 5" \ -c "tls1_3 client state: 3" \ + -c "tls1_3 client state: 9" \ -c "tls1_3 client state: 13" \ - -c "tls1_3 client state: 20" \ -c "tls1_3 client state: 11" \ -c "tls1_3 client state: 14" \ -c "tls1_3 client state: 15" \ @@ -8852,8 +8852,8 @@ run_test "TLS1.3: Test client hello msg work - gnutls" \ -c "tls1_3 client state: 19" \ -c "tls1_3 client state: 5" \ -c "tls1_3 client state: 3" \ + -c "tls1_3 client state: 9" \ -c "tls1_3 client state: 13" \ - -c "tls1_3 client state: 20" \ -c "tls1_3 client state: 11" \ -c "tls1_3 client state: 14" \ -c "tls1_3 client state: 15" \ From c13f935c05df20d6cb80380d3b0fb40a754dfda9 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 11 Nov 2021 06:13:22 +0000 Subject: [PATCH 941/966] Align code styles of indent and so on Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index e989d71770..42c786aee0 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -862,7 +862,7 @@ static int ssl_tls13_preprocess_finished_message( mbedtls_ssl_context *ssl ) sizeof( ssl->handshake->state_local.finished_in.digest ), &ssl->handshake->state_local.finished_in.digest_len, ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ? - MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT ); + MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_tls13_calculate_verify_data", ret ); @@ -878,7 +878,7 @@ static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, { /* * struct { - * opaque verify_data[Hash.length]; + * opaque verify_data[Hash.length]; * } Finished; */ const unsigned char *expected_verify_data = @@ -891,7 +891,7 @@ static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR, - MBEDTLS_ERR_SSL_DECODE_ERROR ); + MBEDTLS_ERR_SSL_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_DECODE_ERROR ); } @@ -909,12 +909,14 @@ static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR, - MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); + MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); return( MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE ); } return( 0 ); } + +#if defined(MBEDTLS_SSL_CLI_C) static int ssl_tls13_postprocess_server_finished_message( mbedtls_ssl_context *ssl ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; @@ -971,14 +973,19 @@ cleanup: } return( ret ); } +#endif /* MBEDTLS_SSL_CLI_C */ static int ssl_tls13_postprocess_finished_message( mbedtls_ssl_context* ssl ) { +#if defined(MBEDTLS_SSL_CLI_C) if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { return( ssl_tls13_postprocess_server_finished_message( ssl ) ); } +#else + ((void) ssl); +#endif /* MBEDTLS_SSL_CLI_C */ return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } From a4c99f2c2d85595cb248fe04638796adb89e3612 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 11 Nov 2021 06:46:35 +0000 Subject: [PATCH 942/966] Remove useless blank line Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 1 - library/ssl_tls13_keys.c | 3 +-- library/ssl_tls13_keys.h | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 42c786aee0..b2a70f3cdd 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -915,7 +915,6 @@ static int ssl_tls13_parse_finished_message( mbedtls_ssl_context *ssl, return( 0 ); } - #if defined(MBEDTLS_SSL_CLI_C) static int ssl_tls13_postprocess_server_finished_message( mbedtls_ssl_context *ssl ) { diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index a030b65d30..3ca28d56ec 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -564,8 +564,7 @@ int mbedtls_ssl_tls1_3_derive_resumption_master_secret( return( 0 ); } -int mbedtls_ssl_tls13_key_schedule_stage_application( - mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; mbedtls_ssl_handshake_params *handshake = ssl->handshake; diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 7ea018339e..d598448b5e 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -586,8 +586,7 @@ int mbedtls_ssl_tls13_generate_handshake_keys( mbedtls_ssl_context *ssl, * \returns \c 0 on success. * \returns A negative error code on failure. */ -int mbedtls_ssl_tls13_key_schedule_stage_application( - mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ); /** * \brief Compute TLS 1.3 application traffic keys. From 74af2a827ed385235d9ccf6055017b6cad5adfcf Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 22 Sep 2021 07:40:30 +0000 Subject: [PATCH 943/966] TLS1.3: Add client finish processing in client side Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 8 +-- library/ssl_tls13_generic.c | 126 ++++++++++++++++++++++++++++++++++++ library/ssl_tls13_keys.c | 50 ++++++++++++++ 3 files changed, 179 insertions(+), 5 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 6deab2a8c7..a0f0c9c986 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1618,11 +1618,9 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) /* * Handler for MBEDTLS_SSL_CLIENT_FINISHED */ -static int ssl_tls1_3_write_client_finished( mbedtls_ssl_context *ssl ) +static int ssl_tls13_write_client_finished( mbedtls_ssl_context *ssl ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); - return( 0 ); + return ( mbedtls_ssl_tls1_3_finished_out_process( ssl ) ); } /* @@ -1689,7 +1687,7 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) break; case MBEDTLS_SSL_CLIENT_FINISHED: - ret = ssl_tls1_3_write_client_finished( ssl ); + ret = ssl_tls13_write_client_finished( ssl ); break; case MBEDTLS_SSL_FLUSH_BUFFERS: diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index b2a70f3cdd..a42ede1e39 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -29,6 +29,7 @@ #include "mbedtls/debug.h" #include "mbedtls/oid.h" #include "mbedtls/platform.h" +#include #include "ssl_misc.h" #include "ssl_tls13_keys.h" @@ -1014,6 +1015,131 @@ cleanup: return( ret ); } +/* + * + * STATE HANDLING: Outgoing Finished + * + */ + +/* + * Overview + */ + +/* Main entry point: orchestrates the other functions */ + +int mbedtls_ssl_finished_out_process( mbedtls_ssl_context *ssl ); + +static int ssl_finished_out_prepare( mbedtls_ssl_context *ssl ); +static int ssl_finished_out_write( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t buflen, + size_t *olen ); +static int ssl_finished_out_postprocess( mbedtls_ssl_context *ssl ); + + +int mbedtls_ssl_tls1_3_finished_out_process( mbedtls_ssl_context *ssl ) +{ + int ret; + unsigned char *buf; + size_t buf_len, msg_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished" ) ); + + if( !ssl->handshake->state_local.finished_out.preparation_done ) + { + MBEDTLS_SSL_PROC_CHK( ssl_finished_out_prepare( ssl ) ); + ssl->handshake->state_local.finished_out.preparation_done = 1; + } + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( ssl, + MBEDTLS_SSL_HS_FINISHED, &buf, &buf_len ) ); + + MBEDTLS_SSL_PROC_CHK( ssl_finished_out_write( + ssl, buf, buf_len, &msg_len ) ); + + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, + buf, msg_len ); + + MBEDTLS_SSL_PROC_CHK( ssl_finished_out_postprocess( ssl ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg( ssl, + buf_len, msg_len ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_flush_output( ssl ) ); + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write finished" ) ); + return( ret ); +} + +static int ssl_finished_out_prepare( mbedtls_ssl_context *ssl ) +{ + int ret; + + /* Compute transcript of handshake up to now. */ + ret = mbedtls_ssl_tls1_3_calc_finished( ssl, + ssl->handshake->state_local.finished_out.digest, + sizeof( ssl->handshake->state_local.finished_out.digest ), + &ssl->handshake->state_local.finished_out.digest_len, + ssl->conf->endpoint ); + + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "calc_finished failed", ret ); + return( ret ); + } + + return( 0 ); +} + +static int ssl_finished_out_postprocess( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + +#if defined(MBEDTLS_SSL_CLI_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + { + /* Compute resumption_master_secret */ + ret = mbedtls_ssl_tls1_3_generate_resumption_master_secret( ssl ); + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, + "mbedtls_ssl_tls1_3_generate_resumption_master_secret ", ret ); + return ( ret ); + } + + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); + } + else +#endif /* MBEDTLS_SSL_CLI_C */ + { + /* Should never happen */ + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + return( 0 ); +} + +static int ssl_finished_out_write( mbedtls_ssl_context *ssl, + unsigned char *buf, + size_t buflen, + size_t *olen ) +{ + size_t finished_len = ssl->handshake->state_local.finished_out.digest_len; + + /* Note: Even if DTLS is used, the current message writing functions + * write TLS headers, and it is only at sending time that the actual + * DTLS header is generated. That's why we unconditionally shift by + * 4 bytes here as opposed to mbedtls_ssl_hs_hdr_len( ssl ). */ + + if( buflen < finished_len ) + return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + + memcpy( buf, ssl->handshake->state_local.finished_out.digest, + ssl->handshake->state_local.finished_out.digest_len ); + + *olen = finished_len; + return( 0 ); +} #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 3ca28d56ec..6dc27a4514 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -593,6 +593,56 @@ int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ) return( 0 ); } +#if defined(MBEDTLS_SSL_NEW_SESSION_TICKET) +int mbedtls_ssl_tls1_3_generate_resumption_master_secret( + mbedtls_ssl_context *ssl ) +{ + int ret = 0; + + mbedtls_md_type_t md_type; + mbedtls_md_info_t const *md_info; + size_t md_size; + + unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; + size_t transcript_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, + ( "=> mbedtls_ssl_tls1_3_generate_resumption_master_secret" ) ); + + md_type = ssl->handshake->ciphersuite_info->mac; + md_info = mbedtls_md_info_from_type( md_type ); + md_size = mbedtls_md_get_size( md_info ); + + ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type, + transcript, sizeof( transcript ), + &transcript_len ); + if( ret != 0 ) + return( ret ); + + ret = mbedtls_ssl_tls1_3_derive_resumption_master_secret( md_type, + ssl->handshake->tls1_3_master_secrets.app, + transcript, transcript_len, + &ssl->session_negotiate->app_secrets ); + if( ret != 0 ) + return( ret ); + + MBEDTLS_SSL_DEBUG_BUF( 4, "Resumption master secret", + ssl->session_negotiate->app_secrets.resumption_master_secret, + md_size ); + + MBEDTLS_SSL_DEBUG_MSG( 2, + ( "<= mbedtls_ssl_tls1_3_generate_resumption_master_secret" ) ); + return( 0 ); +} +#else /* MBEDTLS_SSL_NEW_SESSION_TICKET */ +int mbedtls_ssl_tls1_3_generate_resumption_master_secret( + mbedtls_ssl_context *ssl ) +{ + ((void) ssl); + return( 0 ); +} +#endif /* MBEDTLS_SSL_NEW_SESSION_TICKET */ + static int ssl_tls1_3_calc_finished_core( mbedtls_md_type_t md_type, unsigned char const *base_key, unsigned char const *transcript, From eab1023dbf9ffe9ae986da7fc053b2ee51c5b8bd Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 25 Oct 2021 07:38:31 +0000 Subject: [PATCH 944/966] Fix some compiling errors for name mismatch Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 2 +- library/ssl_tls13_generic.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index a0f0c9c986..b64d3269d1 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1620,7 +1620,7 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) */ static int ssl_tls13_write_client_finished( mbedtls_ssl_context *ssl ) { - return ( mbedtls_ssl_tls1_3_finished_out_process( ssl ) ); + return ( mbedtls_ssl_tls13_finished_out_process( ssl ) ); } /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index a42ede1e39..d1a20dfd13 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1037,7 +1037,7 @@ static int ssl_finished_out_write( mbedtls_ssl_context *ssl, static int ssl_finished_out_postprocess( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls1_3_finished_out_process( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls13_finished_out_process( mbedtls_ssl_context *ssl ) { int ret; unsigned char *buf; @@ -1076,7 +1076,7 @@ static int ssl_finished_out_prepare( mbedtls_ssl_context *ssl ) int ret; /* Compute transcript of handshake up to now. */ - ret = mbedtls_ssl_tls1_3_calc_finished( ssl, + ret = mbedtls_ssl_tls1_3_calculate_expected_finished( ssl, ssl->handshake->state_local.finished_out.digest, sizeof( ssl->handshake->state_local.finished_out.digest ), &ssl->handshake->state_local.finished_out.digest_len, From c00ba8131088b85d883cf0683c8fc2f9c9f7aecb Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Fri, 29 Oct 2021 02:42:35 +0000 Subject: [PATCH 945/966] Remove MBEDTLS_SSL_NEW_SESSION_TICKET in TLS1.3 MVP Signed-off-by: XiaokangQian --- library/ssl_tls13_keys.c | 43 ---------------------------------------- 1 file changed, 43 deletions(-) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 6dc27a4514..5eb52ab8c5 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -593,55 +593,12 @@ int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ) return( 0 ); } -#if defined(MBEDTLS_SSL_NEW_SESSION_TICKET) -int mbedtls_ssl_tls1_3_generate_resumption_master_secret( - mbedtls_ssl_context *ssl ) -{ - int ret = 0; - - mbedtls_md_type_t md_type; - mbedtls_md_info_t const *md_info; - size_t md_size; - - unsigned char transcript[MBEDTLS_MD_MAX_SIZE]; - size_t transcript_len; - - MBEDTLS_SSL_DEBUG_MSG( 2, - ( "=> mbedtls_ssl_tls1_3_generate_resumption_master_secret" ) ); - - md_type = ssl->handshake->ciphersuite_info->mac; - md_info = mbedtls_md_info_from_type( md_type ); - md_size = mbedtls_md_get_size( md_info ); - - ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type, - transcript, sizeof( transcript ), - &transcript_len ); - if( ret != 0 ) - return( ret ); - - ret = mbedtls_ssl_tls1_3_derive_resumption_master_secret( md_type, - ssl->handshake->tls1_3_master_secrets.app, - transcript, transcript_len, - &ssl->session_negotiate->app_secrets ); - if( ret != 0 ) - return( ret ); - - MBEDTLS_SSL_DEBUG_BUF( 4, "Resumption master secret", - ssl->session_negotiate->app_secrets.resumption_master_secret, - md_size ); - - MBEDTLS_SSL_DEBUG_MSG( 2, - ( "<= mbedtls_ssl_tls1_3_generate_resumption_master_secret" ) ); - return( 0 ); -} -#else /* MBEDTLS_SSL_NEW_SESSION_TICKET */ int mbedtls_ssl_tls1_3_generate_resumption_master_secret( mbedtls_ssl_context *ssl ) { ((void) ssl); return( 0 ); } -#endif /* MBEDTLS_SSL_NEW_SESSION_TICKET */ static int ssl_tls1_3_calc_finished_core( mbedtls_md_type_t md_type, unsigned char const *base_key, From e1655e4db8b4972648621eff854e91d0f40e8c94 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 3 Nov 2021 07:13:47 +0000 Subject: [PATCH 946/966] Change naming styles and fix ci failure Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 2 +- library/ssl_tls13_generic.c | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index b64d3269d1..6c009213bf 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1620,7 +1620,7 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) */ static int ssl_tls13_write_client_finished( mbedtls_ssl_context *ssl ) { - return ( mbedtls_ssl_tls13_finished_out_process( ssl ) ); + return ( mbedtls_ssl_tls13_process_finished_out( ssl ) ); } /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index d1a20dfd13..6fc141a5d4 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1027,17 +1027,15 @@ cleanup: /* Main entry point: orchestrates the other functions */ -int mbedtls_ssl_finished_out_process( mbedtls_ssl_context *ssl ); - -static int ssl_finished_out_prepare( mbedtls_ssl_context *ssl ); -static int ssl_finished_out_write( mbedtls_ssl_context *ssl, +static int ssl_prepare_finished_out( mbedtls_ssl_context *ssl ); +static int ssl_write_finished_out( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *olen ); -static int ssl_finished_out_postprocess( mbedtls_ssl_context *ssl ); +static int ssl_postprocess_finished_out( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls13_finished_out_process( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls13_process_finished_out( mbedtls_ssl_context *ssl ) { int ret; unsigned char *buf; @@ -1047,20 +1045,20 @@ int mbedtls_ssl_tls13_finished_out_process( mbedtls_ssl_context *ssl ) if( !ssl->handshake->state_local.finished_out.preparation_done ) { - MBEDTLS_SSL_PROC_CHK( ssl_finished_out_prepare( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_prepare_finished_out( ssl ) ); ssl->handshake->state_local.finished_out.preparation_done = 1; } MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( ssl, MBEDTLS_SSL_HS_FINISHED, &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_finished_out_write( + MBEDTLS_SSL_PROC_CHK( ssl_write_finished_out( ssl, buf, buf_len, &msg_len ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, buf, msg_len ); - MBEDTLS_SSL_PROC_CHK( ssl_finished_out_postprocess( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_postprocess_finished_out( ssl ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg( ssl, buf_len, msg_len ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_flush_output( ssl ) ); @@ -1071,7 +1069,7 @@ cleanup: return( ret ); } -static int ssl_finished_out_prepare( mbedtls_ssl_context *ssl ) +static int ssl_prepare_finished_out( mbedtls_ssl_context *ssl ) { int ret; @@ -1091,7 +1089,7 @@ static int ssl_finished_out_prepare( mbedtls_ssl_context *ssl ) return( 0 ); } -static int ssl_finished_out_postprocess( mbedtls_ssl_context *ssl ) +static int ssl_postprocess_finished_out( mbedtls_ssl_context *ssl ) { int ret = 0; @@ -1112,6 +1110,7 @@ static int ssl_finished_out_postprocess( mbedtls_ssl_context *ssl ) else #endif /* MBEDTLS_SSL_CLI_C */ { + ((void) ssl); /* Should never happen */ return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } @@ -1119,7 +1118,7 @@ static int ssl_finished_out_postprocess( mbedtls_ssl_context *ssl ) return( 0 ); } -static int ssl_finished_out_write( mbedtls_ssl_context *ssl, +static int ssl_write_finished_out( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *olen ) From cc90c9441363143fb3693a3b26d40cf92991961b Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 9 Nov 2021 12:30:09 +0000 Subject: [PATCH 947/966] Rebase and change code Solve conflicts. Rename functions Align coding style Signed-off-by: XiaokangQian --- library/ssl_misc.h | 1 + library/ssl_tls13_client.c | 2 +- library/ssl_tls13_generic.c | 37 +++++++++++++++---------------------- library/ssl_tls13_keys.c | 7 ------- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 362117fd9a..2408fd1211 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1185,6 +1185,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ); diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 6c009213bf..df8dfdf963 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1620,7 +1620,7 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) */ static int ssl_tls13_write_client_finished( mbedtls_ssl_context *ssl ) { - return ( mbedtls_ssl_tls13_process_finished_out( ssl ) ); + return ( mbedtls_ssl_tls13_write_finished_message( ssl ) ); } /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 6fc141a5d4..39a04ac20e 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -975,7 +975,7 @@ cleanup: } #endif /* MBEDTLS_SSL_CLI_C */ -static int ssl_tls13_postprocess_finished_message( mbedtls_ssl_context* ssl ) +static int ssl_tls13_postprocess_finished_message( mbedtls_ssl_context *ssl ) { #if defined(MBEDTLS_SSL_CLI_C) @@ -1017,7 +1017,7 @@ cleanup: /* * - * STATE HANDLING: Outgoing Finished + * STATE HANDLING: Write and send Finished message. * */ @@ -1027,15 +1027,15 @@ cleanup: /* Main entry point: orchestrates the other functions */ -static int ssl_prepare_finished_out( mbedtls_ssl_context *ssl ); -static int ssl_write_finished_out( mbedtls_ssl_context *ssl, +static int ssl_prepare_finished_message( mbedtls_ssl_context *ssl ); +static int ssl_tls13_write_finished_message_bod( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *olen ); -static int ssl_postprocess_finished_out( mbedtls_ssl_context *ssl ); +static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls13_process_finished_out( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ) { int ret; unsigned char *buf; @@ -1045,20 +1045,20 @@ int mbedtls_ssl_tls13_process_finished_out( mbedtls_ssl_context *ssl ) if( !ssl->handshake->state_local.finished_out.preparation_done ) { - MBEDTLS_SSL_PROC_CHK( ssl_prepare_finished_out( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_prepare_finished_message( ssl ) ); ssl->handshake->state_local.finished_out.preparation_done = 1; } MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( ssl, MBEDTLS_SSL_HS_FINISHED, &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_write_finished_out( + MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_finished_message_bod( ssl, buf, buf_len, &msg_len ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, - buf, msg_len ); + buf, msg_len ); - MBEDTLS_SSL_PROC_CHK( ssl_postprocess_finished_out( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_finished_message( ssl ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg( ssl, buf_len, msg_len ) ); MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_flush_output( ssl ) ); @@ -1069,12 +1069,12 @@ cleanup: return( ret ); } -static int ssl_prepare_finished_out( mbedtls_ssl_context *ssl ) +static int ssl_prepare_finished_message( mbedtls_ssl_context *ssl ) { int ret; /* Compute transcript of handshake up to now. */ - ret = mbedtls_ssl_tls1_3_calculate_expected_finished( ssl, + ret = mbedtls_ssl_tls13_calculate_verify_data( ssl, ssl->handshake->state_local.finished_out.digest, sizeof( ssl->handshake->state_local.finished_out.digest ), &ssl->handshake->state_local.finished_out.digest_len, @@ -1089,21 +1089,14 @@ static int ssl_prepare_finished_out( mbedtls_ssl_context *ssl ) return( 0 ); } -static int ssl_postprocess_finished_out( mbedtls_ssl_context *ssl ) +static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context *ssl ) { - int ret = 0; #if defined(MBEDTLS_SSL_CLI_C) if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { /* Compute resumption_master_secret */ - ret = mbedtls_ssl_tls1_3_generate_resumption_master_secret( ssl ); - if( ret != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, - "mbedtls_ssl_tls1_3_generate_resumption_master_secret ", ret ); - return ( ret ); - } + ((void) ssl); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); } @@ -1118,7 +1111,7 @@ static int ssl_postprocess_finished_out( mbedtls_ssl_context *ssl ) return( 0 ); } -static int ssl_write_finished_out( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_finished_message_bod( mbedtls_ssl_context *ssl, unsigned char *buf, size_t buflen, size_t *olen ) diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 5eb52ab8c5..3ca28d56ec 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -593,13 +593,6 @@ int mbedtls_ssl_tls13_key_schedule_stage_application( mbedtls_ssl_context *ssl ) return( 0 ); } -int mbedtls_ssl_tls1_3_generate_resumption_master_secret( - mbedtls_ssl_context *ssl ) -{ - ((void) ssl); - return( 0 ); -} - static int ssl_tls1_3_calc_finished_core( mbedtls_md_type_t md_type, unsigned char const *base_key, unsigned char const *transcript, From 8773aa0da95fbae3d83c7e63a72363338a8d2798 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 10 Nov 2021 07:33:09 +0000 Subject: [PATCH 948/966] Align coding styles in generic for client finish Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 39a04ac20e..d52ec2f799 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1027,10 +1027,10 @@ cleanup: /* Main entry point: orchestrates the other functions */ -static int ssl_prepare_finished_message( mbedtls_ssl_context *ssl ); -static int ssl_tls13_write_finished_message_bod( mbedtls_ssl_context *ssl, +static int ssl_tls13_prepare_finished_message( mbedtls_ssl_context *ssl ); +static int ssl_tls13_write_finished_message_body( mbedtls_ssl_context *ssl, unsigned char *buf, - size_t buflen, + unsigned char *end, size_t *olen ); static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context *ssl ); @@ -1041,19 +1041,19 @@ int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ) unsigned char *buf; size_t buf_len, msg_len; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished message" ) ); if( !ssl->handshake->state_local.finished_out.preparation_done ) { - MBEDTLS_SSL_PROC_CHK( ssl_prepare_finished_message( ssl ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_finished_message( ssl ) ); ssl->handshake->state_local.finished_out.preparation_done = 1; } MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( ssl, MBEDTLS_SSL_HS_FINISHED, &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_finished_message_bod( - ssl, buf, buf_len, &msg_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_finished_message_body( + ssl, buf, buf + buf_len, &msg_len ) ); mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, buf, msg_len ); @@ -1065,11 +1065,11 @@ int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ) cleanup: - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write finished" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write finished message" ) ); return( ret ); } -static int ssl_prepare_finished_message( mbedtls_ssl_context *ssl ) +static int ssl_tls13_prepare_finished_message( mbedtls_ssl_context *ssl ) { int ret; @@ -1111,25 +1111,19 @@ static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context *ssl ) return( 0 ); } -static int ssl_tls13_write_finished_message_bod( mbedtls_ssl_context *ssl, +static int ssl_tls13_write_finished_message_body( mbedtls_ssl_context *ssl, unsigned char *buf, - size_t buflen, + unsigned char *end, size_t *olen ) { - size_t finished_len = ssl->handshake->state_local.finished_out.digest_len; + size_t verify_data_len = ssl->handshake->state_local.finished_out.digest_len; - /* Note: Even if DTLS is used, the current message writing functions - * write TLS headers, and it is only at sending time that the actual - * DTLS header is generated. That's why we unconditionally shift by - * 4 bytes here as opposed to mbedtls_ssl_hs_hdr_len( ssl ). */ - - if( buflen < finished_len ) - return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); + MBEDTLS_SSL_CHK_BUF_PTR( buf, end, verify_data_len ); memcpy( buf, ssl->handshake->state_local.finished_out.digest, - ssl->handshake->state_local.finished_out.digest_len ); + verify_data_len ); - *olen = finished_len; + *olen = verify_data_len; return( 0 ); } From 35dc625e37d7a96ea83ba35c62c0f92c16cb25f1 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 11 Nov 2021 08:16:19 +0000 Subject: [PATCH 949/966] Move the location of functions Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 89 ++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index d52ec2f799..064da54874 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1020,55 +1020,10 @@ cleanup: * STATE HANDLING: Write and send Finished message. * */ - /* - * Overview + * Implement */ -/* Main entry point: orchestrates the other functions */ - -static int ssl_tls13_prepare_finished_message( mbedtls_ssl_context *ssl ); -static int ssl_tls13_write_finished_message_body( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ); -static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context *ssl ); - - -int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ) -{ - int ret; - unsigned char *buf; - size_t buf_len, msg_len; - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished message" ) ); - - if( !ssl->handshake->state_local.finished_out.preparation_done ) - { - MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_finished_message( ssl ) ); - ssl->handshake->state_local.finished_out.preparation_done = 1; - } - - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( ssl, - MBEDTLS_SSL_HS_FINISHED, &buf, &buf_len ) ); - - MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_finished_message_body( - ssl, buf, buf + buf_len, &msg_len ) ); - - mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, - buf, msg_len ); - - MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_finished_message( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg( ssl, - buf_len, msg_len ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_flush_output( ssl ) ); - -cleanup: - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write finished message" ) ); - return( ret ); -} - static int ssl_tls13_prepare_finished_message( mbedtls_ssl_context *ssl ) { int ret; @@ -1095,7 +1050,6 @@ static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_SSL_CLI_C) if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) { - /* Compute resumption_master_secret */ ((void) ssl); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); @@ -1112,9 +1066,9 @@ static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context *ssl ) } static int ssl_tls13_write_finished_message_body( mbedtls_ssl_context *ssl, - unsigned char *buf, - unsigned char *end, - size_t *olen ) + unsigned char *buf, + unsigned char *end, + size_t *olen ) { size_t verify_data_len = ssl->handshake->state_local.finished_out.digest_len; @@ -1127,6 +1081,41 @@ static int ssl_tls13_write_finished_message_body( mbedtls_ssl_context *ssl, return( 0 ); } +/* Main entry point: orchestrates the other functions */ +int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + unsigned char *buf; + size_t buf_len, msg_len; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished message" ) ); + + if( !ssl->handshake->state_local.finished_out.preparation_done ) + { + MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_finished_message( ssl ) ); + ssl->handshake->state_local.finished_out.preparation_done = 1; + } + + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( ssl, + MBEDTLS_SSL_HS_FINISHED, &buf, &buf_len ) ); + + MBEDTLS_SSL_PROC_CHK( ssl_tls13_write_finished_message_body( + ssl, buf, buf + buf_len, &msg_len ) ); + + mbedtls_ssl_tls1_3_add_hs_msg_to_checksum( ssl, MBEDTLS_SSL_HS_FINISHED, + buf, msg_len ); + + MBEDTLS_SSL_PROC_CHK( ssl_tls13_finalize_finished_message( ssl ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_finish_handshake_msg( ssl, + buf_len, msg_len ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_flush_output( ssl ) ); + +cleanup: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write finished message" ) ); + return( ret ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_TLS_C */ From 0fa6643eb5969a166587446f09cce4d1faceeb6a Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 15 Nov 2021 03:33:57 +0000 Subject: [PATCH 950/966] Align coding stles and remove useless code Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 9 ++++++++- library/ssl_tls13_generic.c | 29 +++++++---------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index df8dfdf963..69d9c665f9 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1620,7 +1620,14 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) */ static int ssl_tls13_write_client_finished( mbedtls_ssl_context *ssl ) { - return ( mbedtls_ssl_tls13_write_finished_message( ssl ) ); + int ret; + + ret = mbedtls_ssl_tls13_write_finished_message( ssl ); + if( ret != 0 ) + return( ret ); + + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); + return( 0 ); } /* diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 064da54874..97ef33d631 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1046,21 +1046,8 @@ static int ssl_tls13_prepare_finished_message( mbedtls_ssl_context *ssl ) static int ssl_tls13_finalize_finished_message( mbedtls_ssl_context *ssl ) { - -#if defined(MBEDTLS_SSL_CLI_C) - if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) - { - ((void) ssl); - - mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_FLUSH_BUFFERS ); - } - else -#endif /* MBEDTLS_SSL_CLI_C */ - { - ((void) ssl); - /* Should never happen */ - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); - } + // TODO: Add back resumption keys calculation after MVP. + ((void) ssl); return( 0 ); } @@ -1071,7 +1058,11 @@ static int ssl_tls13_write_finished_message_body( mbedtls_ssl_context *ssl, size_t *olen ) { size_t verify_data_len = ssl->handshake->state_local.finished_out.digest_len; - + /* + * struct { + * opaque verify_data[Hash.length]; + * } Finished; + */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, verify_data_len ); memcpy( buf, ssl->handshake->state_local.finished_out.digest, @@ -1090,12 +1081,6 @@ int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished message" ) ); - if( !ssl->handshake->state_local.finished_out.preparation_done ) - { - MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_finished_message( ssl ) ); - ssl->handshake->state_local.finished_out.preparation_done = 1; - } - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( ssl, MBEDTLS_SSL_HS_FINISHED, &buf, &buf_len ) ); From dce82245acc80b69a1d28f4e66115018371a9870 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 15 Nov 2021 06:01:26 +0000 Subject: [PATCH 951/966] Fix the compile issue about prepare message Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 97ef33d631..3678e681a2 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1081,6 +1081,8 @@ int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished message" ) ); + MBEDTLS_SSL_PROC_CHK( ssl_tls13_prepare_finished_message( ssl ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_start_handshake_msg( ssl, MBEDTLS_SSL_HS_FINISHED, &buf, &buf_len ) ); From 9ec8fcfddd090f91154b99cb64b3735cff77f357 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 15 Nov 2021 08:24:08 +0000 Subject: [PATCH 952/966] Improve failure messag for calculating verify data Signed-off-by: XiaokangQian --- library/ssl_tls13_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 3678e681a2..f17bf994c2 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1037,7 +1037,7 @@ static int ssl_tls13_prepare_finished_message( mbedtls_ssl_context *ssl ) if( ret != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "calc_finished failed", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "calculate_verify_data failed", ret ); return( ret ); } From fff613aa1047462efe44ca71d771efad3ccab2fe Mon Sep 17 00:00:00 2001 From: Tom Cosgrove Date: Mon, 15 Nov 2021 13:54:59 +0000 Subject: [PATCH 953/966] Fix list of LTS braches in CONTRIBUTING.md, and back link from BRANCHES.md Signed-off-by: Tom Cosgrove --- BRANCHES.md | 2 +- CONTRIBUTING.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/BRANCHES.md b/BRANCHES.md index a63f070341..60218b099a 100644 --- a/BRANCHES.md +++ b/BRANCHES.md @@ -62,7 +62,7 @@ had to break ABI compatibility in an LTS branch, but we occasionally had to increase code size for a security fix.) For contributors, see the [Backwards Compatibility section of -CONTRIBUTING](CONTRIBUTING.md#cackwords-compatibility). +CONTRIBUTING](CONTRIBUTING.md#backwards-compatibility). ## Current Branches diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3a9547a51..dcaa3603b9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,8 +52,7 @@ It would be highly appreciated if contributions are backported to LTS branches i The list of maintained branches can be found in the [Current Branches section of BRANCHES.md](BRANCHES.md#current-branches). -Currently maintained LTS branches are: -1. [mbedtls-2.7](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.7) +The only currently maintained LTS branch is: 1. [mbedtls-2.16](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.16) From a3087e881e9d4c024ec43c9951d4425f3d87db31 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 16 Nov 2021 02:04:21 +0000 Subject: [PATCH 954/966] Fix finished message decryption fail issue Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 69d9c665f9..1516523e54 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1328,6 +1328,7 @@ static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) handshake->transform_handshake = transform_handshake; mbedtls_ssl_set_inbound_transform( ssl, transform_handshake ); + mbedtls_ssl_set_outbound_transform( ssl, ssl->handshake->transform_handshake ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "Switch to handshake keys for inbound traffic" ) ); ssl->session_in = ssl->session_negotiate; From d69da6c3c30306e850694c73a713f4e087b28440 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 16 Nov 2021 10:32:48 +0000 Subject: [PATCH 955/966] Improve PSA error return code psa_key_derivation_output_key: prioritize BAD_STATE over NOT_PERMITTED If psa_key_derivation_output_key() is called on an operation which hasn't been set up or which has been aborted, return PSA_ERROR_BAD_STATE. Only return PSA_ERROR_NOT_PERMITTED if the operation state is ok for psa_key_derivation_input_bytes() or psa_key_derivation_output_bytes() but not ok to output a key. Ideally psa_key_derivation_output_key() would return PSA_ERROR_NOT_PERMITTED only when psa_key_derivation_output_bytes() is possible, but this is clumsier to implement. Signed-off-by: Dave Rodgman --- library/psa_crypto.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index d713ac823e..7591b6bb1a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -4763,6 +4763,9 @@ psa_status_t psa_key_derivation_output_key( const psa_key_attributes_t *attribut if( psa_get_key_bits( attributes ) == 0 ) return( PSA_ERROR_INVALID_ARGUMENT ); + if( operation->alg == PSA_ALG_NONE ) + return( PSA_ERROR_BAD_STATE ); + if( ! operation->can_output_key ) return( PSA_ERROR_NOT_PERMITTED ); From 3f86a90261965fd4b712e21880d1918e7c61d045 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 16 Nov 2021 12:05:38 +0000 Subject: [PATCH 956/966] Update test to handle changed error code Update test to handle changed error code from psa_key_derivation_output_key Signed-off-by: Dave Rodgman --- tests/suites/test_suite_psa_crypto.data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 6dbf18c8e6..9060159f59 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -4262,7 +4262,7 @@ PSA key derivation: HKDF-SHA-256, bad key type, key output depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_256 # Whether we get NOT_PERMITTED or BAD_STATE for the output is an implementation # detail. -derive_input:PSA_ALG_HKDF(PSA_ALG_SHA_256):PSA_KEY_DERIVATION_INPUT_SALT:PSA_KEY_TYPE_NONE:"":PSA_SUCCESS:PSA_KEY_DERIVATION_INPUT_SECRET:PSA_KEY_TYPE_RAW_DATA:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":PSA_ERROR_INVALID_ARGUMENT:PSA_KEY_DERIVATION_INPUT_INFO:PSA_KEY_TYPE_NONE:"":PSA_ERROR_BAD_STATE:PSA_KEY_TYPE_RAW_DATA:PSA_ERROR_NOT_PERMITTED +derive_input:PSA_ALG_HKDF(PSA_ALG_SHA_256):PSA_KEY_DERIVATION_INPUT_SALT:PSA_KEY_TYPE_NONE:"":PSA_SUCCESS:PSA_KEY_DERIVATION_INPUT_SECRET:PSA_KEY_TYPE_RAW_DATA:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":PSA_ERROR_INVALID_ARGUMENT:PSA_KEY_DERIVATION_INPUT_INFO:PSA_KEY_TYPE_NONE:"":PSA_ERROR_BAD_STATE:PSA_KEY_TYPE_RAW_DATA:PSA_ERROR_BAD_STATE PSA key derivation: HKDF-SHA-256, direct secret, direct output depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_256 From 491d849ad14b8bb92ffcfd8bc4ae044daed5bbb4 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 16 Nov 2021 12:12:49 +0000 Subject: [PATCH 957/966] Fix derive_input test ignoring parameter Fix derive_input test hardcoding key type instead of using test argument. Signed-off-by: Dave Rodgman --- tests/suites/test_suite_psa_crypto.function | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 1aa95275a4..d28de0c206 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -5934,7 +5934,7 @@ void derive_input( int alg_arg, if( output_key_type != PSA_KEY_TYPE_NONE ) { psa_reset_key_attributes( &attributes ); - psa_set_key_type( &attributes, PSA_KEY_TYPE_RAW_DATA ); + psa_set_key_type( &attributes, output_key_type ); psa_set_key_bits( &attributes, 8 ); actual_output_status = psa_key_derivation_output_key( &attributes, &operation, From 3ce4d51c11602db443ffccd798af3d92c32d6e79 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 17 Nov 2021 02:11:36 +0000 Subject: [PATCH 958/966] Move set_outbound_transform to finalize server finished. Signed-off-by: XiaokangQian --- library/ssl_tls13_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 1516523e54..a2e5f33a0d 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1328,7 +1328,6 @@ static int ssl_tls13_finalize_server_hello( mbedtls_ssl_context *ssl ) handshake->transform_handshake = transform_handshake; mbedtls_ssl_set_inbound_transform( ssl, transform_handshake ); - mbedtls_ssl_set_outbound_transform( ssl, ssl->handshake->transform_handshake ); MBEDTLS_SSL_DEBUG_MSG( 1, ( "Switch to handshake keys for inbound traffic" ) ); ssl->session_in = ssl->session_negotiate; @@ -1612,6 +1611,7 @@ static int ssl_tls1_3_process_server_finished( mbedtls_ssl_context *ssl ) if( ret != 0 ) return( ret ); + mbedtls_ssl_set_outbound_transform( ssl, ssl->handshake->transform_handshake ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CLIENT_FINISHED ); return( 0 ); } From 378254d3e32e4df75d1ad92aed471a70bbbd581a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Sat, 30 Oct 2021 21:44:47 +0800 Subject: [PATCH 959/966] Implement handshake wrapup Signed-off-by: Jerry Yu --- library/ssl_misc.h | 3 +++ library/ssl_tls13_client.c | 15 +++++++++++---- library/ssl_tls13_generic.c | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 2408fd1211..1eccb5e97b 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1070,6 +1070,9 @@ int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +void mbedtls_ssl_tls13_handshake_wrapup( mbedtls_ssl_context *ssl ); + /** * \brief TLS 1.3 client side state machine entry * diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index a2e5f33a0d..d848415316 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1636,7 +1636,7 @@ static int ssl_tls13_write_client_finished( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_flush_buffers( mbedtls_ssl_context *ssl ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "handshake: done" ) ); mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_HANDSHAKE_WRAPUP ); return( 0 ); } @@ -1646,9 +1646,16 @@ static int ssl_tls1_3_flush_buffers( mbedtls_ssl_context *ssl ) */ static int ssl_tls1_3_handshake_wrapup( mbedtls_ssl_context *ssl ) { - ((void) ssl); - MBEDTLS_SSL_DEBUG_MSG( 1, ( "%s hasn't been implemented", __func__ ) ); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Switch to application keys for inbound traffic" ) ); + mbedtls_ssl_set_inbound_transform ( ssl, ssl->transform_application ); + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Switch to application keys for outbound traffic" ) ); + mbedtls_ssl_set_outbound_transform( ssl, ssl->transform_application ); + + mbedtls_ssl_tls13_handshake_wrapup( ssl ); + + mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_HANDSHAKE_OVER ); + return( 0 ); } int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index f17bf994c2..48678ff8ea 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1103,6 +1103,26 @@ cleanup: return( ret ); } +void mbedtls_ssl_tls13_handshake_wrapup( mbedtls_ssl_context *ssl ) +{ + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "=> handshake wrapup" ) ); + + /* + * Free the previous session and switch in the current one + */ + if( ssl->session ) + { + + mbedtls_ssl_session_free( ssl->session ); + mbedtls_free( ssl->session ); + } + ssl->session = ssl->session_negotiate; + ssl->session_negotiate = NULL; + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "<= handshake wrapup" ) ); +} + #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_TLS_C */ From e1b1e2de6545e3eb9d330ec3b17b7a64fa68e22e Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 29 Oct 2021 17:46:32 +0800 Subject: [PATCH 960/966] Add minimal feature sets test Replace original negative test with work test. Now, we can work with the simple test. Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 43759c59e4..0343818bd1 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8809,12 +8809,10 @@ run_test "TLS1.3: handshake dispatch test: tls1_3 only" \ requires_openssl_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_disabled MBEDTLS_USE_PSA_CRYPTO -run_test "TLS1.3: Test client hello msg work - openssl" \ - "$O_NEXT_SRV -tls1_3 -msg -no_middlebox" \ +run_test "TLS1.3: minimal feature sets - openssl" \ + "$O_NEXT_SRV -msg -tls1_3 -no_middlebox -num_tickets 0 -no_resume_ephemeral -no_cache" \ "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3" \ - 1 \ - -c "SSL - The requested feature is not available" \ - -s "ServerHello" \ + 0 \ -c "tls1_3 client state: 0" \ -c "tls1_3 client state: 2" \ -c "tls1_3 client state: 19" \ @@ -8841,11 +8839,10 @@ requires_gnutls_next_no_ticket requires_gnutls_next_disable_tls13_compat requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_disabled MBEDTLS_USE_PSA_CRYPTO -run_test "TLS1.3: Test client hello msg work - gnutls" \ +run_test "TLS1.3: minimal feature sets - gnutls" \ "$G_NEXT_SRV --debug=4 --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3:+CIPHER-ALL:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE --disable-client-cert" \ "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3" \ - 1 \ - -c "SSL - The requested feature is not available" \ + 0 \ -s "SERVER HELLO was queued" \ -c "tls1_3 client state: 0" \ -c "tls1_3 client state: 2" \ From cfe64f0b24aedbf96f571c44bc7f4918455af2be Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 15 Nov 2021 13:54:06 +0800 Subject: [PATCH 961/966] fix various issues Signed-off-by: Jerry Yu --- library/ssl_tls13_generic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 48678ff8ea..12ef4d58c8 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1109,11 +1109,10 @@ void mbedtls_ssl_tls13_handshake_wrapup( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 3, ( "=> handshake wrapup" ) ); /* - * Free the previous session and switch in the current one + * Free the previous session and switch to the current one. */ if( ssl->session ) { - mbedtls_ssl_session_free( ssl->session ); mbedtls_free( ssl->session ); } From 6d38c195825fc69ac983a8f9df0b9301e015a981 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 15 Nov 2021 14:01:04 +0800 Subject: [PATCH 962/966] Add http connection pass check Signed-off-by: Jerry Yu --- tests/ssl-opt.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 0343818bd1..1ac34dae77 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8832,7 +8832,8 @@ run_test "TLS1.3: minimal feature sets - openssl" \ -c "=> parse certificate verify" \ -c "<= parse certificate verify" \ -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ - -c "<= parse finished message" + -c "<= parse finished message" \ + -c "HTTP/1.0 200 ok" requires_gnutls_tls1_3 requires_gnutls_next_no_ticket @@ -8863,7 +8864,8 @@ run_test "TLS1.3: minimal feature sets - gnutls" \ -c "=> parse certificate verify" \ -c "<= parse certificate verify" \ -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ - -c "<= parse finished message" + -c "<= parse finished message" \ + -c "HTTP/1.0 200 OK" # Test heap memory usage after handshake From a6e6c27bd37895c79be52b74eb7415e560b61811 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 17 Nov 2021 17:54:13 +0800 Subject: [PATCH 963/966] Grouplize tls1_3 special functions Signed-off-by: Jerry Yu --- library/ssl_misc.h | 136 ++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 71 deletions(-) diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 1eccb5e97b..6eec644354 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -1069,24 +1069,6 @@ int mbedtls_ssl_write_hostname_ext( mbedtls_ssl_context *ssl, int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ); -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - -void mbedtls_ssl_tls13_handshake_wrapup( mbedtls_ssl_context *ssl ); - -/** - * \brief TLS 1.3 client side state machine entry - * - * \param ssl SSL context - */ -int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ); - -/** - * \brief TLS 1.3 server side state machine entry - * - * \param ssl SSL context - */ -int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl ); -#endif int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl ); @@ -1187,9 +1169,6 @@ static inline int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ); - int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ); @@ -1490,7 +1469,72 @@ void mbedtls_ssl_buffering_free( mbedtls_ssl_context *ssl ); void mbedtls_ssl_flight_free( mbedtls_ssl_flight_item *flight ); #endif /* MBEDTLS_SSL_PROTO_DTLS */ +/** + * ssl utils functions for checking configuration. + */ + #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +static inline int mbedtls_ssl_conf_is_tls13_only( const mbedtls_ssl_config *conf ) +{ + if( conf->min_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && + conf->max_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && + conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 && + conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) + { + return( 1 ); + } + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) +static inline int mbedtls_ssl_conf_is_tls12_only( const mbedtls_ssl_config *conf ) +{ + if( conf->min_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && + conf->max_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && + conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 && + conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + return( 1 ); + } + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_config *conf ) +{ + if( conf->min_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && + conf->max_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && + conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 && + conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) + { + return( 1 ); + } + return( 0 ); +} +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL*/ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) + +int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl ); +void mbedtls_ssl_tls13_handshake_wrapup( mbedtls_ssl_context *ssl ); + +/** + * \brief TLS 1.3 client side state machine entry + * + * \param ssl SSL context + */ +int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl ); + +/** + * \brief TLS 1.3 server side state machine entry + * + * \param ssl SSL context + */ +int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl ); + /* * Helper functions around key exchange modes. @@ -1578,56 +1622,6 @@ static inline int mbedtls_ssl_tls1_3_some_psk_enabled( mbedtls_ssl_context *ssl MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); } -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ - -/** - * ssl utils functions for checking configuration. - */ - -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -static inline int mbedtls_ssl_conf_is_tls13_only( const mbedtls_ssl_config *conf ) -{ - if( conf->min_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && - conf->max_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && - conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 && - conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) - { - return( 1 ); - } - return( 0 ); -} -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ - -#if defined(MBEDTLS_SSL_PROTO_TLS1_2) -static inline int mbedtls_ssl_conf_is_tls12_only( const mbedtls_ssl_config *conf ) -{ - if( conf->min_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && - conf->max_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && - conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 && - conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) - { - return( 1 ); - } - return( 0 ); -} -#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ - -#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_config *conf ) -{ - if( conf->min_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && - conf->max_major_ver == MBEDTLS_SSL_MAJOR_VERSION_3 && - conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 && - conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 ) - { - return( 1 ); - } - return( 0 ); -} -#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL*/ - -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) - /* * Helper functions for NamedGroup. */ From 1e4423b535e4a5f5c9c3426f48a611a4153d0a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Wed, 17 Nov 2021 14:39:02 +0100 Subject: [PATCH 964/966] Remove expected failure from test_psa_compliance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #5143 was fixed in PR #5180. Signed-off-by: Bence Szépkúti --- tests/scripts/test_psa_compliance.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 2f6358132d..11b0c6a438 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -33,11 +33,6 @@ import sys # Test number 2xx corresponds to the files in the folder # psa-arch-tests/api-tests/dev_apis/crypto/test_c0xx EXPECTED_FAILURES = { - # psa_key_derivation_output_key() returns PSA_ERROR_NOT_PERMITTED instead of - # PSA_ERROR_BAD_STATE when called after the operation was aborted. - # - Tracked in issue #5143 - 221, - # psa_aead_[encrypt/decrypt]() returns PSA_ERROR_NOT_SUPPORTED instead of # PSA_ERROR_INVALID_ARGUMENT when called with an invalid nonce. # - Tracked in issue #5144 From 357b78e42c2e5ce6cd3f56e3aac2bd58669ac814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Tue, 9 Nov 2021 13:17:17 +0100 Subject: [PATCH 965/966] Indicate if we know that a nonce length is invalid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This restores the behaviour found in the previously released versions and development_2.x. Signed-off-by: Bence Szépkúti --- library/psa_crypto.c | 6 +++--- tests/scripts/test_psa_compliance.py | 5 ----- tests/suites/test_suite_psa_crypto.data | 12 ++++++------ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 7591b6bb1a..4677ea9e48 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3658,13 +3658,13 @@ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, case PSA_ALG_CHACHA20_POLY1305: if( nonce_length == 12 ) return( PSA_SUCCESS ); - break; + return( PSA_ERROR_NOT_SUPPORTED ); #endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */ default: - break; + return( PSA_ERROR_NOT_SUPPORTED ); } - return( PSA_ERROR_NOT_SUPPORTED ); + return( PSA_ERROR_INVALID_ARGUMENT ); } psa_status_t psa_aead_encrypt( mbedtls_svc_key_id_t key, diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 11b0c6a438..ea52c93eba 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -33,11 +33,6 @@ import sys # Test number 2xx corresponds to the files in the folder # psa-arch-tests/api-tests/dev_apis/crypto/test_c0xx EXPECTED_FAILURES = { - # psa_aead_[encrypt/decrypt]() returns PSA_ERROR_NOT_SUPPORTED instead of - # PSA_ERROR_INVALID_ARGUMENT when called with an invalid nonce. - # - Tracked in issue #5144 - 224, 225, - # Multipart CCM is not supported. # - Tracked in issue #3721 252, 253, 254, 255, 256, 257, 258, 259, 261, diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 9060159f59..0904f630aa 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2537,19 +2537,19 @@ aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WI PSA AEAD decrypt: AES-CCM, invalid nonce length 6 depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c090693056":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c090693056":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA AEAD decrypt: AES-CCM, invalid nonce length 14 depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd97200":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_CCM:"48c0906930561e0ab0ef4cd97200":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA AEAD decrypt: AES-CCM_8, invalid nonce length 6 depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c090693056":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c090693056":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA AEAD decrypt: AES-CCM_8, invalid nonce length 14 depends_on:PSA_WANT_ALG_CCM:PSA_WANT_KEY_TYPE_AES -aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c0906930561e0ab0ef4cd97200":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_AES:"4189351B5CAEA375A0299E81C621BF43":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_CCM, 8 ):"48c0906930561e0ab0ef4cd97200":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"4535d12b4377928a7c0a61c9f825a48671ea05910748c8ef":PSA_ERROR_INVALID_ARGUMENT PSA AEAD encrypt/decrypt, AES-GCM, 19 bytes #1 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES @@ -2705,11 +2705,11 @@ aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WI PSA AEAD decrypt: AES-GCM, nonce=0 (bad) depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_GCM:"":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":PSA_ERROR_INVALID_ARGUMENT PSA AEAD decrypt: AES-GCM, nonce=0 (bad), TAG=12 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES -aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_AES:"a0ec7b0052541d9e9c091fb7fc481409":PSA_ALG_AEAD_WITH_SHORTENED_TAG( PSA_ALG_GCM, 12 ):"":"40a27c1d1e23ea3dbe8056b2774861a4a201cce49f19997d19206d8c8a343951":"26c56961c035a7e452cce61bc6ee220d77b3f94d18fd10b6":"":PSA_ERROR_INVALID_ARGUMENT PSA AEAD decrypt: AES-GCM, invalid tag length 18 depends_on:PSA_WANT_ALG_GCM:PSA_WANT_KEY_TYPE_AES From 6d48e20d4ba04e641e71b9181e7d694383aba873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Sz=C3=A9pk=C3=BAti?= Date: Mon, 15 Nov 2021 20:04:15 +0100 Subject: [PATCH 966/966] Indicate nonce sizes invalid for ChaCha20-Poly1305 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bence Szépkúti --- ChangeLog.d/chacha20-poly1305-invalid-nonce.txt | 3 +++ library/psa_crypto.c | 4 +++- tests/suites/test_suite_psa_crypto.data | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 ChangeLog.d/chacha20-poly1305-invalid-nonce.txt diff --git a/ChangeLog.d/chacha20-poly1305-invalid-nonce.txt b/ChangeLog.d/chacha20-poly1305-invalid-nonce.txt new file mode 100644 index 0000000000..ca3f9aceea --- /dev/null +++ b/ChangeLog.d/chacha20-poly1305-invalid-nonce.txt @@ -0,0 +1,3 @@ +Changes + * Indicate in the error returned if the nonce length used with + ChaCha20-Poly1305 is invalid, and not just unsupported. diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 4677ea9e48..0a04ba1061 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3658,7 +3658,9 @@ static psa_status_t psa_aead_check_nonce_length( psa_algorithm_t alg, case PSA_ALG_CHACHA20_POLY1305: if( nonce_length == 12 ) return( PSA_SUCCESS ); - return( PSA_ERROR_NOT_SUPPORTED ); + else if( nonce_length == 8 ) + return( PSA_ERROR_NOT_SUPPORTED ); + break; #endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */ default: return( PSA_ERROR_NOT_SUPPORTED ); diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 0904f630aa..2c5537f391 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -2821,11 +2821,11 @@ aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495 PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=11, too short) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"0700000040414243444546":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"0700000040414243444546":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_INVALID_ARGUMENT PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=13, too long) depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20 -aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"07000000404142434445464700":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED +aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"07000000404142434445464700":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_INVALID_ARGUMENT PSA AEAD encrypt/decrypt: invalid algorithm (CTR) depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C