summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package.xml2
-rw-r--r--tests/crypt_checksalt.phpt2
-rw-r--r--tests/crypt_gensalt.phpt18
-rw-r--r--tests/password_compat.phpt2
-rw-r--r--xpass.c8
-rw-r--r--xpass.stub.php22
-rw-r--r--xpass_arginfo.h22
7 files changed, 37 insertions, 39 deletions
diff --git a/package.xml b/package.xml
index b47f016..f59c2bd 100644
--- a/package.xml
+++ b/package.xml
@@ -27,7 +27,7 @@ distributions, using extended crypt library (libxcrypt):
</stability>
<license uri="https://www.php.net/license/3_01.txt" filesource="LICENSE">PHP-3.01</license>
<notes>
-- add crypt_gensalt(?string $salt = null, int $count = 0): ?string {}
+- add crypt_gensalt(?string $prefix = null, int $count = 0): ?string {}
- add crypt_preferred_method(): ?string {}
- add crypt_checksalt(string $salt): int {}
</notes>
diff --git a/tests/crypt_checksalt.phpt b/tests/crypt_checksalt.phpt
index f34f585..0a0f6ee 100644
--- a/tests/crypt_checksalt.phpt
+++ b/tests/crypt_checksalt.phpt
@@ -3,7 +3,7 @@ Test crypt_checksalt
--FILE--
<?php
// salt with old algo is OK or LEGACY
-$r = crypt_checksalt(crypt_gensalt(XPASS_CRYPT_STD_DES));
+$r = crypt_checksalt(crypt_gensalt(CRYPT_PREFIX_STD_DES));
var_dump($r === CRYPT_SALT_METHOD_LEGACY || $r === CRYPT_SALT_OK);
// salt with default algo is OK
diff --git a/tests/crypt_gensalt.phpt b/tests/crypt_gensalt.phpt
index b838a04..945e520 100644
--- a/tests/crypt_gensalt.phpt
+++ b/tests/crypt_gensalt.phpt
@@ -2,15 +2,15 @@
Test crypt_gensalt
--FILE--
<?php
-var_dump(crypt_gensalt(XPASS_CRYPT_STD_DES));
-var_dump(crypt_gensalt(XPASS_CRYPT_EXT_DES));
-var_dump(crypt_gensalt(XPASS_CRYPT_MD5));
-var_dump(crypt_gensalt(XPASS_CRYPT_BLOWFISH));
-var_dump(crypt_gensalt(XPASS_CRYPT_SHA256));
-var_dump(crypt_gensalt(XPASS_CRYPT_SHA512));
-var_dump(crypt_gensalt(XPASS_CRYPT_SCRYPT));
-var_dump(crypt_gensalt(XPASS_CRYPT_GOST_YESCRYPT));
-var_dump(crypt_gensalt(XPASS_CRYPT_YESCRYPT));
+var_dump(crypt_gensalt(CRYPT_PREFIX_STD_DES));
+var_dump(crypt_gensalt(CRYPT_PREFIX_EXT_DES));
+var_dump(crypt_gensalt(CRYPT_PREFIX_MD5));
+var_dump(crypt_gensalt(CRYPT_PREFIX_BLOWFISH));
+var_dump(crypt_gensalt(CRYPT_PREFIX_SHA256));
+var_dump(crypt_gensalt(CRYPT_PREFIX_SHA512));
+var_dump(crypt_gensalt(CRYPT_PREFIX_SCRYPT));
+var_dump(crypt_gensalt(CRYPT_PREFIX_GOST_YESCRYPT));
+var_dump(crypt_gensalt(CRYPT_PREFIX_YESCRYPT));
?>
--EXPECTF--
diff --git a/tests/password_compat.phpt b/tests/password_compat.phpt
index 3dd6ad2..2571b02 100644
--- a/tests/password_compat.phpt
+++ b/tests/password_compat.phpt
@@ -9,7 +9,7 @@ $h = password_hash($secret, PASSWORD_BCRYPT);
var_dump($h, password_verify($secret, $h), $h===crypt($secret, $h));
/* generate with crypt, check with both */
-$h = crypt($secret, crypt_gensalt(XPASS_CRYPT_BLOWFISH));
+$h = crypt($secret, crypt_gensalt(CRYPT_PREFIX_BLOWFISH));
var_dump($h, password_verify($secret, $h), $h===crypt($secret, $h));
?>
--EXPECTF--
diff --git a/xpass.c b/xpass.c
index cb16131..b37863e 100644
--- a/xpass.c
+++ b/xpass.c
@@ -190,14 +190,14 @@ PHP_FUNCTION(crypt_preferred_method)
/* {{{ Determine whether the user's passphrase should be re-hashed using the currently preferred hashing method */
PHP_FUNCTION(crypt_checksalt)
{
- char *prefix;
- size_t prefix_len;
+ char *salt;
+ size_t salt_len;
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_STRING(prefix, prefix_len)
+ Z_PARAM_STRING(salt, salt_len)
ZEND_PARSE_PARAMETERS_END();
- RETURN_LONG(crypt_checksalt(prefix));
+ RETURN_LONG(crypt_checksalt(salt));
}
/* }}} */
diff --git a/xpass.stub.php b/xpass.stub.php
index 4cb0d67..68718da 100644
--- a/xpass.stub.php
+++ b/xpass.stub.php
@@ -6,26 +6,24 @@
*/
-/* use XPASS prefix to avoid conflicts with standard constants */
-
/** @var string */
-const XPASS_CRYPT_STD_DES = '';
+const CRYPT_PREFIX_STD_DES = '';
/** @var string */
-const XPASS_CRYPT_EXT_DES = '_';
+const CRYPT_PREFIX_EXT_DES = '_';
/** @var string */
-const XPASS_CRYPT_MD5 = '$1$';
+const CRYPT_PREFIX_MD5 = '$1$';
/** @var string */
-const XPASS_CRYPT_BLOWFISH = '$2y$';
+const CRYPT_PREFIX_BLOWFISH = '$2y$';
/** @var string */
-const XPASS_CRYPT_SHA256 = '$5$';
+const CRYPT_PREFIX_SHA256 = '$5$';
/** @var string */
-const XPASS_CRYPT_SHA512 = '$6$';
+const CRYPT_PREFIX_SHA512 = '$6$';
/** @var string */
-const XPASS_CRYPT_SCRYPT = '$7$';
+const CRYPT_PREFIX_SCRYPT = '$7$';
/** @var string */
-const XPASS_CRYPT_GOST_YESCRYPT = '$gy$';
+const CRYPT_PREFIX_GOST_YESCRYPT = '$gy$';
/** @var string */
-const XPASS_CRYPT_YESCRYPT = '$y$';
+const CRYPT_PREFIX_YESCRYPT = '$y$';
/**
* @var int
@@ -54,7 +52,7 @@ const CRYPT_SALT_METHOD_LEGACY = UNKNOWN;
const CRYPT_SALT_TOO_CHEAP = UNKNOWN;
-function crypt_gensalt(?string $salt = null, int $count = 0): ?string {}
+function crypt_gensalt(?string $prefix = null, int $count = 0): ?string {}
function crypt_preferred_method(): ?string {}
diff --git a/xpass_arginfo.h b/xpass_arginfo.h
index 87ad78f..f530d0f 100644
--- a/xpass_arginfo.h
+++ b/xpass_arginfo.h
@@ -1,8 +1,8 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 09c1d047a579afe870fadd302bd2e34a5d06c370 */
+ * Stub hash: 9f75db3279543b07de6b59e720e8521694200a7c */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_crypt_gensalt, 0, 0, IS_STRING, 1)
- ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, salt, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, prefix, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
@@ -26,15 +26,15 @@ static const zend_function_entry ext_functions[] = {
static void register_xpass_symbols(int module_number)
{
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_STD_DES", "", CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_EXT_DES", "_", CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_MD5", "$1$", CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_BLOWFISH", "$2y$", CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_SHA256", "$5$", CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_SHA512", "$6$", CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_SCRYPT", "$7$", CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_GOST_YESCRYPT", "$gy$", CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("XPASS_CRYPT_YESCRYPT", "$y$", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_STD_DES", "", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_EXT_DES", "_", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_MD5", "$1$", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_BLOWFISH", "$2y$", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_SHA256", "$5$", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_SHA512", "$6$", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_SCRYPT", "$7$", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_GOST_YESCRYPT", "$gy$", CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("CRYPT_PREFIX_YESCRYPT", "$y$", CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CRYPT_SALT_OK", CRYPT_SALT_OK, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CRYPT_SALT_INVALID", CRYPT_SALT_INVALID, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CRYPT_SALT_METHOD_DISABLED", CRYPT_SALT_METHOD_DISABLED, CONST_PERSISTENT);