rsa/README.md

68 lines
2.4 KiB
Markdown
Raw Normal View History

2018-07-17 21:16:31 +02:00
# RSA
[![crates.io](https://img.shields.io/crates/v/rsa.svg)](https://crates.io/crates/rsa) [![Documentation](https://docs.rs/rsa/badge.svg)](https://docs.rs/rsa) [![Build Status](https://github.com/rustcrypto/RSA/workflows/CI/badge.svg)](https://github.com/RustCrypto/RSA/actions) ![minimum rustc 1.44](https://img.shields.io/badge/rustc-1.44+-blue.svg)
2018-07-17 21:16:31 +02:00
A portable RSA implementation in pure Rust.
2018-07-17 21:16:31 +02:00
2020-11-30 04:07:40 -06:00
: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](https://github.com/RustCrypto/RSA/issues/60) for more information.
2018-07-17 21:16:31 +02:00
## Example
```rust
use rsa::{PublicKey, RSAPrivateKey, PaddingScheme};
use rand::rngs::OsRng;
2019-12-11 01:15:49 +01:00
let mut rng = OsRng;
let bits = 2048;
let priv_key = RSAPrivateKey::new(&mut rng, bits).expect("failed to generate a key");
2020-11-24 15:01:04 +01:00
let pub_key = RSAPublicKey::from(&priv_key);
// Encrypt
let data = b"hello world";
2020-03-06 21:11:24 +01:00
let enc_data = pub_key.encrypt(&mut rng, PaddingScheme::new_pkcs1v15(), &data[..]).expect("failed to encrypt");
assert_ne!(&data[..], &enc_data[..]);
// Decrypt
2020-03-06 21:11:24 +01:00
let dec_data = priv_key.decrypt(PaddingScheme::new_pkcs1v15(), &enc_data).expect("failed to decrypt");
assert_eq!(&data[..], &dec_data[..]);
```
2018-07-17 21:16:31 +02:00
## Status
2018-07-24 22:05:29 +02:00
Currently at Phase 1 (v) :construction:.
2018-07-17 21:16:31 +02:00
There will be three phases before `1.0` :ship: can be released.
1. :construction: Make it work
2019-02-20 20:29:49 +01:00
- [x] Prime generation :white_check_mark:
- [x] Key generation :white_check_mark:
- [x] PKCS1v1.5: Encryption & Decryption :white_check_mark:
- [x] PKCS1v1.5: Sign & Verify :white_check_mark:
- [ ] PKCS1v1.5 (session key): Encryption & Decryption
- [x] OAEP: Encryption & Decryption
2020-03-06 21:11:24 +01:00
- [x] PSS: Sign & Verify
2019-02-20 20:29:49 +01:00
- [x] Key import & export
2018-07-17 21:16:31 +02:00
2. :rocket: Make it fast
2019-02-20 20:29:49 +01:00
- [x] Benchmarks :white_check_mark:
- [ ] compare to other implementations :construction:
- [ ] optimize :construction:
2018-07-17 21:16:31 +02:00
3. :lock: Make it secure
2019-02-20 20:29:49 +01:00
- [ ] Fuzz testing
- [ ] Security Audits
2018-07-17 21:16:31 +02:00
## License
Licensed under either of
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* [MIT license](http://opensource.org/licenses/MIT)
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
2019-02-20 20:29:49 +01:00
dual licensed as above, without any additional terms or conditions.