1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
Description: Adapt unit tests so that they can run with OpenSSL3
With OpenSSL3, some ciphers are not available anymore when the legacy
provider is not enabled. Especially, 'des' cypher is provided by the legacy
provider in OpenSSL3, and the legacy provider is not enabled by default.
So change the cypher to "tripledes" instead of "des".
.
When running OpenSSL < 3, use the old behavior
Forwarded: https://github.com/bcit-ci/CodeIgniter/issues/6171
Author: Fab Stz <fabstz-it@yahoo.fr>
Last-Update: 2023-06-24
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -208,7 +208,11 @@
$this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
// Try DES in ECB mode, just for the sake of changing stuff
- $this->encryption->initialize(array('cipher' => 'des', 'mode' => 'ecb', 'key' => substr($key, 0, 8)));
+ if(OPENSSL_VERSION_NUMBER >= 0x3000000f) {
+ $this->encryption->initialize(array('cipher' => 'tripledes', 'mode' => 'ecb', 'key' => substr($key, 0, 8)));
+ } else {
+ $this->encryption->initialize(array('cipher' => 'des', 'mode' => 'ecb', 'key' => substr($key, 0, 8)));
+ }
$this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
}
|