apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1449315 - in /apr/apr-util/branches/1.5.x: ./ test/testpass.c
Date Sat, 23 Feb 2013 13:23:44 GMT
Author: sf
Date: Sat Feb 23 13:23:43 2013
New Revision: 1449315

URL: http://svn.apache.org/r1449315
Log:
Merge r1449314:
Add testcases for extended crypt algorithms

PR: 54603

Modified:
    apr/apr-util/branches/1.5.x/   (props changed)
    apr/apr-util/branches/1.5.x/test/testpass.c

Propchange: apr/apr-util/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1449314

Modified: apr/apr-util/branches/1.5.x/test/testpass.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/test/testpass.c?rev=1449315&r1=1449314&r2=1449315&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/test/testpass.c (original)
+++ apr/apr-util/branches/1.5.x/test/testpass.c Sat Feb 23 13:23:43 2013
@@ -34,6 +34,12 @@
 #define CRYPT_ALGO_SUPPORTED 1
 #endif
 
+#if defined __GLIBC_PREREQ
+#if __GLIBC_PREREQ(2,7)
+#define GLIBCSHA_ALGO_SUPPORTED
+#endif
+#endif
+
 #if CRYPT_ALGO_SUPPORTED
 
 static struct {
@@ -142,6 +148,33 @@ static void test_md5pass(abts_case *tc, 
                        apr_password_validate(pass2, hash));
 }
 
+#ifdef GLIBCSHA_ALGO_SUPPORTED
+
+static struct {
+    const char *password;
+    const char *hash;
+} glibc_sha_pws[] = {
+    /* SHA256 */
+    { "secret1", "$5$0123456789abcdef$SFX.CooXBS8oXsbAPgU/UyiCodhrLQ19sBgvcA3Zh1D" },
+    { "secret2", "$5$rounds=100000$0123456789abcdef$dLXfO5m4d.xv8G66kpz2LyL0.Mi5wjLlH0m7rtgyhyB"
},
+    /* SHA512 */
+    { "secret3", "$6$0123456789abcdef$idOsOfoWwnCQkJm9hd2hxS4NnEs9nBA9poOFXsvtrYSoSHaOToCfyUoZwKe.ZCZnq7D95tGVoi2jxZZMyVwTL1"
},
+    { "secret4", "$6$rounds=100000$0123456789abcdef$ZiAMjbeA.iIGTWxq2oks9Bvz9sfxaoGPgAtpwimPEwFwkSNMTK7lLwABzzldds/n4UgCQ16HqawPrCrePr4YX1"
},
+    { NULL, NULL }
+};
+
+static void test_glibc_shapass(abts_case *tc, void *data)
+{
+    int i = 0;
+    while (glibc_sha_pws[i].password) {
+        APR_ASSERT_SUCCESS(tc, "check for valid glibc crypt-sha password",
+                           apr_password_validate(glibc_sha_pws[i].password,
+                                                 glibc_sha_pws[i].hash));
+        i++;
+    }
+}
+#endif
+
 static void test_bcryptpass(abts_case *tc, void *data)
 {
     const char *pass = "hellojed";
@@ -177,6 +210,9 @@ abts_suite *testpass(abts_suite *suite)
     abts_run_test(suite, test_shapass, NULL);
     abts_run_test(suite, test_md5pass, NULL);
     abts_run_test(suite, test_bcryptpass, NULL);
+#ifdef GLIBCSHA_ALGO_SUPPORTED
+    abts_run_test(suite, test_glibc_shapass, NULL);
+#endif
     
     return suite;
 }



Mime
View raw message