@@ -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 }
0 commit comments