diff --git a/features/mbedtls/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL/src/default_random_seed.cpp b/features/mbedtls/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL/src/default_random_seed.cpp index 64a6431697..d7c85ac6d6 100644 --- a/features/mbedtls/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL/src/default_random_seed.cpp +++ b/features/mbedtls/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL/src/default_random_seed.cpp @@ -5,6 +5,10 @@ int mbed_default_seed_read(unsigned char *buf, size_t buf_len) { + /* Make sure that in case of an error the value will be negative + * return (-1 * rc); + * Mbed TLS errors are negative values + */ psa_its_status_t rc = psa_its_get(PSA_CRYPTO_ITS_RANDOM_SEED_UID, 0, buf_len, buf); return ( -1 * rc ); } @@ -12,6 +16,10 @@ int mbed_default_seed_read(unsigned char *buf, size_t buf_len) int mbed_default_seed_write(unsigned char *buf, size_t buf_len) { psa_its_status_t rc = psa_its_set(PSA_CRYPTO_ITS_RANDOM_SEED_UID, buf_len, buf, 0); + /* Make sure that in case of an error the value will be negative + * return (-1 * rc); + * Mbed TLS errors are negative values + */ return ( -1 * rc ); }