2929#define SIG1 (x ) (ROTRIGHT(x, 17 ) ^ ROTRIGHT(x, 19 ) ^ ((x) >> 10 ))
3030
3131/* *************************** VARIABLES *****************************/
32- static const unsigned int k[64 ] = {
32+ static const uint32_t k[64 ] = {
3333 0x428a2f98 , 0x71374491 , 0xb5c0fbcf , 0xe9b5dba5 , 0x3956c25b , 0x59f111f1 ,
3434 0x923f82a4 , 0xab1c5ed5 , 0xd807aa98 , 0x12835b01 , 0x243185be , 0x550c7dc3 ,
3535 0x72be5d74 , 0x80deb1fe , 0x9bdc06a7 , 0xc19bf174 , 0xe49b69c1 , 0xefbe4786 ,
@@ -43,9 +43,9 @@ static const unsigned int k[64] = {
4343 0x90befffa , 0xa4506ceb , 0xbef9a3f7 , 0xc67178f2 };
4444
4545/* ********************** FUNCTION DEFINITIONS ***********************/
46- void trantor_sha256_transform (SHA256_CTX *ctx, const BYTE data[])
46+ void trantor_sha256_transform (SHA256_CTX *ctx, const uint8_t data[])
4747{
48- WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64 ];
48+ uint32_t a, b, c, d, e, f, g, h, i, j, t1, t2, m[64 ];
4949
5050 for (i = 0 , j = 0 ; i < 16 ; ++i, j += 4 )
5151 m[i] = (data[j] << 24 ) | (data[j + 1 ] << 16 ) | (data[j + 2 ] << 8 ) |
@@ -100,9 +100,9 @@ void trantor_sha256_init(SHA256_CTX *ctx)
100100 ctx->state [7 ] = 0x5be0cd19 ;
101101}
102102
103- void trantor_sha256_update (SHA256_CTX *ctx, const BYTE data[], size_t len)
103+ void trantor_sha256_update (SHA256_CTX *ctx, const uint8_t data[], size_t len)
104104{
105- WORD i;
105+ uint32_t i;
106106
107107 for (i = 0 ; i < len; ++i)
108108 {
@@ -117,9 +117,9 @@ void trantor_sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len)
117117 }
118118}
119119
120- void trantor_sha256_final (SHA256_CTX *ctx, BYTE hash[])
120+ void trantor_sha256_final (SHA256_CTX *ctx, uint8_t hash[])
121121{
122- WORD i;
122+ uint32_t i;
123123
124124 i = ctx->datalen ;
125125
@@ -141,14 +141,14 @@ void trantor_sha256_final(SHA256_CTX *ctx, BYTE hash[])
141141
142142 // Append to the padding the total message's length in bits and transform.
143143 ctx->bitlen += ctx->datalen * 8 ;
144- ctx->data [63 ] = ctx->bitlen ;
145- ctx->data [62 ] = ctx->bitlen >> 8 ;
146- ctx->data [61 ] = ctx->bitlen >> 16 ;
147- ctx->data [60 ] = ctx->bitlen >> 24 ;
148- ctx->data [59 ] = ctx->bitlen >> 32 ;
149- ctx->data [58 ] = ctx->bitlen >> 40 ;
150- ctx->data [57 ] = ctx->bitlen >> 48 ;
151- ctx->data [56 ] = ctx->bitlen >> 56 ;
144+ ctx->data [63 ] = ( uint8_t ) ctx->bitlen ;
145+ ctx->data [62 ] = ( uint8_t )( ctx->bitlen >> 8 ) ;
146+ ctx->data [61 ] = ( uint8_t )( ctx->bitlen >> 16 ) ;
147+ ctx->data [60 ] = ( uint8_t )( ctx->bitlen >> 24 ) ;
148+ ctx->data [59 ] = ( uint8_t )( ctx->bitlen >> 32 ) ;
149+ ctx->data [58 ] = ( uint8_t )( ctx->bitlen >> 40 ) ;
150+ ctx->data [57 ] = ( uint8_t )( ctx->bitlen >> 48 ) ;
151+ ctx->data [56 ] = ( uint8_t )( ctx->bitlen >> 56 ) ;
152152 trantor_sha256_transform (ctx, ctx->data );
153153
154154 // Since this implementation uses little endian byte ordering and SHA uses
0 commit comments