summaryrefslogtreecommitdiff
path: root/crypto/hash
diff options
context:
space:
mode:
authorKai Gunger <kgunger12@gmail.com>2026-11-15 04:23:39 -0500
committerKai Gunger <kgunger12@gmail.com>2026-11-15 04:23:39 -0500
commit3e09a6ae3aea3b90961e4216339368775ea7c842 (patch)
tree181277b38e19e04d24868e29ca58a9002e1ec284 /crypto/hash
parent11a6fb0fed699a4028bcd454c0f175ca01607a68 (diff)
cstring Map to void pointer
Diffstat (limited to 'crypto/hash')
-rw-r--r--crypto/hash/siphash.tnsl21
1 files changed, 6 insertions, 15 deletions
diff --git a/crypto/hash/siphash.tnsl b/crypto/hash/siphash.tnsl
index 98be8f8..b536f85 100644
--- a/crypto/hash/siphash.tnsl
+++ b/crypto/hash/siphash.tnsl
@@ -9,11 +9,16 @@
# Jean-Philippe Aumasson
# Daniel J. Bernstein
-# This implementation was written by NatCounter for libtnsl
+# This implementation was adapted by NatCounter for libtnsl
+# and probably only works on LE systems at the moment
int SIPHASH_CROUNDS = 2
int SIPHASH_DROUNDS = 4
+struct SipHashKey {
+ uint64 k0, k1
+}
+
/; SIPHASH_ROTL (uint64 x, b) [uint64]
return (x << b) | (x >> (64 - b))
;/
@@ -42,14 +47,6 @@ int SIPHASH_DROUNDS = 4
return out
;/
-/; SIPHASH_TRACE (uint64 v0, v1, v2, v3)
- _print("TRACE:\n\0")
- _print_num(" v0: %016lx\n\0", v0)
- _print_num(" v1: %016lx\n\0", v1)
- _print_num(" v2: %016lx\n\0", v2)
- _print_num(" v3: %016lx\n\0", v3)
-;/
-
/; siphash (~uint8 in, uint64 in_len, ~uint8 k, ~uint8 out, uint64 out_len) [int]
uint64 v0 = 0x736f6d65
@@ -84,7 +81,6 @@ int SIPHASH_DROUNDS = 4
m = SIPHASH_U8_TO_64_LE(in)
v3 = v3 ^ m
- SIPHASH_TRACE(v0, v1, v2, v3)
/; loop (i = 0; i < SIPHASH_CROUNDS ) [i++]
v0 = v0 + v1
v1 = SIPHASH_ROTL(v1, 13)
@@ -107,14 +103,11 @@ int SIPHASH_DROUNDS = 4
/; loop (left--; left !< 0) [left--]
uint64 ii = in{left}
- _print_num("ii: %08x\n\0", ii)
b = b | (ii << (left * 8))
;/
- _print_num("b: %016lx\n\0", b)
v3 = v3 ^ b
- SIPHASH_TRACE(v0, v1, v2, v3)
/; loop (i = 0; i < SIPHASH_CROUNDS ) [i++]
v0 = v0 + v1
v1 = SIPHASH_ROTL(v1, 13)
@@ -140,7 +133,6 @@ int SIPHASH_DROUNDS = 4
v2 = v2 ^ 0xff
;/
- SIPHASH_TRACE(v0, v1, v2, v3)
/; loop (i = 0; i < SIPHASH_DROUNDS ) [i++]
v0 = v0 + v1
v1 = SIPHASH_ROTL(v1, 13)
@@ -167,7 +159,6 @@ int SIPHASH_DROUNDS = 4
v1 = v1 ^ 0xdd
- SIPHASH_TRACE(v0, v1, v2, v3)
/; loop (i = 0; i < SIPHASH_DROUNDS ) [i++]
v0 = v0 + v1
v1 = SIPHASH_ROTL(v1, 13)