Skip to content

Commit

Permalink
Add RSASSA-PSS encryption OID to AlgorithmIdentifier
Browse files Browse the repository at this point in the history
The Object Identifier (OID) for the RSASSA-PSS encryption algorithm has been added to the AlgorithmIdentifier class. Adjustments have also been made to handle this additional case in OneAsymmetricKey. This enhances support for encryption variety and expands compatibility.
  • Loading branch information
Spomky committed Mar 30, 2024
1 parent ac80fe2 commit 2fea410
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 4 additions & 2 deletions src/CryptoTypes/Asymmetric/OneAsymmetricKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.');
}

/**
Expand Down

0 comments on commit 2fea410

Please sign in to comment.