aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2024-08-29 17:51:55 +0900
committerYawning Angel <yawning@schwanenlied.me>2025-03-23 19:14:33 +0900
commit50d40c2a268af654487cb16ca1abbdbd3154d796 (patch)
treeef7004db496f7e2e59f11c9444445aa84c65dd25
parent6e8710fce43fb6890ca751d7a48d5cc15c93f1c1 (diff)
core/crypto/chacha20poly1305: Add missing assertions
-rw-r--r--core/crypto/chacha20poly1305/chacha20poly1305.odin4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/crypto/chacha20poly1305/chacha20poly1305.odin b/core/crypto/chacha20poly1305/chacha20poly1305.odin
index 3de2532dd..bb80f560b 100644
--- a/core/crypto/chacha20poly1305/chacha20poly1305.odin
+++ b/core/crypto/chacha20poly1305/chacha20poly1305.odin
@@ -96,6 +96,8 @@ init_xchacha :: proc(ctx: ^Context, key: []byte, impl := chacha20.DEFAULT_IMPLEM
//
// dst and plaintext MUST alias exactly or not at all.
seal :: proc(ctx: ^Context, dst, tag, iv, aad, plaintext: []byte) {
+ assert(ctx._is_initialized)
+
ciphertext := dst
_validate_common_slice_sizes(tag, iv, aad, plaintext, ctx._is_xchacha)
if len(ciphertext) != len(plaintext) {
@@ -151,6 +153,8 @@ seal :: proc(ctx: ^Context, dst, tag, iv, aad, plaintext: []byte) {
// dst and plaintext MUST alias exactly or not at all.
@(require_results)
open :: proc(ctx: ^Context, dst, iv, aad, ciphertext, tag: []byte) -> bool {
+ assert(ctx._is_initialized)
+
plaintext := dst
_validate_common_slice_sizes(tag, iv, aad, ciphertext, ctx._is_xchacha)
if len(ciphertext) != len(plaintext) {