diff options
| author | Remi Collet <remi@remirepo.net> | 2026-04-10 10:23:27 +0200 |
|---|---|---|
| committer | Remi Collet <remi@php.net> | 2026-04-10 10:23:27 +0200 |
| commit | 26f7d7dc29cd079d8c58f8c5cf59e6b45338234d (patch) | |
| tree | 2918e0b4169f99e822760e11355aaa8957d16ebe | |
| parent | 3aca69bd0b7739d6430c2c80f8f9a0ee65b315c3 (diff) | |
improve algo availability check
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | config.m4 | 33 | ||||
| -rw-r--r-- | package.xml | 4 |
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 @@ -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="/"> |
