Separate SHA224 from SHA256 config options.
These options are still dependant on each other.
This is an intermediate step.
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
diff --git a/library/sha256.c b/library/sha256.c
index a94f325..264d33a 100644
--- a/library/sha256.c
+++ b/library/sha256.c
@@ -105,6 +105,12 @@
SHA256_VALIDATE_RET( ctx != NULL );
SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
+#if defined(MBEDTLS_SHA224_C)
+ SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
+#else
+ SHA256_VALIDATE_RET( is224 == 0 );
+#endif
+
ctx->total[0] = 0;
ctx->total[1] = 0;
@@ -122,6 +128,7 @@
}
else
{
+#if defined(MBEDTLS_SHA224_C)
/* SHA-224 */
ctx->state[0] = 0xC1059ED8;
ctx->state[1] = 0x367CD507;
@@ -131,6 +138,7 @@
ctx->state[5] = 0x68581511;
ctx->state[6] = 0x64F98FA7;
ctx->state[7] = 0xBEFA4FA4;
+#endif
}
ctx->is224 = is224;
@@ -388,7 +396,9 @@
PUT_UINT32_BE( ctx->state[5], output, 20 );
PUT_UINT32_BE( ctx->state[6], output, 24 );
+#if defined(MBEDTLS_SHA224_C)
if( ctx->is224 == 0 )
+#endif
PUT_UINT32_BE( ctx->state[7], output, 28 );
return( 0 );
@@ -407,7 +417,12 @@
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
mbedtls_sha256_context ctx;
+#if defined(MBEDTLS_SHA224_C)
SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
+#else
+ SHA256_VALIDATE_RET( is224 == 0 );
+#endif
+
SHA256_VALIDATE_RET( ilen == 0 || input != NULL );
SHA256_VALIDATE_RET( (unsigned char *)output != NULL );