authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-31 11:59:51-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-09-01 17:54:07-07:00
log8d2acff197a46a9de33ce78713291428aa45ee7c
tree009e91f14db769398fdfebb5929a783d148af583
parent89dd2b7ac23f298b5ac37ae022724b43c2137091

disable slow scrypt tests


1 files changed, 27 insertions(+), 13 deletions(-)

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