pub fn from_pem(pem: &[u8]) -> Result<Self> {
        let pk = PKey::public_key_from_pem(pem)?;
        match pk.id() {
            Id::RSA => {
                let k = RsaPublicKey::from_pkey(pk, None)?;
                Ok(Self::Rsa(k))
            }
            Id::EC => {
                let k = EcdsaPublicKey::from_pkey(pk)?;
                Ok(Self::Ecdsa(k))
            }
            Id::ED25519 => {
                let k = Ed25519PublicKey::from_pkey(pk)?;
                Ok(Self::Ed25519(k))
            }
            _ => Err(Error::UnsupportedOrInvalidKey),
        }
    }
/// Read an RSA/EC/Ed25519 public key from PEM.
///
/// For an EC/Ed25519 public key, algorithm is deduced from the curve, e.g.
/// P-256 -> ES256.
///
/// For an RSA public key, signatures generated by any RSA algorithms can be
/// verified.
Read an RSA/EC/Ed25519 public key from PEM.
For an EC/Ed25519 public key, algorithm is deduced from the curve, e.g.

For an RSA public key, signatures generated by any RSA algorithms can be
verified.
Read an RSA / EC / Ed25519 public key from PEM . For an EC / Ed25519 public key algorithm is deduced from the curve e . g . For an RSA public key signatures generated by any RSA algorithms can be verified .
pub fn from_pem(pem: &[u8]) -> Result<Self> {
        let pk = PKey::public_key_from_pem(pem)?;
        match pk.id() {
            Id::RSA => {
                let k = RsaPublicKey::from_pkey(pk, None)?;
                Ok(Self::Rsa(k))
            }
            Id::EC => {
                let k = EcdsaPublicKey::from_pkey(pk)?;
                Ok(Self::Ecdsa(k))
            }
            Id::ED25519 => {
                let k = Ed25519PublicKey::from_pkey(pk)?;
                Ok(Self::Ed25519(k))
            }
            _ => Err(Error::UnsupportedOrInvalidKey),
        }
    }
pub fn from_pem ( pem : & [ u8 ] ) -> Result < Self > { let pk = PKey :: public_key_from_pem ( pem ) ? ; match pk . id ( ) { Id :: RSA => { let k = RsaPublicKey :: from_pkey ( pk , None ) ? ; Ok ( Self :: Rsa ( k ) ) } Id :: EC => { let k = EcdsaPublicKey :: from_pkey ( pk ) ? ; Ok ( Self :: Ecdsa ( k ) ) } Id :: ED25519 => { let k = Ed25519PublicKey :: from_pkey ( pk ) ? ; Ok ( Self :: Ed25519 ( k ) ) } _ => Err ( Error :: UnsupportedOrInvalidKey ) , } }
Read an RSA/EC/Ed25519 public key from PEM.
Read an RSA / EC / Ed25519 public key from PEM .
pem
&[u8]
pem
&[u8]