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 /config.m4 | |
| parent | 3aca69bd0b7739d6430c2c80f8f9a0ee65b315c3 (diff) | |
improve algo availability check
Diffstat (limited to 'config.m4')
| -rw-r--r-- | config.m4 | 33 |
1 files changed, 24 insertions, 9 deletions
@@ -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]) |
