#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

#715 in Cryptography

Download history 346/week @ 2022-10-08 409/week @ 2022-10-15 267/week @ 2022-10-22 435/week @ 2022-10-29 452/week @ 2022-11-05 407/week @ 2022-11-12 394/week @ 2022-11-19 298/week @ 2022-11-26 325/week @ 2022-12-03 425/week @ 2022-12-10 331/week @ 2022-12-17 236/week @ 2022-12-24 186/week @ 2022-12-31 256/week @ 2023-01-07 338/week @ 2023-01-14 375/week @ 2023-01-21

1,193 downloads per month
Used in fewer than 7 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.7MB
~36K SLoC