diff --git a/lib/std/crypto/blake2.zig b/lib/std/crypto/blake2.zig index e2107dda56f667e9ecdcaf045c9f4d7bb9eb6da3..80557eb2554a88560bfaf3fb00d474b89dab3411 100644 --- a/lib/std/crypto/blake2.zig +++ b/lib/std/crypto/blake2.zig @@ -184,6 +184,18 @@ pub fn Blake2s(comptime out_bits: usize) type { r.* ^= v[i] ^ v[i + 8]; } } + + pub const Error = error{}; + pub const Writer = std.io.Writer(*Self, Error, write); + + fn write(self: *Self, bytes: []const u8) Error!usize { + self.update(bytes); + return bytes.len; + } + + pub fn writer(self: *Self) Writer { + return .{ .context = self }; + } }; } diff --git a/lib/std/crypto/blake3.zig b/lib/std/crypto/blake3.zig index b2077bb9e797774b4a32fb49201ce29abda1bdf9..7f2c21be3350171904462a1b5afc66f4ffe2525b 100644 --- a/lib/std/crypto/blake3.zig +++ b/lib/std/crypto/blake3.zig @@ -472,6 +472,18 @@ pub const Blake3 = struct { } output.rootOutputBytes(out_slice); } + + pub const Error = error{}; + pub const Writer = std.io.Writer(*Blake3, Error, write); + + fn write(self: *Blake3, bytes: []const u8) Error!usize { + self.update(bytes); + return bytes.len; + } + + pub fn writer(self: *Blake3) Writer { + return .{ .context = self }; + } }; // Use named type declarations to workaround crash with anonymous structs (issue #4373). diff --git a/lib/std/crypto/gimli.zig b/lib/std/crypto/gimli.zig index fc4b5313b816a64f8fe4427de3edf0d0c5c18dc9..3e2fad4229fca72c44c0deab197224d4bbc0bd8a 100644 --- a/lib/std/crypto/gimli.zig +++ b/lib/std/crypto/gimli.zig @@ -257,6 +257,18 @@ pub const Hash = struct { self.state.squeeze(out); } + + pub const Error = error{}; + pub const Writer = std.io.Writer(*Self, Error, write); + + fn write(self: *Self, bytes: []const u8) Error!usize { + self.update(bytes); + return bytes.len; + } + + pub fn writer(self: *Self) Writer { + return .{ .context = self }; + } }; pub fn hash(out: []u8, in: []const u8, options: Hash.Options) void { diff --git a/lib/std/crypto/sha1.zig b/lib/std/crypto/sha1.zig index b464fb03f52afb856a831e780315d1531605a457..99289e35c400c7005987e321d5b2ed85b3e1f029 100644 --- a/lib/std/crypto/sha1.zig +++ b/lib/std/crypto/sha1.zig @@ -256,6 +256,18 @@ pub const Sha1 = struct { d.s[3] +%= v[3]; d.s[4] +%= v[4]; } + + pub const Error = error{}; + pub const Writer = std.io.Writer(*Self, Error, write); + + fn write(self: *Self, bytes: []const u8) Error!usize { + self.update(bytes); + return bytes.len; + } + + pub fn writer(self: *Self) Writer { + return .{ .context = self }; + } }; const htest = @import("test.zig"); diff --git a/lib/std/crypto/sha2.zig b/lib/std/crypto/sha2.zig index 2d2a70c87f9be93519d3334086dfaab9e082fad0..b7a78c4b44e56950df0f76ffb292130cf39ce5c6 100644 --- a/lib/std/crypto/sha2.zig +++ b/lib/std/crypto/sha2.zig @@ -277,6 +277,18 @@ fn Sha2x32(comptime params: Sha2Params32) type { d.s[6] +%= v[6]; d.s[7] +%= v[7]; } + + pub const Error = error{}; + pub const Writer = std.io.Writer(*Self, Error, write); + + fn write(self: *Self, bytes: []const u8) Error!usize { + self.update(bytes); + return bytes.len; + } + + pub fn writer(self: *Self) Writer { + return .{ .context = self }; + } }; } diff --git a/lib/std/crypto/sha3.zig b/lib/std/crypto/sha3.zig index db8126d183d4f2f60448c179eecc245ad9f9af48..ccc0775df1c8550ec27d5eb0bff704a1ac68ea8d 100644 --- a/lib/std/crypto/sha3.zig +++ b/lib/std/crypto/sha3.zig @@ -78,6 +78,18 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type { mem.copy(u8, out[op..], d.s[0..len]); } + + pub const Error = error{}; + pub const Writer = std.io.Writer(*Self, Error, write); + + fn write(self: *Self, bytes: []const u8) Error!usize { + self.update(bytes); + return bytes.len; + } + + pub fn writer(self: *Self) Writer { + return .{ .context = self }; + } }; } diff --git a/lib/std/crypto/siphash.zig b/lib/std/crypto/siphash.zig index c984e04490a18b487280334b1fb87ae5686509fb..50706a0f35318c494637835694bf82fb6de2b9c1 100644 --- a/lib/std/crypto/siphash.zig +++ b/lib/std/crypto/siphash.zig @@ -231,6 +231,18 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize) pub fn toInt(msg: []const u8, key: *const [key_length]u8) T { return State.hash(msg, key); } + + pub const Error = error{}; + pub const Writer = std.io.Writer(*Self, Error, write); + + fn write(self: *Self, bytes: []const u8) Error!usize { + self.update(bytes); + return bytes.len; + } + + pub fn writer(self: *Self) Writer { + return .{ .context = self }; + } }; }