1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/siphash.h
shyouhei 04c94f95d1 switch SipHash from SipHash24 to SipHash13 variant
SipHash13 is secure enough to be used in hash-tables,
and SipHash's author confirms that.
Rust already considered switch to SipHash13:
  https://github.com/rust-lang/rust/issues/29754#issue-116174313
Jean-Philippe Aumasson confirmation:
  https://github.com/rust-lang/rust/issues/29754#issuecomment-156073946
Merged pull request:
  https://github.com/rust-lang/rust/pull/33940

From: Sokolov Yura aka funny_falcon <funny.falcon@gmail.com>
Date: Thu, 8 Dec 2016 20:31:29 +0300
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
Fixes: [Feature #13017]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-20 06:01:23 +00:00

48 lines
1.3 KiB
C

#ifndef SIPHASH_H
#define SIPHASH_H 1
#include <stdlib.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#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_hash13(const uint8_t key[16], const uint8_t *data, size_t len);
#endif