1
0
mirror of https://github.com/BLAKE2/libb2 synced 2024-11-23 00:32:03 +01:00

consistent checks

This commit is contained in:
JP Aumasson 2015-10-14 23:03:06 +02:00
parent 4b5f51eeae
commit e0f4101303
5 changed files with 15 additions and 3 deletions

@ -367,6 +367,8 @@ int blake2b( uint8_t *out, const void *in, const void *key, size_t outlen, size_
if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
if( keylen > BLAKE2B_KEYBYTES ) return -1;
if( keylen > 0 )
{
if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1;

@ -420,6 +420,8 @@ int blake2b( uint8_t *out, const void *in, const void *key, size_t outlen, size_
if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
if( keylen > BLAKE2B_KEYBYTES ) return -1;
if( keylen )
{
if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1;

@ -349,12 +349,16 @@ int blake2s( uint8_t *out, const void *in, const void *key, size_t outlen, size_
blake2s_state S[1];
/* Verify parameters */
if ( NULL == in ) return -1;
if ( NULL == in && inlen > 0 ) return -1;
if ( NULL == out ) return -1;
if ( NULL == key && keylen > 0 ) return -1;
if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
if( keylen > BLAKE2S_KEYBYTES ) return -1;
if( keylen > 0 )
{
if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1;

@ -390,12 +390,16 @@ int blake2s( uint8_t *out, const void *in, const void *key, size_t outlen, size_
blake2s_state S[1];
/* Verify parameters */
if ( NULL == in ) return -1;
if ( NULL == in && inlen > 0 ) return -1;
if ( NULL == out ) return -1;
if ( NULL == key && keylen > 0) return -1;
if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
if( keylen > BLAKE2S_KEYBYTES ) return -1;
if( keylen > 0 )
{
if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1;

@ -197,7 +197,7 @@ int blake2sp( uint8_t *out, const void *in, const void *key, size_t outlen, size
blake2s_state FS[1];
/* Verify parameters */
if ( NULL == in ) return -1;
if ( NULL == in && inlen > 0 ) return -1;
if ( NULL == out ) return -1;