瀏覽代碼

Add generic procedure for default SipHash 2-4

zhibog 3 年之前
父節點
當前提交
b6dc253d8b
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      core/crypto/siphash/siphash.odin

+ 20 - 0
core/crypto/siphash/siphash.odin

@@ -8,6 +8,8 @@ package siphash
         zhibog:  Initial implementation.
 
     Implementation of the SipHash hashing algorithm, as defined at <https://github.com/veorq/SipHash> and <https://www.aumasson.jp/siphash/siphash.pdf>
+
+    Use the specific procedures for a certain setup. The generic procdedures will default to Siphash 2-4
 */
 
 import "core:crypto"
@@ -116,6 +118,17 @@ sum_2_4 :: proc {
     sum_bytes_to_buffer_2_4,
 }
 
+sum_string           :: sum_string_2_4
+sum_bytes            :: sum_bytes_2_4
+sum_string_to_buffer :: sum_string_to_buffer_2_4
+sum_bytes_to_buffer  :: sum_bytes_to_buffer_2_4
+sum :: proc {
+    sum_string,
+    sum_bytes,
+    sum_string_to_buffer,
+    sum_bytes_to_buffer,
+}
+
 // verify_u64_2_4 will check if the supplied tag matches with the output you 
 // will get from the provided message and key
 verify_u64_2_4 :: proc (tag: u64 msg, key: []byte) -> bool {
@@ -135,6 +148,13 @@ verify_2_4 :: proc {
     verify_u64_2_4,
 }
 
+verify_bytes :: verify_bytes_2_4
+verify_u64   :: verify_u64_2_4
+verify :: proc {
+    verify_bytes,
+    verify_u64,
+}
+
 // sum_string_4_8 will hash the given message with the key and return
 // the computed hash as a u64
 sum_string_4_8 :: proc(msg, key: string) -> u64 {