@@ -496,37 +496,37 @@ const pbkdf_prf = struct {
496
496
hasher : Sha512 ,
497
497
sha2pass : [Sha512 .digest_length ]u8 ,
498
498
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 {
500
500
var ctx = Self .init (key );
501
501
ctx .update (msg );
502
502
ctx .final (out );
503
503
}
504
504
505
- fn init (key : []const u8 ) Self {
505
+ pub fn init (key : []const u8 ) Self {
506
506
var self : Self = undefined ;
507
507
self .hasher = Sha512 .init (.{});
508
508
Sha512 .hash (key , & self .sha2pass , .{});
509
509
return self ;
510
510
}
511
511
512
- fn update (self : * Self , msg : []const u8 ) void {
512
+ pub fn update (self : * Self , msg : []const u8 ) void {
513
513
self .hasher .update (msg );
514
514
}
515
515
516
- fn final (self : * Self , out : * [mac_length ]u8 ) void {
516
+ pub fn final (self : * Self , out : * [mac_length ]u8 ) void {
517
517
var sha2salt : [Sha512 .digest_length ]u8 = undefined ;
518
518
self .hasher .final (& sha2salt );
519
519
out .* = hash (self .sha2pass , sha2salt );
520
520
}
521
521
522
522
/// Matches OpenBSD function
523
523
/// 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 {
525
525
var cdata : [8 ]u32 = undefined ;
526
526
{
527
527
const ciphertext = "OxychromaticBlowfishSwatDynamite" ;
528
528
var j : usize = 0 ;
529
- for (cdata ) | * v | {
529
+ for (& cdata ) | * v | {
530
530
v .* = State .toWord (ciphertext , & j );
531
531
}
532
532
}
@@ -557,7 +557,7 @@ const pbkdf_prf = struct {
557
557
558
558
// zap
559
559
crypto .utils .secureZero (u32 , & cdata );
560
- crypto .utils .secureZero (State , @as ( * [ 1 ] State , & state ) );
560
+ crypto .utils .secureZero (u32 , & state . subkeys );
561
561
562
562
return out ;
563
563
}
0 commit comments