summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--config.m433
-rw-r--r--package.xml4
3 files changed, 27 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a8d0ef8..93c5a08 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
# Unreleased
+- improve algo availability check
+
# Version 1.2.0 - 2026-01-13
- add SM3 hash algos available in libxcrypt 4.5
diff --git a/config.m4 b/config.m4
index a4156a0..ecaa8ed 100644
--- a/config.m4
+++ b/config.m4
@@ -22,9 +22,14 @@ if test "$PHP_XPASS" != "no"; then
#include <stdlib.h>
int main(void) {
- char salt[8];
- salt[0]='$'; salt[1]='y'; salt[2]='$'; salt[3]=0;
- return crypt_gensalt(salt, 0, NULL, 0) ? 0 : 1;
+ 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])
@@ -40,9 +45,14 @@ int main(void) {
#include <stdlib.h>
int main(void) {
- char salt[8];
- salt[0]='$'; salt[1]='6'; salt[2]='$'; salt[3]=0;
- return crypt_gensalt(salt, 0, NULL, 0) ? 0 : 1;
+ 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])
@@ -58,9 +68,14 @@ int main(void) {
#include <stdlib.h>
int main(void) {
- char salt[8];
- salt[0]='$'; salt[1]='s'; salt[2]='m'; salt[3]='3'; salt[4]='$'; salt[5]=0;
- return crypt_gensalt(salt, 0, NULL, 0) ? 0 : 1;
+ 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])
diff --git a/package.xml b/package.xml
index 7c1a7b3..d171dbc 100644
--- a/package.xml
+++ b/package.xml
@@ -37,9 +37,7 @@ See PHP documentation on https://www.php.net/xpass
</stability>
<license uri="https://www.php.net/license/3_01.txt" filesource="LICENSE">PHP-3.01</license>
<notes><![CDATA[
-- add SM3 hash algos available in libxcrypt 4.5
-- add CRYPT_PREFIX_SM3CRYPT and CRYPT_PREFIX_SM3_YESCRYPT constants
-- add PASSWORD_SM3CRYPT and PASSWORD_SM3_YESCRYPT constants
+- improve algo availability check
]]></notes>
<contents>
<dir name="/">