Jakub Konka a649ce16e0
feat: allow for custom public exponent value in keygen
This commit adds a function to `rsa::algorithms` called
`generate_multi_prime_key_with_exp` which allows the caller
to specify a custom value for the public key exponent.

This commit also adds a convenience routine to `rsa::RSAPrivateKey`
called `new_with_exp` which allows the caller to specify the
custom value for the public key exponent as part of `rsa::RSAPrivateKey`
constructor.

Exposing the public key exponent matches an OpenSSL call
`openssl::rsa::generate_with_e` which is useful in certain
settings such when generating the signing keys for SGX enclaves.
2020-07-29 12:33:45 +02:00
2020-06-11 13:20:51 +02:00
2018-07-17 20:16:31 +02:00
2020-06-11 14:13:09 +02:00
2018-07-17 21:16:31 +02:00
2018-07-17 21:16:31 +02:00
2019-10-13 15:34:57 +02:00

RSA

crates.io Documentation Build Status minimum rustc 1.36

A portable RSA implementation in pure Rust.

⚠️ WARNING: This library has not been audited, so please do not use for production code.

Example

use rsa::{PublicKey, RSAPrivateKey, PaddingScheme};
use rand::rngs::OsRng;

let mut rng = OsRng;
let bits = 2048;
let priv_key = RSAPrivateKey::new(&mut rng, bits).expect("failed to generate a key");
let pub_key = RSAPublicKey::from(&private_key);

// Encrypt
let data = b"hello world";
let enc_data = pub_key.encrypt(&mut rng, PaddingScheme::new_pkcs1v15(), &data[..]).expect("failed to encrypt");
assert_ne!(&data[..], &enc_data[..]);

// Decrypt
let dec_data = priv_key.decrypt(PaddingScheme::new_pkcs1v15(), &enc_data).expect("failed to decrypt");
assert_eq!(&data[..], &dec_data[..]);

Status

Currently at Phase 1 (v) 🚧.

There will be three phases before 1.0 🚢 can be released.

  1. 🚧 Make it work
    • Prime generation
    • Key generation
    • PKCS1v1.5: Encryption & Decryption
    • PKCS1v1.5: Sign & Verify
    • PKCS1v1.5 (session key): Encryption & Decryption
    • OAEP: Encryption & Decryption
    • PSS: Sign & Verify
    • Key import & export
  2. 🚀 Make it fast
    • Benchmarks
    • compare to other implementations 🚧
    • optimize 🚧
  3. 🔒 Make it secure
    • Fuzz testing
    • Security Audits

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Description
RSA implementation in pure Rust. Forked from https://github.com/RustCrypto/RSA
Readme 729 KiB
Languages
Rust 100%