#crypto #cryptography #rsa #der

rsa-der

Crate to encode and decode public RSA keys using DER

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

#256 in Cryptography

Download history 87/week @ 2021-09-26 58/week @ 2021-10-03 161/week @ 2021-10-10 107/week @ 2021-10-17 120/week @ 2021-10-24 129/week @ 2021-10-31 321/week @ 2021-11-07 119/week @ 2021-11-14 279/week @ 2021-11-21 257/week @ 2021-11-28 295/week @ 2021-12-05 172/week @ 2021-12-12 173/week @ 2021-12-19 138/week @ 2021-12-26 239/week @ 2022-01-02 308/week @ 2022-01-09

865 downloads per month
Used in 4 crates

MIT/Apache

9KB
114 lines

rsa-der

Documentation crates.io

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.6MB
~36K SLoC