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