mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 02:45:41 +01:00
Add tests to generate more random than MBEDTLS_CTR_DRBG_MAX_REQUEST
Add tests that call psa_generate_random() (possibly via psa_generate_key()) with a size that's larger than MBEDTLS_CTR_DRBG_MAX_REQUEST. This causes psa_generate_random() to fail because it calls mbedtls_ctr_drbg_random() without taking the maximum request size of CTR_DRBG into account. Non-regression test for #206
This commit is contained in:
parent
a6b2f60b4c
commit
bdc96fd636
@ -2209,6 +2209,15 @@ generate_random:19
|
||||
PSA generate random: 260 bytes
|
||||
generate_random:260
|
||||
|
||||
PSA generate random: MBEDTLS_CTR_DRBG_MAX_REQUEST bytes
|
||||
generate_random:MBEDTLS_CTR_DRBG_MAX_REQUEST
|
||||
|
||||
PSA generate random: MBEDTLS_CTR_DRBG_MAX_REQUEST+1 bytes
|
||||
generate_random:MBEDTLS_CTR_DRBG_MAX_REQUEST + 1
|
||||
|
||||
PSA generate random: 2*MBEDTLS_CTR_DRBG_MAX_REQUEST+1 bytes
|
||||
generate_random:2 * MBEDTLS_CTR_DRBG_MAX_REQUEST + 1
|
||||
|
||||
PSA generate key: bad type (0)
|
||||
generate_key:PSA_KEY_TYPE_NONE:128:PSA_KEY_USAGE_EXPORT:0:PSA_ERROR_NOT_SUPPORTED
|
||||
|
||||
@ -2227,6 +2236,12 @@ generate_key:PSA_KEY_TYPE_RAW_DATA:7:PSA_KEY_USAGE_EXPORT:0:PSA_ERROR_INVALID_AR
|
||||
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: raw data, (MBEDTLS_CTR_DRBG_MAX_REQUEST + 1) * 8 bits
|
||||
generate_key:PSA_KEY_TYPE_RAW_DATA:(MBEDTLS_CTR_DRBG_MAX_REQUEST + 1) * 8:PSA_KEY_USAGE_EXPORT:0:PSA_SUCCESS
|
||||
|
||||
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
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include "mbedtls/asn1write.h"
|
||||
#include "mbedtls/oid.h"
|
||||
|
||||
/* For MBEDTLS_CTR_DRBG_MAX_REQUEST, knowing that psa_generate_random()
|
||||
* uses mbedtls_ctr_drbg internally. */
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
|
||||
#include "psa_crypto_helpers.h"
|
||||
|
||||
/* Tests that require more than 128kB of RAM plus change have this symbol
|
||||
@ -14,6 +18,8 @@
|
||||
* platforms. */
|
||||
#define HAVE_RAM_AVAILABLE_128K
|
||||
|
||||
#include "psa/crypto.h"
|
||||
|
||||
/** An invalid export length that will never be set by psa_export_key(). */
|
||||
static const size_t INVALID_EXPORT_LENGTH = ~0U;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user