Skip to content

Commit

Permalink
Adhere strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
sop committed Nov 28, 2017
1 parent 7ca91ec commit 8f52d72
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/PKCS8/EncryptedPrivateKeyInfo.php
Expand Up @@ -4,6 +4,7 @@

namespace Sop\PKCS8;

use ASN1\Type\UnspecifiedType;
use ASN1\Type\Constructed\Sequence;
use ASN1\Type\Primitive\OctetString;
use Sop\CryptoBridge\Crypto;
Expand Down Expand Up @@ -75,7 +76,7 @@ public static function fromASN1(Sequence $seq): self
*/
public static function fromDER(string $data): self
{
return self::fromASN1(Sequence::fromDER($data));
return self::fromASN1(UnspecifiedType::fromDER($data)->asSequence());
}

/**
Expand Down Expand Up @@ -163,7 +164,8 @@ public function decryptWithPassword(string $password, Crypto $crypto = null): Pr
try {
$scheme = PBEScheme::fromAlgorithmIdentifier($ai, $crypto);
$data = $scheme->decrypt($this->_data, $password);
return PrivateKeyInfo::fromASN1(Sequence::fromDER($data));
return PrivateKeyInfo::fromASN1(
UnspecifiedType::fromDER($data)->asSequence());
} catch (\RuntimeException $e) {
throw new \RuntimeException("Failed to decrypt private key.", 0, $e);
}
Expand Down

0 comments on commit 8f52d72

Please sign in to comment.