MCPcopy Create free account
hub / github.com/assaultcube/AC / sha512

Function sha512

source/src/crypto.cpp:262–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262void sha512(uchar *hash, const uchar *msg, int msglen)
263{
264 uint64_t state[8] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
265 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL };
266 uint64_t total = msglen * 8ULL;
267 for(; msglen >= 128; msglen -= 128)
268 {
269 sha512_compress(state, msg);
270 msg += 128;
271 }
272 uchar endmsg[128] = { 0 };
273 memcpy(endmsg, msg, msglen);
274 endmsg[msglen] = 0x80;
275 if(msglen > 111)
276 {
277 sha512_compress(state, endmsg);
278 memset(endmsg, 0, 128);
279 }
280 *((uint64_t*)(endmsg + 120)) = bigswap(total);
281 sha512_compress(state, endmsg);
282 loopi(8) ((uint64_t*)hash)[i] = bigswap(state[i]);
283}
284#undef RR64
285#undef SHA512ROUND
286

Callers 8

crypto.cppFile · 0.85
__hashtestFunction · 0.85
entropy_getFunction · 0.85
passphrase2keyFunction · 0.85
privkey_from_preprivFunction · 0.85
ed25519_signFunction · 0.85
ed25519_sign_checkFunction · 0.85

Calls 3

sha512_compressFunction · 0.85
bigswapFunction · 0.85
loopiFunction · 0.70

Tested by

no test coverage detected