pub trait PublicKeyEncryption {
type PublicKey;
type SecretKey;
// Required methods
fn keygen(bits: usize) -> (Self::PublicKey, Self::SecretKey);
fn encrypt(pk: &Self::PublicKey, plaintext: &[u8]) -> Vec<u8> ⓘ;
fn decrypt(sk: &Self::SecretKey, ciphertext: &[u8]) -> Option<Vec<u8>>;
}Expand description
Trait for public-key encryption schemes.
Like SignatureScheme, this trait is currently informational –
the RSA encryption helpers in rsa::pkcs1 and rsa::oaep take
a parameter of type rsa::rsa::RsaPublicKey / RsaSecretKey
directly rather than going through this trait, because OAEP and
PKCS#1 v1.5 each take additional protocol parameters (label, RNG)
that don’t fit the simple shape below.
Required Associated Types§
Required Methods§
Sourcefn keygen(bits: usize) -> (Self::PublicKey, Self::SecretKey)
fn keygen(bits: usize) -> (Self::PublicKey, Self::SecretKey)
Generate a key pair of the given bit size.
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.