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

Function blake2s_final

freebsd/contrib/libb2/blake2s.c:362–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360
361
362int blake2s_final( blake2s_state *S, uint8_t *out, size_t outlen )
363{
364 uint8_t buffer[BLAKE2S_OUTBYTES];
365
366 if(outlen != S->outlen ) return -1;
367
368 if( S->buflen > BLAKE2S_BLOCKBYTES )
369 {
370 blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
371 blake2s_compress( S, S->buf );
372 S->buflen -= BLAKE2S_BLOCKBYTES;
373 memcpy( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
374 }
375
376 blake2s_increment_counter( S, ( uint32_t )S->buflen );
377 blake2s_set_lastblock( S );
378 memset( S->buf + S->buflen, 0, 2 * BLAKE2S_BLOCKBYTES - S->buflen ); /* Padding */
379 blake2s_compress( S, S->buf );
380
381 for( int i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
382 store32( buffer + sizeof( S->h[i] ) * i, S->h[i] );
383
384 memcpy( out, buffer, outlen );
385 return 0;
386}
387
388int blake2s( uint8_t *out, const void *in, const void *key, size_t outlen, size_t inlen, size_t keylen )
389{

Callers 4

blake2sp_finalFunction · 0.70
blake2spFunction · 0.70
blake2sFunction · 0.70
blake2_cipher_processFunction · 0.50

Calls 6

memsetFunction · 0.85
store32Function · 0.85
blake2s_compressFunction · 0.70
blake2s_set_lastblockFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected