Expand description
Integration between uselesskey test fixtures and the RustCrypto ecosystem.
This crate provides extension traits that convert uselesskey fixtures into native RustCrypto types, making it easy to use test fixtures with code that depends on the RustCrypto crates directly.
§Features
Enable the key types you need:
rsa- RSA keypairs ->rsa::RsaPrivateKey/rsa::RsaPublicKeyecdsa- ECDSA keypairs ->p256::ecdsa::SigningKey/p384::ecdsa::SigningKeyed25519- Ed25519 keypairs ->ed25519_dalek::SigningKey/VerifyingKeyhmac- HMAC secrets ->hmac::Hmac<Sha256>/Sha384/Sha512all- All of the above
§Example: RSA sign and verify
use uselesskey_core::Factory;
use uselesskey_rsa::{RsaFactoryExt, RsaSpec};
use uselesskey_rustcrypto::RustCryptoRsaExt;
use rsa::pkcs1v15::SigningKey;
use rsa::signature::{Signer, Verifier};
use rsa::sha2::Sha256;
let fx = Factory::random();
let keypair = fx.rsa("test", RsaSpec::rs256());
let private_key = keypair.rsa_private_key();
let signing_key = SigningKey::<Sha256>::new_unprefixed(private_key);
let signature = signing_key.sign(b"hello world");
let public_key = keypair.rsa_public_key();
let verifying_key = rsa::pkcs1v15::VerifyingKey::<Sha256>::new_unprefixed(public_key);
verifying_key.verify(b"hello world", &signature).unwrap();Traits§
- Rust
Crypto Ecdsa Ext - Extension trait to convert uselesskey ECDSA fixtures into RustCrypto
p256/p384types. - Rust
Crypto Ed25519 Ext - Extension trait to convert uselesskey Ed25519 fixtures into
ed25519-dalektypes. - Rust
Crypto Hmac Ext - Extension trait to convert uselesskey HMAC fixtures into
hmac::Hmactypes. - Rust
Crypto RsaExt - Extension trait to convert uselesskey RSA fixtures into RustCrypto
rsatypes.