/// Parse the ASN.1 DER-encoded algorithm identifier in `asn1` into a
/// `SignatureScheme`. This will fail if `asn1` is not a known signature scheme.
Parse the ASN.1 DER-encoded algorithm identifier in `asn1` into a
`SignatureScheme`. This will fail if `asn1` is not a known signature scheme.
Parse the ASN . 1 DER - encoded algorithm identifier in ` asn1 ` into a ` SignatureScheme ` . This will fail if ` asn1 ` is not a known signature scheme .
pub fn parse_algorithmid(asn1: &[u8]) -> Result<SignatureScheme, Error> {
    match asn1 {
        include_bytes!("data/alg-rsa-pkcs1-sha256.der") => Ok(SignatureScheme::RSA_PKCS1_SHA256),
        include_bytes!("data/alg-rsa-pkcs1-sha384.der") => Ok(SignatureScheme::RSA_PKCS1_SHA384),
        include_bytes!("data/alg-rsa-pkcs1-sha512.der") => Ok(SignatureScheme::RSA_PKCS1_SHA512),
        include_bytes!("data/alg-ecdsa-sha256.der") => Ok(SignatureScheme::ECDSA_NISTP256_SHA256),
        include_bytes!("data/alg-ecdsa-sha384.der") => Ok(SignatureScheme::ECDSA_NISTP384_SHA384),
        include_bytes!("data/alg-ed25519.der") => Ok(SignatureScheme::ED25519),
        e if e.starts_with(&RSASSA_PSS_PREFIX[..]) => match &e[RSASSA_PSS_PREFIX.len()..] {
            include_bytes!("data/alg-rsa-pss-sha256-v0.der")
            | include_bytes!("data/alg-rsa-pss-sha256-v1.der")
            | include_bytes!("data/alg-rsa-pss-sha256-v2.der")
            | include_bytes!("data/alg-rsa-pss-sha256-v3.der") =>
                Ok(SignatureScheme::RSA_PSS_SHA256),
            include_bytes!("data/alg-rsa-pss-sha384-v0.der")
            | include_bytes!("data/alg-rsa-pss-sha384-v1.der")
            | include_bytes!("data/alg-rsa-pss-sha384-v2.der")
            | include_bytes!("data/alg-rsa-pss-sha384-v3.der") =>
                Ok(SignatureScheme::RSA_PSS_SHA384),
            include_bytes!("data/alg-rsa-pss-sha512-v0.der")
            | include_bytes!("data/alg-rsa-pss-sha512-v1.der")
            | include_bytes!("data/alg-rsa-pss-sha512-v2.der")
            | include_bytes!("data/alg-rsa-pss-sha512-v3.der") =>
                Ok(SignatureScheme::RSA_PSS_SHA512),
            _ => Err(Error::UnsupportedSignatureAlgorithm),
        },
        _ => Err(Error::UnsupportedSignatureAlgorithm),
    }
}
pub fn parse_algorithmid ( asn1 : & [ u8 ] ) -> Result < SignatureScheme , Error > { match asn1 { include_bytes ! ( " " ) => Ok ( SignatureScheme :: RSA_PKCS1_SHA256 ) , include_bytes ! ( " " ) => Ok ( SignatureScheme :: RSA_PKCS1_SHA384 ) , include_bytes ! ( " " ) => Ok ( SignatureScheme :: RSA_PKCS1_SHA512 ) , include_bytes ! ( " " ) => Ok ( SignatureScheme :: ECDSA_NISTP256_SHA256 ) , include_bytes ! ( " " ) => Ok ( SignatureScheme :: ECDSA_NISTP384_SHA384 ) , include_bytes ! ( " " ) => Ok ( SignatureScheme :: ED25519 ) , e if e . starts_with ( & RSASSA_PSS_PREFIX [ .. ] ) => match & e [ RSASSA_PSS_PREFIX . len ( ) .. ] { include_bytes ! ( " " ) | include_bytes ! ( " " ) | include_bytes ! ( " " ) | include_bytes ! ( " " ) => Ok ( SignatureScheme :: RSA_PSS_SHA256 ) , include_bytes ! ( " " ) | include_bytes ! ( " " ) | include_bytes ! ( " " ) | include_bytes ! ( " " ) => Ok ( SignatureScheme :: RSA_PSS_SHA384 ) , include_bytes ! ( " " ) | include_bytes ! ( " " ) | include_bytes ! ( " " ) | include_bytes ! ( " " ) => Ok ( SignatureScheme :: RSA_PSS_SHA512 ) , _ => Err ( Error :: UnsupportedSignatureAlgorithm ) , } , _ => Err ( Error :: UnsupportedSignatureAlgorithm ) , } }
Parse the ASN.1 DER-encoded algorithm identifier in `asn1` into a
`SignatureScheme`.
Parse the ASN . 1 DER - encoded algorithm identifier in ` asn1 ` into a ` SignatureScheme ` .
asn1
&[u8]