| 408 | |
| 409 | |
| 410 | int blake2b( uint8_t *out, const void *in, const void *key, size_t outlen, size_t inlen, size_t keylen ) |
| 411 | { |
| 412 | blake2b_state S[1]; |
| 413 | |
| 414 | /* Verify parameters */ |
| 415 | if ( NULL == in && inlen > 0 ) return -1; |
| 416 | |
| 417 | if ( NULL == out ) return -1; |
| 418 | |
| 419 | if( NULL == key && keylen > 0 ) return -1; |
| 420 | |
| 421 | if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1; |
| 422 | |
| 423 | if( keylen > BLAKE2B_KEYBYTES ) return -1; |
| 424 | |
| 425 | if( keylen ) |
| 426 | { |
| 427 | if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1; |
| 428 | } |
| 429 | else |
| 430 | { |
| 431 | if( blake2b_init( S, outlen ) < 0 ) return -1; |
| 432 | } |
| 433 | |
| 434 | if( blake2b_update( S, ( uint8_t * )in, inlen ) < 0) return -1; |
| 435 | return blake2b_final( S, out, outlen ); |
| 436 | } |
| 437 | |
| 438 | #if defined(SUPERCOP) |
| 439 | int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen ) |
no test coverage detected