Skip to content

pss: remove redundant verify_algorithm_id call in SigningKey::try_from#660

Open
VolodymyrBg wants to merge 1 commit intoRustCrypto:masterfrom
VolodymyrBg:redundant-verify-algorithm-id
Open

pss: remove redundant verify_algorithm_id call in SigningKey::try_from#660
VolodymyrBg wants to merge 1 commit intoRustCrypto:masterfrom
VolodymyrBg:redundant-verify-algorithm-id

Conversation

@VolodymyrBg
Copy link

The explicit [verify_algorithm_id()]

RSA/src/encoding.rs

Lines 152 to 169 in 1e94064

/// Verify that the `AlgorithmIdentifier` for a key is correct.
pub(crate) fn verify_algorithm_id(algorithm: &spki::AlgorithmIdentifierRef) -> spki::Result<()> {
match algorithm.oid {
pkcs1::ALGORITHM_OID => {
if algorithm.parameters_any()? != pkcs8::der::asn1::Null.into() {
return Err(spki::Error::KeyMalformed);
}
}
ID_RSASSA_PSS => {
if algorithm.parameters.is_some() {
return Err(spki::Error::KeyMalformed);
}
}
_ => return Err(spki::Error::OidUnknown { oid: algorithm.oid }),
};
Ok(())
}
call before RsaPrivateKey::try_from() was redundant because RsaPrivateKey::try_from() already performs the same
check internally. This matches the pattern used in [BlindedSigningKey]
pub struct BlindedSigningKey<D>
where
D: Digest,
{
inner: RsaPrivateKey,
salt_len: usize,
phantom: PhantomData<D>,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant