| ... | ... | @@ -523,7 +523,12 @@ pub fn strVerify( |
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | | test "scrypt kdf" { |
| 526 | // These tests take way too long to run, so I have disabled them. |
| 527 | const run_long_tests = false; |
| 528 | |
| 529 | test "kdf" { |
| 530 | if (!run_long_tests) return error.SkipZigTest; |
| 531 | |
| 527 | 532 | const password = "testpass"; |
| 528 | 533 | const salt = "saltsalt"; |
| 529 | 534 | |
| ... | ... | @@ -537,7 +542,9 @@ test "scrypt kdf" { |
| 537 | 542 | try std.testing.expectEqualSlices(u8, &bytes, &dk); |
| 538 | 543 | } |
| 539 | 544 | |
| 540 | | test "scrypt kdf rfc 1" { |
| 545 | test "kdf rfc 1" { |
| 546 | if (!run_long_tests) return error.SkipZigTest; |
| 547 | |
| 541 | 548 | const password = ""; |
| 542 | 549 | const salt = ""; |
| 543 | 550 | |
| ... | ... | @@ -551,7 +558,9 @@ test "scrypt kdf rfc 1" { |
| 551 | 558 | try std.testing.expectEqualSlices(u8, &bytes, &dk); |
| 552 | 559 | } |
| 553 | 560 | |
| 554 | | test "scrypt kdf rfc 2" { |
| 561 | test "kdf rfc 2" { |
| 562 | if (!run_long_tests) return error.SkipZigTest; |
| 563 | |
| 555 | 564 | const password = "password"; |
| 556 | 565 | const salt = "NaCl"; |
| 557 | 566 | |
| ... | ... | @@ -565,7 +574,9 @@ test "scrypt kdf rfc 2" { |
| 565 | 574 | try std.testing.expectEqualSlices(u8, &bytes, &dk); |
| 566 | 575 | } |
| 567 | 576 | |
| 568 | | test "scrypt kdf rfc 3" { |
| 577 | test "kdf rfc 3" { |
| 578 | if (!run_long_tests) return error.SkipZigTest; |
| 579 | |
| 569 | 580 | const password = "pleaseletmein"; |
| 570 | 581 | const salt = "SodiumChloride"; |
| 571 | 582 | |
| ... | ... | @@ -579,11 +590,8 @@ test "scrypt kdf rfc 3" { |
| 579 | 590 | try std.testing.expectEqualSlices(u8, &bytes, &dk); |
| 580 | 591 | } |
| 581 | 592 | |
| 582 | | test "scrypt kdf rfc 4" { |
| 583 | | // skip slow test |
| 584 | | if (true) { |
| 585 | | return error.SkipZigTest; |
| 586 | | } |
| 593 | test "kdf rfc 4" { |
| 594 | if (!run_long_tests) return error.SkipZigTest; |
| 587 | 595 | |
| 588 | 596 | const password = "pleaseletmein"; |
| 589 | 597 | const salt = "SodiumChloride"; |
| ... | ... | @@ -598,7 +606,9 @@ test "scrypt kdf rfc 4" { |
| 598 | 606 | try std.testing.expectEqualSlices(u8, &bytes, &dk); |
| 599 | 607 | } |
| 600 | 608 | |
| 601 | | test "scrypt password hashing (crypt format)" { |
| 609 | test "password hashing (crypt format)" { |
| 610 | if (!run_long_tests) return error.SkipZigTest; |
| 611 | |
| 602 | 612 | const str = "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5"; |
| 603 | 613 | const password = "Y0!?iQa9M%5ekffW(`"; |
| 604 | 614 | try CryptFormatHasher.verify(std.testing.allocator, str, password); |
| ... | ... | @@ -609,7 +619,9 @@ test "scrypt password hashing (crypt format)" { |
| 609 | 619 | try CryptFormatHasher.verify(std.testing.allocator, str2, password); |
| 610 | 620 | } |
| 611 | 621 | |
| 612 | | test "scrypt strHash and strVerify" { |
| 622 | test "strHash and strVerify" { |
| 623 | if (!run_long_tests) return error.SkipZigTest; |
| 624 | |
| 613 | 625 | const alloc = std.testing.allocator; |
| 614 | 626 | |
| 615 | 627 | const password = "testpass"; |
| ... | ... | @@ -631,7 +643,9 @@ test "scrypt strHash and strVerify" { |
| 631 | 643 | try strVerify(s1, password, verify_options); |
| 632 | 644 | } |
| 633 | 645 | |
| 634 | | test "scrypt unix-scrypt" { |
| 646 | test "unix-scrypt" { |
| 647 | if (!run_long_tests) return error.SkipZigTest; |
| 648 | |
| 635 | 649 | const alloc = std.testing.allocator; |
| 636 | 650 | |
| 637 | 651 | // https://gitlab.com/jas/scrypt-unix-crypt/blob/master/unix-scrypt.txt |
| ... | ... | @@ -648,7 +662,7 @@ test "scrypt unix-scrypt" { |
| 648 | 662 | } |
| 649 | 663 | } |
| 650 | 664 | |
| 651 | | test "scrypt crypt format" { |
| 665 | test "crypt format" { |
| 652 | 666 | const str = "$7$C6..../....SodiumChloride$kBGj9fHznVYFQMEn/qDCfrDevf9YDtcDdKvEqHJLV8D"; |
| 653 | 667 | const params = try crypt_format.deserialize(crypt_format.HashResult(32), str); |
| 654 | 668 | var buf: [str.len]u8 = undefined; |