From bee96c8db9fe118578b5677abdcebe90cdda7a89 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 23 Nov 2020 21:00:09 +0100 Subject: [PATCH] Explain the conditions for checking DRBG error codes Signed-off-by: Gilles Peskine --- library/psa_crypto.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 66c4f7de0..b3d7eb465 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -215,6 +215,8 @@ psa_status_t mbedtls_to_psa_error( int ret ) #if !( defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) || \ defined(MBEDTLS_PSA_HMAC_DRBG_MD_TYPE) ) + /* Only check CTR_DRBG error codes if underlying mbedtls_xxx + * functions are passed a CTR_DRBG instance. */ case MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED: return( PSA_ERROR_INSUFFICIENT_ENTROPY ); case MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG: @@ -243,6 +245,8 @@ psa_status_t mbedtls_to_psa_error( int ret ) #if !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) && \ defined(MBEDTLS_PSA_HMAC_DRBG_MD_TYPE) + /* Only check HMAC_DRBG error codes if underlying mbedtls_xxx + * functions are passed a HMAC_DRBG instance. */ case MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED: return( PSA_ERROR_INSUFFICIENT_ENTROPY ); case MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG: