Tony Arcieri a26e7f563c
Cargo.lock: bump dependencies (#383)
Updates the following dependencies:

    $ cargo update
    Updating crates.io index
    Updating bitflags v2.4.0 -> v2.4.1
    Updating byteorder v1.4.3 -> v1.5.0
    Removing cc v1.0.83
    Updating cpufeatures v0.2.9 -> v0.2.11
    Updating errno v0.3.4 -> v0.3.7
    Removing errno-dragonfly v0.1.2
    Updating getrandom v0.2.10 -> v0.2.11
    Updating libc v0.2.148 -> v0.2.150
    Updating libm v0.2.7 -> v0.2.8
    Updating linux-raw-sys v0.4.8 -> v0.4.11
    Updating num-traits v0.2.16 -> v0.2.17
    Updating proc-macro2 v1.0.67 -> v1.0.69
    Updating proptest v1.3.1 -> v1.4.0
    Updating redox_syscall v0.3.5 -> v0.4.1
    Updating regex-syntax v0.7.5 -> v0.8.2
    Updating rustix v0.38.20 -> v0.38.25
    Updating serde v1.0.188 -> v1.0.192
    Updating serde_derive v1.0.188 -> v1.0.192
    Updating signature v2.1.0 -> v2.2.0
    Updating smallvec v1.11.1 -> v1.11.2
    Updating syn v2.0.37 -> v2.0.39
    Updating tempfile v3.8.0 -> v3.8.1
    Updating zeroize v1.6.0 -> v1.7.0
2023-11-20 12:53:32 -07:00
2023-03-01 21:54:18 -07:00
2023-10-26 11:26:21 -06:00
2023-10-26 11:26:21 -06:00
2018-07-17 21:16:31 +02:00
2018-07-17 21:16:31 +02:00
2023-04-23 19:53:07 -06:00

RustCrypto: RSA

crates.io Documentation Build Status dependency status MSRV Project Chat

A portable RSA implementation in pure Rust.

Example

use rsa::{Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey};

let mut rng = rand::thread_rng();
let bits = 2048;
let priv_key = RsaPrivateKey::new(&mut rng, bits).expect("failed to generate a key");
let pub_key = RsaPublicKey::from(&priv_key);

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

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

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 your Cargo.toml. Key generation is much faster when building with higher optimization levels, but this will increase the compile time a bit.

[profile.debug]
opt-level = 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.

[profile.dev.package.num-bigint-dig]
opt-level = 3

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

Security Notes

This crate has received one security audit by Include Security, with only one minor finding which has since been addressed.

See the open security issues on our issue tracker for other known problems.

Notably the implementation of modular exponentiation is not constant time, but timing variability is masked using random blinding, a commonly used technique.

Minimum Supported Rust Version (MSRV)

All crates in this repository support Rust 1.65 or higher.

In the future MSRV 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.

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