Skip to content

Commit

Permalink
use verify_algorithm_id for pss::SigningKey decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
LWEdslev committed Mar 27, 2024
1 parent 645bc55 commit c925b49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use zeroize::Zeroizing;
pub const ID_RSASSA_PSS: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.10");

/// Verify that the `AlgorithmIdentifier` for a key is correct.
fn verify_algorithm_id(algorithm: &pkcs8::AlgorithmIdentifierRef) -> pkcs8::spki::Result<()> {
pub(crate) fn verify_algorithm_id(algorithm: &pkcs8::AlgorithmIdentifierRef) -> pkcs8::spki::Result<()> {
match algorithm.oid {
pkcs1::ALGORITHM_OID => {
if algorithm.parameters_any()? != pkcs8::der::asn1::Null.into() {
Expand Down
6 changes: 2 additions & 4 deletions src/pss/signing_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{get_pss_signature_algo_id, sign_digest, Signature, VerifyingKey};
use crate::encoding::ID_RSASSA_PSS;
use crate::encoding::verify_algorithm_id;
use crate::{Result, RsaPrivateKey};
use const_oid::AssociatedOid;
use core::marker::PhantomData;
Expand Down Expand Up @@ -232,9 +232,7 @@ where
type Error = pkcs8::Error;

fn try_from(private_key_info: pkcs8::PrivateKeyInfo<'_>) -> pkcs8::Result<Self> {
private_key_info
.algorithm
.assert_algorithm_oid(ID_RSASSA_PSS)?;
verify_algorithm_id(&private_key_info.algorithm)?;
RsaPrivateKey::try_from(private_key_info).map(Self::new)
}
}
Expand Down

0 comments on commit c925b49

Please sign in to comment.