Ruby
2.0.0p247(2013-06-27revision41674)
|
00001 #ifndef SIPHASH_H 00002 #define SIPHASH_H 1 00003 #include <stdlib.h> 00004 #ifdef HAVE_STDINT_H 00005 #include <stdint.h> 00006 #endif 00007 #ifdef HAVE_INTTYPES_H 00008 #include <inttypes.h> 00009 #endif 00010 00011 #ifndef HAVE_UINT64_T 00012 typedef struct { 00013 uint32_t u32[2]; 00014 } sip_uint64_t; 00015 #define uint64_t sip_uint64_t 00016 #else 00017 typedef uint64_t sip_uint64_t; 00018 #endif 00019 00020 typedef struct { 00021 int c; 00022 int d; 00023 uint64_t v[4]; 00024 uint8_t buf[sizeof(uint64_t)]; 00025 uint8_t buflen; 00026 uint8_t msglen_byte; 00027 } sip_state; 00028 00029 typedef struct sip_interface_st sip_interface; 00030 00031 typedef struct { 00032 sip_state state[1]; 00033 const sip_interface *methods; 00034 } sip_hash; 00035 00036 sip_hash *sip_hash_new(const uint8_t key[16], int c, int d); 00037 sip_hash *sip_hash_init(sip_hash *h, const uint8_t key[16], int c, int d); 00038 int sip_hash_update(sip_hash *h, const uint8_t *data, size_t len); 00039 int sip_hash_final(sip_hash *h, uint8_t **digest, size_t *len); 00040 int sip_hash_final_integer(sip_hash *h, uint64_t *digest); 00041 int sip_hash_digest(sip_hash *h, const uint8_t *data, size_t data_len, uint8_t **digest, size_t *digest_len); 00042 int sip_hash_digest_integer(sip_hash *h, const uint8_t *data, size_t data_len, uint64_t *digest); 00043 void sip_hash_free(sip_hash *h); 00044 void sip_hash_dump(sip_hash *h); 00045 00046 uint64_t sip_hash24(const uint8_t key[16], const uint8_t *data, size_t len); 00047 00048 #endif 00049