-
-
Save jedisct1/7f6fe80fe61867ed4337bb4881b36105 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cargo.toml: | |
// [dependencies] | |
// rsa = "0.9.6" | |
// rand = "0.8.5" | |
fn main() -> Result<(), Box<dyn std::error::Error>> { | |
use rsa::pkcs8::DecodePrivateKey as _; | |
// Ciphertext | |
let ciphertext = include_bytes!("signed_message.bin"); | |
// Unencrypted RSA private key in PEM format | |
let rsa_pem = include_str!("sessionprivatekey.pem"); | |
// Import the RSA private key | |
let mut rsa_key = rsa::RsaPrivateKey::from_pkcs8_pem(rsa_pem)?; | |
rsa_key.precompute()?; | |
// Decrypt the ciphertext | |
let mut rng = rand::thread_rng(); | |
let plaintext = rsa_key.decrypt_blinded(&mut rng, rsa::Pkcs1v15Encrypt, ciphertext)?; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment