diff --git a/src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php b/src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php index 71226d4..c78e174 100644 --- a/src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php +++ b/src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php @@ -29,6 +29,8 @@ abstract class AlgorithmIdentifier implements AlgorithmIdentifierType final public const OID_SHA1_WITH_RSA_ENCRYPTION = '1.2.840.113549.1.1.5'; + final public const OID_RSASSA_PSS_ENCRYPTION = '1.2.840.113549.1.1.10'; + final public const OID_SHA256_WITH_RSA_ENCRYPTION = '1.2.840.113549.1.1.11'; final public const OID_SHA384_WITH_RSA_ENCRYPTION = '1.2.840.113549.1.1.12'; diff --git a/src/CryptoTypes/Asymmetric/OneAsymmetricKey.php b/src/CryptoTypes/Asymmetric/OneAsymmetricKey.php index 0ead218..ec231a2 100644 --- a/src/CryptoTypes/Asymmetric/OneAsymmetricKey.php +++ b/src/CryptoTypes/Asymmetric/OneAsymmetricKey.php @@ -181,8 +181,9 @@ public function privateKey(): PrivateKey { $algo = $this->algorithmIdentifier(); switch ($algo->oid()) { - // RSA + // RSA (including RSASSA-PSS) case AlgorithmIdentifier::OID_RSA_ENCRYPTION: + case AlgorithmIdentifier::OID_RSASSA_PSS_ENCRYPTION: return RSAPrivateKey::fromDER($this->privateKeyData); // elliptic curve case AlgorithmIdentifier::OID_EC_PUBLIC_KEY: @@ -225,8 +226,9 @@ public function privateKey(): PrivateKey return X448PrivateKey::fromOctetString(OctetString::fromDER($this->privateKeyData), $pubkey) ->withVersion($this->version) ->withAttributes($this->attributes); + default: + throw new RuntimeException('Private key ' . $algo->name() . ' not supported.'); } - throw new RuntimeException('Private key ' . $algo->name() . ' not supported.'); } /**