]> granicus.if.org Git - php/commitdiff
Make code in openssl ext tests more consistent
authorJakub Zelenka <bukka@php.net>
Thu, 21 Jun 2018 15:38:19 +0000 (16:38 +0100)
committerJakub Zelenka <bukka@php.net>
Thu, 21 Jun 2018 15:38:19 +0000 (16:38 +0100)
Mainly use spaces for indent and fix some other CS issues. Also
drop checks for unsupported OpenSSL library versions.

88 files changed:
ext/openssl/tests/001.phpt
ext/openssl/tests/bug28382.phpt
ext/openssl/tests/bug36732.phpt
ext/openssl/tests/bug37820.phpt
ext/openssl/tests/bug38255.phpt
ext/openssl/tests/bug38261.phpt
ext/openssl/tests/bug39217.phpt
ext/openssl/tests/bug41033.phpt
ext/openssl/tests/bug46127.phpt
ext/openssl/tests/bug48182.phpt
ext/openssl/tests/bug54992.phpt
ext/openssl/tests/bug55259.phpt
ext/openssl/tests/bug55646.phpt
ext/openssl/tests/bug61124.phpt
ext/openssl/tests/bug61930.phpt
ext/openssl/tests/bug65538_001.phpt
ext/openssl/tests/bug65538_002.phpt
ext/openssl/tests/bug65538_003.phpt
ext/openssl/tests/bug65698.phpt
ext/openssl/tests/bug65729.phpt
ext/openssl/tests/bug66501.phpt
ext/openssl/tests/bug67403.phpt
ext/openssl/tests/bug68265.phpt
ext/openssl/tests/bug68879.phpt
ext/openssl/tests/bug68920.phpt
ext/openssl/tests/bug69215.phpt
ext/openssl/tests/bug70438.phpt
ext/openssl/tests/bug71917.phpt
ext/openssl/tests/bug72333.phpt
ext/openssl/tests/bug72336.phpt
ext/openssl/tests/bug72362.phpt
ext/openssl/tests/bug73072.phpt
ext/openssl/tests/bug73478.phpt
ext/openssl/tests/bug73833.phpt
ext/openssl/tests/bug74022_2.phpt
ext/openssl/tests/bug74159.phpt
ext/openssl/tests/bug74402.phpt
ext/openssl/tests/bug74720_1.phpt
ext/openssl/tests/bug74798.phpt
ext/openssl/tests/bug76296.phpt
ext/openssl/tests/capture_peer_cert_001.phpt
ext/openssl/tests/check_default_conf_path.phpt
ext/openssl/tests/cipher_tests.inc
ext/openssl/tests/cve-2013-6420.phpt
ext/openssl/tests/cve2013_4073.phpt
ext/openssl/tests/ecc.phpt
ext/openssl/tests/openssl_csr_export_bacis.phpt
ext/openssl/tests/openssl_csr_export_to_file_basic.phpt
ext/openssl/tests/openssl_csr_get_public_key_basic.phpt
ext/openssl/tests/openssl_csr_get_subject_basic.phpt
ext/openssl/tests/openssl_csr_sign_basic.phpt
ext/openssl/tests/openssl_decrypt_ccm.phpt
ext/openssl/tests/openssl_decrypt_gcm.phpt
ext/openssl/tests/openssl_encrypt_ccm.phpt
ext/openssl/tests/openssl_encrypt_gcm.phpt
ext/openssl/tests/openssl_error_string_basic.phpt
ext/openssl/tests/openssl_peer_fingerprint_basic.phpt
ext/openssl/tests/openssl_pkcs7_decrypt_basic.phpt
ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt
ext/openssl/tests/openssl_pkcs7_encrypt_basic.phpt
ext/openssl/tests/openssl_pkcs7_sign_basic.phpt
ext/openssl/tests/openssl_pkey_new_basic.phpt
ext/openssl/tests/openssl_private_encrypt_basic.phpt
ext/openssl/tests/openssl_public_encrypt_basic.phpt
ext/openssl/tests/openssl_random_pseudo_bytes_basic.phpt
ext/openssl/tests/openssl_spki_export_basic.phpt
ext/openssl/tests/openssl_spki_export_challenge_basic.phpt
ext/openssl/tests/openssl_spki_new_basic.phpt
ext/openssl/tests/openssl_spki_verify_basic.phpt
ext/openssl/tests/openssl_x509_export_basic.phpt
ext/openssl/tests/openssl_x509_export_to_file_basic.phpt
ext/openssl/tests/openssl_x509_fingerprint_basic.phpt
ext/openssl/tests/openssl_x509_parse_basic.phpt
ext/openssl/tests/peer_verification.phpt
ext/openssl/tests/san_peer_matching.phpt
ext/openssl/tests/session_meta_capture.phpt
ext/openssl/tests/sni_server.phpt
ext/openssl/tests/stream_crypto_flags_001.phpt
ext/openssl/tests/stream_crypto_flags_002.phpt
ext/openssl/tests/stream_crypto_flags_004.phpt
ext/openssl/tests/stream_server_reneg_limit.phpt
ext/openssl/tests/stream_verify_peer_name_001.phpt
ext/openssl/tests/stream_verify_peer_name_002.phpt
ext/openssl/tests/stream_verify_peer_name_003.phpt
ext/openssl/tests/streams_crypto_method.phpt
ext/openssl/tests/tlsv1.0_wrapper.phpt
ext/openssl/tests/tlsv1.1_wrapper.phpt
ext/openssl/tests/tlsv1.2_wrapper.phpt

index 9bcb3d890ed93abaf33ce1dde7e4c2bada730b32..7f5af24ae69b5c3079cf614679a35c011f78f13c 100644 (file)
@@ -9,28 +9,33 @@ if (!@openssl_pkey_new()) die("skip cannot create private key");
 <?php
 echo "Creating private key\n";
 
-$conf = array('config' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'openssl.cnf');
+$conf = array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf');
 $privkey = openssl_pkey_new($conf);
 
-if ($privkey === false)
-       die("failed to create private key");
+if ($privkey === false) {
+    die("failed to create private key");
+}
 
 $passphrase = "banana";
-$key_file_name = tempnam(sys_get_temp_dir(), "ssl");
-if ($key_file_name === false)
-       die("failed to get a temporary filename!");
+$key_file_name = __DIR__ . '/001-tmp.key';
+if ($key_file_name === false) {
+    die("failed to get a temporary filename!");
+}
 
 echo "Export key to file\n";
 
-openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase, $conf) or die("failed to export to file $key_file_name");
+if (!openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase, $conf)) {
+    die("failed to export to file $key_file_name");
+}
 var_dump(is_resource($privkey));
 
 echo "Load key from file - array syntax\n";
 
 $loaded_key = openssl_pkey_get_private(array("file://$key_file_name", $passphrase));
 
-if ($loaded_key === false)
-       die("failed to load key using array syntax");
+if ($loaded_key === false) {
+    die("failed to load key using array syntax");
+}
 
 openssl_pkey_free($loaded_key);
 
@@ -38,8 +43,9 @@ echo "Load key using direct syntax\n";
 
 $loaded_key = openssl_pkey_get_private("file://$key_file_name", $passphrase);
 
-if ($loaded_key === false)
-       die("failed to load key using direct syntax");
+if ($loaded_key === false) {
+    die("failed to load key using direct syntax");
+}
 
 openssl_pkey_free($loaded_key);
 
@@ -48,15 +54,13 @@ echo "Load key manually and use string syntax\n";
 $key_content = file_get_contents($key_file_name);
 $loaded_key = openssl_pkey_get_private($key_content, $passphrase);
 
-if ($loaded_key === false)
-       die("failed to load key using string syntax");
-
+if ($loaded_key === false) {
+    die("failed to load key using string syntax");
+}
 openssl_pkey_free($loaded_key);
 
 echo "OK!\n";
 
-@unlink($key_file_name);
-
 ?>
 --EXPECT--
 Creating private key
@@ -66,3 +70,8 @@ Load key from file - array syntax
 Load key using direct syntax
 Load key manually and use string syntax
 OK!
+--CLEAN--
+<?php
+$key_file_name = __DIR__ . DIRECTORY_SEPARATOR . '001-tmp.key';
+@unlink($key_file_name);
+?>
\ No newline at end of file
index 2bedeb2d67156995be22c5c6f7b903901f9be1f7..c3888e962b68c6425007480b269711a8c28cc58e 100644 (file)
@@ -2,8 +2,7 @@
 Bug #28382 (openssl_x509_parse extensions support)
 --SKIPIF--
 <?php 
-if (!extension_loaded("openssl")) die("skip"); 
-if (OPENSSL_VERSION_NUMBER<0x009070af) die("skip");
+if (!extension_loaded("openssl")) die("skip");
 ?>
 --FILE--
 <?php
index 87fad9843e61e68934446cd680faac4e5c13fa2b..5c1b70724d3b8af0fda58579a91eeedbe15becb2 100644 (file)
@@ -3,22 +3,21 @@ Bug #36732 (add support for req_extensions in openss_csr_new and sign)
 --SKIPIF--
 <?php 
 if (!extension_loaded("openssl")) die("skip");
-if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
 ?>
 --FILE--
 <?php 
 $configargs = array(
-        "req_extensions" => "v3_req",
-        "x509_extensions" => "usr_cert",
-               "config" => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf",
+    "req_extensions" => "v3_req",
+    "x509_extensions" => "usr_cert",
+    "config" => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf",
 );
 
 $dn = array(
-        "countryName" => "GB",
-        "stateOrProvinceName" => "Berkshire",
-        "localityName" => "Newbury",
-        "organizationName" => "My Company Ltd",
-        "commonName" => "Demo Cert"
+    "countryName" => "GB",
+    "stateOrProvinceName" => "Berkshire",
+    "localityName" => "Newbury",
+    "organizationName" => "My Company Ltd",
+    "commonName" => "Demo Cert"
 );
 
 $key = openssl_pkey_new();
@@ -29,11 +28,11 @@ $str = '';
 openssl_csr_export($csr, $str, false);
 
 if (strpos($str, 'Requested Extensions:')) {
-       echo "Ok\n";
+    echo "Ok\n";
 }
 openssl_x509_export($crt, $str, false);
 if (strpos($str, 'X509v3 extensions:')) {
-       echo "Ok\n";
+    echo "Ok\n";
 }
 ?>
 --EXPECTF--
index 2eef8c5bdc6511d0aca7b0a6be2e9bb927a86853..994f9e412cd2e62fee3466c515845e87a485836e 100644 (file)
@@ -3,7 +3,6 @@ openssl_sign/verify: accept different algos
 --SKIPIF--
 <?php 
 if (!extension_loaded("openssl")) die("skip");
-if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
 ?>
 --FILE--
 <?php 
@@ -15,19 +14,18 @@ $priv_key = file_get_contents($file_key);
 $priv_key_id = openssl_get_privatekey($priv_key);
 
 
-
 $pub_key = file_get_contents($file_pub);
 $pub_key_id = openssl_get_publickey($pub_key);
 $data = "some custom data";
 if (!openssl_sign($data, $signature, $priv_key_id, OPENSSL_ALGO_MD5)) {
-       echo "openssl_sign failed.";
+    echo "openssl_sign failed.";
 }
 
 $ok = openssl_verify($data, $signature, $pub_key_id, OPENSSL_ALGO_MD5);
 if ($ok == 1) {
-   echo "Ok";
+    echo "Ok";
 } elseif ($ok == 0) {
-   echo "openssl_verify failed.";
+    echo "openssl_verify failed.";
 }
 
 
index 487260553933d015dcd3a54d3cfbc47f6a022972..9eca6594a95af97bc9adf4cfdb7ec2aa8fcce3ed 100644 (file)
@@ -11,9 +11,9 @@ $signature = '';
 $ok = openssl_verify("foo", $signature, $pub_key_id, OPENSSL_ALGO_MD5);
 
 class test {
-       function __toString() {
-               return "test object";
-       }
+    function __toString() {
+        return "test object";
+    }
 }
 $t = new test;
 
index 66de8b876ca8dc6e85d28e64c5dae95cb187c484..66919473203a74cea344b3f1fffb276c4e6f450a 100644 (file)
@@ -8,9 +8,9 @@ if (!extension_loaded("openssl")) die("skip");
 <?php
 $cert = false;
 class test {
-       function __toString() {
-               return "test object";
-       }
+    function __toString() {
+        return "test object";
+    }
 }
 $t = new test;
 
index 7895e2f3de3f423d86e4bfded3a1aa02a0512266..ad64058a56b34e9b30d5bf12b574bfdbc2de5b3e 100644 (file)
@@ -9,9 +9,9 @@ if (!extension_loaded("openssl")) die("skip");
 $dir = dirname(__FILE__);
 $certs = array('bug39217cert2.txt', 'bug39217cert1.txt');
 foreach($certs as $cert) {
-       $res = openssl_x509_parse(file_get_contents($dir . '/' . $cert));
-       print_r($res['serialNumber']);
-       echo "\n";
+    $res = openssl_x509_parse(file_get_contents($dir . '/' . $cert));
+    print_r($res['serialNumber']);
+    echo "\n";
 }
 ?>
 --EXPECTF--
index 4e9bea3e3e29a40dfbf06cd78aac18fe1de73ba0..f52a4c7d2751ef1532c84b503105d3c9b19bfc67 100644 (file)
@@ -3,7 +3,6 @@
 --SKIPIF--
 <?php 
 if (!extension_loaded("openssl")) die("skip, openssl required");
-if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
 ?>
 --FILE--
 <?php
index 5410d2f87e8b19b4087ea3ee8faef732289ff9b7..f11d8baf0bee083c2664a080b8e21aac35ecf669 100644 (file)
@@ -4,7 +4,7 @@
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
-if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip openssl version too low");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -38,5 +38,6 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECT--
 Sending bug 46127
index 5211c23d20d674116f7381aaefdd0098b3cde6a6..d11cddf27345f66246da563c149b5ea50fab684e 100644 (file)
@@ -4,7 +4,7 @@ Bug #48182: ssl handshake fails during asynchronous socket connection
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
-if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip openssl version too low");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -44,6 +44,7 @@ echo "Running bug48182\n";
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 Running bug48182
 Sending bug48182
index 878cb4a8725b373a8d97d14b86e8d6a2786c3667..01369dca00104805245fc3558d73ecb5cc787ee4 100644 (file)
@@ -4,6 +4,7 @@ Bug #54992: Stream not closed and error not returned when SSL CN_match fails
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -36,6 +37,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 Warning: stream_socket_client(): Peer certificate CN=`bug54992.local' did not match expected CN=`buga_buga' in %s on line %d
 
index b58d28ad73eaf575616056944407697d613c8d20..88e5a17ce4f6a8a9c8b56c96792b594431ca0ce6 100644 (file)
@@ -6,13 +6,13 @@ Bug #55259 (openssl extension does not get the DH parameters from DH key resourc
 <?php
 
 $phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' .
-               'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
-               '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
-               '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
-$dh_details = array( 'p' => $phex, 'g' => '2' );
-$dh = openssl_pkey_new(array( 'dh'=> array( 'p' => $phex, 'g' => '2' )));
+        'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
+        '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
+        '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
+$dh_details = array('p' => $phex, 'g' => '2');
+$dh = openssl_pkey_new(array('dh'=> array('p' => $phex, 'g' => '2')));
 var_dump($dh);
-$dh = openssl_pkey_new(array( 'dh'=> array( 'p' => hex2bin($phex), 'g' => '2' )));
+$dh = openssl_pkey_new(array('dh'=> array( 'p' => hex2bin($phex), 'g' => '2')));
 $details = openssl_pkey_get_details($dh);
 var_dump(bin2hex($details['dh']['p']));
 var_dump($details['dh']['g']);
index 6c504588c8a64074a1b09346851292cc366dc84f..a7e4152779ce91bbf507ab36cc42e69b2387feea 100644 (file)
@@ -1,28 +1,43 @@
 --TEST--
 Bug #55646: textual input in openssl_csr_new() is not expected in UTF-8
 --SKIPIF--
-<?php
-if (!function_exists('openssl_csr_new'))
-       die('skip no openssl extension');
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
 --FILE--
 <?php
-function stringAsHex($string){$unpacked = unpack("H*", $string);return implode(" ", str_split($unpacked[1],2));}
 
-$config = array("digest_alg" => "sha1","x509_extensions" => "v3_ca","req_extensions" => "v3_req","private_key_bits" => 2048,"private_key_type" => OPENSSL_KEYTYPE_RSA,"encrypt_key" => false,);
+function stringAsHex($string) {
+    $unpacked = unpack("H*", $string);
+    return implode(" ", str_split($unpacked[1],2));
+}
+
+$config = array(
+    "digest_alg" => "sha1",
+    "x509_extensions" => "v3_ca",
+    "req_extensions" => "v3_req",
+    "private_key_bits" => 2048,
+    "private_key_type" => OPENSSL_KEYTYPE_RSA,
+    "encrypt_key" => false,
+);
 $csr_info = array(
-  "countryName" => "US",
-  "stateOrProvinceName" => "Utah",
-  "localityName" => "Lindon",
-  "organizationName" => "Chinese",
-  "organizationalUnitName" => "IT \xe4\xba\x92",
-  "commonName" => "www.example.com",);
+    "countryName" => "US",
+    "stateOrProvinceName" => "Utah",
+    "localityName" => "Lindon",
+    "organizationName" => "Chinese",
+    "organizationalUnitName" => "IT \xe4\xba\x92",
+    "commonName" => "www.example.com",
+);
 $private = openssl_pkey_new($config);
 while (openssl_error_string()) {}
-$csr_res = openssl_csr_new($csr_info, $private,
-       ['config' => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf"]);
+$csr_res = openssl_csr_new(
+    $csr_info,
+    $private,
+    ['config' => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf"]
+);
 if (!$csr_res) {
-       while ($e = openssl_error_string()) { $err = $e; }
-       die("Failed; last error: $err");
+    while ($e = openssl_error_string()) {
+        $err = $e;
+       }
+    die("Failed; last error: $err");
 }
 openssl_csr_export($csr_res, $csr);
 $output = openssl_csr_get_subject($csr);
@@ -31,6 +46,7 @@ echo "A: ".$csr_info["organizationalUnitName"]."\n";
 echo "B: ".stringAsHex($csr_info["organizationalUnitName"])."\n";
 echo "C: ".$output['OU']."\n";
 echo "D: ".stringAsHex($output['OU'])."\n";
+?>
 --EXPECT--
 A: IT äº’
 B: 49 54 20 e4 ba 92
index 9b21da5048419397ef963eafd117e5aadce56eb2..1f2b073d3e30a26c204490cf5f8d34460817a3d4 100644 (file)
@@ -1,12 +1,19 @@
 --TEST--\r
 Bug #61124: Segmentation fault with openssl_decrypt\r
 --SKIPIF--\r
-<?php \r
-if (!extension_loaded("openssl")) die("skip");\r
+<?php if (!extension_loaded("openssl")) die("skip"); ?>\r
 --FILE--\r
 <?php\r
-var_dump(openssl_decrypt('kzo w2RMExUTYQXW2Xzxmg==', 'aes-128-cbc', 'pass', false, 'pass'));\r
-\r
+var_dump(\r
+    openssl_decrypt(\r
+        'kzo w2RMExUTYQXW2Xzxmg==',\r
+        'aes-128-cbc',\r
+        'pass',\r
+        false,\r
+        'pass'\r
+    )\r
+);\r
+?>\r
 --EXPECTF--\r
 Warning: openssl_decrypt(): IV passed is only 4 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in %s on line %d\r
 bool(false)\r
index 55dc42fded05100bb5f50024fc809d11d83a681f..6d8742b80d9fc36b41ef7d3a067ac6fd44462db7 100644 (file)
@@ -12,7 +12,9 @@ $data = <<<DATA
 Please verify me
 DATA;
 
-$sig = 'f9Gyb6NV/ENn7GUa37ygTLcF93XHf5fbFTnoYF/O+fXbq3iChGUbET0RuhOsptlAODi6JsDLnJO4ikcVZo0tC1fFTj3LyCuPy3ZdgJbbVxQ/rviROCmuMFTqUW/Xa2LQYiapeCCgLQeWTLg7TM/BoHEkKbKLG/XT5jHvep1758A=';
+$sig = 'f9Gyb6NV/ENn7GUa37ygTLcF93XHf5fbFTnoYF/O+fXbq3iChGUbET0RuhOsptl' .
+        'AODi6JsDLnJO4ikcVZo0tC1fFTj3LyCuPy3ZdgJbbVxQ/rviROCmuMFTqUW/Xa2' .
+        'LQYiapeCCgLQeWTLg7TM/BoHEkKbKLG/XT5jHvep1758A=';
 
 $key = openssl_get_publickey($cert);
 var_dump(openssl_get_publickey($key));
index e666859d0d82ff5b0f14c07c9762e9d2a6bb6016..290bbeff3541cac69bc835de231bfe0ae01fc4db 100644 (file)
@@ -4,6 +4,7 @@ Bug #65538: SSL context "cafile" supports stream wrappers
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -48,5 +49,6 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECT--
 string(12) "Hello World!"
index 21a23a26780a923d770a4ffd8b339bb7d8a077ec..7dddb12564bf9aaaf743f4ce9be34565fd940dda 100644 (file)
@@ -8,12 +8,12 @@ if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
 --FILE--
 <?php
 $clientCtx = stream_context_create(['ssl' => [
-       // We don't get any ca list from php.net but it does not matter as we
-       // care about the fact that the external stream is not allowed.
-       // We can't use http://curl.haxx.se/ca/cacert.pem for this test
-       // as it is redirected to https which means the test would depend
-       // on system cafile when opening stream.
-       'cafile' => 'http://www.php.net',
+    // We don't get any ca list from php.net but it does not matter as we
+    // care about the fact that the external stream is not allowed.
+    // We can't use http://curl.haxx.se/ca/cacert.pem for this test
+    // as it is redirected to https which means the test would depend
+    // on system cafile when opening stream.
+    'cafile' => 'http://www.php.net',
 ]]);
 file_get_contents('https://github.com', false, $clientCtx);
 ?>
index da99779143d593658d31615fe7e8e89564ac598f..042e7d08bcba3422a60399b9bf8be4bab55c2854 100644 (file)
@@ -5,6 +5,7 @@ Bug #65538: SSL context "cafile" supports phar wrapper
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!extension_loaded("phar")) die("skip phar not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -49,5 +50,6 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 string(12) "Hello World!"
index 5b693421fe55efe78fb74ee9e12d07d1737d32b9..ba1efc739c4c0775acb91fc6e230d9b4d096943c 100644 (file)
@@ -1,9 +1,7 @@
 --TEST--
 Bug #65689 (GeneralizedTime format parsing)
 --SKIPIF--
-<?php 
-if (!extension_loaded("openssl")) die("skip"); 
-?>
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
 --FILE--
 <?php
 $crt = substr(__FILE__, 0, -4).'.crt';
index 347dc55e758cbc4c1ea19148b2174aabe674f217..5e91197b701ead35a5ac9f5198a637259e220dd3 100644 (file)
@@ -4,6 +4,7 @@ Bug #65729: CN_match gives false positive when wildcard is used
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -42,6 +43,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 Warning: stream_socket_client(): Peer certificate CN=`*.test.com' did not match expected CN=`foo.test.com.sg' in %s on line %d
 
index 99ac4f55deae8ef6f04355f990d52d28952fc1c3..d6894089a0bd9ac0b8dba28c3376aec54264f16a 100644 (file)
@@ -4,6 +4,7 @@ Bug #66501: EC private key support in openssl_sign
 <?php \r
 if (!extension_loaded("openssl")) die("skip");\r
 if (!defined('OPENSSL_KEYTYPE_EC')) die("skip no EC available");\r
+?>\r
 --FILE--\r
 <?php\r
 $pkey = 'ASN1 OID: prime256v1\r
@@ -18,5 +19,6 @@ sqOTOnMoezkbSmVVMuwz9flvnqHGmQvmug==
 $key = openssl_pkey_get_private($pkey);\r
 $res = openssl_sign($data ='alpha', $sign, $key, 'SHA1');\r
 var_dump($res);\r
+?>\r
 --EXPECTF--\r
 bool(true)\r
index 0a19686af1b7e434afef7716b139d9ff2c579a8f..76c5c8613cf89c96395a10035f97fa91fbfa6d67 100644 (file)
@@ -1,8 +1,7 @@
 --TEST--
 Bug #67403: Add signatureType to openssl_x509_parse
 --SKIPIF--
-<?php
-if (!extension_loaded("openssl")) die("skip");
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
 --FILE--
 <?php
 $r = openssl_x509_parse(file_get_contents(__DIR__.'/bug64802.pem'));
@@ -14,6 +13,7 @@ $r = openssl_x509_parse(file_get_contents(__DIR__.'/bug37820cert.pem'));
 var_dump($r['signatureTypeSN']);
 var_dump($r['signatureTypeLN']);
 var_dump($r['signatureTypeNID']);
+?>
 --EXPECTF--
 string(8) "RSA-SHA1"
 string(21) "sha1WithRSAEncryption"
index aff9a9e511c4069d0f6b6a097a76653695ac312c..f2c867670a7edd70fc43bde9808a9d61f468c00d 100644 (file)
@@ -4,6 +4,7 @@ Bug #68265: SAN match fails with trailing DNS dot
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -36,6 +37,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 
index 2982d00c36bef73dfad5e029efbde6e05fccf5b5..8cf9044c93ff3fb3172b9361b54d31227e749cf7 100644 (file)
@@ -4,6 +4,7 @@ Bug #68879: Match IP address fields in subjectAltName checks
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -36,6 +37,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 
index 52a103f641bd17b45ec9bb6110b62d2cf001c8e2..4c6271819b2ad840afa48eece631c31cd1ce1f79 100644 (file)
@@ -4,6 +4,7 @@ Bug #68920: peer_fingerprint input checks should be strict
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -47,6 +48,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 Warning: stream_socket_client(): Expected peer fingerprint must be a string or an array in %s on line %d
 
index 2e2fe9222bf1e0c88d9d4deeb76bb9a5aeb399ab..ab9eec677030332eb30b612912ef7420652b32e9 100644 (file)
@@ -4,6 +4,7 @@ Bug #69215: Crypto servers should send client CA list
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -43,6 +44,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 
index 937e9f3bd9a14a1bef44e6b92d3696590510f553..e25c37168b9344d679d69eb523461aa3c27f8b17 100644 (file)
@@ -2,11 +2,9 @@
 Request #70438: Add IV parameter for openssl_seal and openssl_open
 --SKIPIF--
 <?php
-if (!extension_loaded("openssl")) {
-       print "skip";
-}
+if (!extension_loaded("openssl")) print "skip";
 if (!in_array('AES-128-CBC', openssl_get_cipher_methods(true))) {
-       print "skip";
+    print "skip";
 }
 ?>
 --FILE--
index d4415b3e32b8948e184f757fc207e3769678299e..c7f91dbb5581259cf6acb43b6077e33e7a5a801e 100644 (file)
@@ -7,12 +7,16 @@ if (!extension_loaded("openssl")) die("skip openssl not loaded");
 --FILE--
 <?php
 function test($envkey) {
-  $publicKey = "file://" . dirname(__FILE__) . "/public.key";
-  $privateKey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
-  openssl_public_encrypt($envkey, $envelope, $publicKey);
-  $sealed = openssl_encrypt('plaintext', 'rc4', $envkey, OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY);
-  openssl_open($sealed, $output, $envelope, $privateKey, 'rc4');
-  var_dump($output === 'plaintext');
+    $publicKey = "file://" . dirname(__FILE__) . "/public.key";
+    $privateKey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
+    openssl_public_encrypt($envkey, $envelope, $publicKey);
+    $sealed = openssl_encrypt(
+        'plaintext',
+        'rc4', $envkey,
+        OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY
+    );
+    openssl_open($sealed, $output, $envelope, $privateKey, 'rc4');
+    var_dump($output === 'plaintext');
 }
 
 // works - key of 16 bytes
index a7b1c93b15026d886a0e63bdd7281db0a4786e53..1350df8501985335f4e633e01717b44d6e775018 100644 (file)
@@ -8,56 +8,56 @@ if (!function_exists("proc_open")) die("skip no proc_open");
 --FILE--
 <?php
 $serverCode = <<<'CODE'
-       $context = stream_context_create(['ssl' => ['local_cert' => __DIR__ . '/bug54992.pem']]);
+    $context = stream_context_create(['ssl' => ['local_cert' => __DIR__ . '/bug54992.pem']]);
 
-       $flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
-       $fp = stream_socket_server("ssl://127.0.0.1:10011", $errornum, $errorstr, $flags, $context);
-       phpt_notify();
-       $conn = stream_socket_accept($fp);
-       $total = 100000;
-       $result = fread($conn, $total);
-       stream_set_blocking($conn, false);
-       usleep(50000);
-       $read = [$conn];
-       while (stream_select($read, $write, $except, 1)) {
-               $result = fread($conn, 100000);
-               if (!$result) {
-                   break;
-               }
-               $total += strlen($result);
-               if ($total >= 4000000) {
-                   break;
-               }
-       }
-       phpt_wait();
+    $flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
+    $fp = stream_socket_server("ssl://127.0.0.1:10011", $errornum, $errorstr, $flags, $context);
+    phpt_notify();
+    $conn = stream_socket_accept($fp);
+    $total = 100000;
+    $result = fread($conn, $total);
+    stream_set_blocking($conn, false);
+    usleep(50000);
+    $read = [$conn];
+    while (stream_select($read, $write, $except, 1)) {
+        $result = fread($conn, 100000);
+        if (!$result) {
+            break;
+        }
+        $total += strlen($result);
+        if ($total >= 4000000) {
+            break;
+        }
+    }
+    phpt_wait();
 CODE;
 
 $clientCode = <<<'CODE'
-       $context = stream_context_create(['ssl' => ['verify_peer' => false, 'peer_name' => 'bug54992.local']]);
-
-       phpt_wait();
-       $fp = stream_socket_client("ssl://127.0.0.1:10011", $errornum, $errorstr, 3000, STREAM_CLIENT_CONNECT, $context);
-       stream_set_blocking($fp, false);
-
-       function blocking_fwrite($fp, $buf) {
-               $write = [$fp];
-               $total = 0;
-               while (stream_select($read, $write, $except, 1)) {
-                       $result = fwrite($fp, $buf);
-                       if (!$result) {
-                           break;
-                       }
-                       $total += $result;
-                       if ($total >= strlen($buf)) {
-                               return $total;
-                       }
-                       $buf = substr($buf, $total);
-               }
-       }
-       $str1 = str_repeat("a", 4000000);
-       blocking_fwrite($fp, $str1);
-       phpt_notify();
-       echo "done";
+    $context = stream_context_create(['ssl' => ['verify_peer' => false, 'peer_name' => 'bug54992.local']]);
+    
+    phpt_wait();
+    $fp = stream_socket_client("ssl://127.0.0.1:10011", $errornum, $errorstr, 3000, STREAM_CLIENT_CONNECT, $context);
+    stream_set_blocking($fp, false);
+    
+    function blocking_fwrite($fp, $buf) {
+        $write = [$fp];
+        $total = 0;
+        while (stream_select($read, $write, $except, 1)) {
+            $result = fwrite($fp, $buf);
+            if (!$result) {
+                break;
+            }
+            $total += $result;
+            if ($total >= strlen($buf)) {
+                return $total;
+            }
+            $buf = substr($buf, $total);
+        }
+    }
+    $str1 = str_repeat("a", 4000000);
+    blocking_fwrite($fp, $str1);
+    phpt_notify();
+    echo "done";
 CODE;
 
 include 'ServerClientTestCase.inc';
index 893b51838dc386a0123eb01fc601bb50f7700638..1defd21dfc3ce06c298024735d46e411ad930593 100644 (file)
@@ -5,18 +5,18 @@ Bug #72336 (openssl_pkey_new does not fail for invalid DSA params)
 --FILE--
 <?php
 $p = '00f8000ae45b2dacb47dd977d58b719d097bdf07cb2c17660ad898518c08' .
-        '1a61659a16daadfaa406a0a994c743df5eda07e36bd0adcad921b77432ff' .
-        '24ccc31e782d647e66768122b578857e9293df78387dc8b44af2a4a3f305' .
-        '1f236b1000a3e31da489c6681b0031f7ec37c2e1091bdb698e7660f135b6' .
-        '996def90090303b7ad';
+    '1a61659a16daadfaa406a0a994c743df5eda07e36bd0adcad921b77432ff' .
+    '24ccc31e782d647e66768122b578857e9293df78387dc8b44af2a4a3f305' .
+    '1f236b1000a3e31da489c6681b0031f7ec37c2e1091bdb698e7660f135b6' .
+    '996def90090303b7ad';
 
 $q = '009b3734fc9f7a4a9d6437ec314e0a78c2889af64b';
 
 $g = '00b320300a0bc55b8f0ec6edc218e2185250f38fbb8291db8a89227f6e41' .
-        '00d47d6ccb9c7d42fc43280ecc2ed386e81ff65bc5d6a2ae78db7372f5dc' .
-        'f780f4558e7ed3dd0c96a1b40727ac56c5165aed700a3b63997893a1fb21' .
-        '4e882221f0dd9604820dc34e2725dd6901c93e0ca56f6d76d495c332edc5' .
-        'b81747c4c447a941f3';
+    '00d47d6ccb9c7d42fc43280ecc2ed386e81ff65bc5d6a2ae78db7372f5dc' .
+    'f780f4558e7ed3dd0c96a1b40727ac56c5165aed700a3b63997893a1fb21' .
+    '4e882221f0dd9604820dc34e2725dd6901c93e0ca56f6d76d495c332edc5' .
+    'b81747c4c447a941f3';
 
 var_dump(openssl_pkey_new(array('dsa' => array('p' => $p, 'q' => $q, 'g' => $g))));
 ?>
index 40acdbed0c696963e2b5218d4c955db393f5870b..cd6ec1e83826b7ad0aaf95022545dd0b36db99c3 100644 (file)
@@ -6,8 +6,26 @@ if (!extension_loaded("openssl")) die("skip openssl not loaded");
 ?>
 --FILE--
 <?php
-var_dump(bin2hex(openssl_encrypt("this is a test string","bf-ecb","12345678", OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY)));
-var_dump(bin2hex(openssl_encrypt("this is a test string","bf-ecb","1234567812345678" , OPENSSL_RAW_DATA)));
+var_dump(
+    bin2hex(
+        openssl_encrypt(
+            "this is a test string",
+            "bf-ecb",
+            "12345678",
+            OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY
+        )
+    )
+);
+var_dump(
+    bin2hex(
+        openssl_encrypt(
+            "this is a test string",
+            "bf-ecb",
+            "1234567812345678",
+            OPENSSL_RAW_DATA
+        )
+    )
+);
 ?>
 --EXPECT--
 string(48) "e3214d1b16e574828c8a3e222202dde81afd1ad2cb165ab3"
index cc352233e1139454bd28c35cfeec01fab998cf7d..8f001829f216e9754d4f6993b7522ecaa46f4500 100644 (file)
@@ -3,39 +3,40 @@ Bug #73072: Invalid path SNI_server_certs causes segfault
 --SKIPIF--
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
+if (!function_exists("proc_open")) die("skip no proc_open");
 ?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
     $flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
-       $ctx = stream_context_create(['ssl' => [
-           'local_cert' => __DIR__ . '/domain1.pem',
-               'SNI_server_certs' => [
-                   "domain1.com" => __DIR__ . "/sni_server_domain1.pem",
-                       "domain2.com" => __DIR__ . "/not_existing.pem",
-               ]
-       ]]);
-
+    $ctx = stream_context_create(['ssl' => [
+        'local_cert' => __DIR__ . '/domain1.pem',
+        'SNI_server_certs' => [
+            "domain1.com" => __DIR__ . "/sni_server_domain1.pem",
+            "domain2.com" => __DIR__ . "/not_existing.pem",
+        ]
+    ]]);
+    
     $server = stream_socket_server('tls://127.0.0.1:64322', $errno, $errstr, $flags, $ctx);
-
+    
     phpt_notify();
-       @stream_socket_accept($server, 3);
-       // if there is a segfault, this won't be called
-       fwrite(STDERR, "done\n");
+    @stream_socket_accept($server, 3);
+    // if there is a segfault, this won't be called
+    fwrite(STDERR, "done\n");
 CODE;
 
 $clientCode = <<<'CODE'
     $flags = STREAM_CLIENT_CONNECT;
-       $ctxArr = [
-           'cafile' => __DIR__ . '/sni_server_ca.pem',
-               'capture_peer_cert' => true
-       ];
+    $ctxArr = [
+        'cafile' => __DIR__ . '/sni_server_ca.pem',
+        'capture_peer_cert' => true
+    ];
 
     phpt_wait();
 
     $ctxArr['peer_name'] = 'domain1.com';
-       $ctx = stream_context_create(['ssl' => $ctxArr]);
-       @stream_socket_client("tls://127.0.0.1:64322", $errno, $errstr, 1, $flags, $ctx);
+    $ctx = stream_context_create(['ssl' => $ctxArr]);
+    @stream_socket_client("tls://127.0.0.1:64322", $errno, $errstr, 1, $flags, $ctx);
 CODE;
 
 include 'ServerClientTestCase.inc';
index 1dfc584164ee760d6e50882c685872f7c560db58..61f0faa0574df31faf10929feea26e4fb5544866 100644 (file)
@@ -1,15 +1,13 @@
 --TEST--
 Bug #73478: openssl_pkey_new() generates wrong pub/priv keys with Diffie Hellman
 --SKIPIF--
-<?php
-if (!extension_loaded("openssl")) die("skip openssl not loaded");
-?>
+<?php if (!extension_loaded("openssl")) die("skip openssl not loaded"); ?>
 --FILE--
 <?php
 $details = [
-  'p' => base64_decode('3Pk6C4g5cuwOGZiaxaLOMQ4dN3F+jZVxu3Yjcxhm5h73Wi4niYsFf5iRwuJ6Y5w/KbYIFFgc07LKOYbSaDcFV31FwuflLcgcehcYduXOp0sUSL/frxiCjv0lGfFOReOCZjSvGUnltTXMgppIO4p2Ij5dSQolfwW9/xby+yLFg6s='),
-  'g' => base64_decode('Ag=='),
-  'priv_key' => base64_decode('jUdcV++P/m7oUodWiqKqKXZVenHRuj92Ig6Fmzs7QlqVdUc5mNBxmEWjug+ObffanPpOeab/LyXwjNMzevtBz3tW4oROau++9EIMJVVQr8fW9zdYBJcYieC5l4t8nRj5/Uu/Z0G2rWVLBleSi28mqqNEvnUs7uxYxrar69lwQYs=')
+    'p' => base64_decode('3Pk6C4g5cuwOGZiaxaLOMQ4dN3F+jZVxu3Yjcxhm5h73Wi4niYsFf5iRwuJ6Y5w/KbYIFFgc07LKOYbSaDcFV31FwuflLcgcehcYduXOp0sUSL/frxiCjv0lGfFOReOCZjSvGUnltTXMgppIO4p2Ij5dSQolfwW9/xby+yLFg6s='),
+    'g' => base64_decode('Ag=='),
+    'priv_key' => base64_decode('jUdcV++P/m7oUodWiqKqKXZVenHRuj92Ig6Fmzs7QlqVdUc5mNBxmEWjug+ObffanPpOeab/LyXwjNMzevtBz3tW4oROau++9EIMJVVQr8fW9zdYBJcYieC5l4t8nRj5/Uu/Z0G2rWVLBleSi28mqqNEvnUs7uxYxrar69lwQYs=')
 ];
 
 $opensslKeyResource = openssl_pkey_new(['dh' => $details]);
index 2ea5f9e411810fb8565c16f8a6e978a3c0829fe0..ad4e0874a8bbba42ff2d334a8867b1a50063f3b8 100644 (file)
@@ -10,18 +10,18 @@ $passwords = ["abc\x00defghijkl", "abcdefghikjl"];
 $conf = ['config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'];
 
 foreach($passwords as $password) {
-       $key = openssl_pkey_new($conf);
+    $key = openssl_pkey_new($conf);
 
-       if (openssl_pkey_export($key, $privatePEM, $password, $conf) === false) {
-               echo "Failed to encrypt.\n";
-       } else {
-               echo "Encrypted!\n";
-       }
-       if (openssl_pkey_get_private($privatePEM, $password) === false) {
-               echo "Failed to decrypt.\n";
-       } else {
-               echo "Decrypted!\n";
-       }
+    if (openssl_pkey_export($key, $privatePEM, $password, $conf) === false) {
+        echo "Failed to encrypt.\n";
+    } else {
+        echo "Encrypted!\n";
+    }
+    if (openssl_pkey_get_private($privatePEM, $password) === false) {
+        echo "Failed to decrypt.\n";
+    } else {
+        echo "Decrypted!\n";
+    }
 }
 ?>
 --EXPECT--
index 65d0977674fcd072da8ea0dc95645f2db8690852..6a7083f32855a546d0fc63e89530fe15a5aff967 100644 (file)
@@ -7,9 +7,9 @@ if (!extension_loaded("openssl")) die("skip");
 --FILE--
 <?php
 function test($p12_contents, $password) {
-       openssl_pkcs12_read($p12_contents, $cert_data, $password);
-       openssl_error_string();
-       var_dump(count($cert_data['extracerts']));
+    openssl_pkcs12_read($p12_contents, $cert_data, $password);
+    openssl_error_string();
+    var_dump(count($cert_data['extracerts']));
 }
 
 $p12_base64 = 'MIIW+QIBAzCCFr8GCSqGSIb3DQEHAaCCFrAEghasMIIWqDCCEV8GCSqGSIb3DQEHBqCCEVAwghFMAgEAMIIRRQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIQOfCxIAgGIICAggAgIIRGFTkvHpJjCtFjukXYVlhyOIqKiS8Zvg84dX244hhI0S51Uyn/tlXM2GD/3hDNVxcVKwP/fKN21lEkoXoK4h2/5BY3qCdZa3Ef3vk44b/+FGCUAqvsOo1ZjD2P/sBGhLu3aFnQ6ktUXlKV4cnqhlF62AqY4e5efQzmJXn+gI8cSNI5c+qQ0RQgGoRY4nJfvMSZG0/DAkirjGikU/2TZd8LwLkxVUBYbF5/T0fNtA3o99+4tF+8ZRv6ArYjplRdwcBbMbzGhn3ytCq6cmVid9iLjwHJFmvAPXKbmu0Lh5eRRznX9gB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QVvbap+FvfcLjMoU6ckLQDZpQSJdFo86MdNedrKbwmVN7pV/M2b3DjPp5ixLCSXJgK3RaATIxQL88IDv4+ySL0Z2t6jUopZ40liyDnHGDl9zajeQ1WaW4yHS65aVlzYHSFvCGr8F/4Lydk5ax5HHqna6LbFeuQ4kUcUaGfiIagtFW+ueyfOckqLnwYisjG5fQmheONPHb7jg/qHQoKasD4TvmwrvUcG20c5J57oZ80C94zySYpdHTaETXHEOwz7NBPP1hplC1IaAfbhwZ48Z0kWWqddfELUC5miapzthvzpycOzL6zWmTLjyTXPZrbkqYfVrD26bsD/YOo54BThGcBdEfu2chT2eNF0rRZwF5U9TACfzMFYxUIVRq4rWAaerppkK5JNBT/la2QxUElh9HPn+0GGL1BYYEPCihciwWy2BwJs1IgjhU4ARTlukuxK+WLPTflwvlOX5G1P5D57up8kxtDncR5IIuZJgWWSFLGOkGeHXmjynLMqS1OCzIId3dj0c3EYBnku82eItAQd5fk7/rs0Lg0S1XeVSrgPphTgviGXzTWSh28S3VZJ2G7k4dr1P/sJQounjbcDrFyYaFxYXEqyO9L6vFShO5z7/vD5h9uLPddE4vC6PKJxZoWopWncLcLljuYKG0k+y4MV9U0/cESYJWzBbcZZpULdesinhxMg1wNPu5FeeFCsZpdhN2FadIuu/Kcsk6xNeDDIwwYXb3hVY0ARRAo//LyLv3zDB0LWz1LH3qJQeZ53DbgZ4VXQ6uK0yTgSsH4Lwaj5oFBPp4NJ3hdGa7trpJbeUMIxJTAjBgkqhkiG9w0BCRUxFgQUh6FIxf4sbyJnvvC+6J1NHGaa9w0wMTAhMAkGBSsOAwIaBQAEFFkCkI701QHxh2zcZkzDy8bn7qKwBAjafnZaU5r0FgICCAA=';
index c031ea2fee0b81cf84ff1ec43f26473ae62c13d3..6a46fa5082ca6bba5ef327005b978850e52d4fca 100644 (file)
@@ -4,7 +4,6 @@ Bug #74159: Writing a large buffer to non-blocking encrypted streams fails
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
-if (OPENSSL_VERSION_NUMBER < 0x10001001) die("skip OpenSSLv1.0.1 required");
 ?>
 --FILE--
 <?php
@@ -13,93 +12,93 @@ if (OPENSSL_VERSION_NUMBER < 0x10001001) die("skip OpenSSLv1.0.1 required");
 // scenarios which might be useful. More reliable test is bug72333.phpt
 $serverCode = <<<'CODE'
     $serverUri = "ssl://127.0.0.1:10012";
-       $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
-       $serverCtx = stream_context_create(['ssl' => [
-           'local_cert' => __DIR__ . '/bug54992.pem',
-               'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER,
-       ]]);
+    $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
+    $serverCtx = stream_context_create(['ssl' => [
+        'local_cert' => __DIR__ . '/bug54992.pem',
+        'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER,
+    ]]);
 
     $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
-       phpt_notify();
+    phpt_notify();
 
     $client = stream_socket_accept($server, 1);
 
     if (!$client) {
-           exit();
-       }
+        exit();
+    }
 
     $data = '';
-       while (strlen($data) < 0xfffff) {
-           $buffer = fread($client, 8192);
-               if (empty($buffer)) {
-                   exit();
-               }
-               $data .= $buffer;
-               usleep(100);
-       }
+    while (strlen($data) < 0xfffff) {
+        $buffer = fread($client, 8192);
+        if (empty($buffer)) {
+            exit();
+        }
+        $data .= $buffer;
+        usleep(100);
+    }
 
     fclose($client);
 CODE;
 
 $clientCode = <<<'CODE'
     function streamRead($stream) : int {
-           return strlen(fread($stream, 8192));
-       }
+        return strlen(fread($stream, 8192));
+    }
 
     function streamWrite($stream, $data) : int {
-           return fwrite($stream, $data);
-       }
+        return fwrite($stream, $data);
+    }
 
     function waitForWrite(...$streams) : bool {
-           $read = null;
-               $except = null;
-               while($streams && !($n = stream_select($read, $streams, $except, 1)));
-               return $n > 0;
-       }
+        $read = null;
+        $except = null;
+        while($streams && !($n = stream_select($read, $streams, $except, 1)));
+        return $n > 0;
+    }
 
     function waitForRead(...$streams) : bool {
-           $write = null;
-               $except = null;
-               while ($streams && !($n = stream_select($streams, $write, $except, 1)));
-               return $n > 0;
-       }
+        $write = null;
+        $except = null;
+        while ($streams && !($n = stream_select($streams, $write, $except, 1)));
+        return $n > 0;
+    }
 
     set_error_handler(function ($errno, $errstr) {
-           exit("$errstr\n");
-       });
+        exit("$errstr\n");
+    });
 
     $serverUri = "tcp://127.0.0.1:10012";
-       $clientFlags = STREAM_CLIENT_CONNECT;
-       $clientCtx = stream_context_create(['ssl' => [
-           'verify_peer' => true,
-               'cafile' => __DIR__ . '/bug54992-ca.pem',
-               'peer_name' => 'bug54992.local',
-       ]]);
+    $clientFlags = STREAM_CLIENT_CONNECT;
+    $clientCtx = stream_context_create(['ssl' => [
+        'verify_peer' => true,
+        'cafile' => __DIR__ . '/bug54992-ca.pem',
+        'peer_name' => 'bug54992.local',
+    ]]);
 
     phpt_wait();
 
     $fp = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx);
 
     stream_set_blocking($fp, false);
-       while (0 === ($n = stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT)));
+    while (0 === ($n = stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT)));
 
     $data = str_repeat("a", 0xfffff);
-       $written = 0;
-       $total = $written;
-       while(!empty($data)) {
-           $written = streamWrite($fp, $data);
-               $total += $written;
-               $data = substr($data, $written);
-               waitForWrite($fp);
-       }
-       printf("Written %d bytes\n", $total);
+    $written = 0;
+    $total = $written;
+    while(!empty($data)) {
+        $written = streamWrite($fp, $data);
+        $total += $written;
+        $data = substr($data, $written);
+        waitForWrite($fp);
+    }
+    printf("Written %d bytes\n", $total);
 
     while(waitForRead($fp)) {
-           streamRead($fp);
-               if (feof($fp)) {
-                   break;
-               }
-       }
+        streamRead($fp);
+        if (feof($fp)) {
+            break;
+        }
+    }
 
     exit("DONE\n");
 CODE;
index 8cd98362df99234c9a31596eee2aea86f282f40f..352d66dbcd0c39756faf571346c0e8cf9e808dfb 100644 (file)
@@ -2,12 +2,8 @@
 Bug #74402 (segfault on random_bytes, bin3hex, openssl_seal)
 --SKIPIF--
 <?php
-if (!extension_loaded("openssl")) {
-       print "skip";
-}
-if (!in_array('AES256', openssl_get_cipher_methods(true))) {
-       print "skip";
-}
+if (!extension_loaded("openssl")) print "skip";
+if (!in_array('AES256', openssl_get_cipher_methods(true))) print "skip";
 ?>
 --FILE--
 <?php
index 9a8099a33cee4c9254f4d4bf74213fc0df7daf26..16935bb516065794ee9c883818ee4f48d05b70a5 100644 (file)
@@ -1,9 +1,7 @@
 --TEST--
 Bug #74720 pkcs7_en/decrypt does not work if \x1a is used in content, variant 1
 --SKIPIF--
-<?php
-if (!extension_loaded("openssl")) die("skip");
-?>
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
 --FILE--
 <?php
 
index 5b41af3efcb29388225b8deecc76d170378272aa..4d5d9ad76b9843ca6c63616e0d359624534fa1e0 100644 (file)
@@ -1,9 +1,7 @@
 --TEST--
 Bug #74798 pkcs7_en/decrypt does not work if \x0a is used in content
 --SKIPIF--
-<?php
-if (!extension_loaded("openssl")) die("skip");
-?>
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
 --FILE--
 <?php
 
index 7ab15dfbf32fde99e5955a5e2777e7ae7f14ca2b..59a73b7d7b58659d4ec2f0765b9f63e3cfef2483 100644 (file)
@@ -7,7 +7,7 @@ Bug #76296 openssl_pkey_get_public does not respect open_basedir
 $dir = __DIR__ . '/bug76296_openbasedir';
 $pem = 'file://' . __DIR__ . '/public.key';
 if (!is_dir($dir)) {
-       mkdir($dir);
+    mkdir($dir);
 }
 
 ini_set('open_basedir', $dir);
index 0396cace43350a20f4fddfa75aa8c51af5a3d0db..c89f7fcb0b14a8d3ac33b5caacb8ded685e5d2a8 100644 (file)
@@ -4,6 +4,7 @@ capture_peer_cert context captures on verify failure
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -35,5 +36,6 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 string(%d) "bug54992.local"
index 16aaa4bc1de1a53da368515d4be23d2f32cfc977..71b1b6a5df3099b2d9a2a11224a193aa569fc109 100644 (file)
@@ -17,7 +17,7 @@ ob_end_clean();
 preg_match(",Openssl default config .* (.*),", $info, $m);
 
 if (isset($m[1])) {
-       var_dump(str_replace('/', '\\', strtolower($m[1])));
+    var_dump(str_replace('/', '\\', strtolower($m[1])));
 }
 ?>
 --EXPECT--
index b9e84af8f8dfd14048e6a77b8b7bb0da61f525ac..b1e46b411e54e4423301dc9ce1f448376f531f02 100644 (file)
 <?php
 $php_openssl_cipher_tests = array(
-       'aes-256-ccm' => array(
-               array(
-                       'key' => '1bde3251d41a8b5ea013c195ae128b21' .
-                                        '8b3e0306376357077ef1c1c78548b92e',
-                       'iv'  => '5b8e40746f6b98e00f1d13ff41',
-                       'aad' => 'c17a32514eb6103f3249e076d4c871dc' .
-                                        '97e04b286699e54491dc18f6d734d4c0',
-                       'tag' => '2024931d73bca480c24a24ece6b6c2bf',
-                       'pt'  => '53bd72a97089e312422bf72e242377b3' .
-                                        'c6ee3e2075389b999c4ef7f28bd2b80a',
-                       'ct'  => '9a5fcccdb4cf04e7293d2775cc76a488' .
-                                        'f042382d949b43b7d6bb2b9864786726',
-               ),
-       ),
-       'aes-128-gcm' => array(
-               array(
-                       'key' => '00000000000000000000000000000000',
-                       'iv'  => '000000000000000000000000',
-                       'tag' => '58e2fccefa7e3061367f1d57a4e7455a',
-                       'pt'  => '',
-                       'ct'  => '',
-               ),
-               array(
-                       'key' => '00000000000000000000000000000000',
-                       'iv'  => '000000000000000000000000',
-                       'tag' => 'ab6e47d42cec13bdf53a67b21257bddf',
-                       'pt'  => '00000000000000000000000000000000',
-                       'ct'  => '0388dace60b6a392f328c2b971b2fe78',
-               ),
-               array(
-                       'key' => 'feffe9928665731c6d6a8f9467308308',
-                       'iv'  => 'cafebabefacedbaddecaf888',
-                       'tag' => '4d5c2af327cd64a62cf35abd2ba6fab4',
-                       'pt'  => 'd9313225f88406e5a55909c5aff5269a' .
-                                        '86a7a9531534f7da2e4c303d8a318a72' .
-                                        '1c3c0c95956809532fcf0e2449a6b525' .
-                                        'b16aedf5aa0de657ba637b391aafd255',
-                       'ct'  => '42831ec2217774244b7221b784d0d49c' .
-                                        'e3aa212f2c02a4e035c17e2329aca12e' .
-                                        '21d514b25466931c7d8f6a5aac84aa05' .
-                                        '1ba30b396a0aac973d58e091473f5985',
-               ),
-               array(
-                       'key' => 'feffe9928665731c6d6a8f9467308308',
-                       'iv'  => 'cafebabefacedbaddecaf888',
-                       'aad' => 'feedfacedeadbeeffeedfacedeadbeefabaddad2',
-                       'tag' => '5bc94fbc3221a5db94fae95ae7121a47',
-                       'pt'  => 'd9313225f88406e5a55909c5aff5269a' .
-                                        '86a7a9531534f7da2e4c303d8a318a72' .
-                                        '1c3c0c95956809532fcf0e2449a6b525' .
-                                        'b16aedf5aa0de657ba637b39',
-                       'ct'  => '42831ec2217774244b7221b784d0d49c' .
-                                        'e3aa212f2c02a4e035c17e2329aca12e' .
-                                        '21d514b25466931c7d8f6a5aac84aa05' .
-                                        '1ba30b396a0aac973d58e091',
-               ),
-               array(
-                       'key' => 'feffe9928665731c6d6a8f9467308308',
-                       'iv'  => 'cafebabefacedbad',
-                       'aad' => 'feedfacedeadbeeffeedfacedeadbeefabaddad2',
-                       'tag' => '3612d2e79e3b0785561be14aaca2fccb',
-                       'pt'  => 'd9313225f88406e5a55909c5aff5269a' .
-                                        '86a7a9531534f7da2e4c303d8a318a72' .
-                                        '1c3c0c95956809532fcf0e2449a6b525' .
-                                        'b16aedf5aa0de657ba637b39',
-                       'ct'  => '61353b4c2806934a777ff51fa22a4755' .
-                                        '699b2a714fcdc6f83766e5f97b6c7423' .
-                                        '73806900e49f24b22b097544d4896b42' .
-                                        '4989b5e1ebac0f07c23f4598'
-               ),
-               array(
-                       'key' => 'feffe9928665731c6d6a8f9467308308',
-                       'iv'  => '9313225df88406e555909c5aff5269aa' .
-                                        '6a7a9538534f7da1e4c303d2a318a728' .
-                                        'c3c0c95156809539fcf0e2429a6b5254' .
-                                        '16aedbf5a0de6a57a637b39b',
-                       'aad' => 'feedfacedeadbeeffeedfacedeadbeefabaddad2',
-                       'tag' => '619cc5aefffe0bfa462af43c1699d050',
-                       'pt'  => 'd9313225f88406e5a55909c5aff5269a' .
-                                        '86a7a9531534f7da2e4c303d8a318a72' .
-                                        '1c3c0c95956809532fcf0e2449a6b525' .
-                                        'b16aedf5aa0de657ba637b39',
-                       'ct'  => '8ce24998625615b603a033aca13fb894' .
-                                        'be9112a5c3a211a8ba262a3cca7e2ca7' .
-                                        '01e4a9a4fba43c90ccdcb281d48c7c6f' .
-                                        'd62875d2aca417034c34aee5',
-               ),
-       )
+    'aes-256-ccm' => array(
+        array(
+            'key' => '1bde3251d41a8b5ea013c195ae128b21' .
+                     '8b3e0306376357077ef1c1c78548b92e',
+            'iv'  => '5b8e40746f6b98e00f1d13ff41',
+            'aad' => 'c17a32514eb6103f3249e076d4c871dc' .
+                     '97e04b286699e54491dc18f6d734d4c0',
+            'tag' => '2024931d73bca480c24a24ece6b6c2bf',
+            'pt'  => '53bd72a97089e312422bf72e242377b3' .
+                     'c6ee3e2075389b999c4ef7f28bd2b80a',
+            'ct'  => '9a5fcccdb4cf04e7293d2775cc76a488' .
+                     'f042382d949b43b7d6bb2b9864786726',
+        ),
+    ),
+    'aes-128-gcm' => array(
+        array(
+            'key' => '00000000000000000000000000000000',
+            'iv'  => '000000000000000000000000',
+            'tag' => '58e2fccefa7e3061367f1d57a4e7455a',
+            'pt'  => '',
+            'ct'  => '',
+        ),
+        array(
+            'key' => '00000000000000000000000000000000',
+            'iv'  => '000000000000000000000000',
+            'tag' => 'ab6e47d42cec13bdf53a67b21257bddf',
+            'pt'  => '00000000000000000000000000000000',
+            'ct'  => '0388dace60b6a392f328c2b971b2fe78',
+        ),
+        array(
+            'key' => 'feffe9928665731c6d6a8f9467308308',
+            'iv'  => 'cafebabefacedbaddecaf888',
+            'tag' => '4d5c2af327cd64a62cf35abd2ba6fab4',
+            'pt'  => 'd9313225f88406e5a55909c5aff5269a' .
+                     '86a7a9531534f7da2e4c303d8a318a72' .
+                     '1c3c0c95956809532fcf0e2449a6b525' .
+                     'b16aedf5aa0de657ba637b391aafd255',
+            'ct'  => '42831ec2217774244b7221b784d0d49c' .
+                     'e3aa212f2c02a4e035c17e2329aca12e' .
+                     '21d514b25466931c7d8f6a5aac84aa05' .
+                     '1ba30b396a0aac973d58e091473f5985',
+        ),
+        array(
+            'key' => 'feffe9928665731c6d6a8f9467308308',
+            'iv'  => 'cafebabefacedbaddecaf888',
+            'aad' => 'feedfacedeadbeeffeedfacedeadbeefabaddad2',
+            'tag' => '5bc94fbc3221a5db94fae95ae7121a47',
+            'pt'  => 'd9313225f88406e5a55909c5aff5269a' .
+                     '86a7a9531534f7da2e4c303d8a318a72' .
+                     '1c3c0c95956809532fcf0e2449a6b525' .
+                     'b16aedf5aa0de657ba637b39',
+            'ct'  => '42831ec2217774244b7221b784d0d49c' .
+                     'e3aa212f2c02a4e035c17e2329aca12e' .
+                     '21d514b25466931c7d8f6a5aac84aa05' .
+                     '1ba30b396a0aac973d58e091',
+        ),
+        array(
+            'key' => 'feffe9928665731c6d6a8f9467308308',
+            'iv'  => 'cafebabefacedbad',
+            'aad' => 'feedfacedeadbeeffeedfacedeadbeefabaddad2',
+            'tag' => '3612d2e79e3b0785561be14aaca2fccb',
+            'pt'  => 'd9313225f88406e5a55909c5aff5269a' .
+                     '86a7a9531534f7da2e4c303d8a318a72' .
+                     '1c3c0c95956809532fcf0e2449a6b525' .
+                     'b16aedf5aa0de657ba637b39',
+            'ct'  => '61353b4c2806934a777ff51fa22a4755' .
+                     '699b2a714fcdc6f83766e5f97b6c7423' .
+                     '73806900e49f24b22b097544d4896b42' .
+                     '4989b5e1ebac0f07c23f4598'
+        ),
+        array(
+            'key' => 'feffe9928665731c6d6a8f9467308308',
+            'iv'  => '9313225df88406e555909c5aff5269aa' .
+                     '6a7a9538534f7da1e4c303d2a318a728' .
+                     'c3c0c95156809539fcf0e2429a6b5254' .
+                     '16aedbf5a0de6a57a637b39b',
+            'aad' => 'feedfacedeadbeeffeedfacedeadbeefabaddad2',
+            'tag' => '619cc5aefffe0bfa462af43c1699d050',
+            'pt'  => 'd9313225f88406e5a55909c5aff5269a' .
+                     '86a7a9531534f7da2e4c303d8a318a72' .
+                     '1c3c0c95956809532fcf0e2449a6b525' .
+                     'b16aedf5aa0de657ba637b39',
+            'ct'  => '8ce24998625615b603a033aca13fb894' .
+                     'be9112a5c3a211a8ba262a3cca7e2ca7' .
+                     '01e4a9a4fba43c90ccdcb281d48c7c6f' .
+                     'd62875d2aca417034c34aee5',
+        ),
+    )
 );
 
 function openssl_get_cipher_tests($method)
 {
-       global $php_openssl_cipher_tests;
+    global $php_openssl_cipher_tests;
 
-       $tests = array();
+    $tests = array();
 
-       foreach ($php_openssl_cipher_tests[$method] as $instance) {
-               $test = array();
-               foreach ($instance as $field_name => $field_value) {
-                       $test[$field_name] = pack("H*", $field_value);
-               }
-               if (!isset($test['aad'])) {
-                       $test['aad'] = "";
-               }
-               $tests[] = $test;
-       }
+    foreach ($php_openssl_cipher_tests[$method] as $instance) {
+        $test = array();
+        foreach ($instance as $field_name => $field_value) {
+            $test[$field_name] = pack("H*", $field_value);
+        }
+        if (!isset($test['aad'])) {
+            $test['aad'] = "";
+        }
+        $tests[] = $test;
+    }
 
-       return $tests;
+    return $tests;
 }
index ccead0aab674528ac32e92f866b67b532dc06c54..4a4b28ca74cae45c7cf38a8f5863cefeca328f7f 100644 (file)
@@ -1,9 +1,7 @@
 --TEST--
 CVE-2013-6420
 --SKIPIF--
-<?php 
-if (!extension_loaded("openssl")) die("skip"); 
-?>
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
 --FILE--
 <?php
 $crt = substr(__FILE__, 0, -4).'.crt';
index e676ddfb999917702c9016d5b9bbbf859c6f2ee9..d1ba849ba6c89a08a3df3e74f3ba59114da85da9 100644 (file)
@@ -1,14 +1,13 @@
 --TEST--
 CVE 2013-4073: Null-byte certificate handling
 --SKIPIF--
-<?php 
-if (!extension_loaded("openssl")) die("skip");
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
 --FILE--
 <?php
 $cert = file_get_contents(__DIR__ . '/cve2013_4073.pem');
 $info = openssl_x509_parse($cert);
 var_export($info['extensions']);
-
+?>
 --EXPECTF--
 array (
   'basicConstraints' => 'CA:FALSE',
index e4c1d20805f5fa30df9c04ee48a934bb3315ce0b..45dcf567131e76476568a4615a9be941365e6d9c 100644 (file)
@@ -5,16 +5,16 @@ openssl_*() with OPENSSL_KEYTYPE_EC
 --FILE--
 <?php
 $args = array(
-       "curve_name" => "secp384r1",
-       "private_key_type" => OPENSSL_KEYTYPE_EC,
+    "curve_name" => "secp384r1",
+    "private_key_type" => OPENSSL_KEYTYPE_EC,
 );
 echo "Testing openssl_pkey_new\n";
 $key1 = openssl_pkey_new($args);
 var_dump($key1);
 
 $argsFailed = array(
-       "curve_name" => "invalid_cuve_name",
-       "private_key_type" => OPENSSL_KEYTYPE_EC,
+    "curve_name" => "invalid_cuve_name",
+    "private_key_type" => OPENSSL_KEYTYPE_EC,
 );
 
 $keyFailed = openssl_pkey_new($argsFailed);
@@ -34,11 +34,11 @@ $d2 = openssl_pkey_get_details($key2);
 var_dump($d1 === $d2);
 
 $dn = array(
-       "countryName" => "BR",
-       "stateOrProvinceName" => "Rio Grande do Sul",
-       "localityName" => "Porto Alegre",
-       "commonName" => "Henrique do N. Angelo",
-       "emailAddress" => "hnangelo@php.net"
+    "countryName" => "BR",
+    "stateOrProvinceName" => "Rio Grande do Sul",
+    "localityName" => "Porto Alegre",
+    "commonName" => "Henrique do N. Angelo",
+    "emailAddress" => "hnangelo@php.net"
 );
 
 // openssl_csr_new creates a new public key pair if the key argument is null
@@ -74,9 +74,9 @@ $curve_names = openssl_get_curve_names();
 var_dump(is_array($curve_names));
 
 foreach ($curve_names as $curve_name) {
-       if ("secp384r1" === $curve_name) {
-               echo "Found secp384r1 in curve names\n";
-       }
+    if ("secp384r1" === $curve_name) {
+        echo "Found secp384r1 in curve names\n";
+    }
 }
 ?>
 --EXPECTF--
index d3f8842e7170c38d20d5c73ce8cd7b288e1be1ff..228a1737640fa306eb0aa235a8c22a5afcbabb26 100644 (file)
@@ -9,19 +9,19 @@ $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
 $config_arg = array('config' => $config);
 
 $dn = array(
-       "countryName" => "BR",
-       "stateOrProvinceName" => "Rio Grande do Sul",
-       "localityName" => "Porto Alegre",
-       "commonName" => "Henrique do N. Angelo",
-       "emailAddress" => "hnangelo@php.net"
+    "countryName" => "BR",
+    "stateOrProvinceName" => "Rio Grande do Sul",
+    "localityName" => "Porto Alegre",
+    "commonName" => "Henrique do N. Angelo",
+    "emailAddress" => "hnangelo@php.net"
 );
 
 $args = array(
-       "digest_alg" => "sha1",
-       "private_key_bits" => 2048,
-       "private_key_type" => OPENSSL_KEYTYPE_DSA,
-       "encrypt_key" => true,
-       "config" => $config,
+    "digest_alg" => "sha1",
+    "private_key_bits" => 2048,
+    "private_key_type" => OPENSSL_KEYTYPE_DSA,
+    "encrypt_key" => true,
+    "config" => $config,
 );
 
 $privkey = openssl_pkey_new($config_arg);
index 1576302ae3f912d42793090d9dc25971e30366e0..ccbd00f49ad5667bd17c2c03db38fc738bf8e046 100644 (file)
@@ -8,28 +8,28 @@ $csrfile = dirname(__FILE__) . "/openssl_csr_export_to_file_csr.tmp";
 $wrong = "wrong";
 $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
 $phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' .
-               'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
-               '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
-               '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
+        'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
+        '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
+        '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
 $dh_details = array('p' => $phex, 'g' => '2');
 $dh = openssl_pkey_new(array(
-       'dh'=> array('p' => hex2bin($phex), 'g' => '2'))
+    'dh'=> array('p' => hex2bin($phex), 'g' => '2'))
 );
 
 $dn = array(
-       "countryName" => "BR",
-       "stateOrProvinceName" => "Rio Grande do Sul",
-       "localityName" => "Porto Alegre",
-       "commonName" => "Henrique do N. Angelo",
-       "emailAddress" => "hnangelo@php.net"
+    "countryName" => "BR",
+    "stateOrProvinceName" => "Rio Grande do Sul",
+    "localityName" => "Porto Alegre",
+    "commonName" => "Henrique do N. Angelo",
+    "emailAddress" => "hnangelo@php.net"
 );
 
 $args = array(
-       "digest_alg" => "sha1",
-       "private_key_bits" => 2048,
-       "private_key_type" => OPENSSL_KEYTYPE_DSA,
-       "encrypt_key" => true,
-       "config" => $config,
+    "digest_alg" => "sha1",
+    "private_key_bits" => 2048,
+    "private_key_type" => OPENSSL_KEYTYPE_DSA,
+    "encrypt_key" => true,
+    "config" => $config,
 );
 
 $privkey_file = 'file://' . dirname(__FILE__) . '/private_rsa_2048.key';
@@ -45,7 +45,7 @@ var_dump(openssl_csr_export_to_file($csr, $csrfile, false));
 <?php
 $csrfile = dirname(__FILE__) . "/openssl_csr_export_to_file_csr.tmp";
 if (file_exists($csrfile)) {
-       unlink($csrfile);
+    unlink($csrfile);
 }
 ?>
 --EXPECTF--
index e8a9b7a0ce2cb38f22538a59a254e664d4e3a353..1958350dfb6efdd68bbb8dbbcec3bfb9dd1507d3 100644 (file)
@@ -8,28 +8,28 @@ if (!extension_loaded("openssl")) die("skip");
 <?php
 $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
 $phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' .
-               'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
-               '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
-               '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
+        'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
+        '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
+        '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
 $dh_details = array('p' => $phex, 'g' => '2');
 $dh = openssl_pkey_new(array(
        'dh'=> array('p' => hex2bin($phex), 'g' => '2'))
 );
 
 $dn = array(
-       "countryName" => "BR",
-       "stateOrProvinceName" => "Rio Grande do Sul",
-       "localityName" => "Porto Alegre",
-       "commonName" => "Henrique do N. Angelo",
-       "emailAddress" => "hnangelo@php.net"
+    "countryName" => "BR",
+    "stateOrProvinceName" => "Rio Grande do Sul",
+    "localityName" => "Porto Alegre",
+    "commonName" => "Henrique do N. Angelo",
+    "emailAddress" => "hnangelo@php.net"
 );
 
 $args = array(
-       "digest_alg" => "sha1",
-       "private_key_bits" => 2048,
-       "private_key_type" => OPENSSL_KEYTYPE_DSA,
-       "encrypt_key" => true,
-       "config" => $config,
+    "digest_alg" => "sha1",
+    "private_key_bits" => 2048,
+    "private_key_type" => OPENSSL_KEYTYPE_DSA,
+    "encrypt_key" => true,
+    "config" => $config,
 );
 
 $privkey_file = 'file://' . dirname(__FILE__) . '/private_rsa_2048.key';
index 6fe41f80e8c354c6710f3c45751f0dfdd9532d70..441ed3339b91956cfdeac06d389efbf3ab836137 100644 (file)
@@ -8,28 +8,28 @@ if (!extension_loaded("openssl")) die("skip");
 <?php
 $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
 $phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' .
-               'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
-               '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
-               '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
+        'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
+        '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
+        '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
 $dh_details = array('p' => $phex, 'g' => '2');
 $dh = openssl_pkey_new(array(
        'dh'=> array('p' => hex2bin($phex), 'g' => '2'))
 );
 
 $dn = array(
-       "countryName" => "BR",
-       "stateOrProvinceName" => "Rio Grande do Sul",
-       "localityName" => "Porto Alegre",
-       "commonName" => "Henrique do N. Angelo",
-       "emailAddress" => "hnangelo@php.net"
+    "countryName" => "BR",
+    "stateOrProvinceName" => "Rio Grande do Sul",
+    "localityName" => "Porto Alegre",
+    "commonName" => "Henrique do N. Angelo",
+    "emailAddress" => "hnangelo@php.net"
 );
 
 $args = array(
-       "digest_alg" => "sha1",
-       "private_key_bits" => 2048,
-       "private_key_type" => OPENSSL_KEYTYPE_DSA,
-       "encrypt_key" => true,
-       "config" => $config,
+    "digest_alg" => "sha1",
+    "private_key_bits" => 2048,
+    "private_key_type" => OPENSSL_KEYTYPE_DSA,
+    "encrypt_key" => true,
+    "config" => $config,
 );
 
 $privkey_file = 'file://' . dirname(__FILE__) . '/private_rsa_2048.key';
index 572bb36695613179631c0a9c7dce544ab1f17a4a..377a3f1f1e47bb9d5ebe7e7f52750546e235b029 100644 (file)
@@ -12,20 +12,20 @@ $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
 $config_arg = array('config' => $config);
 
 $dn = array(
-       "countryName" => "BR",
-       "stateOrProvinceName" => "Rio Grande do Sul",
-       "localityName" => "Porto Alegre",
-       "commonName" => "Henrique do N. Angelo",
-       "emailAddress" => "hnangelo@php.net"
-       );
+    "countryName" => "BR",
+    "stateOrProvinceName" => "Rio Grande do Sul",
+    "localityName" => "Porto Alegre",
+    "commonName" => "Henrique do N. Angelo",
+    "emailAddress" => "hnangelo@php.net"
+);
 
 $args = array(
-       "digest_alg" => "sha1",
-       "private_key_bits" => 2048,
-       "private_key_type" => OPENSSL_KEYTYPE_DSA,
-       "encrypt_key" => true,
-       "config" => $config
-       );
+    "digest_alg" => "sha1",
+    "private_key_bits" => 2048,
+    "private_key_type" => OPENSSL_KEYTYPE_DSA,
+    "encrypt_key" => true,
+    "config" => $config
+);
 
 $privkey = openssl_pkey_new($config_arg);
 $csr = openssl_csr_new($dn, $privkey, $args);
index beb307493863cf00258c8e341c9250795114f565..87b6d4b26465fca7dd51afd74868a8b51f79e602 100644 (file)
@@ -14,10 +14,10 @@ $method = 'aes-256-ccm';
 $tests = openssl_get_cipher_tests($method);
 
 foreach ($tests as $idx => $test) {
-       echo "TEST $idx\n";
-       $pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
-               $test['iv'], $test['tag'], $test['aad']);
-       var_dump($test['pt'] === $pt);
+    echo "TEST $idx\n";
+    $pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
+        $test['iv'], $test['tag'], $test['aad']);
+    var_dump($test['pt'] === $pt);
 }
 
 // no IV
index 11802e9d8e94927bb540b5e0bb71199a9c20d14d..5c243a8fad3432c2b43582106ee516a207791a81 100644 (file)
@@ -14,10 +14,10 @@ $method = 'aes-128-gcm';
 $tests = openssl_get_cipher_tests($method);
 
 foreach ($tests as $idx => $test) {
-       echo "TEST $idx\n";
-       $pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
-               $test['iv'], $test['tag'], $test['aad']);
-       var_dump($test['pt'] === $pt);
+    echo "TEST $idx\n";
+    $pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
+        $test['iv'], $test['tag'], $test['aad']);
+    var_dump($test['pt'] === $pt);
 }
 
 // no IV
index 945e81dfd75ae97bf9cfd24c876f6b337d81aaf8..c8610bc96bc41eb82ccc0eb9803ee746af54856b 100644 (file)
@@ -3,9 +3,9 @@ openssl_encrypt() with CCM cipher algorithm tests
 --SKIPIF--
 <?php
 if (!extension_loaded("openssl"))
-       die("skip");
+    die("skip");
 if (!in_array('aes-256-ccm', openssl_get_cipher_methods()))
-       die("skip: aes-256-ccm not available");
+    die("skip: aes-256-ccm not available");
 ?>
 --FILE--
 <?php
@@ -14,11 +14,11 @@ $method = 'aes-256-ccm';
 $tests = openssl_get_cipher_tests($method);
 
 foreach ($tests as $idx => $test) {
-       echo "TEST $idx\n";
-       $ct = openssl_encrypt($test['pt'], $method, $test['key'], OPENSSL_RAW_DATA,
-               $test['iv'], $tag, $test['aad'], strlen($test['tag']));
-       var_dump($test['ct'] === $ct);
-       var_dump($test['tag'] === $tag);
+    echo "TEST $idx\n";
+    $ct = openssl_encrypt($test['pt'], $method, $test['key'], OPENSSL_RAW_DATA,
+        $test['iv'], $tag, $test['aad'], strlen($test['tag']));
+    var_dump($test['ct'] === $ct);
+    var_dump($test['tag'] === $tag);
 }
 
 // Empty IV error
index 60b48cd091661793907dd95b4e93fb276f46e83c..e2be5109807684b7d29ed66c53bbee74180a1bab 100644 (file)
@@ -14,11 +14,11 @@ $method = 'aes-128-gcm';
 $tests = openssl_get_cipher_tests($method);
 
 foreach ($tests as $idx => $test) {
-       echo "TEST $idx\n";
-       $ct = openssl_encrypt($test['pt'], $method, $test['key'], OPENSSL_RAW_DATA,
-               $test['iv'], $tag, $test['aad'], strlen($test['tag']));
-       var_dump($test['ct'] === $ct);
-       var_dump($test['tag'] === $tag);
+    echo "TEST $idx\n";
+    $ct = openssl_encrypt($test['pt'], $method, $test['key'], OPENSSL_RAW_DATA,
+        $test['iv'], $tag, $test['aad'], strlen($test['tag']));
+    var_dump($test['ct'] === $ct);
+    var_dump($test['tag'] === $tag);
 }
 
 // Empty IV error
index 7817fbafb2f0ced50d464438c1af1fcdd70bd38e..0f1acd7dc527e2b664fe317d91b071c59c0c61ff 100644 (file)
@@ -6,35 +6,35 @@ openssl_error_string() tests
 <?php
 // helper function to check openssl errors
 function expect_openssl_errors($name, $expected_error_codes) {
-       $expected_errors = array_fill_keys($expected_error_codes, false);
-       while (($error_string = openssl_error_string()) !== false) {
-               if (strlen($error_string) > 14) {
-                       $error_code = substr($error_string, 6, 8);
-                       if (isset($expected_errors[$error_code])) {
-                               $expected_errors[$error_code] = true;
-                       }
-               }
-       }
+    $expected_errors = array_fill_keys($expected_error_codes, false);
+    while (($error_string = openssl_error_string()) !== false) {
+        if (strlen($error_string) > 14) {
+            $error_code = substr($error_string, 6, 8);
+            if (isset($expected_errors[$error_code])) {
+                $expected_errors[$error_code] = true;
+            }
+        }
+    }
 
-       $fail = false;
-       foreach ($expected_errors as $error_code => $error_code_found) {
-               if (!$error_code_found) {
-                       $fail = true;
-                       echo "$name: no error code $error_code\n";
-               }
-       }
+    $fail = false;
+    foreach ($expected_errors as $error_code => $error_code_found) {
+        if (!$error_code_found) {
+            $fail = true;
+            echo "$name: no error code $error_code\n";
+        }
+    }
 
-       if (!$fail) {
-               echo "$name: ok\n";
-       }
+    if (!$fail) {
+        echo "$name: ok\n";
+    }
 }
 
 // helper for debugging errors
 function dump_openssl_errors($name) {
-       echo "\n$name\n";
-       while (($error_string = openssl_error_string()) !== false) {
-               var_dump($error_string);
-       }
+    echo "\n$name\n";
+    while (($error_string = openssl_error_string()) !== false) {
+        var_dump($error_string);
+    }
 }
 
 // common output file
@@ -71,10 +71,10 @@ for ($i = 0; $i < 20; $i++) {
 }
 $error_queue_size = 0;
 while (($enc_error_new = openssl_error_string()) !== false) {
-       if ($enc_error_new !== $enc_error) {
-               echo "The new encoding error doesn't match the expected one\n";
-       }
-       ++$error_queue_size;
+    if ($enc_error_new !== $enc_error) {
+        echo "The new encoding error doesn't match the expected one\n";
+    }
+    ++$error_queue_size;
 }
 var_dump($error_queue_size);
 echo "\n";
index 743233579a105cf5d365fee11af675cc24b9c513..430de54dfdda4505cc3616ffb704c3db9616b7f8 100644 (file)
@@ -4,6 +4,7 @@ Testing peer fingerprint on connection
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -44,6 +45,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 Warning: stream_socket_client(): peer_fingerprint match failure in %s on line %d
 
index cf6c0df8ac4f2250515d442c4943dd610c3dd88b..623126fc591b5dd6da41d388d067805a2a97b98e 100644 (file)
@@ -8,11 +8,11 @@ $infile = dirname(__FILE__) . "/cert.crt";
 $privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
 $encrypted = tempnam(sys_get_temp_dir(), "ssl");
 if ($encrypted === false)
-       die("failed to get a temporary filename!");
+    die("failed to get a temporary filename!");
 $outfile = tempnam(sys_get_temp_dir(), "ssl");
 if ($outfile === false) {
-       unlink($outfile);
-       die("failed to get a temporary filename!");
+    unlink($outfile);
+    die("failed to get a temporary filename!");
 }
 
 $single_cert = "file://" . dirname(__FILE__) . "/cert.crt";
@@ -33,12 +33,12 @@ var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $empty, $privkey));
 var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $empty));
 
 if (file_exists($encrypted)) {
-       echo "true\n";
-       unlink($encrypted);
+    echo "true\n";
+    unlink($encrypted);
 }
 if (file_exists($outfile)) {
-       echo "true\n";
-       unlink($outfile);
+    echo "true\n";
+    unlink($outfile);
 }
 ?>
 --EXPECTF--
index e8ba2645507753ad3eb003b2bb1c49c559cb4908..d4105db75acab4686a3eea993fd99eed25198744 100644 (file)
@@ -6,7 +6,7 @@ openssl_pkcs7_decrypt() and invalid parameters
 <?php
 
 function myErrorHandler($errno, $errstr, $errfile, $errline) {
-       var_dump($errstr);
+    var_dump($errstr);
 } 
 set_error_handler("myErrorHandler"); 
 
index 210e5de934c7e8562a90b8b26e7253fe95fbe3fa..2132b402aa4b75e790e3d7af67dd4e98cb8e6a18 100644 (file)
@@ -7,10 +7,10 @@ openssl_pkcs7_encrypt() tests
 $infile = dirname(__FILE__) . "/cert.crt";
 $outfile = tempnam(sys_get_temp_dir(), "ssl");
 if ($outfile === false)
-       die("failed to get a temporary filename!");
+    die("failed to get a temporary filename!");
 $outfile2 = tempnam(sys_get_temp_dir(), "ssl");
 if ($outfile2 === false)
-       die("failed to get a temporary filename!");
+    die("failed to get a temporary filename!");
 
 $single_cert = "file://" . dirname(__FILE__) . "/cert.crt";
 $privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
@@ -37,12 +37,12 @@ var_dump(openssl_pkcs7_encrypt($infile, $outfile, $multi_certs, $headers));
 var_dump(openssl_pkcs7_encrypt($infile, $outfile, array_map('openssl_x509_read', $multi_certs) , $headers));
 
 if (file_exists($outfile)) {
-       echo "true\n";
-       unlink($outfile);
+    echo "true\n";
+    unlink($outfile);
 }
 if (file_exists($outfile2)) {
-       echo "true\n";
-       unlink($outfile2);
+    echo "true\n";
+    unlink($outfile2);
 }
 ?>
 --EXPECTF--
index d6ce799848d25a3bddc4900d04bc1411742398e6..0e29901c7e7ac36a8039d3aa6b694cd189d91adb 100644 (file)
@@ -7,7 +7,7 @@ openssl_pkcs7_sign() tests
 $infile = dirname(__FILE__) . "/cert.crt";
 $outfile = tempnam(sys_get_temp_dir(), "ssl");
 if ($outfile === false) {
-       die("failed to get a temporary filename!");
+    die("failed to get a temporary filename!");
 }
 
 $privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
@@ -32,8 +32,8 @@ var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty));
 var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $wrong, $headers));
 
 if (file_exists($outfile)) {
-       echo "true\n";
-       unlink($outfile);
+    echo "true\n";
+    unlink($outfile);
 }
 ?>
 --EXPECTF--
index b73b1f580cfb2a6e8081359b27b184c72763f3ee..41e67b2a047315e1815472f90bfa3f20c3d2404f 100644 (file)
@@ -10,30 +10,30 @@ function openssl_pkey_test_cmp($expected, $bin_key) {
 
 // RSA
 $nhex = "BBF82F090682CE9C2338AC2B9DA871F7368D07EED41043A440D6B6F07454F51F" .
-               "B8DFBAAF035C02AB61EA48CEEB6FCD4876ED520D60E1EC4619719D8A5B8B807F" .
-               "AFB8E0A3DFC737723EE6B4B7D93A2584EE6A649D060953748834B2454598394E" .
-               "E0AAB12D7B61A51F527A9A41F6C1687FE2537298CA2A8F5946F8E5FD091DBDCB";
+        "B8DFBAAF035C02AB61EA48CEEB6FCD4876ED520D60E1EC4619719D8A5B8B807F" .
+        "AFB8E0A3DFC737723EE6B4B7D93A2584EE6A649D060953748834B2454598394E" .
+        "E0AAB12D7B61A51F527A9A41F6C1687FE2537298CA2A8F5946F8E5FD091DBDCB";
 
 $ehex = "11";
 $dhex = "A5DAFC5341FAF289C4B988DB30C1CDF83F31251E0668B42784813801579641B2" .
-               "9410B3C7998D6BC465745E5C392669D6870DA2C082A939E37FDCB82EC93EDAC9" .
-               "7FF3AD5950ACCFBC111C76F1A9529444E56AAF68C56C092CD38DC3BEF5D20A93" .
-               "9926ED4F74A13EDDFBE1A1CECC4894AF9428C2B7B8883FE4463A4BC85B1CB3C1";
+        "9410B3C7998D6BC465745E5C392669D6870DA2C082A939E37FDCB82EC93EDAC9" .
+        "7FF3AD5950ACCFBC111C76F1A9529444E56AAF68C56C092CD38DC3BEF5D20A93" .
+        "9926ED4F74A13EDDFBE1A1CECC4894AF9428C2B7B8883FE4463A4BC85B1CB3C1";
 
 $phex = "EECFAE81B1B9B3C908810B10A1B5600199EB9F44AEF4FDA493B81A9E3D84F632" .
-               "124EF0236E5D1E3B7E28FAE7AA040A2D5B252176459D1F397541BA2A58FB6599";
+        "124EF0236E5D1E3B7E28FAE7AA040A2D5B252176459D1F397541BA2A58FB6599";
 
 $qhex = "C97FB1F027F453F6341233EAAAD1D9353F6C42D08866B1D05A0F2035028B9D86" .
-               "9840B41666B42E92EA0DA3B43204B5CFCE3352524D0416A5A441E700AF461503";
+        "9840B41666B42E92EA0DA3B43204B5CFCE3352524D0416A5A441E700AF461503";
 
 $rsa= openssl_pkey_new(array(
-       'rsa' => array(
-               'n' => hex2bin($nhex),
-               'e' => hex2bin($ehex),
-               'd' => hex2bin($dhex),
-               'p' => hex2bin($phex),
-               'q' => hex2bin($qhex),
-       )
+    'rsa' => array(
+        'n' => hex2bin($nhex),
+        'e' => hex2bin($ehex),
+        'd' => hex2bin($dhex),
+        'p' => hex2bin($phex),
+        'q' => hex2bin($qhex),
+    )
 ));
 $details = openssl_pkey_get_details($rsa);
 $rsa_details = $details['rsa'];
@@ -45,24 +45,24 @@ openssl_pkey_test_cmp($qhex, $rsa_details['q']);
 
 // DSA
 $phex = '00f8000ae45b2dacb47dd977d58b719d097bdf07cb2c17660ad898518c08' .
-               '1a61659a16daadfaa406a0a994c743df5eda07e36bd0adcad921b77432ff' .
-               '24ccc31e782d647e66768122b578857e9293df78387dc8b44af2a4a3f305' .
-               '1f236b1000a3e31da489c6681b0031f7ec37c2e1091bdb698e7660f135b6' .
-               '996def90090303b7ad';
+        '1a61659a16daadfaa406a0a994c743df5eda07e36bd0adcad921b77432ff' .
+        '24ccc31e782d647e66768122b578857e9293df78387dc8b44af2a4a3f305' .
+        '1f236b1000a3e31da489c6681b0031f7ec37c2e1091bdb698e7660f135b6' .
+        '996def90090303b7ad';
 
 $qhex = '009b3734fc9f7a4a9d6437ec314e0a78c2889af64b';
 
 $ghex = '00b320300a0bc55b8f0ec6edc218e2185250f38fbb8291db8a89227f6e41' .
-               '00d47d6ccb9c7d42fc43280ecc2ed386e81ff65bc5d6a2ae78db7372f5dc' .
-               'f780f4558e7ed3dd0c96a1b40727ac56c5165aed700a3b63997893a1fb21' .
-               '4e882221f0dd9604820dc34e2725dd6901c93e0ca56f6d76d495c332edc5' .
-               'b81747c4c447a941f3';
+        '00d47d6ccb9c7d42fc43280ecc2ed386e81ff65bc5d6a2ae78db7372f5dc' .
+        'f780f4558e7ed3dd0c96a1b40727ac56c5165aed700a3b63997893a1fb21' .
+        '4e882221f0dd9604820dc34e2725dd6901c93e0ca56f6d76d495c332edc5' .
+        'b81747c4c447a941f3';
 $dsa = openssl_pkey_new(array(
-       'dsa' => array(
-               'p' => hex2bin($phex),
-               'q' => hex2bin($qhex),
-               'g' => hex2bin($ghex)
-       )
+    'dsa' => array(
+        'p' => hex2bin($phex),
+        'q' => hex2bin($qhex),
+        'g' => hex2bin($ghex)
+    )
 ));
 $details = openssl_pkey_get_details($dsa);
 $dsa_details = $details['dsa'];
@@ -74,13 +74,13 @@ var_dump(strlen($dsa_details['pub_key']));
 
 // DH
 $phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' .
-               'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
-               '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
-               '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
+        'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
+        '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
+        '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
 
 $dh_details = array('p' => $phex, 'g' => '2');
 $dh = openssl_pkey_new(array(
-       'dh'=> array('p' => hex2bin($phex), 'g' => '2'))
+    'dh'=> array('p' => hex2bin($phex), 'g' => '2'))
 );
 $details = openssl_pkey_get_details($dh);
 $dh_details = $details['dh'];
index a2a51521587df29d937f522ce1e361baec23544e..968537c3c3d96ac76c110b5b46fbf44e2b10ae46 100644 (file)
@@ -10,9 +10,9 @@ $pubkey = "file://" . dirname(__FILE__) . "/public.key";
 $wrong = "wrong";
 
 class test {
-       function __toString() {
-               return "test";
-       }
+    function __toString() {
+        return "test";
+    }
 }
 $obj = new test;
 
index a3c4c57539683695e26a276e60a48031a3e3ca28..e9d47c26b07d3ff33c21b81314ae3d7677d8de0b 100644 (file)
@@ -10,9 +10,9 @@ $pubkey = "file://" . dirname(__FILE__) . "/public.key";
 $wrong = "wrong";
 
 class test {
-       function __toString() {
-               return "test";
-       }
+    function __toString() {
+        return "test";
+    }
 }
 $obj = new test;
 
index ac5a3079a10d619e82df1eed0befaa159ed30d2b..68c11dde2c050ee4ecd8c024b833b2f6f1ba6d3e 100644 (file)
@@ -5,7 +5,7 @@ openssl_random_pseudo_bytes() tests
 --FILE--
 <?php
 for ($i = 0; $i < 10; $i++) {
-       var_dump(bin2hex(openssl_random_pseudo_bytes($i, $strong)));
+    var_dump(bin2hex(openssl_random_pseudo_bytes($i, $strong)));
 }
 
 ?>
index 1e3bd1fd399c7c9eb0e3115d100fa03de3704aae..8871c1016da050eb9572a50039e424a59bad8c07 100644 (file)
@@ -12,39 +12,39 @@ if (!@openssl_pkey_new()) die("skip cannot create private key");
 $key_sizes = array(1024, 2048, 4096);
 $pkeys = array();
 foreach ($key_sizes as $key_size) {
-       $key_file = "file://" . dirname(__FILE__) . "/private_rsa_" . $key_size . ".key";
-       $pkeys[] = openssl_pkey_get_private($key_file);
+    $key_file = "file://" . dirname(__FILE__) . "/private_rsa_" . $key_size . ".key";
+    $pkeys[] = openssl_pkey_get_private($key_file);
 }
 
 
 /* array of available hashings to test */
 $algo = array(
-       OPENSSL_ALGO_MD4,
-       OPENSSL_ALGO_MD5,
-       OPENSSL_ALGO_SHA1,
-       OPENSSL_ALGO_SHA224,
-       OPENSSL_ALGO_SHA256,
-       OPENSSL_ALGO_SHA384,
-       OPENSSL_ALGO_SHA512,
-       OPENSSL_ALGO_RMD160
+    OPENSSL_ALGO_MD4,
+    OPENSSL_ALGO_MD5,
+    OPENSSL_ALGO_SHA1,
+    OPENSSL_ALGO_SHA224,
+    OPENSSL_ALGO_SHA256,
+    OPENSSL_ALGO_SHA384,
+    OPENSSL_ALGO_SHA512,
+    OPENSSL_ALGO_RMD160
 );
 
 /* loop over key sizes for test */
 foreach ($pkeys as $pkey) {
 
-       /* loop to create and verify results */
-       foreach ($algo as $value) {
-               $spkac = openssl_spki_new($pkey, _uuid(), $value);
-               echo openssl_spki_export(preg_replace('/SPKAC=/', '', $spkac));
-       }
+    /* loop to create and verify results */
+    foreach ($algo as $value) {
+        $spkac = openssl_spki_new($pkey, _uuid(), $value);
+        echo openssl_spki_export(preg_replace('/SPKAC=/', '', $spkac));
+    }
 }
 
 /* generate a random challenge */
 function _uuid() {
-       return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
-               mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
-               mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
-               mt_rand(0, 0xffff), mt_rand(0, 0xffff));
+    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
+        mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff));
 }
 
 
index 07a69d3b454ee97a4969dd5beb9b8f7d8c707d46..2b947221bb822c9e40da3706a4b030205380f1f2 100644 (file)
@@ -14,40 +14,40 @@ if (!@openssl_pkey_new()) die("skip cannot create private key");
 $key_sizes = array(1024, 2048, 4096);
 $pkeys = array();
 foreach ($key_sizes as $key_size) {
-       $key_file = "file://" . dirname(__FILE__) . "/private_rsa_" . $key_size . ".key";
-       $pkeys[] = openssl_pkey_get_private($key_file);
+    $key_file = "file://" . dirname(__FILE__) . "/private_rsa_" . $key_size . ".key";
+    $pkeys[] = openssl_pkey_get_private($key_file);
 }
 
 
 /* array of available hashings to test */
 $algo = array(
-       OPENSSL_ALGO_MD4,
-       OPENSSL_ALGO_MD5,
-       OPENSSL_ALGO_SHA1,
-       OPENSSL_ALGO_SHA224,
-       OPENSSL_ALGO_SHA256,
-       OPENSSL_ALGO_SHA384,
-       OPENSSL_ALGO_SHA512,
-       OPENSSL_ALGO_RMD160
+    OPENSSL_ALGO_MD4,
+    OPENSSL_ALGO_MD5,
+    OPENSSL_ALGO_SHA1,
+    OPENSSL_ALGO_SHA224,
+    OPENSSL_ALGO_SHA256,
+    OPENSSL_ALGO_SHA384,
+    OPENSSL_ALGO_SHA512,
+    OPENSSL_ALGO_RMD160
 );
 
 /* loop over key sizes for test */
 foreach ($pkeys as $pkey) {
 
-       /* loop to create and verify results */
-       foreach ($algo as $value) {
-               $spkac = openssl_spki_new($pkey, _uuid(), $value);
-               var_dump(openssl_spki_export_challenge(preg_replace('/SPKAC=/', '', $spkac)));
-               var_dump(openssl_spki_export_challenge($spkac  . 'Make it fail'));
-       }
+    /* loop to create and verify results */
+    foreach ($algo as $value) {
+        $spkac = openssl_spki_new($pkey, _uuid(), $value);
+        var_dump(openssl_spki_export_challenge(preg_replace('/SPKAC=/', '', $spkac)));
+        var_dump(openssl_spki_export_challenge($spkac  . 'Make it fail'));
+    }
 }
 
 /* generate a random challenge */
 function _uuid() {
-       return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
-               mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
-               mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
-               mt_rand(0, 0xffff), mt_rand(0, 0xffff));
+    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
+        mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff));
 }
 
 
index b31d6f91847549bde91d8501c570df0307ac66cc..7f9e02361806d32b89ccdc6b7ab56b4dc6770357 100644 (file)
@@ -11,38 +11,38 @@ if (!extension_loaded("openssl")) die("skip");
 $key_sizes = array(1024, 2048, 4096);
 $pkeys = array();
 foreach ($key_sizes as $key_size) {
-       $key_file = "file://" . dirname(__FILE__) . "/private_rsa_" . $key_size . ".key";
-       $pkeys[] = openssl_pkey_get_private($key_file);
+    $key_file = "file://" . dirname(__FILE__) . "/private_rsa_" . $key_size . ".key";
+    $pkeys[] = openssl_pkey_get_private($key_file);
 }
 
 
 /* array of available hashings to test */
 $algo = array(
-       OPENSSL_ALGO_MD4,
-       OPENSSL_ALGO_MD5,
-       OPENSSL_ALGO_SHA1,
-       OPENSSL_ALGO_SHA224,
-       OPENSSL_ALGO_SHA256,
-       OPENSSL_ALGO_SHA384,
-       OPENSSL_ALGO_SHA512,
-       OPENSSL_ALGO_RMD160
+    OPENSSL_ALGO_MD4,
+    OPENSSL_ALGO_MD5,
+    OPENSSL_ALGO_SHA1,
+    OPENSSL_ALGO_SHA224,
+    OPENSSL_ALGO_SHA256,
+    OPENSSL_ALGO_SHA384,
+    OPENSSL_ALGO_SHA512,
+    OPENSSL_ALGO_RMD160
 );
 
 /* loop over key sizes for test */
 foreach ($pkeys as $pkey) {
 
-       /* loop to create and verify results */
-       foreach ($algo as $value) {
-               var_dump(openssl_spki_new($pkey, _uuid(), $value));
-       }
+    /* loop to create and verify results */
+    foreach ($algo as $value) {
+        var_dump(openssl_spki_new($pkey, _uuid(), $value));
+    }
 }
 
 /* generate a random challenge */
 function _uuid() {
-       return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
-               mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
-               mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
-               mt_rand(0, 0xffff), mt_rand(0, 0xffff));
+    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
+        mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff));
 }
 
 ?>
index 7b56a37e13f7de6b5ff4e172c8f6caa662eb6ca6..4abfc1798c37e87bb6fee48a2ba261b42825c340 100644 (file)
@@ -13,38 +13,38 @@ if (!extension_loaded("openssl")) die("skip");
 $key_sizes = array(1024, 2048, 4096);
 $pkeys = array();
 foreach ($key_sizes as $key_size) {
-       $key_file = "file://" . dirname(__FILE__) . "/private_rsa_" . $key_size . ".key";
-       $pkeys[] = openssl_pkey_get_private($key_file);
+    $key_file = "file://" . dirname(__FILE__) . "/private_rsa_" . $key_size . ".key";
+    $pkeys[] = openssl_pkey_get_private($key_file);
 }
 
 
 /* array of available hashings to test */
 $algo = array(
-       OPENSSL_ALGO_SHA1,
-       OPENSSL_ALGO_SHA224,
-       OPENSSL_ALGO_SHA256,
-       OPENSSL_ALGO_SHA384,
-       OPENSSL_ALGO_SHA512,
-       OPENSSL_ALGO_RMD160
+    OPENSSL_ALGO_SHA1,
+    OPENSSL_ALGO_SHA224,
+    OPENSSL_ALGO_SHA256,
+    OPENSSL_ALGO_SHA384,
+    OPENSSL_ALGO_SHA512,
+    OPENSSL_ALGO_RMD160
 );
 
 /* loop over key sizes for test */
 foreach ($pkeys as $pkey) {
 
-       /* loop to create and verify results */
-       foreach ($algo as $value) {
-               $spkac = openssl_spki_new($pkey, _uuid(), $value);
-               var_dump(openssl_spki_verify(preg_replace('/SPKAC=/', '', $spkac)));
-               var_dump(openssl_spki_verify($spkac . 'Make it fail'));
-       }
+    /* loop to create and verify results */
+    foreach ($algo as $value) {
+        $spkac = openssl_spki_new($pkey, _uuid(), $value);
+        var_dump(openssl_spki_verify(preg_replace('/SPKAC=/', '', $spkac)));
+        var_dump(openssl_spki_verify($spkac . 'Make it fail'));
+    }
 }
 
 /* generate a random challenge */
 function _uuid() {
-       return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
-               mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
-               mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
-               mt_rand(0, 0xffff), mt_rand(0, 0xffff));
+    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
+        mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff));
 }
 
 
index 4177bd7798fa1bc0340e97b3c1fb260e25d45143..94cb4fa48c3f8c6a1dae17c53bab424c913e3736 100644 (file)
@@ -19,7 +19,7 @@ var_dump(openssl_x509_export($d, $output4)); // read cert from a resource
 var_dump(openssl_x509_export($e, $output5)); // read an array, fails
 
 if (PHP_EOL !== "\n") {
-       $a = str_replace(PHP_EOL, "\n", $a);
+    $a = str_replace(PHP_EOL, "\n", $a);
 }
 
 var_dump(strcmp($output, $a));
index 68ba93230d7e16c3e60c2f060e16d084fc2b7dd4..04e6d9e565706fe9e38d6163ec98760f4f2c7df2 100644 (file)
@@ -25,7 +25,7 @@ var_dump($exists = file_exists($outfilename));
 <?php
 $outfilename = dirname(__FILE__) . "/openssl_x509_export_to_file__outfilename.tmp";
 if (file_exists($outfilename)) {
-       unlink($outfilename);
+    unlink($outfilename);
 }
 ?>
 --EXPECTF--
index add65cb3e302d6b797c89af1749fec1971ff6ded..f47255ac1b400f44f905ae78de701b6850eb833c 100644 (file)
@@ -1,9 +1,7 @@
 --TEST--
 openssl_x509_fingerprint() tests
 --SKIPIF--
-<?php
-if (!extension_loaded("openssl")) die("skip");
-?>
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
 --FILE--
 <?php
 
index 65cc062e403749f7f179513ab7e5825e4e592434..8c04b791fc097ca7ef31e0d1229f824aba940f13 100644 (file)
@@ -1,9 +1,7 @@
 --TEST--
 openssl_x509_parse() tests
 --SKIPIF--
-<?php if (!extension_loaded("openssl")) print "skip"; 
-if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0");
-?>
+<?php if (!extension_loaded("openssl")) print "skip"; ?>
 --FILE--
 <?php
 $cert = "file://" . dirname(__FILE__) . "/cert.crt";
index 6aff34ddd802dc45965b60532df9d904d04074e3..3abc191667574e2cf1313e20a6319bf20dc19f55 100644 (file)
@@ -4,6 +4,7 @@ Peer verification enabled for client streams
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -54,6 +55,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 bool(false)
 bool(false)
index 0e1f30cb649508376f3422691ae819e9aeda4224..f048c4e0f1545b6eb95b2d0c2be2aa3b4c03a82c 100644 (file)
@@ -4,6 +4,7 @@ Peer verification matches SAN names
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -39,6 +40,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 
index a09d7e878071f037193761aa26c7f669faa4b23a..caa3a87075eaa59da66836e80b85c431b649ac18 100644 (file)
@@ -4,7 +4,7 @@ Capture SSL session meta array in stream context
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
-if (OPENSSL_VERSION_NUMBER < 0x10001001) die("skip OpenSSLv1.0.1 required");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -53,6 +53,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 string(5) "TLSv1"
 string(7) "TLSv1.1"
index d55c5d69a1b711b39e2761ff652a0184e887259b..76ea4f7325af08d6c4c66d252b6c57dab5c0c61d 100644 (file)
@@ -3,6 +3,8 @@ sni_server
 --SKIPIF--
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
+if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -54,6 +56,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 string(%d) "cs.php.net"
 string(%d) "uk.php.net"
index 1ba930936f742fa87b490d8546a986f17018011c..d65220c12814406fc79295d65a87181a00e217e2 100644 (file)
@@ -4,6 +4,7 @@ Basic bitwise stream crypto context flag assignment
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -41,6 +42,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 resource(%d) of type (stream)
index e57f2b7069874192f945808e6cc1ed8e96029200..379736dd81ac0652b816cfde51f955721cd7d161 100644 (file)
@@ -4,7 +4,7 @@ TLSv1.1 and TLSv1.2 bitwise stream crypto flag assignment
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
-if (OPENSSL_VERSION_NUMBER < 0x10001001) die("skip OpenSSLv1.0.1 required");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -49,6 +49,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 resource(%d) of type (stream)
index e51a2bab3e0dc289d9d4afcfb682cd97c1f27a3b..8ebeb9a30443fd36f6b052e1aa7f61f74134122c 100644 (file)
@@ -4,6 +4,7 @@ Specific protocol method specification
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -53,6 +54,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 bool(false)
index d355505e541e0dc12572d0f459babe2e5f6cf1dd..f0353351a23a11296e0fb751fc116c9a408b36ef 100644 (file)
@@ -7,7 +7,7 @@ if (!function_exists("proc_open")) die("skip no proc_open");
 exec('openssl help', $out, $code);
 if ($code > 0) die("skip couldn't locate openssl binary");
 if(substr(PHP_OS, 0, 3) == 'WIN') {
-   die('skip not suitable for Windows');
+    die('skip not suitable for Windows');
 }
 ?>
 --FILE--
@@ -85,5 +85,6 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($serverCode, $clientCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
index 4aecf8c7446ad8f3446b8e3ab0e9119d650bb2b5..e39994b12f0bb35006768cf3925bf5caa1259f5e 100644 (file)
@@ -4,6 +4,7 @@ Verify host name by default in client transfers
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -35,5 +36,6 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
index cfee8b1c07ab4052c3f9c0d922deb1ae27d59acb..01081bf5a0c835d035b32a5ec228fdaf87552fe0 100644 (file)
@@ -4,6 +4,7 @@ Allow host name mismatch when "verify_host" disabled
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -36,5 +37,6 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
index e4e083f7f607f64912f111485e564ba740c737e9..3865453262b70a52cd415549938d8bf8c1de03e0 100644 (file)
@@ -4,6 +4,7 @@ Host name mismatch triggers error
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -35,6 +36,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 Warning: stream_socket_client(): Peer certificate CN=`bug54992.local' did not match expected CN=`127.0.0.1' in %s on line %d
 
index f8ec86498da8f2650496ef432b64675a16d0530b..19d08f38a3ec4cc48c52a3f9a2edabf05b41f926 100644 (file)
@@ -4,7 +4,7 @@ Specific crypto method for ssl:// transports.
 <?php
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
-if (OPENSSL_VERSION_NUMBER < 0x10001001) die("skip OpenSSLv1.0.1 required");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -49,5 +49,6 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 Hello World!
index c0477dfe329f92a5a050f3b7144b153ad1aeed54..952a288305826bf980a4c8f63b24d374001e6d66 100644 (file)
@@ -4,6 +4,7 @@ tlsv1.0 stream wrapper
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -41,6 +42,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 bool(false)
index a5dba299ec5b237c1961ad0ac6291c81ffd19698..eedf54fea74ddb6a398285614df6f25b09ab9d4b 100644 (file)
@@ -4,7 +4,7 @@ tlsv1.1 stream wrapper
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
-if (OPENSSL_VERSION_NUMBER < 0x10001001) die("skip OpenSSL 1.0.1 required");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -42,6 +42,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 bool(false)
index 42980cf6615e5cb8d4ed50355b85227fa9facb16..3d7b3ba26cbdfdb4427c7a0ed830ba3865c1ea85 100644 (file)
@@ -4,7 +4,7 @@ tlsv1.2 stream wrapper
 <?php 
 if (!extension_loaded("openssl")) die("skip openssl not loaded");
 if (!function_exists("proc_open")) die("skip no proc_open");
-if (OPENSSL_VERSION_NUMBER < 0x10001001) die("skip OpenSSL 1.0.1 required");
+?>
 --FILE--
 <?php
 $serverCode = <<<'CODE'
@@ -42,6 +42,7 @@ CODE;
 
 include 'ServerClientTestCase.inc';
 ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
+?>
 --EXPECTF--
 resource(%d) of type (stream)
 bool(false)