MCPcopy Create free account
hub / github.com/F-Stack/f-stack / blake2b_final

Function blake2b_final

freebsd/contrib/libb2/blake2b-ref.c:331–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331int blake2b_final( blake2b_state *S, uint8_t *out, size_t outlen )
332{
333 uint8_t buffer[BLAKE2B_OUTBYTES];
334 size_t i;
335
336 if(S->outlen != outlen) return -1;
337
338 if( S->buflen > BLAKE2B_BLOCKBYTES )
339 {
340 blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
341 blake2b_compress( S, S->buf );
342 S->buflen -= BLAKE2B_BLOCKBYTES;
343 memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, S->buflen );
344 }
345
346 blake2b_increment_counter( S, S->buflen );
347 blake2b_set_lastblock( S );
348 memset( S->buf + S->buflen, 0, 2 * BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */
349 blake2b_compress( S, S->buf );
350
351 for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
352 store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
353
354 memcpy( out, buffer, outlen );
355 return 0;
356}
357
358int blake2b( uint8_t *out, const void *in, const void *key, size_t outlen, size_t inlen, size_t keylen )
359{

Callers 1

blake2bFunction · 0.70

Calls 6

memsetFunction · 0.85
store64Function · 0.85
blake2b_compressFunction · 0.70
blake2b_set_lastblockFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected