Skip to content

Commit 33343b3

Browse files
committed
Fix code review
1 parent 907ebd3 commit 33343b3

8 files changed

+67
-67
lines changed

ext/openssl/openssl.c

+20-20
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
865865
zend_long cipher_algo = Z_LVAL_P(item);
866866
const EVP_CIPHER* cipher = php_openssl_get_evp_cipher_from_algo(cipher_algo);
867867
if (cipher == NULL) {
868-
php_error_docref(NULL, E_WARNING, "Unknown cipher method for private key");
868+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm for private key");
869869
return FAILURE;
870870
} else {
871871
req->priv_key_encrypt_cipher = cipher;
@@ -1182,7 +1182,7 @@ PHP_MINIT_FUNCTION(openssl)
11821182
REGISTER_LONG_CONSTANT("X509_PURPOSE_ANY", X509_PURPOSE_ANY, CONST_CS|CONST_PERSISTENT);
11831183
#endif
11841184

1185-
/* signature algorithm constants */
1185+
/* digest algorithm constants */
11861186
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA1", OPENSSL_ALGO_SHA1, CONST_CS|CONST_PERSISTENT);
11871187
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD5", OPENSSL_ALGO_MD5, CONST_CS|CONST_PERSISTENT);
11881188
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD4", OPENSSL_ALGO_MD4, CONST_CS|CONST_PERSISTENT);
@@ -1563,7 +1563,7 @@ PHP_FUNCTION(openssl_spki_new)
15631563
mdtype = php_openssl_get_evp_md_from_algo(algo);
15641564

15651565
if (!mdtype) {
1566-
php_error_docref(NULL, E_WARNING, "Unknown digest method");
1566+
php_error_docref(NULL, E_WARNING, "Unknown digest algorithm");
15671567
goto cleanup;
15681568
}
15691569

@@ -1589,7 +1589,7 @@ PHP_FUNCTION(openssl_spki_new)
15891589

15901590
if (!NETSCAPE_SPKI_sign(spki, pkey, mdtype)) {
15911591
php_openssl_store_errors();
1592-
php_error_docref(NULL, E_WARNING, "Unable to sign with specified digest method");
1592+
php_error_docref(NULL, E_WARNING, "Unable to sign with specified digest algorithm");
15931593
goto cleanup;
15941594
}
15951595

@@ -1845,7 +1845,7 @@ zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_b
18451845
zend_string *ret;
18461846

18471847
if (!(mdtype = EVP_get_digestbyname(method))) {
1848-
php_error_docref(NULL, E_WARNING, "Unknown hashing algorithm");
1848+
php_error_docref(NULL, E_WARNING, "Unknown digest algorithm");
18491849
return NULL;
18501850
} else if (!X509_digest(peer, mdtype, md, &n)) {
18511851
php_openssl_store_errors();
@@ -4807,7 +4807,7 @@ PHP_FUNCTION(openssl_pbkdf2)
48074807
}
48084808

48094809
if (!digest) {
4810-
php_error_docref(NULL, E_WARNING, "Unknown signature algorithm");
4810+
php_error_docref(NULL, E_WARNING, "Unknown digest algorithm");
48114811
RETURN_FALSE;
48124812
}
48134813

@@ -6483,7 +6483,7 @@ PHP_FUNCTION(openssl_sign)
64836483
mdtype = php_openssl_get_evp_md_from_algo(method_long);
64846484
}
64856485
if (!mdtype) {
6486-
php_error_docref(NULL, E_WARNING, "Unknown signature algorithm");
6486+
php_error_docref(NULL, E_WARNING, "Unknown digest algorithm");
64876487
RETURN_FALSE;
64886488
}
64896489

@@ -6540,7 +6540,7 @@ PHP_FUNCTION(openssl_verify)
65406540
mdtype = php_openssl_get_evp_md_from_algo(method_long);
65416541
}
65426542
if (!mdtype) {
6543-
php_error_docref(NULL, E_WARNING, "Unknown signature algorithm");
6543+
php_error_docref(NULL, E_WARNING, "Unknown digest algorithm");
65446544
RETURN_FALSE;
65456545
}
65466546

@@ -6596,13 +6596,13 @@ PHP_FUNCTION(openssl_seal)
65966596

65976597
cipher = EVP_get_cipherbyname(method);
65986598
if (!cipher) {
6599-
php_error_docref(NULL, E_WARNING, "Unknown signature algorithm");
6599+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
66006600
RETURN_FALSE;
66016601
}
66026602

66036603
iv_len = EVP_CIPHER_iv_length(cipher);
66046604
if (!iv && iv_len > 0) {
6605-
zend_argument_value_error(6, "cannot be null for the chosen cipher method");
6605+
zend_argument_value_error(6, "cannot be null for the chosen cipher algorithm");
66066606
RETURN_THROWS();
66076607
}
66086608

@@ -6725,14 +6725,14 @@ PHP_FUNCTION(openssl_open)
67256725

67266726
cipher = EVP_get_cipherbyname(method);
67276727
if (!cipher) {
6728-
php_error_docref(NULL, E_WARNING, "Unknown cipher method");
6728+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
67296729
RETURN_FALSE;
67306730
}
67316731

67326732
cipher_iv_len = EVP_CIPHER_iv_length(cipher);
67336733
if (cipher_iv_len > 0) {
67346734
if (!iv) {
6735-
zend_argument_value_error(6, "cannot be null for the chosen cipher method");
6735+
zend_argument_value_error(6, "cannot be null for the chosen cipher algorithm");
67366736
RETURN_THROWS();
67376737
}
67386738
if ((size_t)cipher_iv_len != iv_len) {
@@ -6778,7 +6778,7 @@ static void php_openssl_add_method(const OBJ_NAME *name, void *arg) /* {{{ */
67786778
}
67796779
/* }}} */
67806780

6781-
/* {{{ Return array of available digest methods */
6781+
/* {{{ Return array of available digest algorithms */
67826782
PHP_FUNCTION(openssl_get_md_methods)
67836783
{
67846784
zend_bool aliases = 0;
@@ -6793,7 +6793,7 @@ PHP_FUNCTION(openssl_get_md_methods)
67936793
}
67946794
/* }}} */
67956795

6796-
/* {{{ Return array of available cipher methods */
6796+
/* {{{ Return array of available cipher algorithms */
67976797
PHP_FUNCTION(openssl_get_cipher_methods)
67986798
{
67996799
zend_bool aliases = 0;
@@ -6854,7 +6854,7 @@ PHP_FUNCTION(openssl_digest)
68546854
}
68556855
mdtype = EVP_get_digestbyname(method);
68566856
if (!mdtype) {
6857-
php_error_docref(NULL, E_WARNING, "Unknown digest method");
6857+
php_error_docref(NULL, E_WARNING, "Unknown digest algorithm");
68586858
RETURN_FALSE;
68596859
}
68606860

@@ -7008,7 +7008,7 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
70087008
}
70097009
} else if (!enc && tag && tag_len > 0) {
70107010
if (!mode->is_aead) {
7011-
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher method does not support AEAD");
7011+
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher algorithm does not support AEAD");
70127012
} else if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, (unsigned char *) tag)) {
70137013
php_error_docref(NULL, E_WARNING, "Setting tag for AEAD cipher decryption failed");
70147014
return FAILURE;
@@ -7020,7 +7020,7 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
70207020
if (key_len > password_len) {
70217021
if ((OPENSSL_DONT_ZERO_PAD_KEY & options) && !EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len)) {
70227022
php_openssl_store_errors();
7023-
php_error_docref(NULL, E_WARNING, "Key length cannot be set for the cipher method");
7023+
php_error_docref(NULL, E_WARNING, "Key length cannot be set for the cipher algorithm");
70247024
return FAILURE;
70257025
}
70267026
key = emalloc(key_len);
@@ -7114,7 +7114,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
71147114

71157115
cipher_type = EVP_get_cipherbyname(method);
71167116
if (!cipher_type) {
7117-
php_error_docref(NULL, E_WARNING, "Unknown cipher method");
7117+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
71187118
return NULL;
71197119
}
71207120

@@ -7230,7 +7230,7 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(
72307230

72317231
cipher_type = EVP_get_cipherbyname(method);
72327232
if (!cipher_type) {
7233-
php_error_docref(NULL, E_WARNING, "Unknown cipher method");
7233+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
72347234
return NULL;
72357235
}
72367236

@@ -7316,7 +7316,7 @@ PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method)
73167316

73177317
cipher_type = EVP_get_cipherbyname(method);
73187318
if (!cipher_type) {
7319-
php_error_docref(NULL, E_WARNING, "Unknown cipher method");
7319+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
73207320
return -1;
73217321
}
73227322

ext/openssl/openssl.stub.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ final class OpenSSLAsymmetricKey
1414
{
1515
}
1616

17-
function openssl_x509_export_to_file(OpenSSLCertificate|string $certificate, string $output_filename, bool $no_description = true): bool {}
17+
function openssl_x509_export_to_file(OpenSSLCertificate|string $certificate, string $output_filename, bool $no_text = true): bool {}
1818

1919
/** @param string $output */
20-
function openssl_x509_export(OpenSSLCertificate|string $certificate, &$output, bool $no_description = true): bool {}
20+
function openssl_x509_export(OpenSSLCertificate|string $certificate, &$output, bool $no_text = true): bool {}
2121

22-
function openssl_x509_fingerprint(OpenSSLCertificate|string $certificate, string $hashing_algorithm = "sha1", bool $raw_output = false): string|false {}
22+
function openssl_x509_fingerprint(OpenSSLCertificate|string $certificate, string $digest_algorithm = "sha1", bool $raw_output = false): string|false {}
2323

2424
/** @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key */
2525
function openssl_x509_check_private_key(OpenSSLCertificate|string $certificate, $private_key): bool {}
@@ -29,7 +29,7 @@ function openssl_x509_verify(OpenSSLCertificate|string $certificate, $public_key
2929

3030
function openssl_x509_parse(OpenSSLCertificate|string $certificate, bool $short_names = true): array|false {}
3131

32-
function openssl_x509_checkpurpose(OpenSSLCertificate|string $certificate, int $purpose, ?array $certificate_authority_info = [], ?string $untrusted_certificates_file = null): bool|int {}
32+
function openssl_x509_checkpurpose(OpenSSLCertificate|string $certificate, int $purpose, ?array $ca_info = [], ?string $untrusted_certificates_file = null): bool|int {}
3333

3434
function openssl_x509_read(OpenSSLCertificate|string $certificate): OpenSSLCertificate|false {}
3535

@@ -48,10 +48,10 @@ function openssl_pkcs12_export(OpenSSLCertificate|string $certificate, &$output,
4848
/** @param array $certificates */
4949
function openssl_pkcs12_read(string $pkcs12, &$certificates, string $passphrase): bool {}
5050

51-
function openssl_csr_export_to_file(OpenSSLCertificateSigningRequest|string $request, string $output_filename, bool $no_description = true): bool {}
51+
function openssl_csr_export_to_file(OpenSSLCertificateSigningRequest|string $request, string $output_filename, bool $no_text = true): bool {}
5252

5353
/** @param OpenSSLAsymmetricKey $output */
54-
function openssl_csr_export(OpenSSLCertificateSigningRequest|string $request, &$output, bool $no_description = true): bool {}
54+
function openssl_csr_export(OpenSSLCertificateSigningRequest|string $request, &$output, bool $no_text = true): bool {}
5555

5656
/** @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key */
5757
function openssl_csr_sign(OpenSSLCertificateSigningRequest|string $request, OpenSSLCertificate|string|null $ca_certificate, $private_key, int $days, ?array $options = null, int $serial = 0): OpenSSLCertificate|false {}
@@ -103,12 +103,12 @@ function openssl_get_privatekey($private_key, ?string $passphrase = null): OpenS
103103

104104
function openssl_pkey_get_details(OpenSSLAsymmetricKey $key): array|false {}
105105

106-
function openssl_pbkdf2(string $passphrase, string $salt, int $key_length, int $iterations, string $digest_method = "sha1"): string|false {}
106+
function openssl_pbkdf2(string $passphrase, string $salt, int $key_length, int $iterations, string $digest_algorithm = "sha1"): string|false {}
107107

108-
function openssl_pkcs7_verify(string $filename, int $flags, ?string $output_filename = null, ?array $certificate_authority_info = null, ?string $untrusted_certificates_filename = null, ?string $content = null, ?string $pk7_filename = null): bool|int {}
108+
function openssl_pkcs7_verify(string $filename, int $flags, ?string $output_filename = null, ?array $ca_info = null, ?string $untrusted_certificates_filename = null, ?string $content = null, ?string $pk7_filename = null): bool|int {}
109109

110110
/** @param OpenSSLCertificate|array|string $certificate */
111-
function openssl_pkcs7_encrypt(string $filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $cipher_method = OPENSSL_CIPHER_RC2_40): bool {}
111+
function openssl_pkcs7_encrypt(string $filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $cipher_algorithm = OPENSSL_CIPHER_RC2_40): bool {}
112112

113113
/** @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key */
114114
function openssl_pkcs7_sign(string $filename, string $output_filename, OpenSSLCertificate|string $certificate, $private_key, ?array $headers, int $flags = PKCS7_DETACHED, ?string $untrusted_certificates_filename = null): bool {}
@@ -122,10 +122,10 @@ function openssl_pkcs7_decrypt(string $filename, string $output_filename, $certi
122122
/** @param array $certificates */
123123
function openssl_pkcs7_read(string $filename, &$certificates): bool {}
124124

125-
function openssl_cms_verify(string $filename, int $flags = 0, ?string $certificates = null, ?array $certificate_authority_info = null, ?string $untrusted_certificates_filename = null, ?string $content = null, ?string $pk7 = null, ?string $sigfile = null, int $encoding = OPENSSL_ENCODING_SMIME): bool {}
125+
function openssl_cms_verify(string $filename, int $flags = 0, ?string $certificates = null, ?array $ca_info = null, ?string $untrusted_certificates_filename = null, ?string $content = null, ?string $pk7 = null, ?string $sigfile = null, int $encoding = OPENSSL_ENCODING_SMIME): bool {}
126126

127127
/** @param OpenSSLCertificate|array|string $certificate */
128-
function openssl_cms_encrypt(string $filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_method = OPENSSL_CIPHER_RC2_40): bool {}
128+
function openssl_cms_encrypt(string $filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_algorithm = OPENSSL_CIPHER_RC2_40): bool {}
129129

130130
/** @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key */
131131
function openssl_cms_sign(string $filename, string $output_filename, OpenSSLCertificate|string $certificate, $private_key, ?array $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, ?string $untrusted_certificates_filename = null): bool {}
@@ -179,13 +179,13 @@ function openssl_verify(string $data, string $signature, $public_key, string|int
179179
* @param array $encrypted_keys
180180
* @param string $initialization_vector
181181
*/
182-
function openssl_seal(string $data, &$sealed_data, &$encrypted_keys, array $public_key, string $cipher_method, &$initialization_vector = null): int|false {}
182+
function openssl_seal(string $data, &$sealed_data, &$encrypted_keys, array $public_key, string $cipher_algorithm, &$initialization_vector = null): int|false {}
183183

184184
/**
185185
* @param string $output
186186
* @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key
187187
*/
188-
function openssl_open(string $data, &$output, string $encrypted_key, $private_key, string $cipher_method, ?string $initialization_vector = null): bool {}
188+
function openssl_open(string $data, &$output, string $encrypted_key, $private_key, string $cipher_algorithm, ?string $initialization_vector = null): bool {}
189189

190190
function openssl_get_md_methods(bool $aliases = false): array {}
191191

@@ -195,14 +195,14 @@ function openssl_get_cipher_methods(bool $aliases = false): array {}
195195
function openssl_get_curve_names(): array|false {}
196196
#endif
197197

198-
function openssl_digest(string $data, string $digest_method, bool $raw_output = false): string|false {}
198+
function openssl_digest(string $data, string $digest_algorithm, bool $raw_output = false): string|false {}
199199

200200
/** @param string $tag */
201-
function openssl_encrypt(string $data, string $cipher_method, string $passphrase, int $options = 0, string $initialization_vector = "", &$tag = null, string $additional_authentication_data = "", int $tag_length = 16): string|false {}
201+
function openssl_encrypt(string $data, string $cipher_algorithm, string $passphrase, int $options = 0, string $initialization_vector = "", &$tag = null, string $additional_authentication_data = "", int $tag_length = 16): string|false {}
202202

203-
function openssl_decrypt(string $data, string $method, string $passphrase, int $options = 0, string $initialization_vector = "", ?string $tag = null, string $additional_authentication_data = ""): string|false {}
203+
function openssl_decrypt(string $data, string $cipher_algorithm, string $passphrase, int $options = 0, string $initialization_vector = "", ?string $tag = null, string $additional_authentication_data = ""): string|false {}
204204

205-
function openssl_cipher_iv_length(string $cipher_method): int|false {}
205+
function openssl_cipher_iv_length(string $cipher_algorithm): int|false {}
206206

207207
function openssl_dh_compute_key(string $public_key, OpenSSLAsymmetricKey $private_key): string|false {}
208208

@@ -215,7 +215,7 @@ function openssl_pkey_derive($public_key, $private_key, int $key_length = 0): st
215215
/** @param bool $strong_result */
216216
function openssl_random_pseudo_bytes(int $length, &$strong_result = null): string {}
217217

218-
function openssl_spki_new(OpenSSLAsymmetricKey $private_key, string $challenge, int $digest_method = OPENSSL_ALGO_MD5): string|false {}
218+
function openssl_spki_new(OpenSSLAsymmetricKey $private_key, string $challenge, int $digest_algorithm = OPENSSL_ALGO_MD5): string|false {}
219219

220220
function openssl_spki_verify(string $signed_public_key_and_challenge): bool {}
221221

0 commit comments

Comments
 (0)