From e3504c94adf4edeabea3883e0e110bb4a9e7e690 Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Sat, 28 Mar 2026 11:47:06 +0900 Subject: [PATCH] core/crypto: Get rid of `set` (only used by legacy) --- core/crypto/crypto.odin | 12 ------------ core/crypto/legacy/md5/md5.odin | 3 ++- core/crypto/legacy/sha1/sha1.odin | 3 ++- tests/benchmark/crypto/benchmark_ecc.odin | 3 ++- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/core/crypto/crypto.odin b/core/crypto/crypto.odin index aa5a67b8f..3218b8670 100644 --- a/core/crypto/crypto.odin +++ b/core/crypto/crypto.odin @@ -85,18 +85,6 @@ zero_explicit :: proc "contextless" (data: rawptr, len: int) -> rawptr { return data } -/* -Set each byte of a memory range to a specific value. - -This procedure copies value specified by the `value` parameter into each of the -`len` bytes of a memory range, located at address `data`. - -This procedure returns the pointer to `data`. -*/ -set :: proc "contextless" (data: rawptr, value: byte, len: int) -> rawptr { - return runtime.memset(data, i32(value), len) -} - // rand_bytes fills the dst buffer with cryptographic entropy taken from // the system entropy source. This routine will block if the system entropy // source is not ready yet. All system entropy source failures are treated diff --git a/core/crypto/legacy/md5/md5.odin b/core/crypto/legacy/md5/md5.odin index 4bbc5d32a..ddc795b7d 100644 --- a/core/crypto/legacy/md5/md5.odin +++ b/core/crypto/legacy/md5/md5.odin @@ -18,6 +18,7 @@ package md5 zhibog, dotbmp: Initial implementation. */ +import "base:intrinsics" import "core:crypto" import "core:encoding/endian" import "core:math/bits" @@ -100,7 +101,7 @@ final :: proc(ctx: ^Context, hash: []byte, finalize_clone: bool = false) { i += 1 } transform(ctx, ctx.data[:]) - crypto.set(&ctx.data, 0, 56) + intrinsics.mem_zero(&ctx.data, 56) } ctx.bitlen += u64(ctx.datalen * 8) diff --git a/core/crypto/legacy/sha1/sha1.odin b/core/crypto/legacy/sha1/sha1.odin index 892f893a6..bf3ad9602 100644 --- a/core/crypto/legacy/sha1/sha1.odin +++ b/core/crypto/legacy/sha1/sha1.odin @@ -19,6 +19,7 @@ package sha1 zhibog, dotbmp: Initial implementation. */ +import "base:intrinsics" import "core:crypto" import "core:encoding/endian" import "core:math/bits" @@ -107,7 +108,7 @@ final :: proc(ctx: ^Context, hash: []byte, finalize_clone: bool = false) { i += 1 } transform(ctx, ctx.data[:]) - crypto.set(&ctx.data, 0, 56) + intrinsics.mem_zero(&ctx.data, 56) } ctx.bitlen += u64(ctx.datalen * 8) diff --git a/tests/benchmark/crypto/benchmark_ecc.odin b/tests/benchmark/crypto/benchmark_ecc.odin index c1809c6ba..95db33ab3 100644 --- a/tests/benchmark/crypto/benchmark_ecc.odin +++ b/tests/benchmark/crypto/benchmark_ecc.odin @@ -2,6 +2,7 @@ package benchmark_core_crypto import "base:runtime" import "core:encoding/hex" +import "core:mem" import "core:log" import "core:testing" import "core:text/table" @@ -161,7 +162,7 @@ bench_ed25519 :: proc() -> (sk, sig, verif: time.Duration) { @(private="file") bench_ecdsa :: proc(curve: ecdsa.Curve, hash: hash.Algorithm) -> (sk, sig, verif: time.Duration) { priv_bytes := make([]byte, ecdsa.PRIVATE_KEY_SIZES[curve], context.temp_allocator) - crypto.set(raw_data(priv_bytes), 0x69, len(priv_bytes)) + mem.set(raw_data(priv_bytes), 0x69, len(priv_bytes)) priv_key: ecdsa.Private_Key start := time.tick_now() for _ in 0 ..< DSA_ITERS {