From: Vsevolod Stakhov Date: Sun, 25 Oct 2015 23:23:20 +0000 (+0000) Subject: Fix issues with keyed hash API. X-Git-Tag: 1.0.7~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=293fbe463c776c1d169d4030db62fff6cf1fbba4;p=rspamd.git Fix issues with keyed hash API. --- diff --git a/src/libcryptobox/blake2/blake2.c b/src/libcryptobox/blake2/blake2.c index 9c3ce8c2b..594459bf7 100644 --- a/src/libcryptobox/blake2/blake2.c +++ b/src/libcryptobox/blake2/blake2.c @@ -140,15 +140,9 @@ void blake2b_keyed_init (blake2b_state *S, const unsigned char *key, size_t keylen) { unsigned char k[BLAKE2B_BLOCKBYTES] = {0}; - if (keylen > BLAKE2B_KEYBYTES) { - fprintf (stderr, - "key size larger than %u passed to blake2b_keyed_init", - BLAKE2B_KEYBYTES); - exit (-1); - } - else { - memcpy (k, key, keylen); - } + + g_assert (keylen <= BLAKE2B_KEYBYTES); + memcpy (k, key, keylen); blake2b_init (S); blake2b_update (S, k, BLAKE2B_BLOCKBYTES); } @@ -278,4 +272,4 @@ blake2b_load (void) } } } -} \ No newline at end of file +} diff --git a/src/libcryptobox/blake2/blake2.h b/src/libcryptobox/blake2/blake2.h index 33a5e99c4..37f1dbb4b 100644 --- a/src/libcryptobox/blake2/blake2.h +++ b/src/libcryptobox/blake2/blake2.h @@ -65,7 +65,7 @@ void blake2b_keyed (unsigned char *hash, const unsigned char *key, size_t keylen); -int blake2b_load (void); +void blake2b_load (void); #if defined(__cplusplus) } diff --git a/src/libcryptobox/cryptobox.h b/src/libcryptobox/cryptobox.h index 7d18e2c32..7977bd0e6 100644 --- a/src/libcryptobox/cryptobox.h +++ b/src/libcryptobox/cryptobox.h @@ -37,6 +37,7 @@ struct rspamd_cryptobox_segment { #define rspamd_cryptobox_MAX_NMBYTES 32 #define rspamd_cryptobox_SIPKEYBYTES 16 #define rspamd_cryptobox_HASHBYTES 64 +#define rspamd_cryptobox_HASHKEYBYTES 64 #define rspamd_cryptobox_HASHSTATEBYTES 256 typedef guchar rspamd_pk_t[rspamd_cryptobox_MAX_PKBYTES];