|
|
c59d11 |
From 8de0fd45cde4826951842f80b6ce109988d47f4f Mon Sep 17 00:00:00 2001
|
|
|
c59d11 |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
c59d11 |
Date: Mon, 7 Apr 2014 12:31:28 +0200
|
|
|
c59d11 |
Subject: [PATCH] t/op/crypt.t: Perform SHA-256 algorithm if default one is
|
|
|
c59d11 |
disabled
|
|
|
c59d11 |
MIME-Version: 1.0
|
|
|
c59d11 |
Content-Type: text/plain; charset=UTF-8
|
|
|
c59d11 |
Content-Transfer-Encoding: 8bit
|
|
|
c59d11 |
|
|
|
c59d11 |
The crypt(3) call may return NULL. This is the case of FIPS-enabled
|
|
|
c59d11 |
platforms. Then "salt makes a difference" test would fail.
|
|
|
c59d11 |
|
|
|
c59d11 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
c59d11 |
---
|
|
|
c59d11 |
t/op/crypt.t | 14 ++++++++++----
|
|
|
c59d11 |
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
c59d11 |
|
|
|
c59d11 |
diff --git a/t/op/crypt.t b/t/op/crypt.t
|
|
|
c59d11 |
index 27c878f..6c43992 100644
|
|
|
c59d11 |
--- a/t/op/crypt.t
|
|
|
c59d11 |
+++ b/t/op/crypt.t
|
|
|
c59d11 |
@@ -28,19 +28,25 @@ BEGIN {
|
|
|
c59d11 |
# bets, given alternative encryption/hashing schemes like MD5,
|
|
|
c59d11 |
# C2 (or higher) security schemes, and non-UNIX platforms.
|
|
|
c59d11 |
|
|
|
c59d11 |
+# Platforms implementing FIPS mode return undef on weak crypto algorithms.
|
|
|
c59d11 |
+my $alg = ''; # Use default algorithm
|
|
|
c59d11 |
+if ( !defined(crypt("ab", "cd")) ) {
|
|
|
c59d11 |
+ $alg = '$5$'; # Use SHA-256
|
|
|
c59d11 |
+}
|
|
|
c59d11 |
+
|
|
|
c59d11 |
SKIP: {
|
|
|
c59d11 |
skip ("VOS crypt ignores salt.", 1) if ($^O eq 'vos');
|
|
|
c59d11 |
- ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt makes a difference");
|
|
|
c59d11 |
+ ok(substr(crypt("ab", $alg . "cd"), 2) ne substr(crypt("ab", $alg. "ce"), 2), "salt makes a difference");
|
|
|
c59d11 |
}
|
|
|
c59d11 |
|
|
|
c59d11 |
$a = "a\xFF\x{100}";
|
|
|
c59d11 |
|
|
|
c59d11 |
-eval {$b = crypt($a, "cd")};
|
|
|
c59d11 |
+eval {$b = crypt($a, $alg . "cd")};
|
|
|
c59d11 |
like($@, qr/Wide character in crypt/, "wide characters ungood");
|
|
|
c59d11 |
|
|
|
c59d11 |
chop $a; # throw away the wide character
|
|
|
c59d11 |
|
|
|
c59d11 |
-eval {$b = crypt($a, "cd")};
|
|
|
c59d11 |
+eval {$b = crypt($a, $alg . "cd")};
|
|
|
c59d11 |
is($@, '', "downgrade to eight bit characters");
|
|
|
c59d11 |
-is($b, crypt("a\xFF", "cd"), "downgrade results agree");
|
|
|
c59d11 |
+is($b, crypt("a\xFF", $alg . "cd"), "downgrade results agree");
|
|
|
c59d11 |
|
|
|
c59d11 |
--
|
|
|
c59d11 |
1.9.0
|
|
|
c59d11 |
|