Coverage Report

Created: 2026-06-02 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/php-src/ext/standard/php_password.h
Line
Count
Source
1
/*
2
   +----------------------------------------------------------------------+
3
   | Copyright © The PHP Group and Contributors.                          |
4
   +----------------------------------------------------------------------+
5
   | This source file is subject to the Modified BSD License that is      |
6
   | bundled with this package in the file LICENSE, and is available      |
7
   | through the World Wide Web at <https://www.php.net/license/>.        |
8
   |                                                                      |
9
   | SPDX-License-Identifier: BSD-3-Clause                                |
10
   +----------------------------------------------------------------------+
11
   | Authors: Anthony Ferrara <ircmaxell@php.net>                         |
12
   |          Charles R. Portwood II <charlesportwoodii@erianna.com>      |
13
   +----------------------------------------------------------------------+
14
*/
15
16
#ifndef PHP_PASSWORD_H
17
#define PHP_PASSWORD_H
18
19
PHP_MINIT_FUNCTION(password);
20
PHP_MSHUTDOWN_FUNCTION(password);
21
22
#define PHP_PASSWORD_DEFAULT    PHP_PASSWORD_BCRYPT
23
0
#define PHP_PASSWORD_BCRYPT_COST 12
24
25
#ifdef HAVE_ARGON2LIB
26
/**
27
 * When updating these values, synchronize values in
28
 *     ext/sodium/php_libsodium.h
29
 *     ext/openssl/php_openssl.h
30
 * Note that libargon/openssl express memlimit in KB, while libsodium uses bytes.
31
 */
32
#define PHP_PASSWORD_ARGON2_MEMORY_COST (64 << 10)
33
#define PHP_PASSWORD_ARGON2_TIME_COST 4
34
#define PHP_PASSWORD_ARGON2_THREADS 1
35
#endif
36
37
typedef struct _php_password_algo {
38
  const char *name;
39
  zend_string *(*hash)(const zend_string *password, zend_array *options);
40
  bool (*verify)(const zend_string *password, const zend_string *hash);
41
  bool (*needs_rehash)(const zend_string *password, zend_array *options);
42
  int (*get_info)(zval *return_value, const zend_string *hash);
43
  bool (*valid)(const zend_string *hash);
44
} php_password_algo;
45
46
extern const php_password_algo php_password_algo_bcrypt;
47
#ifdef HAVE_ARGON2LIB
48
extern const php_password_algo php_password_algo_argon2i;
49
extern const php_password_algo php_password_algo_argon2id;
50
#endif
51
52
PHPAPI int php_password_algo_register(const char*, const php_password_algo*);
53
PHPAPI void php_password_algo_unregister(const char*);
54
PHPAPI const php_password_algo* php_password_algo_default(void);
55
PHPAPI zend_string *php_password_algo_extract_ident(const zend_string*);
56
PHPAPI const php_password_algo* php_password_algo_find(const zend_string*);
57
58
PHPAPI const php_password_algo* php_password_algo_identify_ex(const zend_string*, const php_password_algo*);
59
0
static inline const php_password_algo* php_password_algo_identify(const zend_string *hash) {
60
0
  return php_password_algo_identify_ex(hash, php_password_algo_default());
61
0
}
Unexecuted instantiation: basic_functions.c:php_password_algo_identify
Unexecuted instantiation: ftp_fopen_wrapper.c:php_password_algo_identify
Unexecuted instantiation: head.c:php_password_algo_identify
Unexecuted instantiation: html.c:php_password_algo_identify
Unexecuted instantiation: http_fopen_wrapper.c:php_password_algo_identify
Unexecuted instantiation: password.c:php_password_algo_identify
Unexecuted instantiation: php_fopen_wrapper.c:php_password_algo_identify
Unexecuted instantiation: fopen_wrappers.c:php_password_algo_identify
Unexecuted instantiation: main.c:php_password_algo_identify
Unexecuted instantiation: php_variables.c:php_password_algo_identify
Unexecuted instantiation: internal_functions_cli.c:php_password_algo_identify
62
63
64
#endif