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

Function blake2s_final

freebsd/contrib/libb2/blake2s-ref.c:321–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321int blake2s_final( blake2s_state *S, uint8_t *out, size_t outlen )
322{
323 uint8_t buffer[BLAKE2S_OUTBYTES];
324 size_t i;
325
326 if(S->outlen != outlen) return -1;
327
328 if( S->buflen > BLAKE2S_BLOCKBYTES )
329 {
330 blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
331 blake2s_compress( S, S->buf );
332 S->buflen -= BLAKE2S_BLOCKBYTES;
333 memcpy( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
334 }
335
336 blake2s_increment_counter( S, ( uint32_t )S->buflen );
337 blake2s_set_lastblock( S );
338 memset( S->buf + S->buflen, 0, 2 * BLAKE2S_BLOCKBYTES - S->buflen ); /* Padding */
339 blake2s_compress( S, S->buf );
340
341 for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
342 store32( buffer + sizeof( S->h[i] ) * i, S->h[i] );
343
344 memcpy( out, buffer, outlen );
345 return 0;
346}
347
348int blake2s( uint8_t *out, const void *in, const void *key, size_t outlen, size_t inlen, size_t keylen )
349{

Callers 1

blake2sFunction · 0.70

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