From b1d6e4139e02e4e597e8c6f7d372519ccf11ac03 Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Tue, 23 Jul 2024 21:12:01 +0900 Subject: [PATCH] core/crypto/aes: Disable bounds checking for the CTR loops --- core/crypto/aes/aes_ctr.odin | 4 ++-- core/crypto/aes/aes_gcm.odin | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/crypto/aes/aes_ctr.odin b/core/crypto/aes/aes_ctr.odin index 1c5fe31e8..154ec0ada 100644 --- a/core/crypto/aes/aes_ctr.odin +++ b/core/crypto/aes/aes_ctr.odin @@ -47,7 +47,7 @@ xor_bytes_ctr :: proc(ctx: ^Context_CTR, dst, src: []byte) { panic("crypto/aes: dst and src alias inexactly") } - for remaining := len(src); remaining > 0; { + #no_bounds_check for remaining := len(src); remaining > 0; { // Process multiple blocks at once if ctx._off == BLOCK_SIZE { if nr_blocks := remaining / BLOCK_SIZE; nr_blocks > 0 { @@ -85,7 +85,7 @@ keystream_bytes_ctr :: proc(ctx: ^Context_CTR, dst: []byte) { assert(ctx._is_initialized) dst := dst - for remaining := len(dst); remaining > 0; { + #no_bounds_check for remaining := len(dst); remaining > 0; { // Process multiple blocks at once if ctx._off == BLOCK_SIZE { if nr_blocks := remaining / BLOCK_SIZE; nr_blocks > 0 { diff --git a/core/crypto/aes/aes_gcm.odin b/core/crypto/aes/aes_gcm.odin index 25e0cc35b..9c9f8edd4 100644 --- a/core/crypto/aes/aes_gcm.odin +++ b/core/crypto/aes/aes_gcm.odin @@ -112,7 +112,7 @@ open_gcm :: proc(ctx: ^Context_GCM, dst, nonce, aad, ciphertext, tag: []byte) -> return ok } -// reset_ctr sanitizes the Context_GCM. The Context_GCM must be +// reset_gcm sanitizes the Context_GCM. The Context_GCM must be // re-initialized to be used again. reset_gcm :: proc "contextless" (ctx: ^Context_GCM) { reset_impl(&ctx._impl)