Lines Matching refs:hash

115 static bool php_password_bcrypt_valid(const zend_string *hash) {  in php_password_bcrypt_valid()  argument
116 const char *h = ZSTR_VAL(hash); in php_password_bcrypt_valid()
117 return (ZSTR_LEN(hash) == 60) && in php_password_bcrypt_valid()
121 static int php_password_bcrypt_get_info(zval *return_value, const zend_string *hash) { in php_password_bcrypt_get_info() argument
124 if (!php_password_bcrypt_valid(hash)) { in php_password_bcrypt_get_info()
129 sscanf(ZSTR_VAL(hash), "$2y$" ZEND_LONG_FMT "$", &cost); in php_password_bcrypt_get_info()
135 static bool php_password_bcrypt_needs_rehash(const zend_string *hash, zend_array *options) { in php_password_bcrypt_needs_rehash() argument
140 if (!php_password_bcrypt_valid(hash)) { in php_password_bcrypt_needs_rehash()
145 sscanf(ZSTR_VAL(hash), "$2y$" ZEND_LONG_FMT "$", &old_cost); in php_password_bcrypt_needs_rehash()
153 static bool php_password_bcrypt_verify(const zend_string *password, const zend_string *hash) { in php_password_bcrypt_verify() argument
155 …t = php_crypt(ZSTR_VAL(password), (int)ZSTR_LEN(password), ZSTR_VAL(hash), (int)ZSTR_LEN(hash), 1); in php_password_bcrypt_verify()
161 if (ZSTR_LEN(hash) < 13) { in php_password_bcrypt_verify()
170 status = php_safe_bcmp(ret, hash); in php_password_bcrypt_verify()
179 zend_string *result, *hash, *salt; in php_password_bcrypt_hash() local
203 hash = zend_string_alloc(ZSTR_LEN(salt) + hash_format_len, 0); in php_password_bcrypt_hash()
204 sprintf(ZSTR_VAL(hash), "%s%s", hash_format, ZSTR_VAL(salt)); in php_password_bcrypt_hash()
205 ZSTR_VAL(hash)[hash_format_len + ZSTR_LEN(salt)] = 0; in php_password_bcrypt_hash() local
210 …result = php_crypt(ZSTR_VAL(password), (int)ZSTR_LEN(password), ZSTR_VAL(hash), (int)ZSTR_LEN(hash in php_password_bcrypt_hash()
211 zend_string_release_ex(hash, 0); in php_password_bcrypt_hash()
238 static int extract_argon2_parameters(const zend_string *hash, in extract_argon2_parameters() argument
242 const char *p = ZSTR_VAL(hash); in extract_argon2_parameters()
243 if (!hash || (ZSTR_LEN(hash) < sizeof("$argon2id$"))) { in extract_argon2_parameters()
261 static int php_password_argon2_get_info(zval *return_value, const zend_string *hash) { in php_password_argon2_get_info() argument
267 extract_argon2_parameters(hash, &v, &memory_cost, &time_cost, &threads); in php_password_argon2_get_info()
276 static bool php_password_argon2_needs_rehash(const zend_string *hash, zend_array *options) { in php_password_argon2_needs_rehash() argument
295 extract_argon2_parameters(hash, &v, &memory_cost, &time_cost, &threads); in php_password_argon2_needs_rehash()
384 static bool php_password_argon2i_verify(const zend_string *password, const zend_string *hash) { in php_password_argon2i_verify() argument
385 …return ARGON2_OK == argon2_verify(ZSTR_VAL(hash), ZSTR_VAL(password), ZSTR_LEN(password), Argon2_i… in php_password_argon2i_verify()
403 static bool php_password_argon2id_verify(const zend_string *password, const zend_string *hash) { in php_password_argon2id_verify() argument
404 …return ARGON2_OK == argon2_verify(ZSTR_VAL(hash), ZSTR_VAL(password), ZSTR_LEN(password), Argon2_i… in php_password_argon2id_verify()
523 zend_string *php_password_algo_extract_ident(const zend_string* hash) { in php_password_algo_extract_ident() argument
526 if (!hash || ZSTR_LEN(hash) < 3) { in php_password_algo_extract_ident()
531 ident = ZSTR_VAL(hash) + 1; in php_password_algo_extract_ident()
541 const php_password_algo* php_password_algo_identify_ex(const zend_string* hash, const php_password_… in php_password_algo_identify_ex() argument
543 zend_string *ident = php_password_algo_extract_ident(hash); in php_password_algo_identify_ex()
551 return (!algo || (algo->valid && !algo->valid(hash))) ? default_algo : algo; in php_password_algo_identify_ex()
558 zend_string *hash, *ident; in PHP_FUNCTION() local
562 Z_PARAM_STR(hash) in PHP_FUNCTION()
568 ident = php_password_algo_extract_ident(hash); in PHP_FUNCTION()
570 if (!algo || (algo->valid && !algo->valid(hash))) { in PHP_FUNCTION()
580 add_assoc_str(return_value, "algo", php_password_algo_extract_ident(hash)); in PHP_FUNCTION()
585 algo->get_info(&options, hash); in PHP_FUNCTION()
595 zend_string *hash; in PHP_FUNCTION() local
602 Z_PARAM_STR(hash) in PHP_FUNCTION()
614 old_algo = php_password_algo_identify_ex(hash, NULL); in PHP_FUNCTION()
620 RETURN_BOOL(old_algo->needs_rehash(hash, options)); in PHP_FUNCTION()
627 zend_string *password, *hash; in PHP_FUNCTION() local
632 Z_PARAM_STR(hash) in PHP_FUNCTION()
635 algo = php_password_algo_identify(hash); in PHP_FUNCTION()
636 RETURN_BOOL(algo && (!algo->verify || algo->verify(password, hash))); in PHP_FUNCTION()
663 digest = algo->hash(password, options); in PHP_FUNCTION()