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

Function blake2b_init_key

freebsd/contrib/libb2/blake2b.c:253–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen )
254{
255 if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
256
257 if ( ( !keylen ) || keylen > BLAKE2B_KEYBYTES ) return -1;
258
259 const blake2b_param P =
260 {
261 ( uint8_t ) outlen,
262 ( uint8_t ) keylen,
263 1,
264 1,
265 0,
266 0,
267 0,
268 0,
269 {0},
270 {0},
271 {0}
272 };
273
274 if( blake2b_init_param( S, &P ) < 0 )
275 return 0;
276
277 {
278 uint8_t block[BLAKE2B_BLOCKBYTES];
279 memset( block, 0, BLAKE2B_BLOCKBYTES );
280 memcpy( block, key, keylen );
281 blake2b_update( S, block, BLAKE2B_BLOCKBYTES );
282 secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */
283 }
284 return 0;
285}
286
287static inline int blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] )
288{

Callers 2

blake2bFunction · 0.70
blake2_cipher_processFunction · 0.50

Calls 5

memsetFunction · 0.85
secure_zero_memoryFunction · 0.85
blake2b_init_paramFunction · 0.70
blake2b_updateFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected