5 unstable releases
0.3.0 | Nov 7, 2021 |
---|---|
0.2.1 | Aug 11, 2019 |
0.2.0 | Aug 11, 2019 |
0.1.1 | Aug 9, 2019 |
0.1.0 | Aug 9, 2019 |
#715 in Cryptography
1,193 downloads per month
Used in fewer than 7 crates
9KB
114 lines
rsa-der
A simple crate to encode and decode RSA public keys to DER-encoded bytes.
See the documentation for examples.
lib.rs
:
A simple crate to encode and decode DER-formatted public RSA keys.
Public keys are passed to and returned from functions simply using the n
and e
components, so any RSA library can be used in conjunction with this crate.
Examples
Convert an RSA public key to DER bytes:
# use rsa::{RSAPrivateKey, PublicKey};
use rand::rngs::OsRng;
# fn generate_key() -> impl PublicKey {
# let mut rng = OsRng::new().unwrap();
# let key = RSAPrivateKey::new(&mut rng, 2048).unwrap();
# key
# }
let key = generate_key();
let der_bytes = rsa_der::public_key_to_der(&key.n().to_bytes_be(), &key.e().to_bytes_be());
Dependencies
~1.1–1.7MB
~36K SLoC