Module sign
Expand description
Message signatures.
The Signer
allows for the computation of cryptographic signatures of
data given a private key. The Verifier
can then be used with the
corresponding public key to verify the integrity and authenticity of that
data given the signature.
§Examples
Sign and verify data given an RSA keypair:
use boring::sign::{Signer, Verifier};
use boring::rsa::Rsa;
use boring::pkey::PKey;
use boring::hash::MessageDigest;
// Generate a keypair
let keypair = Rsa::generate(2048).unwrap();
let keypair = PKey::from_rsa(keypair).unwrap();
let data = b"hello, world!";
let data2 = b"hola, mundo!";
// Sign the data
let mut signer = Signer::new(MessageDigest::sha256(), &keypair).unwrap();
signer.update(data).unwrap();
signer.update(data2).unwrap();
let signature = signer.sign_to_vec().unwrap();
// Verify the data
let mut verifier = Verifier::new(MessageDigest::sha256(), &keypair).unwrap();
verifier.update(data).unwrap();
verifier.update(data2).unwrap();
assert!(verifier.verify(&signature).unwrap());
Structs§
- Salt lengths that must be used with
set_rsa_pss_saltlen
. - A type which computes cryptographic signatures of data.