mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 04:55:51 +01:00
Implement MBEDTLS_SHA256_NO_SHA224
This commit is contained in:
parent
9b781b2880
commit
8463d29156
@ -60,8 +60,10 @@ typedef struct mbedtls_sha256_context
|
||||
uint32_t total[2]; /*!< The number of Bytes processed. */
|
||||
uint32_t state[8]; /*!< The intermediate digest state. */
|
||||
unsigned char buffer[64]; /*!< The data block being processed. */
|
||||
#if !defined(MBEDTLS_SHA256_NO_SHA224)
|
||||
int is224; /*!< Determines which function to use:
|
||||
0: Use SHA-256, or 1: Use SHA-224. */
|
||||
#endif
|
||||
}
|
||||
mbedtls_sha256_context;
|
||||
|
||||
|
@ -132,6 +132,9 @@ int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 )
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_SHA256_NO_SHA224)
|
||||
return( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA );
|
||||
#else
|
||||
/* SHA-224 */
|
||||
ctx->state[0] = 0xC1059ED8;
|
||||
ctx->state[1] = 0x367CD507;
|
||||
@ -141,9 +144,12 @@ int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 )
|
||||
ctx->state[5] = 0x68581511;
|
||||
ctx->state[6] = 0x64F98FA7;
|
||||
ctx->state[7] = 0xBEFA4FA4;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_SHA256_NO_SHA224)
|
||||
ctx->is224 = is224;
|
||||
#endif
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
@ -395,7 +401,9 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
|
||||
sha256_put_uint32_be( ctx->state[5], output, 20 );
|
||||
sha256_put_uint32_be( ctx->state[6], output, 24 );
|
||||
|
||||
#if !defined(MBEDTLS_SHA256_NO_SHA224)
|
||||
if( ctx->is224 == 0 )
|
||||
#endif
|
||||
sha256_put_uint32_be( ctx->state[7], output, 28 );
|
||||
|
||||
return( 0 );
|
||||
|
Loading…
Reference in New Issue
Block a user