diff options
Diffstat (limited to 'core/crypto/aes')
| -rw-r--r-- | core/crypto/aes/aes_ctr.odin | 5 | ||||
| -rw-r--r-- | core/crypto/aes/aes_ctr_hw_intel.odin | 5 | ||||
| -rw-r--r-- | core/crypto/aes/aes_gcm.odin | 21 | ||||
| -rw-r--r-- | core/crypto/aes/aes_gcm_hw_intel.odin | 21 | ||||
| -rw-r--r-- | core/crypto/aes/aes_impl.odin | 8 |
5 files changed, 29 insertions, 31 deletions
diff --git a/core/crypto/aes/aes_ctr.odin b/core/crypto/aes/aes_ctr.odin index a74133235..9d7a0b80b 100644 --- a/core/crypto/aes/aes_ctr.odin +++ b/core/crypto/aes/aes_ctr.odin @@ -4,7 +4,6 @@ import "core:bytes" import "core:crypto/_aes/ct64" import "core:encoding/endian" import "core:math/bits" -import "core:mem" // CTR_IV_SIZE is the size of the CTR mode IV in bytes. CTR_IV_SIZE :: 16 @@ -117,7 +116,7 @@ reset_ctr :: proc "contextless" (ctx: ^Context_CTR) { ctx._off = 0 ctx._ctr_hi = 0 ctx._ctr_lo = 0 - mem.zero_explicit(&ctx._buffer, size_of(ctx._buffer)) + zero_explicit(&ctx._buffer, size_of(ctx._buffer)) ctx._is_initialized = false } @@ -172,7 +171,7 @@ ctr_blocks :: proc(ctx: ^Context_CTR, dst, src: []byte, nr_blocks: int) #no_boun // Write back the counter. ctx._ctr_hi, ctx._ctr_lo = ctr_hi, ctr_lo - mem.zero_explicit(&tmp, size_of(tmp)) + zero_explicit(&tmp, size_of(tmp)) } @(private) diff --git a/core/crypto/aes/aes_ctr_hw_intel.odin b/core/crypto/aes/aes_ctr_hw_intel.odin index 415758b24..f30122c86 100644 --- a/core/crypto/aes/aes_ctr_hw_intel.odin +++ b/core/crypto/aes/aes_ctr_hw_intel.odin @@ -4,7 +4,6 @@ package aes import "base:intrinsics" import "core:crypto/_aes" import "core:math/bits" -import "core:mem" import "core:simd/x86" @(private) @@ -130,8 +129,8 @@ ctr_blocks_hw :: proc(ctx: ^Context_CTR, dst, src: []byte, nr_blocks: int) #no_b // Write back the counter. ctx._ctr_hi, ctx._ctr_lo = ctr_hi, ctr_lo - mem.zero_explicit(&blks, size_of(blks)) - mem.zero_explicit(&sks, size_of(sks)) + zero_explicit(&blks, size_of(blks)) + zero_explicit(&sks, size_of(sks)) } @(private, enable_target_feature = "sse2") diff --git a/core/crypto/aes/aes_gcm.odin b/core/crypto/aes/aes_gcm.odin index d349aa353..bb87788ac 100644 --- a/core/crypto/aes/aes_gcm.odin +++ b/core/crypto/aes/aes_gcm.odin @@ -5,7 +5,6 @@ import "core:crypto" import "core:crypto/_aes" import "core:crypto/_aes/ct64" import "core:encoding/endian" -import "core:mem" // GCM_IV_SIZE is the default size of the GCM IV in bytes. GCM_IV_SIZE :: 12 @@ -59,9 +58,9 @@ seal_gcm :: proc(ctx: ^Context_GCM, dst, tag, iv, aad, plaintext: []byte) { final_ghash_ct64(&s, &h, &j0_enc, len(aad), len(plaintext)) copy(tag, s[:]) - mem.zero_explicit(&h, len(h)) - mem.zero_explicit(&j0, len(j0)) - mem.zero_explicit(&j0_enc, len(j0_enc)) + zero_explicit(&h, len(h)) + zero_explicit(&j0, len(j0)) + zero_explicit(&j0_enc, len(j0_enc)) } // open_gcm authenticates the aad and ciphertext, and decrypts the ciphertext, @@ -94,13 +93,13 @@ open_gcm :: proc(ctx: ^Context_GCM, dst, iv, aad, ciphertext, tag: []byte) -> bo ok := crypto.compare_constant_time(s[:], tag) == 1 if !ok { - mem.zero_explicit(raw_data(dst), len(dst)) + zero_explicit(raw_data(dst), len(dst)) } - mem.zero_explicit(&h, len(h)) - mem.zero_explicit(&j0, len(j0)) - mem.zero_explicit(&j0_enc, len(j0_enc)) - mem.zero_explicit(&s, len(s)) + zero_explicit(&h, len(h)) + zero_explicit(&j0, len(j0)) + zero_explicit(&j0_enc, len(j0_enc)) + zero_explicit(&s, len(s)) return ok } @@ -249,6 +248,6 @@ gctr_ct64 :: proc( } } - mem.zero_explicit(&tmp, size_of(tmp)) - mem.zero_explicit(&tmp2, size_of(tmp2)) + zero_explicit(&tmp, size_of(tmp)) + zero_explicit(&tmp2, size_of(tmp2)) } diff --git a/core/crypto/aes/aes_gcm_hw_intel.odin b/core/crypto/aes/aes_gcm_hw_intel.odin index 3982d1452..c6e564773 100644 --- a/core/crypto/aes/aes_gcm_hw_intel.odin +++ b/core/crypto/aes/aes_gcm_hw_intel.odin @@ -6,7 +6,6 @@ import "core:crypto" import "core:crypto/_aes" import "core:crypto/_aes/hw_intel" import "core:encoding/endian" -import "core:mem" import "core:simd/x86" @(private) @@ -23,9 +22,9 @@ gcm_seal_hw :: proc(ctx: ^Context_Impl_Hardware, dst, tag, iv, aad, plaintext: [ final_ghash_hw(&s, &h, &j0_enc, len(aad), len(plaintext)) copy(tag, s[:]) - mem.zero_explicit(&h, len(h)) - mem.zero_explicit(&j0, len(j0)) - mem.zero_explicit(&j0_enc, len(j0_enc)) + zero_explicit(&h, len(h)) + zero_explicit(&j0, len(j0)) + zero_explicit(&j0_enc, len(j0_enc)) } @(private) @@ -42,13 +41,13 @@ gcm_open_hw :: proc(ctx: ^Context_Impl_Hardware, dst, iv, aad, ciphertext, tag: ok := crypto.compare_constant_time(s[:], tag) == 1 if !ok { - mem.zero_explicit(raw_data(dst), len(dst)) + zero_explicit(raw_data(dst), len(dst)) } - mem.zero_explicit(&h, len(h)) - mem.zero_explicit(&j0, len(j0)) - mem.zero_explicit(&j0_enc, len(j0_enc)) - mem.zero_explicit(&s, len(s)) + zero_explicit(&h, len(h)) + zero_explicit(&j0, len(j0)) + zero_explicit(&j0_enc, len(j0_enc)) + zero_explicit(&s, len(s)) return ok } @@ -228,8 +227,8 @@ gctr_hw :: proc( n -= l } - mem.zero_explicit(&blks, size_of(blks)) - mem.zero_explicit(&sks, size_of(sks)) + zero_explicit(&blks, size_of(blks)) + zero_explicit(&sks, size_of(sks)) } // BUG: Sticking this in gctr_hw (like the other implementations) crashes diff --git a/core/crypto/aes/aes_impl.odin b/core/crypto/aes/aes_impl.odin index f26874809..b95abfaf0 100644 --- a/core/crypto/aes/aes_impl.odin +++ b/core/crypto/aes/aes_impl.odin @@ -1,9 +1,11 @@ package aes +import "core:crypto" import "core:crypto/_aes/ct64" -import "core:mem" import "core:reflect" +zero_explicit :: crypto.zero_explicit + @(private) Context_Impl :: union { ct64.Context, @@ -41,5 +43,5 @@ init_impl :: proc(ctx: ^Context_Impl, key: []byte, impl: Implementation) { @(private) reset_impl :: proc "contextless" (ctx: ^Context_Impl) { - mem.zero_explicit(ctx, size_of(Context_Impl)) -} + zero_explicit(ctx, size_of(Context_Impl)) +}
\ No newline at end of file |