From 3bdb32949b873293de8c05698ada0c1668b6c4ca Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Wed, 5 Aug 2026 17:33:31 +0900 Subject: [PATCH] core/crypto/noise: Reject encrypt/decrypt when `n` == 2^64 - 1 Spec defines the maximal value of `n` as reserved. --- core/crypto/noise/protocol.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/crypto/noise/protocol.odin b/core/crypto/noise/protocol.odin index 7327e638b..4bbe858da 100644 --- a/core/crypto/noise/protocol.odin +++ b/core/crypto/noise/protocol.odin @@ -217,7 +217,7 @@ cipherstate_encrypt_with_ad :: proc(self: ^Cipher_State, ad, plaintext, dst: []b } _encrypt(&self.ctx, self.n, ad, plaintext, dst) self.n += 1 - if self.n == 0 { + if self.n == max(u64) { self.n_exhausted = true } } else { @@ -249,7 +249,7 @@ cipherstate_decrypt_with_ad :: proc(self: ^Cipher_State, ad, ciphertext, dst: [] return nil, status } self.n += 1 - if self.n == 0 { + if self.n == max(u64) { self.n_exhausted = true } } else {