Verify that the `AlgorithmIdentifier` for a key is correct.
(algorithm: &spki::AlgorithmIdentifierRef)
| 155 | |
| 156 | /// Verify that the `AlgorithmIdentifier` for a key is correct. |
| 157 | pub(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 | |
| 175 | impl TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for PrivateKey { |
| 176 | type Error = pkcs8::Error; |