Skip to main content

RsaFactoryExt

Trait RsaFactoryExt 

Source
pub trait RsaFactoryExt {
    // Required method
    fn rsa(&self, label: impl AsRef<str>, spec: RsaSpec) -> RsaKeyPair;
}
Expand description

Extension trait to hang RSA helpers off the core Factory.

Required Methods§

Source

fn rsa(&self, label: impl AsRef<str>, spec: RsaSpec) -> RsaKeyPair

Generate (or retrieve from cache) an RSA keypair fixture.

The label identifies this keypair within your test suite. In deterministic mode, seed + label + spec always produces the same key.

§Examples
use uselesskey_core::{Factory, Seed};
use uselesskey_rsa::{RsaFactoryExt, RsaSpec};

let seed = Seed::from_env_value("test-seed").unwrap();
let fx = Factory::deterministic(seed);
let keypair = fx.rsa("my-service", RsaSpec::rs256());

let pem = keypair.private_key_pkcs8_pem();
assert!(pem.contains("BEGIN PRIVATE KEY"));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RsaFactoryExt for Factory

Source§

fn rsa(&self, label: impl AsRef<str>, spec: RsaSpec) -> RsaKeyPair

Implementors§