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
157 …t = php_crypt(ZSTR_VAL(password), (int)ZSTR_LEN(password), ZSTR_VAL(hash), (int)ZSTR_LEN(hash), 1); in php_password_bcrypt_verify()
163 if (ZSTR_LEN(ret) != ZSTR_LEN(hash) || ZSTR_LEN(hash) < 13) { in php_password_bcrypt_verify()
172 for (i = 0; i < ZSTR_LEN(hash); i++) { in php_password_bcrypt_verify()
173 status |= (ZSTR_VAL(ret)[i] ^ ZSTR_VAL(hash)[i]); in php_password_bcrypt_verify()
183 zend_string *result, *hash, *salt; in php_password_bcrypt_hash() local
207 hash = zend_string_alloc(ZSTR_LEN(salt) + hash_format_len, 0); in php_password_bcrypt_hash()
208 sprintf(ZSTR_VAL(hash), "%s%s", hash_format, ZSTR_VAL(salt)); in php_password_bcrypt_hash()
209 ZSTR_VAL(hash)[hash_format_len + ZSTR_LEN(salt)] = 0; in php_password_bcrypt_hash() local
214 …result = php_crypt(ZSTR_VAL(password), (int)ZSTR_LEN(password), ZSTR_VAL(hash), (int)ZSTR_LEN(hash… in php_password_bcrypt_hash()
215 zend_string_release_ex(hash, 0); in php_password_bcrypt_hash()
242 static int extract_argon2_parameters(const zend_string *hash, in extract_argon2_parameters() argument
246 const char *p = ZSTR_VAL(hash); in extract_argon2_parameters()
247 if (!hash || (ZSTR_LEN(hash) < sizeof("$argon2id$"))) { in extract_argon2_parameters()
265 static int php_password_argon2_get_info(zval *return_value, const zend_string *hash) { in php_password_argon2_get_info() argument
271 extract_argon2_parameters(hash, &v, &memory_cost, &time_cost, &threads); in php_password_argon2_get_info()
280 static bool php_password_argon2_needs_rehash(const zend_string *hash, zend_array *options) { in php_password_argon2_needs_rehash() argument
299 extract_argon2_parameters(hash, &v, &memory_cost, &time_cost, &threads); in php_password_argon2_needs_rehash()
388 static bool php_password_argon2i_verify(const zend_string *password, const zend_string *hash) { in php_password_argon2i_verify() argument
389 …return ARGON2_OK == argon2_verify(ZSTR_VAL(hash), ZSTR_VAL(password), ZSTR_LEN(password), Argon2_i… in php_password_argon2i_verify()
407 static bool php_password_argon2id_verify(const zend_string *password, const zend_string *hash) { in php_password_argon2id_verify() argument
408 …return ARGON2_OK == argon2_verify(ZSTR_VAL(hash), ZSTR_VAL(password), ZSTR_LEN(password), Argon2_i… in php_password_argon2id_verify()
527 zend_string *php_password_algo_extract_ident(const zend_string* hash) { in php_password_algo_extract_ident() argument
530 if (!hash || ZSTR_LEN(hash) < 3) { in php_password_algo_extract_ident()
535 ident = ZSTR_VAL(hash) + 1; in php_password_algo_extract_ident()
545 const php_password_algo* php_password_algo_identify_ex(const zend_string* hash, const php_password_… in php_password_algo_identify_ex() argument
547 zend_string *ident = php_password_algo_extract_ident(hash); in php_password_algo_identify_ex()
555 return (!algo || (algo->valid && !algo->valid(hash))) ? default_algo : algo; in php_password_algo_identify_ex()
562 zend_string *hash, *ident; in PHP_FUNCTION() local
566 Z_PARAM_STR(hash) in PHP_FUNCTION()
572 ident = php_password_algo_extract_ident(hash); in PHP_FUNCTION()
574 if (!algo || (algo->valid && !algo->valid(hash))) { in PHP_FUNCTION()
584 add_assoc_str(return_value, "algo", php_password_algo_extract_ident(hash)); in PHP_FUNCTION()
589 algo->get_info(&options, hash); in PHP_FUNCTION()
599 zend_string *hash; in PHP_FUNCTION() local
606 Z_PARAM_STR(hash) in PHP_FUNCTION()
618 old_algo = php_password_algo_identify_ex(hash, NULL); in PHP_FUNCTION()
624 RETURN_BOOL(old_algo->needs_rehash(hash, options)); in PHP_FUNCTION()
631 zend_string *password, *hash; in PHP_FUNCTION() local
636 Z_PARAM_STR(hash) in PHP_FUNCTION()
639 algo = php_password_algo_identify(hash); in PHP_FUNCTION()
640 RETURN_BOOL(algo && (!algo->verify || algo->verify(password, hash))); in PHP_FUNCTION()
667 digest = algo->hash(password, options); in PHP_FUNCTION()