//byteswap the input (if we're on a little endian cpu, as we are) for (i = 0; i < SHA2_BLOCK_SIZE / sizeof(uint32_t); i++)
state->w[i] = __builtin_bswap32(state->w[i]);
//init working variables
a = state->h[0];
b = state->h[1];
c = state->h[2];
d = state->h[3];
e = state->h[4];
f = state->h[5];
g = state->h[6];
h = state->h[7];
//64 rounds for (i = 0; i < 64; i++) {
uint32_t s1 = ror(e, 6) ^ ror(e, 11) ^ ror(e, 25);
uint32_t ch = (e & f) ^ ((~e) & g);
uint32_t temp1 = h + s1 + ch + k[i] + state->w[i];
uint32_t s0 = ror(a, 2) ^ ror(a, 13) ^ ror(a, 22);
uint32_t maj = (a & b) ^ (a & c) ^ (b & c);
uint32_t temp2 = s0 + maj;
h = g;
g = f;
f = e;
e = d + temp1;
d = c;
c = b;
b = a;
a = temp1 + temp2;
}
//put result back into state
state->h[0] += a;
state->h[1] += b;
state->h[2] += c;
state->h[3] += d;
state->h[4] += e;
state->h[5] += f;
state->h[6] += g;
state->h[7] += h;
}
state->msgLen += numBytes; while (numBytes) {
uint32_t bytesToCopy;
//step 1: copy data into state if there is space & there is data
bytesToCopy = numBytes; if (bytesToCopy > SHA2_BLOCK_SIZE - state->bufBytesUsed)
bytesToCopy = SHA2_BLOCK_SIZE - state->bufBytesUsed;
memcpy(state->b + state->bufBytesUsed, inBytes, bytesToCopy);
inBytes += bytesToCopy;
numBytes -= bytesToCopy;
state->bufBytesUsed += bytesToCopy;
//step 2: if there is a full block, process it if (state->bufBytesUsed == SHA2_BLOCK_SIZE) {
sha2processBlock(state);
state->bufBytesUsed = 0;
}
}
}
//append the one
sha2processBytes(state, &appendend, 1);
//append the zeroes
appendend = 0; while (state->bufBytesUsed != 56)
sha2processBytes(state, &appendend, 1);
//append the length in bits (we can safely write into state since we're sure where to write to (we're definitely 56-bytes into a block) for (i = 0; i < 8; i++, dataLenInBits >>= 8)
state->b[63 - i] = dataLenInBits;
//process last block
sha2processBlock(state);
//return pointer to hash return state->h;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.