aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcryptobox
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-25 23:23:20 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-25 23:23:20 +0000
commit293fbe463c776c1d169d4030db62fff6cf1fbba4 (patch)
treed597d0fc3b33fddbacf23916809ca9da73e78927 /src/libcryptobox
parent6ca35268fea102054277895f45425bc8a64992b8 (diff)
downloadrspamd-293fbe463c776c1d169d4030db62fff6cf1fbba4.tar.gz
rspamd-293fbe463c776c1d169d4030db62fff6cf1fbba4.zip
Fix issues with keyed hash API.
Diffstat (limited to 'src/libcryptobox')
-rw-r--r--src/libcryptobox/blake2/blake2.c14
-rw-r--r--src/libcryptobox/blake2/blake2.h2
-rw-r--r--src/libcryptobox/cryptobox.h1
3 files changed, 6 insertions, 11 deletions
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];