[][src]Crate rsa_export

rsa_export allows you to export your RSA key, generated via the rsa crate, with PKCS#1 or PKCS#8 encoding

Note: Multi-prime keys are not supported

The keys can also be exported into the PEM format by enabling the feature pem_export

Example:

use rsa::RSAPrivateKey;
use rand::rngs::OsRng;

fn main() {
    let mut rng = OsRng;
    let key = RSAPrivateKey::new(&mut rng, 2048).unwrap();

    let pkcs1_encoded_private = rsa_export::pkcs1::private_key(&key).unwrap();
    let pkcs1_encoded_public = rsa_export::pkcs1::public_key(&key.to_public_key()).unwrap();

    let pkcs8_encoded_private = rsa_export::pkcs8::private_key(&key).unwrap();
    let pkcs8_encoded_public = rsa_export::pkcs8::public_key(&key.to_public_key()).unwrap();
}

Modules

pem

Encode a public/private key encoded with PKCS#1 or PKCS#8 into the PEM format Encode PKCS#1 or PKCS#8 encoded keys into the PEM format

pkcs1

Encode a public/private key with PKCS#1

pkcs8

Encode a public/private key with PKCS#8