fn spki_from_components(e: &[u8], n: &[u8]) -> CryptoResult<Vec<u8>> {
        use num_bigint::Sign;
        use simple_asn1::*;

        let n = ASN1Block::Integer(0, BigInt::from_bytes_be(Sign::Plus, n));
        let e = ASN1Block::Integer(0, BigInt::from_bytes_be(Sign::Plus, e));
        let blocks = vec![n, e];

        let pkcs1 =
            to_der(&ASN1Block::Sequence(0, blocks)).map_err(|e| CryptoError::InvalidArgument {
                message: format!("{:?}", e),
            })?;

        let oid = ASN1Block::ObjectIdentifier(0, oid!(1, 2, 840, 113549, 1, 1, 1));
        let alg = ASN1Block::Sequence(0, vec![oid, ASN1Block::Null(0)]);
        let octet_string = ASN1Block::BitString(0, pkcs1.len() * 8, pkcs1);
        let blocks = vec![alg, octet_string];

        to_der(&ASN1Block::Sequence(0, blocks)).map_err(|e| CryptoError::InvalidArgument {
            message: format!("{:?}", e),
        })
    }
/// Create the SPKI encoding of an RSA public key from the public parameters
///
/// # Arguments
/// * `e` the public exponent, encoded in big-endian bytes
/// * `n` the public modulus, encoded in big-endian bytes
Create the SPKI encoding of an RSA public key from the public parameters
Create the SPKI encoding of an RSA public key from the public parameters
fn spki_from_components(e: &[u8], n: &[u8]) -> CryptoResult<Vec<u8>> {
        use num_bigint::Sign;
        use simple_asn1::*;
        let n = ASN1Block::Integer(0, BigInt::from_bytes_be(Sign::Plus, n));
        let e = ASN1Block::Integer(0, BigInt::from_bytes_be(Sign::Plus, e));
        let blocks = vec![n, e];
        let pkcs1 =
            to_der(&ASN1Block::Sequence(0, blocks)).map_err(|e| CryptoError::InvalidArgument {
                message: format!("{:?}", e),
            })?;
        let oid = ASN1Block::ObjectIdentifier(0, oid!(1, 2, 840, 113549, 1, 1, 1));
        let alg = ASN1Block::Sequence(0, vec![oid, ASN1Block::Null(0)]);
        let octet_string = ASN1Block::BitString(0, pkcs1.len() * 8, pkcs1);
        let blocks = vec![alg, octet_string];
        to_der(&ASN1Block::Sequence(0, blocks)).map_err(|e| CryptoError::InvalidArgument {
            message: format!("{:?}", e),
        })
    }
fn spki_from_components ( e : & [ u8 ] , n : & [ u8 ] ) -> CryptoResult < Vec < u8 > > { use num_bigint :: Sign ; use simple_asn1 :: * ; let n = ASN1Block :: Integer ( 0 , BigInt :: from_bytes_be ( Sign :: Plus , n ) ) ; let e = ASN1Block :: Integer ( 0 , BigInt :: from_bytes_be ( Sign :: Plus , e ) ) ; let blocks = vec ! [ n e ] ; let pkcs1 = to_der ( & ASN1Block :: Sequence ( 0 , blocks ) ) . map_err ( | e | CryptoError :: InvalidArgument { message : format ! ( " " e ) , } ) ? ; let oid = ASN1Block :: ObjectIdentifier ( 0 , oid ! ( 1 2 840 113549 1 1 1 ) ) ; let alg = ASN1Block :: Sequence ( 0 , vec ! [ oid ASN1Block Null ( 0 ) ] ) ; let octet_string = ASN1Block :: BitString ( 0 , pkcs1 . len ( ) * 8 , pkcs1 ) ; let blocks = vec ! [ alg octet_string ] ; to_der ( & ASN1Block :: Sequence ( 0 , blocks ) ) . map_err ( | e | CryptoError :: InvalidArgument { message : format ! ( " " e ) , } ) }
Create the SPKI encoding of an RSA public key from the public parameters
Create the SPKI encoding of an RSA public key from the public parameters
e
&[u8]
n
&[u8]
e
&[u8]
n
&[u8]