diff --git a/lib/std/crypto.zig b/lib/std/crypto.zig index 7833a31237bff443a652bc9c4ca639c81e90e98f..d020d61e14c9c3d27712ed05bacf03d16ca1c5b6 100644 --- 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 index 45b2beb91b253ae0ee7fb6a8151bf82c0df47817..8e33eb80750c0b6c43e3f0106ff45636ef22670e 100644 --- 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 index 5bf5a57428897f54595c785eeb4b1bd6acdbb30d..3d6e4d89c33b785dfbeda0fc2fd03a12cf88be2b 100644 --- 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 {