win_crypto_ng::asymmetric

Module signature

Source
Expand description

Digital signature facilities.

A scheme to verify the authenticity of digital messages or documents using asymmetric cryptography.

§Example

use win_crypto_ng::asymmetric::signature::{Signer, Verifier, SignaturePadding};
use win_crypto_ng::asymmetric::{AsymmetricKey, Rsa};
use win_crypto_ng::hash::HashAlgorithmId;

let key = AsymmetricKey::builder(Rsa).key_bits(1024).build().unwrap();

let data: Vec<u8> = (0..32).collect();
let padding = SignaturePadding::pkcs1(HashAlgorithmId::Sha256);
let signature = key.sign(&*data, Some(padding)).expect("Signing to succeed");

key.verify(&data, &signature, Some(padding)).expect("Signature to be valid");

key.verify(&[0xDE, 0xAD], &signature, Some(padding)).expect_err("Bad digest");
key.verify(&data, &[0xDE, 0xAD], Some(padding)).expect_err("Bad signature");

Structs§

Pkcs1Padding
PKCS #1 padding scheme.
PssPadding
Probabilistic Signature Scheme (PSS) padding scheme.

Enums§

SignaturePadding
Padding scheme to be used when creating/verifying a hash signature.

Traits§

Signer
Create a signature for a given payload using an asymmetric key.
Verifier
Verify a signature for a given input using an asymmetric key.