core/crypto/siphash: Cleanups

- Use `encoding/endian`
- Use `math/bits`
- Add `@(private)` annotations to internals
- Minor optimization
This commit is contained in:
Yawning Angel
2023-11-17 16:53:29 +09:00
parent 7c1119f217
commit a162b51588
2 changed files with 19 additions and 20 deletions
+4 -4
View File
@@ -14,7 +14,7 @@ package vendor_siphash
*/
import "core:crypto"
import "core:crypto/util"
import "core:encoding/endian"
import botan "../bindings"
@@ -35,7 +35,7 @@ sum_bytes_1_3 :: proc (msg, key: []byte) -> u64 {
init(&ctx, key[:], 1, 3)
update(&ctx, msg[:])
final(&ctx, dst[:])
return util.U64_LE(dst[:])
return endian.unchecked_get_u64le(dst[:])
}
// sum_string_to_buffer_1_3 will hash the given message with the key and write
@@ -94,7 +94,7 @@ sum_bytes_2_4 :: proc (msg, key: []byte) -> u64 {
init(&ctx, key[:])
update(&ctx, msg[:])
final(&ctx, dst[:])
return util.U64_LE(dst[:])
return endian.unchecked_get_u64le(dst[:])
}
// sum_string_to_buffer_2_4 will hash the given message with the key and write
@@ -172,7 +172,7 @@ sum_bytes_4_8 :: proc (msg, key: []byte) -> u64 {
init(&ctx, key[:], 4, 8)
update(&ctx, msg[:])
final(&ctx, dst[:])
return util.U64_LE(dst[:])
return endian.unchecked_get_u64le(dst[:])
}
// sum_string_to_buffer_4_8 will hash the given message with the key and write