29
29
#define SIG1 (x ) (ROTRIGHT(x, 17 ) ^ ROTRIGHT(x, 19 ) ^ ((x) >> 10 ))
30
30
31
31
/* *************************** VARIABLES *****************************/
32
- static const unsigned int k[64 ] = {
32
+ static const uint32_t k[64 ] = {
33
33
0x428a2f98 , 0x71374491 , 0xb5c0fbcf , 0xe9b5dba5 , 0x3956c25b , 0x59f111f1 ,
34
34
0x923f82a4 , 0xab1c5ed5 , 0xd807aa98 , 0x12835b01 , 0x243185be , 0x550c7dc3 ,
35
35
0x72be5d74 , 0x80deb1fe , 0x9bdc06a7 , 0xc19bf174 , 0xe49b69c1 , 0xefbe4786 ,
@@ -43,9 +43,9 @@ static const unsigned int k[64] = {
43
43
0x90befffa , 0xa4506ceb , 0xbef9a3f7 , 0xc67178f2 };
44
44
45
45
/* ********************** 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[])
47
47
{
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 ];
49
49
50
50
for (i = 0 , j = 0 ; i < 16 ; ++i, j += 4 )
51
51
m[i] = (data[j] << 24 ) | (data[j + 1 ] << 16 ) | (data[j + 2 ] << 8 ) |
@@ -100,9 +100,9 @@ void trantor_sha256_init(SHA256_CTX *ctx)
100
100
ctx->state [7 ] = 0x5be0cd19 ;
101
101
}
102
102
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)
104
104
{
105
- WORD i;
105
+ uint32_t i;
106
106
107
107
for (i = 0 ; i < len; ++i)
108
108
{
@@ -117,9 +117,9 @@ void trantor_sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len)
117
117
}
118
118
}
119
119
120
- void trantor_sha256_final (SHA256_CTX *ctx, BYTE hash[])
120
+ void trantor_sha256_final (SHA256_CTX *ctx, uint8_t hash[])
121
121
{
122
- WORD i;
122
+ uint32_t i;
123
123
124
124
i = ctx->datalen ;
125
125
@@ -141,14 +141,14 @@ void trantor_sha256_final(SHA256_CTX *ctx, BYTE hash[])
141
141
142
142
// Append to the padding the total message's length in bits and transform.
143
143
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 ) ;
152
152
trantor_sha256_transform (ctx, ctx->data );
153
153
154
154
// Since this implementation uses little endian byte ordering and SHA uses
0 commit comments