mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 00:25:39 +01:00
Get rid of half-baked HAVE_RAM_128K in favor of dynamic heap checking
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
00c3e87422
commit
69967ce17e
@ -357,11 +357,9 @@ depends_on:MBEDTLS_AES_C
|
||||
import_with_data:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":PSA_KEY_TYPE_AES:128:PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
PSA import large key: raw, 65528 bits (ok)
|
||||
depends_on:HAVE_RAM_AVAILABLE_128K
|
||||
import_large_key:PSA_KEY_TYPE_RAW_DATA:8191:PSA_SUCCESS
|
||||
|
||||
PSA import large key: raw, 65536 bits (not supported)
|
||||
depends_on:HAVE_RAM_AVAILABLE_128K
|
||||
import_large_key:PSA_KEY_TYPE_RAW_DATA:8192:PSA_ERROR_NOT_SUPPORTED
|
||||
|
||||
PSA import RSA key pair: maximum size exceeded
|
||||
@ -2520,8 +2518,8 @@ derive_key:PSA_ALG_HKDF(PSA_ALG_SHA_256):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
|
||||
# and not expected to be raised any time soon) is less than the maximum
|
||||
# output from HKDF-SHA512 (255*64 = 16320 bytes).
|
||||
PSA key derivation: largest possible key
|
||||
depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_512:HAVE_RAM_AVAILABLE_128K
|
||||
derive_key:PSA_ALG_HKDF(PSA_ALG_SHA_512):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":PSA_KEY_TYPE_RAW_DATA:PSA_MAX_KEY_BITS:PSA_SUCCESS
|
||||
depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_512
|
||||
derive_large_key:PSA_ALG_HKDF(PSA_ALG_SHA_512):"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":PSA_KEY_TYPE_RAW_DATA:PSA_MAX_KEY_BITS:PSA_SUCCESS
|
||||
|
||||
PSA key derivation: key too large
|
||||
depends_on:MBEDTLS_SHA512_C
|
||||
@ -2679,8 +2677,7 @@ PSA generate key: raw data, (2 * MBEDTLS_CTR_DRBG_MAX_REQUEST + 1) * 8 bits
|
||||
generate_key:PSA_KEY_TYPE_RAW_DATA:(2 * MBEDTLS_CTR_DRBG_MAX_REQUEST + 1) * 8:PSA_KEY_USAGE_EXPORT:0:PSA_SUCCESS
|
||||
|
||||
PSA generate key: raw data, 65528 bits (ok)
|
||||
depends_on:HAVE_RAM_AVAILABLE_128K
|
||||
generate_key:PSA_KEY_TYPE_RAW_DATA:65528:PSA_KEY_USAGE_EXPORT:0:PSA_SUCCESS
|
||||
generate_large_key:PSA_KEY_TYPE_RAW_DATA:65528:PSA_KEY_USAGE_EXPORT:0:PSA_SUCCESS
|
||||
|
||||
PSA generate key: raw data, 65536 bits (not supported)
|
||||
generate_key:PSA_KEY_TYPE_RAW_DATA:65536:PSA_KEY_USAGE_EXPORT:0:PSA_ERROR_NOT_SUPPORTED
|
||||
|
@ -9,13 +9,6 @@
|
||||
* uses mbedtls_ctr_drbg internally. */
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
|
||||
/* Tests that require more than 128kB of RAM plus change have this symbol
|
||||
* as a dependency. Currently we always define this symbol, so the tests
|
||||
* are always executed. In the future we should make this conditional
|
||||
* so that tests that require a lot of memory are skipped on constrained
|
||||
* platforms. */
|
||||
#define HAVE_RAM_AVAILABLE_128K
|
||||
|
||||
#include "psa/crypto.h"
|
||||
#include "psa_crypto_slot_management.h"
|
||||
|
||||
@ -1588,9 +1581,9 @@ void import_large_key( int type_arg, int byte_size_arg,
|
||||
size_t buffer_size = byte_size + 1;
|
||||
size_t n;
|
||||
|
||||
/* It would be better to skip the test than fail it if the allocation
|
||||
* fails, but the test framework doesn't support this yet. */
|
||||
ASSERT_ALLOC( buffer, buffer_size );
|
||||
/* Skip the test case if the target running the test cannot
|
||||
* accomodate large keys due to heap size constraints */
|
||||
ASSERT_ALLOC_WEAK( buffer, buffer_size );
|
||||
memset( buffer, 'K', byte_size );
|
||||
|
||||
PSA_ASSERT( psa_crypto_init( ) );
|
||||
@ -5332,6 +5325,26 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void derive_large_key( int alg_arg,
|
||||
data_t *key_data, data_t *input1, data_t *input2,
|
||||
int type_arg, int bits_arg,
|
||||
int expected_status_arg )
|
||||
{
|
||||
size_t key_bytes = PSA_BITS_TO_BYTES(bits_arg);
|
||||
uint8_t* buffer = NULL;
|
||||
|
||||
/* Check that the target running this test can accomodate large
|
||||
* keys on its heap, before calling the actual generate_key test */
|
||||
ASSERT_ALLOC_WEAK(buffer, key_bytes);
|
||||
mbedtls_free( buffer );
|
||||
|
||||
test_derive_key( alg_arg, key_data, input1, input2, type_arg, bits_arg, expected_status_arg );
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void key_agreement_setup( int alg_arg,
|
||||
int our_key_type_arg, int our_key_alg_arg,
|
||||
@ -5640,6 +5653,27 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void generate_large_key( int type_arg,
|
||||
int bits_arg,
|
||||
int usage_arg,
|
||||
int alg_arg,
|
||||
int expected_status_arg )
|
||||
{
|
||||
size_t key_bytes = PSA_BITS_TO_BYTES(bits_arg);
|
||||
uint8_t* buffer = NULL;
|
||||
|
||||
/* Check that the target running this test can accomodate large
|
||||
* keys on its heap, before calling the actual generate_key test */
|
||||
ASSERT_ALLOC_WEAK(buffer, key_bytes);
|
||||
mbedtls_free( buffer );
|
||||
|
||||
test_generate_key( type_arg, bits_arg, usage_arg, alg_arg, expected_status_arg );
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_RSA_C:MBEDTLS_GENPRIME:MBEDTLS_PKCS1_V15 */
|
||||
void generate_key_rsa( int bits_arg,
|
||||
data_t *e_arg,
|
||||
|
Loading…
Reference in New Issue
Block a user