Lines Matching refs:hash
116 static bool php_password_bcrypt_valid(const zend_string *hash) { in php_password_bcrypt_valid() argument
117 const char *h = ZSTR_VAL(hash); in php_password_bcrypt_valid()
118 return (ZSTR_LEN(hash) == 60) && in php_password_bcrypt_valid()
122 static int php_password_bcrypt_get_info(zval *return_value, const zend_string *hash) { in php_password_bcrypt_get_info() argument
125 if (!php_password_bcrypt_valid(hash)) { in php_password_bcrypt_get_info()
130 sscanf(ZSTR_VAL(hash), "$2y$" ZEND_LONG_FMT "$", &cost); in php_password_bcrypt_get_info()
136 static bool php_password_bcrypt_needs_rehash(const zend_string *hash, zend_array *options) { in php_password_bcrypt_needs_rehash() argument
141 if (!php_password_bcrypt_valid(hash)) { in php_password_bcrypt_needs_rehash()
146 sscanf(ZSTR_VAL(hash), "$2y$" ZEND_LONG_FMT "$", &old_cost); in php_password_bcrypt_needs_rehash()
154 static bool php_password_bcrypt_verify(const zend_string *password, const zend_string *hash) { in php_password_bcrypt_verify() argument
156 …t = php_crypt(ZSTR_VAL(password), (int)ZSTR_LEN(password), ZSTR_VAL(hash), (int)ZSTR_LEN(hash), 1); in php_password_bcrypt_verify()
162 if (ZSTR_LEN(hash) < 13) { in php_password_bcrypt_verify()
171 status = php_safe_bcmp(ret, hash); in php_password_bcrypt_verify()
180 zend_string *result, *hash, *salt; in php_password_bcrypt_hash() local
204 hash = zend_string_concat2(hash_format, hash_format_len, ZSTR_VAL(salt), ZSTR_LEN(salt)); in php_password_bcrypt_hash()
209 …result = php_crypt(ZSTR_VAL(password), (int)ZSTR_LEN(password), ZSTR_VAL(hash), (int)ZSTR_LEN(hash… in php_password_bcrypt_hash()
210 zend_string_release_ex(hash, 0); in php_password_bcrypt_hash()
237 static int extract_argon2_parameters(const zend_string *hash, in extract_argon2_parameters() argument
241 const char *p = ZSTR_VAL(hash); in extract_argon2_parameters()
242 if (!hash || (ZSTR_LEN(hash) < sizeof("$argon2id$"))) { in extract_argon2_parameters()
260 static int php_password_argon2_get_info(zval *return_value, const zend_string *hash) { in php_password_argon2_get_info() argument
266 extract_argon2_parameters(hash, &v, &memory_cost, &time_cost, &threads); in php_password_argon2_get_info()
275 static bool php_password_argon2_needs_rehash(const zend_string *hash, zend_array *options) { in php_password_argon2_needs_rehash() argument
294 extract_argon2_parameters(hash, &v, &memory_cost, &time_cost, &threads); in php_password_argon2_needs_rehash()
383 static bool php_password_argon2i_verify(const zend_string *password, const zend_string *hash) { in php_password_argon2i_verify() argument
384 …return ARGON2_OK == argon2_verify(ZSTR_VAL(hash), ZSTR_VAL(password), ZSTR_LEN(password), Argon2_i… in php_password_argon2i_verify()
402 static bool php_password_argon2id_verify(const zend_string *password, const zend_string *hash) { in php_password_argon2id_verify() argument
403 …return ARGON2_OK == argon2_verify(ZSTR_VAL(hash), ZSTR_VAL(password), ZSTR_LEN(password), Argon2_i… in php_password_argon2id_verify()
510 zend_string *php_password_algo_extract_ident(const zend_string* hash) { in php_password_algo_extract_ident() argument
513 if (!hash || ZSTR_LEN(hash) < 3) { in php_password_algo_extract_ident()
518 ident = ZSTR_VAL(hash) + 1; in php_password_algo_extract_ident()
528 const php_password_algo* php_password_algo_identify_ex(const zend_string* hash, const php_password_… in php_password_algo_identify_ex() argument
530 zend_string *ident = php_password_algo_extract_ident(hash); in php_password_algo_identify_ex()
538 return (!algo || (algo->valid && !algo->valid(hash))) ? default_algo : algo; in php_password_algo_identify_ex()
545 zend_string *hash, *ident; in PHP_FUNCTION() local
549 Z_PARAM_STR(hash) in PHP_FUNCTION()
555 ident = php_password_algo_extract_ident(hash); in PHP_FUNCTION()
557 if (!algo || (algo->valid && !algo->valid(hash))) { in PHP_FUNCTION()
567 add_assoc_str(return_value, "algo", php_password_algo_extract_ident(hash)); in PHP_FUNCTION()
572 algo->get_info(&options, hash); in PHP_FUNCTION()
582 zend_string *hash; in PHP_FUNCTION() local
589 Z_PARAM_STR(hash) in PHP_FUNCTION()
601 old_algo = php_password_algo_identify_ex(hash, NULL); in PHP_FUNCTION()
607 RETURN_BOOL(old_algo->needs_rehash(hash, options)); in PHP_FUNCTION()
614 zend_string *password, *hash; in PHP_FUNCTION() local
619 Z_PARAM_STR(hash) in PHP_FUNCTION()
622 algo = php_password_algo_identify(hash); in PHP_FUNCTION()
623 RETURN_BOOL(algo && (!algo->verify || algo->verify(password, hash))); in PHP_FUNCTION()
650 digest = algo->hash(password, options); in PHP_FUNCTION()