Trait rsa::PrivateKeyPemEncoding [−][src]
Trait for encoding the private key in the PEM format
Important: Encoding multi prime keys isn’t supported. See RustCrypto/RSA#66 for more info
Associated Constants
const PKCS1_HEADER: &'static str
[src]
const PKCS8_HEADER: &'static str
[src]
Provided methods
fn to_pem_pkcs1(&self) -> Result<String>
[src]
Converts a Private key into PKCS1
encoded bytes in pem format.
Encodes the key with the header:
-----BEGIN <name> PRIVATE KEY-----
Example
use rsa::{RSAPrivateKey, PrivateKeyPemEncoding}; use rand::rngs::OsRng; let mut rng = OsRng; let bits = 2048; let private_key = RSAPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); let _ = private_key.to_pem_pkcs1();
fn to_pem_pkcs1_with_config(&self, config: EncodeConfig) -> Result<String>
[src]
Converts a Private key into PKCS1
encoded bytes in pem format with encoding config.
Example
use pem::{EncodeConfig, LineEnding}; let _ = private_key.to_pem_pkcs1_with_config(EncodeConfig { line_ending: LineEnding::CRLF, });
fn to_pem_pkcs8(&self) -> Result<String>
[src]
Converts a Private key into PKCS8
encoded bytes in pem format.
Encodes the key with the header:
-----BEGIN PRIVATE KEY-----
Example
use rsa::{RSAPrivateKey, PrivateKeyPemEncoding}; use rand::rngs::OsRng; let mut rng = OsRng; let bits = 2048; let private_key = RSAPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); let _ = private_key.to_pem_pkcs8();
fn to_pem_pkcs8_with_config(&self, config: EncodeConfig) -> Result<String>
[src]
Converts a Private key into PKCS8
encoded bytes in pem format with encoding config.
Example
use pem::{EncodeConfig, LineEnding}; let _ = private_key.to_pem_pkcs8_with_config(EncodeConfig { line_ending: LineEnding::CRLF, });