Skip to content

Commit 87c9016

Browse files
committed
Fix code review
1 parent 973712b commit 87c9016

7 files changed

+39
-39
lines changed

ext/openssl/openssl.c

Lines changed: 14 additions & 14 deletions
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

Lines changed: 8 additions & 8 deletions
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 {}
@@ -105,7 +105,7 @@ function openssl_pkey_get_details(OpenSSLAsymmetricKey $key): array|false {}
105105

106106
function openssl_pbkdf2(string $passphrase, string $salt, int $key_length, int $iterations, string $digest_method = "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 */
111111
function openssl_pkcs7_encrypt(string $filename, string $output_filename, $certificate, ?array $headers, int $flags = 0, int $cipher_method = OPENSSL_CIPHER_RC2_40): bool {}
@@ -122,7 +122,7 @@ 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 */
128128
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 {}

ext/openssl/openssl_arginfo.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 5bd602f87346fb9071b2456324cb445a4c6715f3 */
2+
* Stub hash: 270c661abc2e136407e1b85232190289d05675aa */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_x509_export_to_file, 0, 2, _IS_BOOL, 0)
55
ZEND_ARG_OBJ_TYPE_MASK(0, certificate, OpenSSLCertificate, MAY_BE_STRING, NULL)
66
ZEND_ARG_TYPE_INFO(0, output_filename, IS_STRING, 0)
7-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, no_description, _IS_BOOL, 0, "true")
7+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, no_text, _IS_BOOL, 0, "true")
88
ZEND_END_ARG_INFO()
99

1010
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_x509_export, 0, 2, _IS_BOOL, 0)
1111
ZEND_ARG_OBJ_TYPE_MASK(0, certificate, OpenSSLCertificate, MAY_BE_STRING, NULL)
1212
ZEND_ARG_INFO(1, output)
13-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, no_description, _IS_BOOL, 0, "true")
13+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, no_text, _IS_BOOL, 0, "true")
1414
ZEND_END_ARG_INFO()
1515

1616
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_openssl_x509_fingerprint, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
1717
ZEND_ARG_OBJ_TYPE_MASK(0, certificate, OpenSSLCertificate, MAY_BE_STRING, NULL)
18-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, hashing_algorithm, IS_STRING, 0, "\"sha1\"")
18+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, digest_algorithm, IS_STRING, 0, "\"sha1\"")
1919
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
2020
ZEND_END_ARG_INFO()
2121

@@ -37,7 +37,7 @@ ZEND_END_ARG_INFO()
3737
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_openssl_x509_checkpurpose, 0, 2, MAY_BE_BOOL|MAY_BE_LONG)
3838
ZEND_ARG_OBJ_TYPE_MASK(0, certificate, OpenSSLCertificate, MAY_BE_STRING, NULL)
3939
ZEND_ARG_TYPE_INFO(0, purpose, IS_LONG, 0)
40-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, certificate_authority_info, IS_ARRAY, 1, "[]")
40+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, ca_info, IS_ARRAY, 1, "[]")
4141
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, untrusted_certificates_file, IS_STRING, 1, "null")
4242
ZEND_END_ARG_INFO()
4343

@@ -74,13 +74,13 @@ ZEND_END_ARG_INFO()
7474
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_csr_export_to_file, 0, 2, _IS_BOOL, 0)
7575
ZEND_ARG_OBJ_TYPE_MASK(0, request, OpenSSLCertificateSigningRequest, MAY_BE_STRING, NULL)
7676
ZEND_ARG_TYPE_INFO(0, output_filename, IS_STRING, 0)
77-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, no_description, _IS_BOOL, 0, "true")
77+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, no_text, _IS_BOOL, 0, "true")
7878
ZEND_END_ARG_INFO()
7979

8080
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_csr_export, 0, 2, _IS_BOOL, 0)
8181
ZEND_ARG_OBJ_TYPE_MASK(0, request, OpenSSLCertificateSigningRequest, MAY_BE_STRING, NULL)
8282
ZEND_ARG_INFO(1, output)
83-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, no_description, _IS_BOOL, 0, "true")
83+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, no_text, _IS_BOOL, 0, "true")
8484
ZEND_END_ARG_INFO()
8585

8686
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_openssl_csr_sign, 0, 4, OpenSSLCertificate, MAY_BE_FALSE)
@@ -162,7 +162,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_openssl_pkcs7_verify, 0, 2, MAY_
162162
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
163163
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
164164
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, output_filename, IS_STRING, 1, "null")
165-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, certificate_authority_info, IS_ARRAY, 1, "null")
165+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, ca_info, IS_ARRAY, 1, "null")
166166
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, untrusted_certificates_filename, IS_STRING, 1, "null")
167167
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, content, IS_STRING, 1, "null")
168168
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pk7_filename, IS_STRING, 1, "null")
@@ -203,7 +203,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_cms_verify, 0, 1, _IS_BO
203203
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
204204
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
205205
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, certificates, IS_STRING, 1, "null")
206-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, certificate_authority_info, IS_ARRAY, 1, "null")
206+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, ca_info, IS_ARRAY, 1, "null")
207207
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, untrusted_certificates_filename, IS_STRING, 1, "null")
208208
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, content, IS_STRING, 1, "null")
209209
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pk7, IS_STRING, 1, "null")

ext/openssl/tests/bug60632.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ try {
2727
}
2828
?>
2929
--EXPECT--
30-
openssl_seal(): Argument #6 ($initialization_vector) cannot be null for the chosen cipher method
30+
openssl_seal(): Argument #6 ($initialization_vector) cannot be null for the chosen cipher algorithm

ext/openssl/tests/bug70438.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ openssl_open($sealed, $decrypted, $ekeys[0], $priv_key, $cipher, $iv);
2626
echo $decrypted;
2727
?>
2828
--EXPECTF--
29-
openssl_seal(): Argument #6 ($initialization_vector) cannot be null for the chosen cipher method
29+
openssl_seal(): Argument #6 ($initialization_vector) cannot be null for the chosen cipher algorithm
3030

3131
Warning: openssl_seal(): Unknown signature algorithm in %s on line %d
3232
openssl_seal() test

ext/openssl/tests/openssl_decrypt_error.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ string(44) "yof6cPPH4mLee6TOc0YQSrh4dvywMqxGUyjp0lV6+aM="
2929
string(44) "yof6cPPH4mLee6TOc0YQSrh4dvywMqxGUyjp0lV6+aM="
3030
bool(false)
3131

32-
Warning: openssl_decrypt(): Unknown cipher method in %s on line %d
32+
Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d
3333
bool(false)
3434
bool(false)
3535

36-
Warning: openssl_decrypt(): Unknown cipher method in %s on line %d
36+
Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d
3737
bool(false)
3838

39-
Warning: openssl_decrypt(): Unknown cipher method in %s on line %d
39+
Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d
4040
bool(false)
4141

42-
Warning: openssl_decrypt(): Unknown cipher method in %s on line %d
42+
Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d
4343
bool(false)
4444

4545
Warning: openssl_encrypt(): The authenticated tag cannot be provided for cipher that doesn not support AEAD in %s on line %d

ext/openssl/tests/openssl_encrypt_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ var_dump(openssl_encrypt($data, $method, $password, 0, $iv, $wrong));
2222
var_dump(openssl_encrypt($data, $method, $password, OPENSSL_DONT_ZERO_PAD_KEY, $iv));
2323
?>
2424
--EXPECTF--
25-
Warning: openssl_encrypt(): Unknown cipher method in %s on line %d
25+
Warning: openssl_encrypt(): Unknown cipher algorithm in %s on line %d
2626
bool(false)
2727

2828
Warning: openssl_encrypt(): The authenticated tag cannot be provided for cipher that doesn not support AEAD in %s on line %d
2929
string(44) "iPR4HulskuaP5Z6me5uImk6BqVyJG73+63tkPauVZYk="
3030

31-
Warning: openssl_encrypt(): Key length cannot be set for the cipher method in %s on line %d
31+
Warning: openssl_encrypt(): Key length cannot be set for the cipher algorithm in %s on line %d
3232
bool(false)

0 commit comments

Comments
 (0)