From ecfa79f6f9a980e14f9ba61d4256c8b7ac84dfdf Mon Sep 17 00:00:00 2001 From: Joni Eskelinen Date: Wed, 15 May 2019 14:41:57 +0300 Subject: [PATCH] Tweak formatting --- lib/PKCS8/EncryptedPrivateKeyInfo.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/PKCS8/EncryptedPrivateKeyInfo.php b/lib/PKCS8/EncryptedPrivateKeyInfo.php index e421569..00dce72 100644 --- a/lib/PKCS8/EncryptedPrivateKeyInfo.php +++ b/lib/PKCS8/EncryptedPrivateKeyInfo.php @@ -15,7 +15,7 @@ use Sop\PKCS5\PBEScheme; /** - * Implements PKCS #8 EncryptedPrivateKeyInfo ASN.1 type. + * Implements PKCS #8 *EncryptedPrivateKeyInfo* ASN.1 type. * * @see https://tools.ietf.org/html/rfc5208#section-6 */ @@ -41,8 +41,7 @@ class EncryptedPrivateKeyInfo * @param EncryptionAlgorithmIdentifier $algo * @param string $data Ciphertext */ - protected function __construct(EncryptionAlgorithmIdentifier $algo, - string $data) + protected function __construct(EncryptionAlgorithmIdentifier $algo, string $data) { $this->_algo = $algo; $this->_data = $data; @@ -64,9 +63,7 @@ public static function fromASN1(Sequence $seq): self throw new \UnexpectedValueException( sprintf('Algorithm %s not supported.', $algo->name())); } - $data = $seq->at(1) - ->asOctetString() - ->string(); + $data = $seq->at(1)->asOctetString()->string(); return new self($algo, $data); } @@ -93,7 +90,7 @@ public static function fromDER(string $data): self */ public static function fromPEM(PEM $pem): self { - if (PEM::TYPE_ENCRYPTED_PRIVATE_KEY != $pem->type()) { + if (PEM::TYPE_ENCRYPTED_PRIVATE_KEY !== $pem->type()) { throw new \UnexpectedValueException('Invalid PEM type.'); } return self::fromDER($pem->data()); @@ -150,8 +147,7 @@ public function toPEM(): PEM } /** - * Decrypt PrivateKeyInfo from the encrypted data using password based - * encryption. + * Decrypt PrivateKeyInfo from the encrypted data using password based encryption. * * @param string $password Password * @param null|Crypto $crypto Crypto engine, use default if not set @@ -163,9 +159,8 @@ public function decryptWithPassword(string $password, ?Crypto $crypto = null): P $ai = $this->_algo; if (!($ai instanceof PBEAlgorithmIdentifier)) { throw new \RuntimeException( - sprintf( - 'Algorithm %s does not support' . - ' password based encryption.', $ai->name())); + sprintf('Algorithm %s does not support' . + ' password based encryption.', $ai->name())); } try { $scheme = PBEScheme::fromAlgorithmIdentifier($ai, $crypto); @@ -178,8 +173,7 @@ public function decryptWithPassword(string $password, ?Crypto $crypto = null): P } /** - * Initialize by encrypting a PrivateKeyInfo using password based - * encryption. + * Initialize by encrypting a PrivateKeyInfo using password based encryption. * * @param PrivateKeyInfo $pki Private key info * @param PBEAlgorithmIdentifier $algo Encryption algorithm