MCPcopy Create free account
hub / github.com/RustCrypto/RSA / verify_algorithm_id

Function verify_algorithm_id

src/encoding.rs:157–173  ·  view source on GitHub ↗

Verify that the `AlgorithmIdentifier` for a key is correct.

(algorithm: &spki::AlgorithmIdentifierRef)

Source from the content-addressed store, hash-verified

155
156/// Verify that the `AlgorithmIdentifier` for a key is correct.
157pub(crate) fn verify_algorithm_id(algorithm: &spki::AlgorithmIdentifierRef) -> spki::Result<()> {
158 match algorithm.oid {
159 pkcs1::ALGORITHM_OID => {
160 if algorithm.parameters_any()? != pkcs8::der::asn1::Null.into() {
161 return Err(spki::Error::KeyMalformed);
162 }
163 }
164 ID_RSASSA_PSS => {
165 if algorithm.parameters.is_some() {
166 return Err(spki::Error::KeyMalformed);
167 }
168 }
169 _ => return Err(spki::Error::OidUnknown { oid: algorithm.oid }),
170 };
171
172 Ok(())
173}
174
175impl TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for PrivateKey {
176 type Error = pkcs8::Error;

Callers 1

try_fromMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected