RSA
A portable RSA implementation in pure Rust.
:warning: WARNING: This crate has been audited by a 3rd party, but a full blog post with the results and the updates made since the audit has not been officially released yet. See #60 for more information.
Example
use ;
use OsRng;
let mut rng = OsRng;
let bits = 2048;
let priv_key = new.expect;
let pub_key = from;
// Encrypt
let data = b"hello world";
let enc_data = pub_key.encrypt.expect;
assert_ne!;
// Decrypt
let dec_data = priv_key.decrypt.expect;
assert_eq!;
Note: If you encounter unusually slow key generation time while using
RsaPrivateKey::new
you can try to compile in release mode or add the following to yourCargo.toml
. Key generation is much faster when building with higher optimization levels, but this will increase the compile time a bit.[] = 3
If you don't want to turn on optimizations for all dependencies, you can only optimize the
num-bigint-dig
dependency. This should give most of the speedups.[] = 3
Status
Currently at Phase 1 (v) :construction:.
There will be three phases before 1.0
:ship: can be released.
- :construction: Make it work
- Prime generation :white_check_mark:
- Key generation :white_check_mark:
- PKCS1v1.5: Encryption & Decryption :white_check_mark:
- PKCS1v1.5: Sign & Verify :white_check_mark:
- PKCS1v1.5 (session key): Encryption & Decryption
- OAEP: Encryption & Decryption
- PSS: Sign & Verify
- Key import & export
- :rocket: Make it fast
- Benchmarks :white_check_mark:
- compare to other implementations :construction:
- optimize :construction:
- :lock: Make it secure
- Fuzz testing
- Security Audits
Minimum Supported Rust Version (MSRV)
All crates in this repository support Rust 1.51 or higher. In future minimally supported version of Rust can be changed, but it will be done with a minor version bump.
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.