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.
diff --git a/library/sha256.c b/library/sha256.c index 9967d52..8a540ad 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 @@ } 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 );