core/crypto/noise: Reject encrypt/decrypt when n == 2^64 - 1

Spec defines the maximal value of `n` as reserved.
This commit is contained in:
Yawning Angel
2026-08-05 17:33:31 +09:00
parent 6e682a768e
commit 3bdb32949b

View File

@@ -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 {