From 4816266205904b1b55ca4cc6e6acce6f42368031 Mon Sep 17 00:00:00 2001 From: Netanel Gonen Date: Sun, 25 Nov 2018 09:31:48 +0200 Subject: [PATCH] add comment to explain why (-1 * rc) is returned --- .../COMPONENT_PSA_SRV_IMPL/src/default_random_seed.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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 ); }