authorgravatar for jahe788@gmail.comIntegratedQuantum <jahe788@gmail.com> 2026-02-13 16:54:10+01:00
committergravatar for jahe788@gmail.comIntegratedQuantum <jahe788@gmail.com> 2026-02-13 17:07:03+01:00
log0bed4fb384f2e4d0f33307f63e9d3a1f023438e4
treebb49b1012029445d2d5fa7edeb1a209095851c79
parent469bf6af07ad16fc5ac1421a302178a3fd508343

crypto: Allow arbitrary types for secureZeroes

also removed some related ptrCasts

3 files changed, 3 insertions(+), 3 deletions(-)

lib/std/crypto.zig+1-1
......@@ -412,7 +412,7 @@ test "issue #4532: no index out of bounds" {
412412/// Sets a slice to zeroes.
413413/// Prevents the store from being optimized out.
414414pub fn secureZero(comptime T: type, s: []volatile T) void {
415 @memset(s, 0);
415 @memset(s, std.mem.zeroes(T));
416416}
417417
418418test secureZero {
lib/std/crypto/ghash_polyval.zig+1-1
......@@ -402,7 +402,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
402402 st.pad();
403403 mem.writeInt(u128, out[0..16], st.acc, endian);
404404
405 std.crypto.secureZero(u8, @as([*]u8, @ptrCast(st))[0..@sizeOf(Self)]);
405 std.crypto.secureZero(Self, st[0..1]);
406406 }
407407
408408 /// Compute the GHASH of a message.
lib/std/crypto/poly1305.zig+1-1
......@@ -184,7 +184,7 @@ pub const Poly1305 = struct {
184184 mem.writeInt(u64, out[0..8], st.h[0], .little);
185185 mem.writeInt(u64, out[8..16], st.h[1], .little);
186186
187 std.crypto.secureZero(u8, @as([*]u8, @ptrCast(st))[0..@sizeOf(Poly1305)]);
187 std.crypto.secureZero(Poly1305, st[0..1]);
188188 }
189189
190190 pub fn create(out: *[mac_length]u8, msg: []const u8, key: *const [key_length]u8) void {