| 356 | } |
| 357 | |
| 358 | int blake2b( uint8_t *out, const void *in, const void *key, size_t outlen, size_t inlen, size_t keylen ) |
| 359 | { |
| 360 | blake2b_state S[1]; |
| 361 | |
| 362 | /* Verify parameters */ |
| 363 | if ( NULL == in && inlen > 0 ) return -1; |
| 364 | |
| 365 | if ( NULL == out ) return -1; |
| 366 | |
| 367 | if( NULL == key && keylen > 0 ) return -1; |
| 368 | |
| 369 | if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1; |
| 370 | |
| 371 | if( keylen > BLAKE2B_KEYBYTES ) return -1; |
| 372 | |
| 373 | if( keylen > 0 ) |
| 374 | { |
| 375 | if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1; |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | if( blake2b_init( S, outlen ) < 0 ) return -1; |
| 380 | } |
| 381 | |
| 382 | if( blake2b_update( S, ( uint8_t * )in, inlen ) < 0 ) return -1; |
| 383 | return blake2b_final( S, out, outlen ); |
| 384 | } |
| 385 | |
| 386 |
nothing calls this directly
no test coverage detected