| ... | @@ -566,10 +566,8 @@ pub fn strHashWithSalt( | ... | @@ -566,10 +566,8 @@ pub fn strHashWithSalt( |
| 566 | } | 566 | } |
| 567 | | 567 | |
| 568 | /// Options for hash verification. | 568 | /// Options for hash verification. |
| 569 | /// | | |
| 570 | /// Allocator is required for scrypt. | | |
| 571 | pub const VerifyOptions = struct { | 569 | pub const VerifyOptions = struct { |
| 572 | allocator: ?mem.Allocator, | 570 | allocator: mem.Allocator, |
| 573 | }; | 571 | }; |
| 574 | | 572 | |
| 575 | /// Verify that a previously computed hash is valid for a given password. | 573 | /// Verify that a previously computed hash is valid for a given password. |
| ... | @@ -578,11 +576,10 @@ pub fn strVerify( | ... | @@ -578,11 +576,10 @@ pub fn strVerify( |
| 578 | password: []const u8, | 576 | password: []const u8, |
| 579 | options: VerifyOptions, | 577 | options: VerifyOptions, |
| 580 | ) Error!void { | 578 | ) Error!void { |
| 581 | const allocator = options.allocator orelse return Error.AllocatorRequired; | | |
| 582 | if (mem.startsWith(u8, str, crypt_format.prefix)) { | 579 | if (mem.startsWith(u8, str, crypt_format.prefix)) { |
| 583 | return CryptFormatHasher.verify(allocator, str, password); | 580 | return CryptFormatHasher.verify(options.allocator, str, password); |
| 584 | } else { | 581 | } else { |
| 585 | return PhcFormatHasher.verify(allocator, str, password); | 582 | return PhcFormatHasher.verify(options.allocator, str, password); |
| 586 | } | 583 | } |
| 587 | } | 584 | } |
| 588 | | 585 | |
| ... | @@ -693,7 +690,7 @@ test "strHash and strVerify" { | ... | @@ -693,7 +690,7 @@ test "strHash and strVerify" { |
| 693 | | 690 | |
| 694 | const password = "testpass"; | 691 | const password = "testpass"; |
| 695 | const params = Params.interactive; | 692 | const params = Params.interactive; |
| 696 | const verify_options = VerifyOptions{ .allocator = alloc }; | 693 | const verify_options: VerifyOptions = .{ .allocator = alloc }; |
| 697 | var buf: [128]u8 = undefined; | 694 | var buf: [128]u8 = undefined; |
| 698 | | 695 | |
| 699 | { | 696 | { |