diff --git a/library/sha256.c b/library/sha256.c index 4819ba3ad1..a20a3e96d0 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -665,9 +665,11 @@ int mbedtls_sha256_finish( mbedtls_sha256_context *ctx, MBEDTLS_PUT_UINT32_BE( ctx->state[5], output, 20 ); MBEDTLS_PUT_UINT32_BE( ctx->state[6], output, 24 ); + int truncated = 0; #if defined(MBEDTLS_SHA224_C) - if( ctx->is224 == 0 ) + truncated = ctx->is224; #endif + if( !truncated ) MBEDTLS_PUT_UINT32_BE( ctx->state[7], output, 28 ); return( 0 );