Skip to content

Commit 9b95dd5

Browse files
committed
Merge branch 'PHP-7.0'
2 parents a19173e + 0ea63cb commit 9b95dd5

File tree

1 file changed

+77
-77
lines changed

1 file changed

+77
-77
lines changed

ext/openssl/openssl.c

+77-77
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ const zend_function_entry openssl_functions[] = {
461461

462462
/* x.509 cert funcs */
463463
PHP_FE(openssl_x509_read, arginfo_openssl_x509_read)
464-
PHP_FE(openssl_x509_free, arginfo_openssl_x509_free)
464+
PHP_FE(openssl_x509_free, arginfo_openssl_x509_free)
465465
PHP_FE(openssl_x509_parse, arginfo_openssl_x509_parse)
466466
PHP_FE(openssl_x509_checkpurpose, arginfo_openssl_x509_checkpurpose)
467467
PHP_FE(openssl_x509_check_private_key, arginfo_openssl_x509_check_private_key)
@@ -509,9 +509,9 @@ const zend_function_entry openssl_functions[] = {
509509
PHP_FE(openssl_get_md_methods, arginfo_openssl_get_md_methods)
510510
PHP_FE(openssl_get_cipher_methods, arginfo_openssl_get_cipher_methods)
511511

512-
PHP_FE(openssl_dh_compute_key, arginfo_openssl_dh_compute_key)
512+
PHP_FE(openssl_dh_compute_key, arginfo_openssl_dh_compute_key)
513513

514-
PHP_FE(openssl_random_pseudo_bytes, arginfo_openssl_random_pseudo_bytes)
514+
PHP_FE(openssl_random_pseudo_bytes, arginfo_openssl_random_pseudo_bytes)
515515
PHP_FE(openssl_error_string, arginfo_openssl_error_string)
516516
PHP_FE_END
517517
};
@@ -620,8 +620,8 @@ struct php_x509_request { /* {{{ */
620620
LHASH_OF(CONF_VALUE) * global_config; /* Global SSL config */
621621
LHASH_OF(CONF_VALUE) * req_config; /* SSL config for this request */
622622
#else
623-
LHASH * global_config; /* Global SSL config */
624-
LHASH * req_config; /* SSL config for this request */
623+
LHASH * global_config; /* Global SSL config */
624+
LHASH * req_config; /* SSL config for this request */
625625
#endif
626626
const EVP_MD * md_alg;
627627
const EVP_MD * digest;
@@ -637,7 +637,7 @@ struct php_x509_request { /* {{{ */
637637

638638
EVP_PKEY * priv_key;
639639

640-
const EVP_CIPHER * priv_key_encrypt_cipher;
640+
const EVP_CIPHER * priv_key_encrypt_cipher;
641641
};
642642
/* }}} */
643643

@@ -671,7 +671,7 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s
671671
int to_add_len = 0;
672672

673673

674-
ne = X509_NAME_get_entry(name, i);
674+
ne = X509_NAME_get_entry(name, i);
675675
obj = X509_NAME_ENTRY_get_object(ne);
676676
nid = OBJ_obj2nid(obj);
677677

@@ -880,18 +880,18 @@ static const EVP_CIPHER * php_openssl_get_evp_cipher_from_algo(zend_long algo);
880880
/* {{{ strip line endings from spkac */
881881
static int openssl_spki_cleanup(const char *src, char *dest)
882882
{
883-
int removed=0;
884-
885-
while (*src) {
886-
if (*src!='\n'&&*src!='\r') {
887-
*dest++=*src;
888-
} else {
889-
++removed;
890-
}
891-
++src;
892-
}
893-
*dest=0;
894-
return removed;
883+
int removed = 0;
884+
885+
while (*src) {
886+
if (*src != '\n' && *src != '\r') {
887+
*dest++ = *src;
888+
} else {
889+
++removed;
890+
}
891+
++src;
892+
}
893+
*dest = 0;
894+
return removed;
895895
}
896896
/* }}} */
897897

@@ -954,7 +954,7 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
954954
if (cipher == NULL) {
955955
php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm for private key.");
956956
return FAILURE;
957-
} else {
957+
} else {
958958
req->priv_key_encrypt_cipher = cipher;
959959
}
960960
} else {
@@ -1693,7 +1693,7 @@ PHP_FUNCTION(openssl_spki_export)
16931693
}
16941694

16951695
out = BIO_new(BIO_s_mem());
1696-
if (out && PEM_write_bio_PUBKEY(out, pkey)) {
1696+
if (out && PEM_write_bio_PUBKEY(out, pkey)) {
16971697
BUF_MEM *bio_buf;
16981698

16991699
BIO_get_mem_ptr(out, &bio_buf);
@@ -1790,7 +1790,7 @@ PHP_FUNCTION(openssl_x509_export)
17901790
if (!notext) {
17911791
X509_print(bio_out, cert);
17921792
}
1793-
if (PEM_write_bio_X509(bio_out, cert)) {
1793+
if (PEM_write_bio_X509(bio_out, cert)) {
17941794
BUF_MEM *bio_buf;
17951795

17961796
zval_dtor(zout);
@@ -1916,44 +1916,44 @@ static int openssl_x509v3_subjectAltName(BIO *bio, X509_EXTENSION *extension)
19161916
p = extension->value->data;
19171917
length = extension->value->length;
19181918
if (method->it) {
1919-
names = (GENERAL_NAMES*)(ASN1_item_d2i(NULL, &p, length,
1920-
ASN1_ITEM_ptr(method->it)));
1919+
names = (GENERAL_NAMES*) (ASN1_item_d2i(NULL, &p, length,
1920+
ASN1_ITEM_ptr(method->it)));
19211921
} else {
1922-
names = (GENERAL_NAMES*)(method->d2i(NULL, &p, length));
1922+
names = (GENERAL_NAMES*) (method->d2i(NULL, &p, length));
19231923
}
19241924
if (names == NULL) {
19251925
return -1;
19261926
}
19271927

19281928
num = sk_GENERAL_NAME_num(names);
19291929
for (i = 0; i < num; i++) {
1930-
GENERAL_NAME *name;
1931-
ASN1_STRING *as;
1932-
name = sk_GENERAL_NAME_value(names, i);
1933-
switch (name->type) {
1934-
case GEN_EMAIL:
1935-
BIO_puts(bio, "email:");
1936-
as = name->d.rfc822Name;
1937-
BIO_write(bio, ASN1_STRING_data(as),
1938-
ASN1_STRING_length(as));
1939-
break;
1940-
case GEN_DNS:
1941-
BIO_puts(bio, "DNS:");
1942-
as = name->d.dNSName;
1943-
BIO_write(bio, ASN1_STRING_data(as),
1944-
ASN1_STRING_length(as));
1945-
break;
1946-
case GEN_URI:
1947-
BIO_puts(bio, "URI:");
1948-
as = name->d.uniformResourceIdentifier;
1949-
BIO_write(bio, ASN1_STRING_data(as),
1950-
ASN1_STRING_length(as));
1951-
break;
1952-
default:
1953-
/* use builtin print for GEN_OTHERNAME, GEN_X400,
1954-
* GEN_EDIPARTY, GEN_DIRNAME, GEN_IPADD and GEN_RID
1955-
*/
1956-
GENERAL_NAME_print(bio, name);
1930+
GENERAL_NAME *name;
1931+
ASN1_STRING *as;
1932+
name = sk_GENERAL_NAME_value(names, i);
1933+
switch (name->type) {
1934+
case GEN_EMAIL:
1935+
BIO_puts(bio, "email:");
1936+
as = name->d.rfc822Name;
1937+
BIO_write(bio, ASN1_STRING_data(as),
1938+
ASN1_STRING_length(as));
1939+
break;
1940+
case GEN_DNS:
1941+
BIO_puts(bio, "DNS:");
1942+
as = name->d.dNSName;
1943+
BIO_write(bio, ASN1_STRING_data(as),
1944+
ASN1_STRING_length(as));
1945+
break;
1946+
case GEN_URI:
1947+
BIO_puts(bio, "URI:");
1948+
as = name->d.uniformResourceIdentifier;
1949+
BIO_write(bio, ASN1_STRING_data(as),
1950+
ASN1_STRING_length(as));
1951+
break;
1952+
default:
1953+
/* use builtin print for GEN_OTHERNAME, GEN_X400,
1954+
* GEN_EDIPARTY, GEN_DIRNAME, GEN_IPADD and GEN_RID
1955+
*/
1956+
GENERAL_NAME_print(bio, name);
19571957
}
19581958
/* trailing ', ' except for last element */
19591959
if (i < (num - 1)) {
@@ -1978,7 +1978,7 @@ PHP_FUNCTION(openssl_x509_parse)
19781978
zval subitem;
19791979
X509_EXTENSION *extension;
19801980
char *extname;
1981-
BIO *bio_out;
1981+
BIO *bio_out;
19821982
BUF_MEM *bio_buf;
19831983
char buf[256];
19841984

@@ -2347,8 +2347,8 @@ static STACK_OF(X509) * php_array_to_X509_sk(zval * zcerts) /* {{{ */
23472347
{
23482348
zval * zcertval;
23492349
STACK_OF(X509) * sk = NULL;
2350-
X509 * cert;
2351-
zend_resource *certresource;
2350+
X509 * cert;
2351+
zend_resource *certresource;
23522352

23532353
sk = sk_X509_new_null();
23542354

@@ -2387,8 +2387,8 @@ static STACK_OF(X509) * php_array_to_X509_sk(zval * zcerts) /* {{{ */
23872387
sk_X509_push(sk, cert);
23882388
}
23892389

2390-
clean_exit:
2391-
return sk;
2390+
clean_exit:
2391+
return sk;
23922392
}
23932393
/* }}} */
23942394

@@ -2446,7 +2446,7 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file)
24462446
/* end parse extra config */
24472447

24482448
/*PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, STACK_OF(X509) *ca,
2449-
int nid_key, int nid_cert, int iter, int mac_iter, int keytype);*/
2449+
int nid_key, int nid_cert, int iter, int mac_iter, int keytype);*/
24502450

24512451
p12 = PKCS12_create(pass, friendly_name, priv_key, cert, ca, 0, 0, 0, 0, 0);
24522452

@@ -2522,7 +2522,7 @@ PHP_FUNCTION(openssl_pkcs12_export)
25222522
p12 = PKCS12_create(pass, friendly_name, priv_key, cert, ca, 0, 0, 0, 0, 0);
25232523

25242524
bio_out = BIO_new(BIO_s_mem());
2525-
if (i2d_PKCS12_bio(bio_out, p12)) {
2525+
if (i2d_PKCS12_bio(bio_out, p12)) {
25262526
BUF_MEM *bio_buf;
25272527

25282528
zval_dtor(zout);
@@ -2638,7 +2638,7 @@ PHP_FUNCTION(openssl_pkcs12_read)
26382638
}
26392639
}
26402640

2641-
cleanup:
2641+
cleanup:
26422642
if (bio_in) {
26432643
BIO_free(bio_in);
26442644
}
@@ -3576,9 +3576,9 @@ PHP_FUNCTION(openssl_pkey_new)
35763576
EVP_PKEY *pkey;
35773577

35783578
if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "rsa", sizeof("rsa")-1)) != NULL &&
3579-
Z_TYPE_P(data) == IS_ARRAY) {
3580-
pkey = EVP_PKEY_new();
3581-
if (pkey) {
3579+
Z_TYPE_P(data) == IS_ARRAY) {
3580+
pkey = EVP_PKEY_new();
3581+
if (pkey) {
35823582
RSA *rsa = RSA_new();
35833583
if (rsa) {
35843584
OPENSSL_PKEY_SET_BN(Z_ARRVAL_P(data), rsa, n);
@@ -3599,10 +3599,10 @@ PHP_FUNCTION(openssl_pkey_new)
35993599
EVP_PKEY_free(pkey);
36003600
}
36013601
RETURN_FALSE;
3602-
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dsa", sizeof("dsa")-1)) != NULL &&
3603-
Z_TYPE_P(data) == IS_ARRAY) {
3604-
pkey = EVP_PKEY_new();
3605-
if (pkey) {
3602+
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dsa", sizeof("dsa") - 1)) != NULL &&
3603+
Z_TYPE_P(data) == IS_ARRAY) {
3604+
pkey = EVP_PKEY_new();
3605+
if (pkey) {
36063606
DSA *dsa = DSA_new();
36073607
if (dsa) {
36083608
OPENSSL_PKEY_SET_BN(Z_ARRVAL_P(data), dsa, p);
@@ -3623,10 +3623,10 @@ PHP_FUNCTION(openssl_pkey_new)
36233623
EVP_PKEY_free(pkey);
36243624
}
36253625
RETURN_FALSE;
3626-
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dh", sizeof("dh")-1)) != NULL &&
3627-
Z_TYPE_P(data) == IS_ARRAY) {
3628-
pkey = EVP_PKEY_new();
3629-
if (pkey) {
3626+
} else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dh", sizeof("dh") - 1)) != NULL &&
3627+
Z_TYPE_P(data) == IS_ARRAY) {
3628+
pkey = EVP_PKEY_new();
3629+
if (pkey) {
36303630
DH *dh = DH_new();
36313631
if (dh) {
36323632
OPENSSL_PKEY_SET_BN(Z_ARRVAL_P(data), dh, p);
@@ -4522,7 +4522,7 @@ PHP_FUNCTION(openssl_private_encrypt)
45224522
switch (pkey->type) {
45234523
case EVP_PKEY_RSA:
45244524
case EVP_PKEY_RSA2:
4525-
successful = (RSA_private_encrypt((int)data_len,
4525+
successful = (RSA_private_encrypt((int)data_len,
45264526
(unsigned char *)data,
45274527
(unsigned char *)ZSTR_VAL(cryptedbuf),
45284528
pkey->pkey.rsa,
@@ -4835,7 +4835,7 @@ PHP_FUNCTION(openssl_verify)
48354835
zval *key;
48364836
EVP_PKEY *pkey;
48374837
int err;
4838-
EVP_MD_CTX md_ctx;
4838+
EVP_MD_CTX md_ctx;
48394839
const EVP_MD *mdtype;
48404840
zend_resource *keyresource = NULL;
48414841
char * data;
@@ -4873,7 +4873,7 @@ PHP_FUNCTION(openssl_verify)
48734873
RETURN_FALSE;
48744874
}
48754875

4876-
EVP_VerifyInit (&md_ctx, mdtype);
4876+
EVP_VerifyInit (&md_ctx, mdtype);
48774877
EVP_VerifyUpdate (&md_ctx, data, data_len);
48784878
err = EVP_VerifyFinal(&md_ctx, (unsigned char *)signature, (unsigned int)signature_len, pkey);
48794879
EVP_MD_CTX_cleanup(&md_ctx);
@@ -5203,22 +5203,22 @@ static zend_bool php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_
52035203
if (*piv_len == 0) {
52045204
/* BC behavior */
52055205
*piv_len = iv_required_len;
5206-
*piv = iv_new;
5206+
*piv = iv_new;
52075207
return 1;
52085208
}
52095209

52105210
if (*piv_len < iv_required_len) {
52115211
php_error_docref(NULL, E_WARNING, "IV passed is only %d bytes long, cipher expects an IV of precisely %d bytes, padding with \\0", *piv_len, iv_required_len);
52125212
memcpy(iv_new, *piv, *piv_len);
52135213
*piv_len = iv_required_len;
5214-
*piv = iv_new;
5214+
*piv = iv_new;
52155215
return 1;
52165216
}
52175217

52185218
php_error_docref(NULL, E_WARNING, "IV passed is %d bytes long which is longer than the %d expected by selected cipher, truncating", *piv_len, iv_required_len);
52195219
memcpy(iv_new, *piv, iv_required_len);
52205220
*piv_len = iv_required_len;
5221-
*piv = iv_new;
5221+
*piv = iv_new;
52225222
return 1;
52235223

52245224
}

0 commit comments

Comments
 (0)