MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / transf

Method transf

src/common/sha2/sha2.cpp:214–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212/* SHA-256 context structure */
213
214void sha256_ctx::transf(const unsigned char* message,
215 unsigned int block_nb)
216{
217 typedef sha2_types::uint32 uint32;
218
219 sha256_ctx* const ctx=this;
220
221 uint32 w[64];
222 uint32 wv[8];
223
224 for (int i = 0; i < (int) block_nb; i++)
225 {
226 const unsigned char* const sub_block = message + (i << 6);
227
228#ifndef UNROLL_LOOPS
229 for (int j = 0; j < 16; j++)
230 {
231 PACK32(&sub_block[j << 2], &w[j]);
232 }
233
234 for (int j = 16; j < 64; j++)
235 {
236 SHA256_SCR(j);
237 }
238
239 for (int j = 0; j < 8; j++)
240 {
241 wv[j] = ctx->h[j];
242 }
243
244 for (int j = 0; j < 64; j++)
245 {
246 const uint32 t1 = wv[7] + SHA256_F2(wv[4]) + CH(wv[4], wv[5], wv[6]) + sha256_k[j] + w[j];
247 const uint32 t2 = SHA256_F1(wv[0]) + MAJ(wv[0], wv[1], wv[2]);
248 wv[7] = wv[6];
249 wv[6] = wv[5];
250 wv[5] = wv[4];
251 wv[4] = wv[3] + t1;
252 wv[3] = wv[2];
253 wv[2] = wv[1];
254 wv[1] = wv[0];
255 wv[0] = t1 + t2;
256 }
257
258 for (int j = 0; j < 8; j++)
259 {
260 ctx->h[j] += wv[j];
261 }
262#else
263 PACK32(&sub_block[ 0], &w[ 0]); PACK32(&sub_block[ 4], &w[ 1]);
264 PACK32(&sub_block[ 8], &w[ 2]); PACK32(&sub_block[12], &w[ 3]);
265 PACK32(&sub_block[16], &w[ 4]); PACK32(&sub_block[20], &w[ 5]);
266 PACK32(&sub_block[24], &w[ 6]); PACK32(&sub_block[28], &w[ 7]);
267 PACK32(&sub_block[32], &w[ 8]); PACK32(&sub_block[36], &w[ 9]);
268 PACK32(&sub_block[40], &w[10]); PACK32(&sub_block[44], &w[11]);
269 PACK32(&sub_block[48], &w[12]); PACK32(&sub_block[52], &w[13]);
270 PACK32(&sub_block[56], &w[14]); PACK32(&sub_block[60], &w[15]);
271

Callers 2

sha_updateMethod · 0.80
sha_finalMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected