From 0be984fd805d8c117612ceae039a343c6e813c16 Mon Sep 17 00:00:00 2001 From: Bastien Miclo Date: Wed, 6 Jan 2021 23:57:47 +0100 Subject: [PATCH 1/4] Fix encodeDER() PHPDoc --- phpseclib/File/ASN1.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index cd4247c1..3055a495 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -826,7 +826,7 @@ abstract class ASN1 * * "Special" mappings can be applied via $special. * - * @param string $source + * @param Element|string|array $source * @param array $mapping * @param array $special * @return string @@ -841,7 +841,7 @@ abstract class ASN1 /** * ASN.1 Encode (Helper function) * - * @param string $source + * @param Element|string|array $source * @param array $mapping * @param int $idx * @param array $special From 619253cdfbadd5ff44f10d459aab3da80a89d35c Mon Sep 17 00:00:00 2001 From: Bastien Miclo Date: Thu, 7 Jan 2021 00:00:26 +0100 Subject: [PATCH 2/4] Allow tests to pass even on Windows with git core.autocrlf on --- tests/Unit/Crypt/DHTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Unit/Crypt/DHTest.php b/tests/Unit/Crypt/DHTest.php index e6e15ba3..cf911b61 100644 --- a/tests/Unit/Crypt/DHTest.php +++ b/tests/Unit/Crypt/DHTest.php @@ -19,11 +19,11 @@ class Unit_Crypt_DHTest extends PhpseclibTestCase { $a = DH::createParameters('diffie-hellman-group1-sha1'); $a = str_replace("\r\n", "\n", trim($a)); - $b = '-----BEGIN DH PARAMETERS----- + $b = str_replace("\r\n", "\n", '-----BEGIN DH PARAMETERS----- MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL /1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC ------END DH PARAMETERS-----'; +-----END DH PARAMETERS-----'); $this->assertSame($b, "$a"); } @@ -43,11 +43,11 @@ Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL $base = new BigInteger(2); $a = DH::createParameters($prime, $base); $a = str_replace("\r\n", "\n", trim($a)); - $b = '-----BEGIN DH PARAMETERS----- + $b = str_replace("\r\n", "\n", '-----BEGIN DH PARAMETERS----- MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL /1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC ------END DH PARAMETERS-----'; +-----END DH PARAMETERS-----'); $this->assertSame($b, "$a"); } From cce21f077fb73ab9eb511ae6d7ae31e3f77fae43 Mon Sep 17 00:00:00 2001 From: Bastien Miclo Date: Thu, 7 Jan 2021 22:05:17 +0100 Subject: [PATCH 3/4] Allow to pass end date as DateTime --- phpseclib/File/X509.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 874bcb11..ba6a0481 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -3061,7 +3061,7 @@ class X509 -- http://tools.ietf.org/html/rfc5280#section-4.1.2.5 */ - if (strtolower($date) == 'lifetime') { + if (is_string($date) && strtolower($date) === 'lifetime') { $temp = '99991231235959Z'; $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . ASN1::encodeLength(strlen($temp)) . $temp; $this->endDate = new Element($temp); From b82766486a4f1d2c4b35b4d88f5f95bc78ee6cf4 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Tue, 12 Jan 2021 16:20:41 +0100 Subject: [PATCH 4/4] Fix imports in PublicKeyLoader --- phpseclib/Crypt/PublicKeyLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Crypt/PublicKeyLoader.php b/phpseclib/Crypt/PublicKeyLoader.php index db4abf7c..c7c7e0af 100644 --- a/phpseclib/Crypt/PublicKeyLoader.php +++ b/phpseclib/Crypt/PublicKeyLoader.php @@ -15,8 +15,8 @@ namespace phpseclib3\Crypt; +use phpseclib3\Crypt\Common\AsymmetricKey; use phpseclib3\Exception\NoKeyLoadedException; -use phpseclib3\Crypt\Common\PrivateKey; use phpseclib3\File\X509; /**