Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/BLAKE2/BLAKE2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJP Aumasson <jeanphilippe.aumasson@gmail.com>2015-10-15 00:03:14 +0300
committerJP Aumasson <jeanphilippe.aumasson@gmail.com>2015-10-15 00:03:14 +0300
commita18d2b03fb0df1458c447d488816b51b1164c006 (patch)
treeaa030f2a137db4c51ccc83f0aa0b2aeb606a2eb9
parent7d657211ab04ff404e050e12aa01db43a3773e66 (diff)
consistent checks
-rw-r--r--ref/blake2b-ref.c8
-rw-r--r--ref/blake2bp-ref.c8
-rw-r--r--ref/blake2s-ref.c8
-rw-r--r--ref/blake2sp-ref.c8
-rw-r--r--sse/blake2b.c8
-rw-r--r--sse/blake2bp.c8
-rw-r--r--sse/blake2s.c8
-rw-r--r--sse/blake2sp.c8
8 files changed, 48 insertions, 16 deletions
diff --git a/ref/blake2b-ref.c b/ref/blake2b-ref.c
index f962671..f9e852a 100644
--- a/ref/blake2b-ref.c
+++ b/ref/blake2b-ref.c
@@ -341,11 +341,15 @@ int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen
blake2b_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;
+ if( NULL == key && keylen > 0 ) return -1;
+
+ if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
+
+ if( keylen > BLAKE2B_KEYBYTES ) return -1;
if( keylen > 0 )
{
diff --git a/ref/blake2bp-ref.c b/ref/blake2bp-ref.c
index 16542ef..d265549 100644
--- a/ref/blake2bp-ref.c
+++ b/ref/blake2bp-ref.c
@@ -190,11 +190,15 @@ int blake2bp( uint8_t *out, const void *in, const void *key, uint8_t outlen, uin
blake2b_state FS[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;
+ if( NULL == key && keylen > 0 ) return -1;
+
+ if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
+
+ if( keylen > BLAKE2B_KEYBYTES ) return -1;
for( size_t i = 0; i < PARALLELISM_DEGREE; ++i )
if( blake2bp_init_leaf( S[i], outlen, keylen, i ) < 0 ) return -1;
diff --git a/ref/blake2s-ref.c b/ref/blake2s-ref.c
index 9678e79..0746ac5 100644
--- a/ref/blake2s-ref.c
+++ b/ref/blake2s-ref.c
@@ -329,11 +329,15 @@ int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen
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; /* Fail here instead if keylen != 0 and key == NULL? */
+ if ( NULL == key && keylen > 0) return -1;
+
+ if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
+
+ if( keylen > BLAKE2S_KEYBYTES ) return -1;
if( keylen > 0 )
{
diff --git a/ref/blake2sp-ref.c b/ref/blake2sp-ref.c
index 0e30e49..4397618 100644
--- a/ref/blake2sp-ref.c
+++ b/ref/blake2sp-ref.c
@@ -188,11 +188,15 @@ int blake2sp( uint8_t *out, const void *in, const void *key, uint8_t outlen, uin
blake2s_state FS[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;
+ if ( NULL == key && keylen > 0) return -1;
+
+ if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
+
+ if( keylen > BLAKE2S_KEYBYTES ) return -1;
for( size_t i = 0; i < PARALLELISM_DEGREE; ++i )
if( blake2sp_init_leaf( S[i], outlen, keylen, i ) < 0 ) return -1;
diff --git a/sse/blake2b.c b/sse/blake2b.c
index 634f0ae..906b10e 100644
--- a/sse/blake2b.c
+++ b/sse/blake2b.c
@@ -375,11 +375,15 @@ int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen
blake2b_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;
+ if( NULL == key && keylen > 0 ) return -1;
+
+ if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
+
+ if( keylen > BLAKE2B_KEYBYTES ) return -1;
if( keylen )
{
diff --git a/sse/blake2bp.c b/sse/blake2bp.c
index d93784c..5734515 100644
--- a/sse/blake2bp.c
+++ b/sse/blake2bp.c
@@ -191,11 +191,15 @@ int blake2bp( uint8_t *out, const void *in, const void *key, uint8_t outlen, uin
blake2b_state FS[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;
+ if( NULL == key && keylen > 0 ) return -1;
+
+ if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
+
+ if( keylen > BLAKE2B_KEYBYTES ) return -1;
for( size_t i = 0; i < PARALLELISM_DEGREE; ++i )
if( blake2bp_init_leaf( S[i], outlen, keylen, i ) < 0 ) return -1;
diff --git a/sse/blake2s.c b/sse/blake2s.c
index 1731b7d..acb0f5a 100644
--- a/sse/blake2s.c
+++ b/sse/blake2s.c
@@ -357,11 +357,15 @@ int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen
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; /* Fail here instead if keylen != 0 and key == NULL? */
+ if ( NULL == key && keylen > 0) return -1;
+
+ if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
+
+ if( keylen > BLAKE2S_KEYBYTES ) return -1;
if( keylen > 0 )
{
diff --git a/sse/blake2sp.c b/sse/blake2sp.c
index 954670f..4e5f3cb 100644
--- a/sse/blake2sp.c
+++ b/sse/blake2sp.c
@@ -188,11 +188,15 @@ int blake2sp( uint8_t *out, const void *in, const void *key, uint8_t outlen, uin
blake2s_state FS[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;
+ if ( NULL == key && keylen > 0) return -1;
+
+ if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
+
+ if( keylen > BLAKE2S_KEYBYTES ) return -1;
for( size_t i = 0; i < PARALLELISM_DEGREE; ++i )
if( blake2sp_init_leaf( S[i], outlen, keylen, i ) < 0 ) return -1;