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:
authorSamuel Neves <sneves@dei.uc.pt>2016-11-09 23:37:09 +0300
committerSamuel Neves <sneves@dei.uc.pt>2016-11-09 23:41:14 +0300
commita90684ab3fe788b2ca45076cf9b38335de289f58 (patch)
tree4b34fa043b9f5d48097527274c59d5ceb1234144
parentd4418edab4b9e7595973f876f82d9fecf54b9d19 (diff)
Address bug with small blake2*p output sizes (see #36)
-rw-r--r--ref/blake2bp-ref.c22
-rw-r--r--ref/blake2sp-ref.c22
-rw-r--r--sse/blake2b.c6
-rw-r--r--sse/blake2bp.c22
-rw-r--r--sse/blake2sp.c22
5 files changed, 75 insertions, 19 deletions
diff --git a/ref/blake2bp-ref.c b/ref/blake2bp-ref.c
index ae48861..d58a152 100644
--- a/ref/blake2bp-ref.c
+++ b/ref/blake2bp-ref.c
@@ -1,14 +1,14 @@
/*
BLAKE2 reference source code package - reference C implementations
-
+
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
-
+
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
-
+
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
@@ -27,6 +27,20 @@
#define PARALLELISM_DEGREE 4
+/*
+ blake2b_init_param defaults to setting the expecting output length
+ from the digest_length parameter block field.
+
+ In some cases, however, we do not want this, as the output length
+ of these instances is given by inner_length instead.
+*/
+static int blake2bp_init_leaf_param( blake2b_state *S, const blake2b_param *P )
+{
+ int err = blake2b_init_param(S, P);
+ S->outlen = P->inner_length;
+ return err;
+}
+
static int blake2bp_init_leaf( blake2b_state *S, size_t outlen, size_t keylen, uint64_t offset )
{
blake2b_param P[1];
@@ -42,7 +56,7 @@ static int blake2bp_init_leaf( blake2b_state *S, size_t outlen, size_t keylen, u
memset( P->reserved, 0, sizeof( P->reserved ) );
memset( P->salt, 0, sizeof( P->salt ) );
memset( P->personal, 0, sizeof( P->personal ) );
- return blake2b_init_param( S, P );
+ return blake2bp_init_leaf_param( S, P );
}
static int blake2bp_init_root( blake2b_state *S, size_t outlen, size_t keylen )
diff --git a/ref/blake2sp-ref.c b/ref/blake2sp-ref.c
index e9e9259..29f5c1d 100644
--- a/ref/blake2sp-ref.c
+++ b/ref/blake2sp-ref.c
@@ -1,14 +1,14 @@
/*
BLAKE2 reference source code package - reference C implementations
-
+
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
-
+
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
-
+
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
@@ -26,6 +26,20 @@
#define PARALLELISM_DEGREE 8
+/*
+ blake2sp_init_param defaults to setting the expecting output length
+ from the digest_length parameter block field.
+
+ In some cases, however, we do not want this, as the output length
+ of these instances is given by inner_length instead.
+*/
+static int blake2sp_init_leaf_param( blake2s_state *S, const blake2s_param *P )
+{
+ int err = blake2s_init_param(S, P);
+ S->outlen = P->inner_length;
+ return err;
+}
+
static int blake2sp_init_leaf( blake2s_state *S, size_t outlen, size_t keylen, uint64_t offset )
{
blake2s_param P[1];
@@ -40,7 +54,7 @@ static int blake2sp_init_leaf( blake2s_state *S, size_t outlen, size_t keylen, u
P->inner_length = BLAKE2S_OUTBYTES;
memset( P->salt, 0, sizeof( P->salt ) );
memset( P->personal, 0, sizeof( P->personal ) );
- return blake2s_init_param( S, P );
+ return blake2sp_init_leaf_param( S, P );
}
static int blake2sp_init_root( blake2s_state *S, size_t outlen, size_t keylen )
diff --git a/sse/blake2b.c b/sse/blake2b.c
index 92423d3..faa9679 100644
--- a/sse/blake2b.c
+++ b/sse/blake2b.c
@@ -1,14 +1,14 @@
/*
BLAKE2 reference source code package - optimized C implementations
-
+
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
-
+
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
-
+
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
diff --git a/sse/blake2bp.c b/sse/blake2bp.c
index 489af81..1996cc4 100644
--- a/sse/blake2bp.c
+++ b/sse/blake2bp.c
@@ -1,14 +1,14 @@
/*
BLAKE2 reference source code package - optimized C implementations
-
+
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
-
+
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
-
+
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
@@ -27,6 +27,20 @@
#define PARALLELISM_DEGREE 4
+/*
+ blake2b_init_param defaults to setting the expecting output length
+ from the digest_length parameter block field.
+
+ In some cases, however, we do not want this, as the output length
+ of these instances is given by inner_length instead.
+*/
+static int blake2bp_init_leaf_param( blake2b_state *S, const blake2b_param *P )
+{
+ int err = blake2b_init_param(S, P);
+ S->outlen = P->inner_length;
+ return err;
+}
+
static int blake2bp_init_leaf( blake2b_state *S, size_t outlen, size_t keylen, uint64_t offset )
{
blake2b_param P[1];
@@ -42,7 +56,7 @@ static int blake2bp_init_leaf( blake2b_state *S, size_t outlen, size_t keylen, u
memset( P->reserved, 0, sizeof( P->reserved ) );
memset( P->salt, 0, sizeof( P->salt ) );
memset( P->personal, 0, sizeof( P->personal ) );
- return blake2b_init_param( S, P );
+ return blake2bp_init_leaf_param( S, P );
}
static int blake2bp_init_root( blake2b_state *S, size_t outlen, size_t keylen )
diff --git a/sse/blake2sp.c b/sse/blake2sp.c
index 00330d7..43ef004 100644
--- a/sse/blake2sp.c
+++ b/sse/blake2sp.c
@@ -1,14 +1,14 @@
/*
BLAKE2 reference source code package - optimized C implementations
-
+
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
-
+
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
-
+
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
@@ -26,6 +26,20 @@
#define PARALLELISM_DEGREE 8
+/*
+ blake2sp_init_param defaults to setting the expecting output length
+ from the digest_length parameter block field.
+
+ In some cases, however, we do not want this, as the output length
+ of these instances is given by inner_length instead.
+*/
+static int blake2sp_init_leaf_param( blake2s_state *S, const blake2s_param *P )
+{
+ int err = blake2s_init_param(S, P);
+ S->outlen = P->inner_length;
+ return err;
+}
+
static int blake2sp_init_leaf( blake2s_state *S, size_t outlen, size_t keylen, uint64_t offset )
{
blake2s_param P[1];
@@ -40,7 +54,7 @@ static int blake2sp_init_leaf( blake2s_state *S, size_t outlen, size_t keylen, u
P->inner_length = BLAKE2S_OUTBYTES;
memset( P->salt, 0, sizeof( P->salt ) );
memset( P->personal, 0, sizeof( P->personal ) );
- return blake2s_init_param( S, P );
+ return blake2sp_init_leaf_param( S, P );
}
static int blake2sp_init_root( blake2s_state *S, size_t outlen, size_t keylen )