aboutsummaryrefslogtreecommitdiffstats
path: root/siphash.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-09 07:12:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-09 07:12:00 +0000
commit525cb66467ff22a50f2e6bf307924459d38cd592 (patch)
treecdf539d08cb2ac619a0376e7241f2b19eccd06b5 /siphash.h
parentfdbd3716781817c840544796d04a7d41b856d9f4 (diff)
downloadruby-525cb66467ff22a50f2e6bf307924459d38cd592.tar.gz
siphash
* random.c (rb_memhash): use siphash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'siphash.h')
-rw-r--r--siphash.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/siphash.h b/siphash.h
new file mode 100644
index 0000000000..2a06f32371
--- /dev/null
+++ b/siphash.h
@@ -0,0 +1,44 @@
+#ifndef SIPHASH_H
+#define SIPHASH_H 1
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#ifndef HAVE_UINT64_T
+typedef struct {
+ uint32_t u32[2];
+} sip_uint64_t;
+#define uint64_t sip_uint64_t
+#else
+typedef uint64_t sip_uint64_t;
+#endif
+
+typedef struct {
+ int c;
+ int d;
+ uint64_t v[4];
+ uint8_t buf[sizeof(uint64_t)];
+ uint8_t buflen;
+ uint8_t msglen_byte;
+} sip_state;
+
+typedef struct sip_interface_st sip_interface;
+
+typedef struct {
+ sip_state state[1];
+ const sip_interface *methods;
+} sip_hash;
+
+sip_hash *sip_hash_new(const uint8_t key[16], int c, int d);
+sip_hash *sip_hash_init(sip_hash *h, const uint8_t key[16], int c, int d);
+int sip_hash_update(sip_hash *h, const uint8_t *data, size_t len);
+int sip_hash_final(sip_hash *h, uint8_t **digest, size_t *len);
+int sip_hash_final_integer(sip_hash *h, uint64_t *digest);
+int sip_hash_digest(sip_hash *h, const uint8_t *data, size_t data_len, uint8_t **digest, size_t *digest_len);
+int sip_hash_digest_integer(sip_hash *h, const uint8_t *data, size_t data_len, uint64_t *digest);
+void sip_hash_free(sip_hash *h);
+void sip_hash_dump(sip_hash *h);
+
+uint64_t sip_hash24(const uint8_t key[16], const uint8_t *data, size_t len);
+
+#endif