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:
Diffstat (limited to 'ref/blake2s-ref.c')
-rw-r--r--ref/blake2s-ref.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ref/blake2s-ref.c b/ref/blake2s-ref.c
index 2bab23f..a10f7ef 100644
--- a/ref/blake2s-ref.c
+++ b/ref/blake2s-ref.c
@@ -53,6 +53,11 @@ static inline int blake2s_clear_lastnode( blake2s_state *S )
}
/* Some helper functions, not necessarily useful */
+static inline int blake2s_is_lastblock( const blake2s_state *S )
+{
+ return S->f[0] != 0;
+}
+
static inline int blake2s_set_lastblock( blake2s_state *S )
{
if( S->last_node ) blake2s_set_lastnode( S );
@@ -306,6 +311,10 @@ int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen )
if( out == NULL || outlen == 0 || outlen > BLAKE2S_OUTBYTES )
return -1;
+ if( blake2s_is_lastblock( S ) )
+ return -1;
+
+
if( S->buflen > BLAKE2S_BLOCKBYTES )
{
blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );