From 9308a7e0115c7ebd330bdd480b5eaafa39d6b579 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 23 Jul 2024 15:25:53 +0200 Subject: [PATCH] Fix compilation issues in crypto.bccrypt and poly1305 --- lib/std/crypto/bcrypt.zig | 14 +++++++------- lib/std/crypto/poly1305.zig | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/std/crypto/bcrypt.zig b/lib/std/crypto/bcrypt.zig index ab7d92a7e6cc..30d83c9a1b4f 100644 --- a/lib/std/crypto/bcrypt.zig +++ b/lib/std/crypto/bcrypt.zig @@ -496,24 +496,24 @@ const pbkdf_prf = struct { hasher: Sha512, sha2pass: [Sha512.digest_length]u8, - fn create(out: *[mac_length]u8, msg: []const u8, key: []const u8) void { + pub fn create(out: *[mac_length]u8, msg: []const u8, key: []const u8) void { var ctx = Self.init(key); ctx.update(msg); ctx.final(out); } - fn init(key: []const u8) Self { + pub fn init(key: []const u8) Self { var self: Self = undefined; self.hasher = Sha512.init(.{}); Sha512.hash(key, &self.sha2pass, .{}); return self; } - fn update(self: *Self, msg: []const u8) void { + pub fn update(self: *Self, msg: []const u8) void { self.hasher.update(msg); } - fn final(self: *Self, out: *[mac_length]u8) void { + pub fn final(self: *Self, out: *[mac_length]u8) void { var sha2salt: [Sha512.digest_length]u8 = undefined; self.hasher.final(&sha2salt); out.* = hash(self.sha2pass, sha2salt); @@ -521,12 +521,12 @@ const pbkdf_prf = struct { /// Matches OpenBSD function /// https://github.com/openbsd/src/blob/6df1256b7792691e66c2ed9d86a8c103069f9e34/lib/libutil/bcrypt_pbkdf.c#L98 - fn hash(sha2pass: [Sha512.digest_length]u8, sha2salt: [Sha512.digest_length]u8) [32]u8 { + pub fn hash(sha2pass: [Sha512.digest_length]u8, sha2salt: [Sha512.digest_length]u8) [32]u8 { var cdata: [8]u32 = undefined; { const ciphertext = "OxychromaticBlowfishSwatDynamite"; var j: usize = 0; - for (cdata) |*v| { + for (&cdata) |*v| { v.* = State.toWord(ciphertext, &j); } } @@ -557,7 +557,7 @@ const pbkdf_prf = struct { // zap crypto.utils.secureZero(u32, &cdata); - crypto.utils.secureZero(State, @as(*[1]State, &state)); + crypto.utils.secureZero(u32, &state.subkeys); return out; } diff --git a/lib/std/crypto/poly1305.zig b/lib/std/crypto/poly1305.zig index 4db3816266f8..3aa3d5b78f34 100644 --- a/lib/std/crypto/poly1305.zig +++ b/lib/std/crypto/poly1305.zig @@ -148,7 +148,7 @@ pub const Poly1305 = struct { return; } @memset(st.buf[st.leftover..], 0); - st.blocks(&st.buf); + st.blocks(&st.buf, false); st.leftover = 0; }