From f5858a6a1d02d5899f1fce92cbdb06f3b079529d Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 14 Feb 2022 19:15:20 -0600 Subject: [PATCH] Tests/RSA: add test for changing PKCS8 encryption parameters --- tests/Unit/Crypt/RSA/CreateKeyTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Unit/Crypt/RSA/CreateKeyTest.php b/tests/Unit/Crypt/RSA/CreateKeyTest.php index b6c030be..fe3f59ef 100644 --- a/tests/Unit/Crypt/RSA/CreateKeyTest.php +++ b/tests/Unit/Crypt/RSA/CreateKeyTest.php @@ -8,6 +8,7 @@ use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\RSA\Formats\Keys\PKCS1; +use phpseclib3\Crypt\RSA\Formats\Keys\PKCS8; use phpseclib3\Crypt\RSA\PrivateKey; use phpseclib3\Crypt\RSA\PublicKey; @@ -66,4 +67,13 @@ class Unit_Crypt_RSA_CreateKeyTestRSA extends PhpseclibTestCase RSA::useBestEngine(); } + + public function test3DESPKCS8Encryption() + { + $key = RSA::createKey(768) + ->withPassword('demo') + ->toString('PKCS8', ['encryptionAlgorithm' => 'pbeWithSHAAnd3-KeyTripleDES-CBC']); + $actual = PKCS8::extractEncryptionAlgorithm($key)['algorithm']; + $this->assertSame($actual, 'pbeWithSHAAnd3-KeyTripleDES-CBC'); + } }