diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-08 13:32:53 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-08 13:32:53 +0100 |
commit | 4cc70328cf728643450ad25eb4c8718942a19e1d (patch) | |
tree | d724a566b7e4dbcbecf6118194f05f854389976e /src/libcryptobox | |
parent | f33dfad9746ac11d187fc2b1d6330106c8d59d17 (diff) | |
download | rspamd-4cc70328cf728643450ad25eb4c8718942a19e1d.tar.gz rspamd-4cc70328cf728643450ad25eb4c8718942a19e1d.zip |
Use new siphash implementation.
Diffstat (limited to 'src/libcryptobox')
-rw-r--r-- | src/libcryptobox/cryptobox.c | 9 | ||||
-rw-r--r-- | src/libcryptobox/cryptobox.h | 13 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c index 847f005f1..e1a3a2b8f 100644 --- a/src/libcryptobox/cryptobox.c +++ b/src/libcryptobox/cryptobox.c @@ -243,3 +243,12 @@ rspamd_cryptobox_encrypt_inplace (guchar *data, gsize len, rspamd_cryptobox_encrypt_nm_inplace (data, len, nonce, nm, sig); rspamd_explicit_memzero (nm, sizeof (nm)); } + + +void +rspamd_cryptobox_siphash (unsigned char *out, const unsigned char *in, + unsigned long long inlen, + const rspamd_sipkey_t k) +{ + siphash24 (out, in, inlen, k); +} diff --git a/src/libcryptobox/cryptobox.h b/src/libcryptobox/cryptobox.h index 0a689d7de..b60af5619 100644 --- a/src/libcryptobox/cryptobox.h +++ b/src/libcryptobox/cryptobox.h @@ -30,12 +30,14 @@ #define rspamd_cryptobox_SKBYTES 32 #define rspamd_cryptobox_MACBYTES 16 #define rspamd_cryptobox_NMBYTES 32 +#define rspamd_cryptobox_SIPKEYBYTES 16 typedef guchar rspamd_pk_t[rspamd_cryptobox_PKBYTES]; typedef guchar rspamd_sk_t[rspamd_cryptobox_SKBYTES]; typedef guchar rspamd_sig_t[rspamd_cryptobox_MACBYTES]; typedef guchar rspamd_nm_t[rspamd_cryptobox_NMBYTES]; typedef guchar rspamd_nonce_t[rspamd_cryptobox_NONCEBYTES]; +typedef guchar rspamd_sipkey_t[rspamd_cryptobox_SIPKEYBYTES]; /** * Init cryptobox library @@ -116,4 +118,15 @@ void rspamd_cryptobox_nm (rspamd_nm_t nm, const rspamd_pk_t pk, const rspamd_sk_ */ void rspamd_explicit_memzero (void * const buf, gsize buflen); +/** + * Calculates siphash-2-4 for a message + * @param out (8 bytes output) + * @param in + * @param inlen + * @param k key (must be 16 bytes) + */ +void rspamd_cryptobox_siphash (unsigned char *out, const unsigned char *in, + unsigned long long inlen, + const rspamd_sipkey_t k); + #endif /* CRYPTOBOX_H_ */ |