From bcca58c6cdb7ca8407c1576ec09b6447a53d084e Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Wed, 3 Oct 2018 16:33:21 +0300 Subject: [PATCH] Add common feature unavailable error Add a common error for the feature unavailable, in the platform module. --- include/mbedtls/error.h | 2 +- include/mbedtls/platform.h | 3 ++- library/error.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h index 39cd67fdb..0c3888987 100644 --- a/include/mbedtls/error.h +++ b/include/mbedtls/error.h @@ -80,7 +80,7 @@ * CHACHA20 3 0x0051-0x0055 * POLY1305 3 0x0057-0x005B * CHACHAPOLY 2 0x0054-0x0056 - * PLATFORM 1 0x0070-0x0070 + * PLATFORM 1 0x0070-0x0072 * * High-level module nr (3 bits - 0x0...-0x7...) * Name ID Nr of Errors diff --git a/include/mbedtls/platform.h b/include/mbedtls/platform.h index 5cd143ce5..89fe8a7b1 100644 --- a/include/mbedtls/platform.h +++ b/include/mbedtls/platform.h @@ -43,7 +43,8 @@ #include "platform_time.h" #endif -#define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070 /**< Hardware accelerator failed */ +#define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070 /**< Hardware accelerator failed */ +#define MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED -0x0072 /**< The requested feature is not supported by the platform */ #ifdef __cplusplus extern "C" { diff --git a/library/error.c b/library/error.c index 27692dbf7..eabee9e21 100644 --- a/library/error.c +++ b/library/error.c @@ -834,6 +834,8 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) #if defined(MBEDTLS_PLATFORM_C) if( use_ret == -(MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED) ) mbedtls_snprintf( buf, buflen, "PLATFORM - Hardware accelerator failed" ); + if( use_ret == -(MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED) ) + mbedtls_snprintf( buf, buflen, "PLATFORM - The requested feature is not supported by the platform" ); #endif /* MBEDTLS_PLATFORM_C */ #if defined(MBEDTLS_POLY1305_C)