Skip to content

Commit ec9c9ea

Browse files
committed
Fix code review
1 parent 973712b commit ec9c9ea

7 files changed

+59
-59
lines changed

ext/openssl/openssl.c

+14-14
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;
@@ -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

@@ -6606,7 +6606,7 @@ PHP_FUNCTION(openssl_seal)
66066606

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

@@ -6730,7 +6730,7 @@ PHP_FUNCTION(openssl_open)
67306730
if (method) {
67316731
cipher = EVP_get_cipherbyname(method);
67326732
if (!cipher) {
6733-
php_error_docref(NULL, E_WARNING, "Unknown cipher method");
6733+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
67346734
RETURN_FALSE;
67356735
}
67366736
} else {
@@ -6740,7 +6740,7 @@ PHP_FUNCTION(openssl_open)
67406740
cipher_iv_len = EVP_CIPHER_iv_length(cipher);
67416741
if (cipher_iv_len > 0) {
67426742
if (!iv) {
6743-
zend_argument_value_error(6, "cannot be null for the chosen cipher method");
6743+
zend_argument_value_error(6, "cannot be null for the chosen cipher algorithm");
67446744
RETURN_THROWS();
67456745
}
67466746
if ((size_t)cipher_iv_len != iv_len) {
@@ -6786,7 +6786,7 @@ static void php_openssl_add_method(const OBJ_NAME *name, void *arg) /* {{{ */
67866786
}
67876787
/* }}} */
67886788

6789-
/* {{{ Return array of available digest methods */
6789+
/* {{{ Return array of available digest algorithms */
67906790
PHP_FUNCTION(openssl_get_md_methods)
67916791
{
67926792
zend_bool aliases = 0;
@@ -6801,7 +6801,7 @@ PHP_FUNCTION(openssl_get_md_methods)
68016801
}
68026802
/* }}} */
68036803

6804-
/* {{{ Return array of available cipher methods */
6804+
/* {{{ Return array of available cipher algorithms */
68056805
PHP_FUNCTION(openssl_get_cipher_methods)
68066806
{
68076807
zend_bool aliases = 0;
@@ -6862,7 +6862,7 @@ PHP_FUNCTION(openssl_digest)
68626862
}
68636863
mdtype = EVP_get_digestbyname(method);
68646864
if (!mdtype) {
6865-
php_error_docref(NULL, E_WARNING, "Unknown digest method");
6865+
php_error_docref(NULL, E_WARNING, "Unknown digest algorithm");
68666866
RETURN_FALSE;
68676867
}
68686868

@@ -7016,7 +7016,7 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
70167016
}
70177017
} else if (!enc && tag && tag_len > 0) {
70187018
if (!mode->is_aead) {
7019-
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher method does not support AEAD");
7019+
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher algorithm does not support AEAD");
70207020
} else if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, (unsigned char *) tag)) {
70217021
php_error_docref(NULL, E_WARNING, "Setting tag for AEAD cipher decryption failed");
70227022
return FAILURE;
@@ -7028,7 +7028,7 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
70287028
if (key_len > password_len) {
70297029
if ((OPENSSL_DONT_ZERO_PAD_KEY & options) && !EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len)) {
70307030
php_openssl_store_errors();
7031-
php_error_docref(NULL, E_WARNING, "Key length cannot be set for the cipher method");
7031+
php_error_docref(NULL, E_WARNING, "Key length cannot be set for the cipher algorithm");
70327032
return FAILURE;
70337033
}
70347034
key = emalloc(key_len);
@@ -7122,7 +7122,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
71227122

71237123
cipher_type = EVP_get_cipherbyname(method);
71247124
if (!cipher_type) {
7125-
php_error_docref(NULL, E_WARNING, "Unknown cipher method");
7125+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
71267126
return NULL;
71277127
}
71287128

@@ -7238,7 +7238,7 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(
72387238

72397239
cipher_type = EVP_get_cipherbyname(method);
72407240
if (!cipher_type) {
7241-
php_error_docref(NULL, E_WARNING, "Unknown cipher method");
7241+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
72427242
return NULL;
72437243
}
72447244

@@ -7324,7 +7324,7 @@ PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method)
73247324

73257325
cipher_type = EVP_get_cipherbyname(method);
73267326
if (!cipher_type) {
7327-
php_error_docref(NULL, E_WARNING, "Unknown cipher method");
7327+
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm");
73287328
return -1;
73297329
}
73307330

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 = null, &$initialization_vector = null): int|false {}
182+
function openssl_seal(string $data, &$sealed_data, &$encrypted_keys, array $public_key, ?string $cipher_algorithm = null, &$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 = null, ?string $initialization_vector = null): bool {}
188+
function openssl_open(string $data, &$output, string $encrypted_key, $private_key, ?string $cipher_algorithm = null, ?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)