From 2f6de42622988d80335c8c014a2d54a935e79e7d Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Thu, 20 Dec 2018 10:22:32 +0000 Subject: [PATCH] Move SHA256_VALIDATE[_RET] outside of MBEDTLS_SHA256_ALT guard Somehow, mbedtls_sha256_ret() is defined even if MBEDTLS_SHA256_ALT is set, and it is using SHA256_VALIDATE_RET. The documentation should be enhanced to indicate that MBEDTLS_SHA256_ALT does _not_ replace the entire module, but only the core SHA-256 functions. --- library/sha256.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/sha256.c b/library/sha256.c index 9967d52f6..8a540adfb 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -49,6 +49,10 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ +#define SHA256_VALIDATE_RET(cond) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA ) +#define SHA256_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond ) + #if !defined(MBEDTLS_SHA256_ALT) /* @@ -74,10 +78,6 @@ do { \ } while( 0 ) #endif -#define SHA256_VALIDATE_RET(cond) \ - MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA ) -#define SHA256_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond ) - void mbedtls_sha256_init( mbedtls_sha256_context *ctx ) { SHA256_VALIDATE( ctx != NULL );