Skip to content

Instantly share code, notes, and snippets.

@jedisct1
Last active September 17, 2024 14:48
Show Gist options
  • Save jedisct1/a08bc80075623a46211a9ec494bdd036 to your computer and use it in GitHub Desktop.
Save jedisct1/a08bc80075623a46211a9ec494bdd036 to your computer and use it in GitHub Desktop.
// 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