@@ -8,6 +8,7 @@
|
||||
#ifndef SIPHASH_H
|
||||
#define SIPHASH_H
|
||||
|
||||
#include "hasher.h"
|
||||
#include "../../stream/stream.h"
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
@@ -16,8 +17,7 @@
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#define WP_SIP_HASHER_128_MAGIC wpU64Const(0x5750534950313238)
|
||||
#define WP_SIP_HASHER_64_MAGIC wpU64Const(0x57505349503634)
|
||||
#define WP_SIP_HASHER_MAGIC wpU64Const(0x5750534950485348)
|
||||
|
||||
typedef struct {
|
||||
u64 lo;
|
||||
@@ -29,72 +29,28 @@ typedef struct {
|
||||
u64 magic;
|
||||
u64 compression;
|
||||
u64 finalisation;
|
||||
} WpSipHasherParams;
|
||||
|
||||
typedef struct {
|
||||
WpSipHasherParams params;
|
||||
u64 hash[2];
|
||||
} WpSipHasher128IO;
|
||||
|
||||
typedef struct {
|
||||
WpSipHasherParams params;
|
||||
u64 hash;
|
||||
} WpSipHasher64IO;
|
||||
} WpSipHasherData;
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wpSip24Hasher128IO(KEY) (WpSipHasher128IO{ \
|
||||
WpSipHasherParams{KEY, WP_SIP_HASHER_128_MAGIC, 2, 4}, \
|
||||
{}, \
|
||||
})
|
||||
#define wpSip48Hasher128IO(KEY) (WpSipHasher128IO{ \
|
||||
WpSipHasherParams{KEY, WP_SIP_HASHER_128_MAGIC, 4, 8}, \
|
||||
{}, \
|
||||
})
|
||||
#define wpSip24Hasher64IO(KEY) (WpSipHasher64IO{ \
|
||||
WpSipHasherParams{KEY, WP_SIP_HASHER_64_MAGIC, 2, 4}, \
|
||||
0, \
|
||||
})
|
||||
#define wpSip48Hasher64IO(KEY) (WpSipHasher64IO{ \
|
||||
WpSipHasherParams{KEY, WP_SIP_HASHER_64_MAGIC, 4, 8}, \
|
||||
0, \
|
||||
})
|
||||
#define wpSip24HasherData(KEY) (WpSipHasherData{KEY, WP_SIP_HASHER_MAGIC, 2, 4})
|
||||
#define wpSip48HasherData(KEY) (WpSipHasherData{KEY, WP_SIP_HASHER_MAGIC, 4, 8})
|
||||
#else
|
||||
#define wpSip24Hasher128IO(KEY) ((WpSipHasher128IO){ \
|
||||
.params = (WpSipHasherParams){ \
|
||||
.key = KEY, \
|
||||
.magic = WP_SIP_HASHER_128_MAGIC, \
|
||||
.compression = 2, \
|
||||
.finalisation = 4, \
|
||||
} \
|
||||
#define wpSip24HasherData(KEY) ((WpSipHasherData){ \
|
||||
.key = KEY, \
|
||||
.magic = WP_SIP_HASHER_MAGIC, \
|
||||
.compression = 2, \
|
||||
.finalisation = 4, \
|
||||
})
|
||||
#define wpSip48Hasher128IO(KEY) ((WpSipHasher128IO){ \
|
||||
.params = (WpSipHasherParams){ \
|
||||
.key = KEY, \
|
||||
.magic = WP_SIP_HASHER_128_MAGIC, \
|
||||
.compression = 4, \
|
||||
.finalisation = 8, \
|
||||
} \
|
||||
})
|
||||
#define wpSip24Hasher64IO(KEY) ((WpSipHasher64IO){ \
|
||||
.params = (WpSipHasherParams){ \
|
||||
.key = KEY, \
|
||||
.magic = WP_SIP_HASHER_64_MAGIC, \
|
||||
.compression = 2, \
|
||||
.finalisation = 4, \
|
||||
} \
|
||||
})
|
||||
#define wpSip48Hasher64IO(KEY) ((WpSipHasher64IO){ \
|
||||
.params = (WpSipHasherParams){ \
|
||||
.key = KEY, \
|
||||
.magic = WP_SIP_HASHER_64_MAGIC, \
|
||||
.compression = 4, \
|
||||
.finalisation = 8, \
|
||||
} \
|
||||
#define wpSip48HasherData(KEY) ((WpSipHasherData){ \
|
||||
.key = KEY, \
|
||||
.magic = WP_SIP_HASHER_MAGIC, \
|
||||
.compression = 4, \
|
||||
.finalisation = 8, \
|
||||
})
|
||||
#endif
|
||||
|
||||
void wpSipHasher128(WpU8Stream *bytes, void *hasher_io);
|
||||
void wpSipHasher64(WpU8Stream *bytes, void *hasher_io);
|
||||
WpU128Hash wpSipHasher128(WpU8Stream *bytes, void *hasher_io);
|
||||
u64 wpSipHasher64(WpU8Stream *bytes, void *hasher_io);
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
||||
Reference in New Issue
Block a user