diff --git a/lib/std/crypto/argon2.zig b/lib/std/crypto/argon2.zig index 9add038b95bb5d46432fcaaeacf59a2f077185fb..e3550abe1d7cfcad3cdc738ac5f2f01e2606e0a5 100644 --- a/lib/std/crypto/argon2.zig +++ b/lib/std/crypto/argon2.zig @@ -609,10 +609,8 @@ pub fn strHash( } /// Options for hash verification. -/// -/// Allocator is required for argon2. pub const VerifyOptions = struct { - allocator: ?mem.Allocator, + allocator: mem.Allocator, }; /// Verify that a previously computed hash is valid for a given password. @@ -622,8 +620,7 @@ pub fn strVerify( options: VerifyOptions, io: Io, ) Error!void { - const allocator = options.allocator orelse return Error.AllocatorRequired; - return PhcFormatHasher.verify(allocator, str, password, io); + return PhcFormatHasher.verify(options.allocator, str, password, io); } test "argon2d" { diff --git a/lib/std/crypto/scrypt.zig b/lib/std/crypto/scrypt.zig index 913feb4b380e909b816924a95131df14ef97cf69..9939188ebff47ad0a631255d7a2bf4be49c30e57 100644 --- a/lib/std/crypto/scrypt.zig +++ b/lib/std/crypto/scrypt.zig @@ -566,10 +566,8 @@ pub fn strHashWithSalt( } /// Options for hash verification. -/// -/// Allocator is required for scrypt. pub const VerifyOptions = struct { - allocator: ?mem.Allocator, + allocator: mem.Allocator, }; /// Verify that a previously computed hash is valid for a given password. @@ -578,11 +576,10 @@ pub fn strVerify( password: []const u8, options: VerifyOptions, ) Error!void { - const allocator = options.allocator orelse return Error.AllocatorRequired; if (mem.startsWith(u8, str, crypt_format.prefix)) { - return CryptFormatHasher.verify(allocator, str, password); + return CryptFormatHasher.verify(options.allocator, str, password); } else { - return PhcFormatHasher.verify(allocator, str, password); + return PhcFormatHasher.verify(options.allocator, str, password); } } @@ -693,7 +690,7 @@ test "strHash and strVerify" { const password = "testpass"; const params = Params.interactive; - const verify_options = VerifyOptions{ .allocator = alloc }; + const verify_options: VerifyOptions = .{ .allocator = alloc }; var buf: [128]u8 = undefined; {