Skip to content

Commit d23a8b3

Browse files
committed
Skip some tests if cipher not available
1 parent 1cf4fb7 commit d23a8b3

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

ext/openssl/tests/bug71917.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Bug #71917: openssl_open() returns junk on envelope < 16 bytes
33
--EXTENSIONS--
44
openssl
5+
--SKIPIF--
6+
<?php
7+
if (!in_array('rc4', openssl_get_cipher_methods())) die('skip rc4 not available');
8+
?>
59
--FILE--
610
<?php
711
function test($envkey) {

ext/openssl/tests/bug72362.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Bug #72362: OpenSSL Blowfish encryption is incorrect for short keys
33
--EXTENSIONS--
44
openssl
5+
--SKIPIF--
6+
<?php
7+
if (!in_array('bf-ecb', openssl_get_cipher_methods())) die('skip bf-ecb not available');
8+
?>
59
--FILE--
610
<?php
711
var_dump(

ext/openssl/tests/openssl_decrypt_basic.phpt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ $padded_data = $data . str_repeat(' ', 16 - (strlen($data) % 16));
2424
$encrypted = openssl_encrypt($padded_data, $method, $password, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv);
2525
$output = openssl_decrypt($encrypted, $method, $password, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv);
2626
var_dump(rtrim($output));
27-
// if we want to prefer variable length cipher setting
28-
$encrypted = openssl_encrypt($data, "bf-ecb", $password, OPENSSL_DONT_ZERO_PAD_KEY);
29-
$output = openssl_decrypt($encrypted, "bf-ecb", $password, OPENSSL_DONT_ZERO_PAD_KEY);
30-
var_dump($output);
27+
28+
if (in_array("bf-ecb", openssl_get_cipher_methods())) {
29+
// if we want to prefer variable length cipher setting
30+
$encrypted = openssl_encrypt($data, "bf-ecb", $password, OPENSSL_DONT_ZERO_PAD_KEY);
31+
$output = openssl_decrypt($encrypted, "bf-ecb", $password, OPENSSL_DONT_ZERO_PAD_KEY);
32+
var_dump($output === $data);
33+
} else {
34+
var_dump(true);
35+
}
3136

3237
// It's okay to pass $tag for a non-authenticated cipher.
3338
// It will be populated with null in that case.
@@ -39,5 +44,5 @@ var_dump($tag);
3944
string(45) "openssl_encrypt() and openssl_decrypt() tests"
4045
string(45) "openssl_encrypt() and openssl_decrypt() tests"
4146
string(45) "openssl_encrypt() and openssl_decrypt() tests"
42-
string(45) "openssl_encrypt() and openssl_decrypt() tests"
47+
bool(true)
4348
NULL

0 commit comments

Comments
 (0)