From cb088e7059e1f12fde99c022c6c7c4a4a68043e0 Mon Sep 17 00:00:00 2001 From: Moran Peker Date: Tue, 17 Jul 2018 17:36:59 +0300 Subject: [PATCH 1/2] Replace ssize_t by ptrdiff_t ssize_t is a POSIX thing, not standard C --- tests/suites/test_suite_psa_crypto.function | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index e9efb3a0a4..c94e4b0864 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -55,7 +55,7 @@ static int asn1_write_10x( unsigned char **p, return( MBEDTLS_ERR_ASN1_INVALID_DATA ); if( bits <= 8 && x >= 1 << ( bits - 1 ) ) return( MBEDTLS_ERR_ASN1_INVALID_DATA ); - if( *p < start || *p - start < (ssize_t) len ) + if( *p < start || *p - start < (ptrdiff_t) len ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); *p -= len; ( *p )[len-1] = x; @@ -492,7 +492,7 @@ void import_export( data_t *data, TEST_ASSERT( data != NULL ); TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( data->len ) ); - export_size = (ssize_t) data->len + export_size_delta; + export_size = (ptrdiff_t) data->len + export_size_delta; exported = mbedtls_calloc( 1, export_size ); TEST_ASSERT( exported != NULL ); if( ! canonical_input ) @@ -593,7 +593,7 @@ void import_export_public_key( data_t *data, TEST_ASSERT( data != NULL ); TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( data->len ) ); - export_size = (ssize_t) data->len; + export_size = (ptrdiff_t) data->len; exported = mbedtls_calloc( 1, export_size ); TEST_ASSERT( exported != NULL ); From f2ffdb87f67992b9d5b768f82e6759c2f0c63d62 Mon Sep 17 00:00:00 2001 From: Moran Peker Date: Sun, 22 Jul 2018 18:23:32 +0300 Subject: [PATCH 2/2] Fix generate_key and hash_setup tests vectors -Add depends_on MBEDTLS_CIPHER_MODE_CTR for CTR test_suite_psa_crypto -Change bad type/hash alg parameter to *_CATEGORY_* --- tests/suites/test_suite_psa_crypto.data | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.data b/tests/suites/test_suite_psa_crypto.data index 27c15389fb..19348bdf32 100644 --- a/tests/suites/test_suite_psa_crypto.data +++ b/tests/suites/test_suite_psa_crypto.data @@ -270,7 +270,7 @@ hash_setup:PSA_ALG_SHA_256:PSA_SUCCESS PSA hash setup: bad (unknown hash algorithm) depends_on:MBEDTLS_MD_C:MBEDTLS_SHA256_C -hash_setup:0x80000000 | PSA_ALG_SHA_256:PSA_ERROR_NOT_SUPPORTED +hash_setup:PSA_ALG_CATEGORY_HASH:PSA_ERROR_NOT_SUPPORTED PSA hash setup: bad (not a hash algorithm) depends_on:MBEDTLS_MD_C:MBEDTLS_SHA256_C @@ -763,8 +763,8 @@ generate_random:19 PSA generate random: 260 bytes generate_random:260 -PSA generate key: bad type (0xffffffff) -generate_key:0xffffffff:128:PSA_KEY_USAGE_EXPORT:0:PSA_ERROR_NOT_SUPPORTED +PSA generate key: bad type (PSA_KEY_TYPE_CATEGORY_MASK) +generate_key:PSA_KEY_TYPE_CATEGORY_MASK:128:PSA_KEY_USAGE_EXPORT:0:PSA_ERROR_NOT_SUPPORTED PSA generate key: bad type (RSA public key) generate_key:PSA_KEY_TYPE_RSA_PUBLIC_KEY:512:PSA_KEY_USAGE_EXPORT:0:PSA_ERROR_NOT_SUPPORTED @@ -779,7 +779,7 @@ PSA generate key: raw data, 8 bits generate_key:PSA_KEY_TYPE_RAW_DATA:8:PSA_KEY_USAGE_EXPORT:0:PSA_SUCCESS PSA generate key: AES, 128 bits, CTR -depends_on:MBEDTLS_AES_C +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CTR generate_key:PSA_KEY_TYPE_AES:128:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CTR:PSA_SUCCESS PSA generate key: AES, 128 bits, GCM