-
-
Save jedisct1/a08bc80075623a46211a9ec494bdd036 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] | |
// boring = { package = "superboring", version = "0.1.2" } | |
fn main() -> Result<(), Box<dyn std::error::Error>> { | |
// 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 rsa_key = boring::rsa::Rsa::private_key_from_pem(rsa_pem.as_bytes())?; | |
// Decrypt the ciphertext | |
let mut plaintext = vec![0; ciphertext.len()]; | |
let plaintext_len = | |
rsa_key.private_decrypt(ciphertext, &mut plaintext, boring::rsa::Padding::PKCS1)?; | |
let plaintext = &plaintext[..plaintext_len]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment