Init PSA in fuzz programs
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
6cec5e9d9e
commit
774f9debf2
9 changed files with 103 additions and 15 deletions
|
@ -30,13 +30,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
mbedtls_entropy_init(&entropy);
|
||||
mbedtls_pk_init(&pk);
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
psa_status_t status = psa_crypto_init();
|
||||
if (status != PSA_SUCCESS) {
|
||||
goto exit;
|
||||
}
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
||||
(const unsigned char *) pers, strlen(pers)) != 0) {
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
mbedtls_pk_init(&pk);
|
||||
ret = mbedtls_pk_parse_key(&pk, Data, Size, NULL, 0,
|
||||
dummy_random, &ctr_drbg);
|
||||
if (ret == 0) {
|
||||
|
@ -83,7 +90,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||
abort();
|
||||
}
|
||||
}
|
||||
exit:
|
||||
mbedtls_entropy_free(&entropy);
|
||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||
mbedtls_pk_free(&pk);
|
||||
mbedtls_psa_crypto_free();
|
||||
#else
|
||||
(void) Data;
|
||||
(void) Size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue