commit 0bed4fb384f2e4d0f33307f63e9d3a1f023438e4 (tree)
parent 469bf6af07ad16fc5ac1421a302178a3fd508343
Author: IntegratedQuantum <jahe788@gmail.com>
Date: Fri, 13 Feb 2026 16:54:10 +0100
crypto: Allow arbitrary types for secureZeroes
also removed some related ptrCasts
Diffstat:
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/std/crypto.zig b/lib/std/crypto.zig
@@ -412,7 +412,7 @@ test "issue #4532: no index out of bounds" {
/// Sets a slice to zeroes.
/// Prevents the store from being optimized out.
pub fn secureZero(comptime T: type, s: []volatile T) void {
- @memset(s, 0);
+ @memset(s, std.mem.zeroes(T));
}
test secureZero {
diff --git a/lib/std/crypto/ghash_polyval.zig b/lib/std/crypto/ghash_polyval.zig
@@ -402,7 +402,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
st.pad();
mem.writeInt(u128, out[0..16], st.acc, endian);
- std.crypto.secureZero(u8, @as([*]u8, @ptrCast(st))[0..@sizeOf(Self)]);
+ std.crypto.secureZero(Self, st[0..1]);
}
/// Compute the GHASH of a message.
diff --git a/lib/std/crypto/poly1305.zig b/lib/std/crypto/poly1305.zig
@@ -184,7 +184,7 @@ pub const Poly1305 = struct {
mem.writeInt(u64, out[0..8], st.h[0], .little);
mem.writeInt(u64, out[8..16], st.h[1], .little);
- std.crypto.secureZero(u8, @as([*]u8, @ptrCast(st))[0..@sizeOf(Poly1305)]);
+ std.crypto.secureZero(Poly1305, st[0..1]);
}
pub fn create(out: *[mac_length]u8, msg: []const u8, key: *const [key_length]u8) void {