Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RSASSA-PSS encryption OID to AlgorithmIdentifier #51

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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