aboutsummaryrefslogtreecommitdiff
path: root/core/crypto
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2023-11-14 15:50:36 +0900
committerYawning Angel <yawning@schwanenlied.me>2023-11-17 16:53:29 +0900
commitaa5a95a4d1ca83e5ef75c059ddced992dfddc2b3 (patch)
treee28861bb4351daa697ac59f6c962c612b44f834f /core/crypto
parentfa1cb28c8fbf0b24dbfc5adf681e0e34a20281c8 (diff)
core/crypto/chacha20poly1305: Cleanups
- Use `encoding/endian`
Diffstat (limited to 'core/crypto')
-rw-r--r--core/crypto/chacha20poly1305/chacha20poly1305.odin10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/crypto/chacha20poly1305/chacha20poly1305.odin b/core/crypto/chacha20poly1305/chacha20poly1305.odin
index ae395f9e0..86fe54e79 100644
--- a/core/crypto/chacha20poly1305/chacha20poly1305.odin
+++ b/core/crypto/chacha20poly1305/chacha20poly1305.odin
@@ -3,7 +3,7 @@ package chacha20poly1305
import "core:crypto"
import "core:crypto/chacha20"
import "core:crypto/poly1305"
-import "core:crypto/util"
+import "core:encoding/endian"
import "core:mem"
KEY_SIZE :: chacha20.KEY_SIZE
@@ -87,8 +87,8 @@ encrypt :: proc (ciphertext, tag, key, nonce, aad, plaintext: []byte) {
// mac_data |= num_to_8_le_bytes(aad.length)
// mac_data |= num_to_8_le_bytes(ciphertext.length)
l_buf := otk[0:16] // Reuse the scratch buffer.
- util.PUT_U64_LE(l_buf[0:8], u64(aad_len))
- util.PUT_U64_LE(l_buf[8:16], u64(ciphertext_len))
+ endian.unchecked_put_u64le(l_buf[0:8], u64(aad_len))
+ endian.unchecked_put_u64le(l_buf[8:16], u64(ciphertext_len))
poly1305.update(&mac_ctx, l_buf)
// tag = poly1305_mac(mac_data, otk)
@@ -128,8 +128,8 @@ decrypt :: proc (plaintext, tag, key, nonce, aad, ciphertext: []byte) -> bool {
poly1305.update(&mac_ctx, ciphertext)
_update_mac_pad16(&mac_ctx, ciphertext_len)
l_buf := otk[0:16] // Reuse the scratch buffer.
- util.PUT_U64_LE(l_buf[0:8], u64(aad_len))
- util.PUT_U64_LE(l_buf[8:16], u64(ciphertext_len))
+ endian.unchecked_put_u64le(l_buf[0:8], u64(aad_len))
+ endian.unchecked_put_u64le(l_buf[8:16], u64(ciphertext_len))
poly1305.update(&mac_ctx, l_buf)
// tag = poly1305_mac(mac_data, otk)