1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
dnl config.m4 for extension xpass
PHP_ARG_ENABLE([xpass],
[whether to enable xpass support],
[AS_HELP_STRING([--enable-xpass],
[Enable xpass support])],
[no])
PHP_ARG_WITH([xpass-dlopen],
[whether to enable dlopen of libxcrypt],
[AS_HELP_STRING([[--with-xpass-dlopen[=libcrypt.so.2]]],
[Enable dlopen of libxcrypt])],
[no], [no])
if test "$PHP_XPASS" != "no"; then
PKG_CHECK_MODULES([LIBXCRYPT], [libxcrypt >= 4.4])
if test "$PHP_XPASS_DLOPEN" = "no"; then
PHP_EVAL_INCLINE([$LIBXCRYPT_CFLAGS])
PHP_EVAL_LIBLINE([$LIBXCRYPT_LIBS], [XPASS_SHARED_LIBADD])
elif test "$PHP_XPASS_DLOPEN" = "yes"; then
AC_DEFINE([USE_LIBCRYPT_DLOPEN], ["libcrypt.so.2"], [ libcrypt path for dlopen ])
PHP_SUBST([USE_LIBCRYPT_DLOPEN])
else
AC_DEFINE_UNQUOTED([USE_LIBCRYPT_DLOPEN], ["$PHP_XPASS_DLOPEN"], [ libcrypt path for dlopen ])
PHP_SUBST([USE_LIBCRYPT_DLOPEN])
fi
old_CFLAGS=$CFLAGS; CFLAGS="$CFLAGS $LIBXCRYPT_CFLAGS"
old_LIBS=$LIBS; LIBS="$LIBS $LIBXCRYPT_LIBS"
AC_MSG_CHECKING([for yescrypt algo])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <string.h>
#include <unistd.h>
#include <crypt.h>
#include <stdlib.h>
int main(void) {
char algo[8], *salt, *hash;
algo[0]='$'; algo[1]='y'; algo[2]='$'; algo[3]=0;
salt = crypt_gensalt(algo, 0, NULL, 0);
if (salt) {
hash = crypt("secret", salt);
return (hash && strlen(hash) == 73 && !memcmp(hash, algo, 3) ? 0 : 1);
}
return 1;
}]])],[
AC_DEFINE([HAVE_CRYPT_YESCRYPT], [1], [ Have yescrypt hash support ])
AC_MSG_RESULT([available])
], [
AC_MSG_RESULT([missing])
])
AC_MSG_CHECKING([for sha512 algo])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <string.h>
#include <unistd.h>
#include <crypt.h>
#include <stdlib.h>
int main(void) {
char algo[8], *salt, *hash;
algo[0]='$'; algo[1]='6'; algo[2]='$'; algo[3]=0;
salt = crypt_gensalt(algo, 0, NULL, 0);
if (salt) {
hash = crypt("secret", salt);
return (hash && strlen(hash) == 106 && !memcmp(hash, algo, 3) ? 0 : 1);
}
return 1;
}]])],[
AC_DEFINE([HAVE_CRYPT_SHA512], [1], [ Have sha512 hash support ])
AC_MSG_RESULT([available])
], [
AC_MSG_RESULT([missing])
])
AC_MSG_CHECKING([for sm3 algo])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <string.h>
#include <unistd.h>
#include <crypt.h>
#include <stdlib.h>
int main(void) {
char algo[8], *salt, *hash;
algo[0]='$'; algo[1]='s'; algo[2]='m'; algo[3]='3'; algo[4]='$'; algo[5]=0;
salt = crypt_gensalt(algo, 0, NULL, 0);
if (salt) {
hash = crypt("secret", salt);
return (hash && strlen(hash) == 65 && !memcmp(hash, algo, 5) ? 0 : 1);
}
return 1;
}]])],[
AC_DEFINE([HAVE_CRYPT_SM3], [1], [ Have sm3 hash support ])
AC_MSG_RESULT([available])
], [
AC_MSG_RESULT([missing])
])
CFLAGS=$old_CFLAGS
LIBS=$old_LIBS
PHP_SUBST([XPASS_SHARED_LIBADD])
AC_DEFINE([HAVE_XPASS], [1], [ Have xpass support ])
PHP_NEW_EXTENSION(xpass, xpass.c, $ext_shared)
fi
|