Skip to content

Commit 2e8acdf

Browse files
authored
Fix compilation issues in crypto.bccrypt and poly1305 (#20756)
1 parent be1e1fa commit 2e8acdf

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/std/crypto/bcrypt.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,37 +496,37 @@ const pbkdf_prf = struct {
496496
hasher: Sha512,
497497
sha2pass: [Sha512.digest_length]u8,
498498

499-
fn create(out: *[mac_length]u8, msg: []const u8, key: []const u8) void {
499+
pub fn create(out: *[mac_length]u8, msg: []const u8, key: []const u8) void {
500500
var ctx = Self.init(key);
501501
ctx.update(msg);
502502
ctx.final(out);
503503
}
504504

505-
fn init(key: []const u8) Self {
505+
pub fn init(key: []const u8) Self {
506506
var self: Self = undefined;
507507
self.hasher = Sha512.init(.{});
508508
Sha512.hash(key, &self.sha2pass, .{});
509509
return self;
510510
}
511511

512-
fn update(self: *Self, msg: []const u8) void {
512+
pub fn update(self: *Self, msg: []const u8) void {
513513
self.hasher.update(msg);
514514
}
515515

516-
fn final(self: *Self, out: *[mac_length]u8) void {
516+
pub fn final(self: *Self, out: *[mac_length]u8) void {
517517
var sha2salt: [Sha512.digest_length]u8 = undefined;
518518
self.hasher.final(&sha2salt);
519519
out.* = hash(self.sha2pass, sha2salt);
520520
}
521521

522522
/// Matches OpenBSD function
523523
/// https://github.com/openbsd/src/blob/6df1256b7792691e66c2ed9d86a8c103069f9e34/lib/libutil/bcrypt_pbkdf.c#L98
524-
fn hash(sha2pass: [Sha512.digest_length]u8, sha2salt: [Sha512.digest_length]u8) [32]u8 {
524+
pub fn hash(sha2pass: [Sha512.digest_length]u8, sha2salt: [Sha512.digest_length]u8) [32]u8 {
525525
var cdata: [8]u32 = undefined;
526526
{
527527
const ciphertext = "OxychromaticBlowfishSwatDynamite";
528528
var j: usize = 0;
529-
for (cdata) |*v| {
529+
for (&cdata) |*v| {
530530
v.* = State.toWord(ciphertext, &j);
531531
}
532532
}
@@ -557,7 +557,7 @@ const pbkdf_prf = struct {
557557

558558
// zap
559559
crypto.utils.secureZero(u32, &cdata);
560-
crypto.utils.secureZero(State, @as(*[1]State, &state));
560+
crypto.utils.secureZero(u32, &state.subkeys);
561561

562562
return out;
563563
}

lib/std/crypto/poly1305.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub const Poly1305 = struct {
148148
return;
149149
}
150150
@memset(st.buf[st.leftover..], 0);
151-
st.blocks(&st.buf);
151+
st.blocks(&st.buf, false);
152152
st.leftover = 0;
153153
}
154154

0 commit comments

Comments
 (0)