|
92 | 92 | }
|
93 | 93 | #endif /* PUT_UINT64_BE */
|
94 | 94 |
|
| 95 | +#if defined(MBEDTLS_SHA512_SMALLER) |
| 96 | +static void sha512_put_uint64_be( uint64_t n, unsigned char *b, uint8_t i ) |
| 97 | +{ |
| 98 | + PUT_UINT64_BE(n, b, i); |
| 99 | +} |
| 100 | +#else |
| 101 | +#define sha512_put_uint64_be PUT_UINT64_BE |
| 102 | +#endif /* MBEDTLS_SHA512_SMALLER */ |
| 103 | + |
95 | 104 | void mbedtls_sha512_init( mbedtls_sha512_context *ctx )
|
96 | 105 | {
|
97 | 106 | SHA512_VALIDATE( ctx != NULL );
|
@@ -403,26 +412,26 @@ int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
|
403 | 412 | | ( ctx->total[1] << 3 );
|
404 | 413 | low = ( ctx->total[0] << 3 );
|
405 | 414 |
|
406 |
| - PUT_UINT64_BE( high, ctx->buffer, 112 ); |
407 |
| - PUT_UINT64_BE( low, ctx->buffer, 120 ); |
| 415 | + sha512_put_uint64_be( high, ctx->buffer, 112 ); |
| 416 | + sha512_put_uint64_be( low, ctx->buffer, 120 ); |
408 | 417 |
|
409 | 418 | if( ( ret = mbedtls_internal_sha512_process( ctx, ctx->buffer ) ) != 0 )
|
410 | 419 | return( ret );
|
411 | 420 |
|
412 | 421 | /*
|
413 | 422 | * Output final state
|
414 | 423 | */
|
415 |
| - PUT_UINT64_BE( ctx->state[0], output, 0 ); |
416 |
| - PUT_UINT64_BE( ctx->state[1], output, 8 ); |
417 |
| - PUT_UINT64_BE( ctx->state[2], output, 16 ); |
418 |
| - PUT_UINT64_BE( ctx->state[3], output, 24 ); |
419 |
| - PUT_UINT64_BE( ctx->state[4], output, 32 ); |
420 |
| - PUT_UINT64_BE( ctx->state[5], output, 40 ); |
| 424 | + sha512_put_uint64_be( ctx->state[0], output, 0 ); |
| 425 | + sha512_put_uint64_be( ctx->state[1], output, 8 ); |
| 426 | + sha512_put_uint64_be( ctx->state[2], output, 16 ); |
| 427 | + sha512_put_uint64_be( ctx->state[3], output, 24 ); |
| 428 | + sha512_put_uint64_be( ctx->state[4], output, 32 ); |
| 429 | + sha512_put_uint64_be( ctx->state[5], output, 40 ); |
421 | 430 |
|
422 | 431 | if( ctx->is384 == 0 )
|
423 | 432 | {
|
424 |
| - PUT_UINT64_BE( ctx->state[6], output, 48 ); |
425 |
| - PUT_UINT64_BE( ctx->state[7], output, 56 ); |
| 433 | + sha512_put_uint64_be( ctx->state[6], output, 48 ); |
| 434 | + sha512_put_uint64_be( ctx->state[7], output, 56 ); |
426 | 435 | }
|
427 | 436 |
|
428 | 437 | return( 0 );
|
|
0 commit comments