summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2019-06-21 16:20:29 +0000
committerJoe Orton <jorton@apache.org>2019-06-21 16:20:29 +0000
commit57748d60a5e58598b8f66feaa7760ebed9a02dbf (patch)
tree712d8a3456a19cdd4b0f20bf62f65912e83517a4 /configure.in
parent07e3fbd647bc9ed047eca8bf8fc22eae47d97daa (diff)
downloadhttpd-57748d60a5e58598b8f66feaa7760ebed9a02dbf.tar.gz
Add support for SHA-2 crypt() algorithm in htpasswd.
* configure.in: Detect SHA-2 support in crypt(). * support/passwd_common.h: Define ALG_CRYPT_SHA256, ALG_CRYPT_SHA512, include ap_config_auto.h. * support/htpasswd.c (check_args): Allow -2, -5, -r arguments for SHA-256, SHA-256 and rounds options respectively. * support/passwd_common.c (parse_common_options): Parse -2, -5, -r args. (mkhash): Generate crypt hash for SHA256/SHA512 algorithms. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1861793 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in22
1 files changed, 22 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 6c8a6d4886..6199f6daf7 100644
--- a/configure.in
+++ b/configure.in
@@ -500,6 +500,28 @@ LIBS=""
AC_SEARCH_LIBS(crypt, crypt)
CRYPT_LIBS="$LIBS"
APACHE_SUBST(CRYPT_LIBS)
+
+if test "$ac_cv_search_crypt" != "no"; then
+ # Test crypt() with the SHA-512 test vector from https://akkadia.org/drepper/SHA-crypt.txt
+ AC_CACHE_CHECK([whether crypt() supports SHA-2], [ap_cv_crypt_sha2], [
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <crypt.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define PASSWD_0 "Hello world!"
+#define SALT_0 "\$6\$saltstring"
+#define EXPECT_0 "\$6\$saltstring\$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJu" \
+ "esI68u4OTLiBFdcbYEdFCoEOfaS35inz1"
+]], [char *result = crypt(PASSWD_0, SALT_0);
+ if (!result) return 1;
+ if (strcmp(result, EXPECT_0)) return 2;
+])], [ap_cv_crypt_sha2=yes], [ap_cv_crypt_sha2=no])])
+ if test "$ap_cv_crypt_sha2" = yes; then
+ AC_DEFINE([HAVE_CRYPT_SHA2], 1, [Define if crypt() supports SHA-2 hashes])
+ fi
+fi
+
LIBS="$saved_LIBS"
dnl See Comment #Spoon