| 386 | } |
| 387 | |
| 388 | int blake2s( uint8_t *out, const void *in, const void *key, size_t outlen, size_t inlen, size_t keylen ) |
| 389 | { |
| 390 | blake2s_state S[1]; |
| 391 | |
| 392 | /* Verify parameters */ |
| 393 | if ( NULL == in && inlen > 0 ) return -1; |
| 394 | |
| 395 | if ( NULL == out ) return -1; |
| 396 | |
| 397 | if ( NULL == key && keylen > 0) return -1; |
| 398 | |
| 399 | if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1; |
| 400 | |
| 401 | if( keylen > BLAKE2S_KEYBYTES ) return -1; |
| 402 | |
| 403 | if( keylen > 0 ) |
| 404 | { |
| 405 | if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1; |
| 406 | } |
| 407 | else |
| 408 | { |
| 409 | if( blake2s_init( S, outlen ) < 0 ) return -1; |
| 410 | } |
| 411 | |
| 412 | if( blake2s_update( S, ( uint8_t * )in, inlen ) < 0) return -1; |
| 413 | return blake2s_final( S, out, outlen ); |
| 414 | } |
| 415 | |
| 416 | #if defined(SUPERCOP) |
| 417 | int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen ) |
no test coverage detected