Skip to content

Commit

Permalink
Extend and speed up pkey export tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bukka committed Oct 30, 2017
1 parent e78e839 commit d8ccffa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
11 changes: 2 additions & 9 deletions ext/openssl/tests/001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ if (!@openssl_pkey_new()) die("skip cannot create private key");
<?php
echo "Creating private key\n";

/* stack up some entropy; performance is not critical,
* and being slow will most likely even help the test.
*/
for ($z = "", $i = 0; $i < 1024; $i++) {
$z .= $i * $i;
if (function_exists("usleep"))
usleep($i);
}

$conf = array('config' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'openssl.cnf');
$privkey = openssl_pkey_new($conf);

Expand All @@ -32,6 +23,7 @@ if ($key_file_name === false)
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");
var_dump(is_resource($privkey));

echo "Load key from file - array syntax\n";

Expand Down Expand Up @@ -69,6 +61,7 @@ echo "OK!\n";
--EXPECT--
Creating private key
Export key to file
bool(true)
Load key from file - array syntax
Load key using direct syntax
Load key manually and use string syntax
Expand Down
3 changes: 2 additions & 1 deletion ext/openssl/tests/openssl_pkey_export_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $tempname = tempnam(sys_get_temp_dir(), 'openssl_ec');
var_dump(openssl_pkey_export_to_file($key, $tempname, NULL, $config_arg));
$details = openssl_pkey_get_details(openssl_pkey_get_private('file://' . $tempname));
var_dump(OPENSSL_KEYTYPE_EC === $details['type']);

var_dump(is_resource($key));
// Clean the temporary file
@unlink($tempname);

Expand All @@ -52,3 +52,4 @@ resource(%d) of type (OpenSSL key)
bool(true)
bool(true)
bool(true)
bool(true)

0 comments on commit d8ccffa

Please sign in to comment.