MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / sha256_process

Function sha256_process

sha256.c:114–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void sha256_process( sha256_context *ctx, const unsigned char data[64] )
115{
116 uint32_t temp1, temp2, W[64];
117 uint32_t A, B, C, D, E, F, G, H;
118
119 GET_UINT32_BE( W[ 0], data, 0 );
120 GET_UINT32_BE( W[ 1], data, 4 );
121 GET_UINT32_BE( W[ 2], data, 8 );
122 GET_UINT32_BE( W[ 3], data, 12 );
123 GET_UINT32_BE( W[ 4], data, 16 );
124 GET_UINT32_BE( W[ 5], data, 20 );
125 GET_UINT32_BE( W[ 6], data, 24 );
126 GET_UINT32_BE( W[ 7], data, 28 );
127 GET_UINT32_BE( W[ 8], data, 32 );
128 GET_UINT32_BE( W[ 9], data, 36 );
129 GET_UINT32_BE( W[10], data, 40 );
130 GET_UINT32_BE( W[11], data, 44 );
131 GET_UINT32_BE( W[12], data, 48 );
132 GET_UINT32_BE( W[13], data, 52 );
133 GET_UINT32_BE( W[14], data, 56 );
134 GET_UINT32_BE( W[15], data, 60 );
135
136#define SHR(x,n) ((x & 0xFFFFFFFF) >> n)
137#define ROTR(x,n) (SHR(x,n) | (x << (32 - n)))
138
139#define S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3))
140#define S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10))
141
142#define S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22))
143#define S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25))
144
145#define F0(x,y,z) ((x & y) | (z & (x | y)))
146#define F1(x,y,z) (z ^ (x & (y ^ z)))
147
148#define R(t) \
149( \
150 W[t] = S1(W[t - 2]) + W[t - 7] + \
151 S0(W[t - 15]) + W[t - 16] \
152)
153
154#define P(a,b,c,d,e,f,g,h,x,K) \
155{ \
156 temp1 = h + S3(e) + F1(e,f,g) + K + x; \
157 temp2 = S2(a) + F0(a,b,c); \
158 d += temp1; h = temp1 + temp2; \
159}
160
161 A = ctx->state[0];
162 B = ctx->state[1];
163 C = ctx->state[2];
164 D = ctx->state[3];
165 E = ctx->state[4];
166 F = ctx->state[5];
167 G = ctx->state[6];
168 H = ctx->state[7];
169
170 P( A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98 );
171 P( H, A, B, C, D, E, F, G, W[ 1], 0x71374491 );

Callers 1

sha256_updateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected