rktio: fix sha_256 for big-endian platforms

The macro for big-endian reads was confused. Just remove the special
case.
This commit is contained in:
Matthew Flatt 2020-12-02 06:05:21 -07:00
parent a7038173aa
commit fe966b9280

View File

@ -36,15 +36,9 @@ typedef uintptr_t size_sha2_t;
typedef rktio_sha2_ctx_t mbedtls_sha256_context; typedef rktio_sha2_ctx_t mbedtls_sha256_context;
#ifdef RKTIO_BIG_ENDIAN
# define GET_UINT32_BE(n,b,i) n = b[i]
# define PUT_UINT32_BE(n,b,i) b[i] = n
#endif
/* /*
* 32-bit integer manipulation macros (big endian) * 32-bit integer manipulation macros (big endian)
*/ */
#ifndef GET_UINT32_BE
#define GET_UINT32_BE(n,b,i) \ #define GET_UINT32_BE(n,b,i) \
do { \ do { \
(n) = ( (uint32_sha2_t) (b)[(i) ] << 24 ) \ (n) = ( (uint32_sha2_t) (b)[(i) ] << 24 ) \
@ -52,9 +46,7 @@ do { \
| ( (uint32_sha2_t) (b)[(i) + 2] << 8 ) \ | ( (uint32_sha2_t) (b)[(i) + 2] << 8 ) \
| ( (uint32_sha2_t) (b)[(i) + 3] ); \ | ( (uint32_sha2_t) (b)[(i) + 3] ); \
} while( 0 ) } while( 0 )
#endif
#ifndef PUT_UINT32_BE
#define PUT_UINT32_BE(n,b,i) \ #define PUT_UINT32_BE(n,b,i) \
do { \ do { \
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
@ -62,7 +54,6 @@ do { \
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
(b)[(i) + 3] = (unsigned char) ( (n) ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \
} while( 0 ) } while( 0 )
#endif
static void mbedtls_sha256_init( mbedtls_sha256_context *ctx ) static void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
{ {