pub enum Algorithm {
FrodoKem640Aes,
FrodoKem976Aes,
FrodoKem1344Aes,
FrodoKem640Shake,
FrodoKem976Shake,
FrodoKem1344Shake,
EphemeralFrodoKem640Aes,
EphemeralFrodoKem976Aes,
EphemeralFrodoKem1344Aes,
EphemeralFrodoKem640Shake,
EphemeralFrodoKem976Shake,
EphemeralFrodoKem1344Shake,
}Expand description
The supported FrodoKem algorithms
Variants§
FrodoKem640Aes
frodo640aes only.The FrodoKEM-640-AES algorithm
FrodoKem976Aes
frodo976aes only.The FrodoKEM-976-AES algorithm
FrodoKem1344Aes
frodo1344aes only.The FrodoKEM-1344-AES algorithm
FrodoKem640Shake
frodo640shake only.The FrodoKEM-640-SHAKE algorithm
FrodoKem976Shake
frodo976shake only.The FrodoKEM-976-SHAKE algorithm
FrodoKem1344Shake
frodo1344shake only.The FrodoKEM-1344-SHAKE algorithm
EphemeralFrodoKem640Aes
efrodo640aes only.The FrodoKEM-640-AES algorithm
EphemeralFrodoKem976Aes
efrodo976aes only.The FrodoKEM-976-AES algorithm
EphemeralFrodoKem1344Aes
efrodo1344aes only.The FrodoKEM-1344-AES algorithm
EphemeralFrodoKem640Shake
efrodo640shake only.The FrodoKEM-640-SHAKE algorithm
EphemeralFrodoKem976Shake
efrodo976shake only.The FrodoKEM-976-SHAKE algorithm
EphemeralFrodoKem1344Shake
efrodo1344shake only.The FrodoKEM-1344-SHAKE algorithm
Implementations§
Source§impl Algorithm
impl Algorithm
Sourcepub fn enabled_algorithms() -> &'static [Algorithm]
pub fn enabled_algorithms() -> &'static [Algorithm]
Get the enabled algorithms
Sourcepub const fn params(&self) -> AlgorithmParams
pub const fn params(&self) -> AlgorithmParams
Get the parameters for this algorithm
Sourcepub fn encryption_key_from_decryption_key(
&self,
secret_key: &DecryptionKey,
) -> EncryptionKey
pub fn encryption_key_from_decryption_key( &self, secret_key: &DecryptionKey, ) -> EncryptionKey
Get the EncryptionKey from a DecryptionKey
Sourcepub fn decryption_key_from_bytes<B: AsRef<[u8]>>(
&self,
buf: B,
) -> FrodoResult<DecryptionKey>
pub fn decryption_key_from_bytes<B: AsRef<[u8]>>( &self, buf: B, ) -> FrodoResult<DecryptionKey>
Obtain a secret key from a byte slice
Returns Err if the byte slice is not the correct length
Sourcepub fn encryption_key_from_bytes<B: AsRef<[u8]>>(
&self,
buf: B,
) -> FrodoResult<EncryptionKey>
pub fn encryption_key_from_bytes<B: AsRef<[u8]>>( &self, buf: B, ) -> FrodoResult<EncryptionKey>
Obtain a public key from a byte slice
Returns Err if the byte slice is not the correct length
Sourcepub fn ciphertext_from_bytes(&self, buf: &[u8]) -> FrodoResult<Ciphertext>
pub fn ciphertext_from_bytes(&self, buf: &[u8]) -> FrodoResult<Ciphertext>
Obtain a ciphertext from a byte slice
Returns Err if the byte slice is not the correct length
Obtain a shared secret from a byte slice
Returns Err if the byte slice is not the correct length
Sourcepub fn generate_keypair(
&self,
rng: impl CryptoRng,
) -> (EncryptionKey, DecryptionKey)
pub fn generate_keypair( &self, rng: impl CryptoRng, ) -> (EncryptionKey, DecryptionKey)
Generate a new keypair consisting of a EncryptionKey and a DecryptionKey
Sourcepub fn try_generate_keypair(
&self,
rng: impl TryCryptoRng,
) -> FrodoResult<(EncryptionKey, DecryptionKey)>
pub fn try_generate_keypair( &self, rng: impl TryCryptoRng, ) -> FrodoResult<(EncryptionKey, DecryptionKey)>
Try to generate a new keypair consisting of a EncryptionKey and a DecryptionKey
Sourcepub fn encapsulate<B: AsRef<[u8]>, S: AsRef<[u8]>>(
&self,
public_key: &EncryptionKey,
msg: B,
salt: S,
) -> FrodoResult<(Ciphertext, SharedSecret)>
pub fn encapsulate<B: AsRef<[u8]>, S: AsRef<[u8]>>( &self, public_key: &EncryptionKey, msg: B, salt: S, ) -> FrodoResult<(Ciphertext, SharedSecret)>
Encapsulate with given message to generate a SharedSecret and a Ciphertext.
NOTE: The message and salt must be of the correct length for the algorithm.
Also, this method is deterministic, meaning that using the same message and salt
will yield the same SharedSecret and Ciphertext
Sourcepub fn encapsulate_with_rng(
&self,
public_key: &EncryptionKey,
rng: impl CryptoRng,
) -> FrodoResult<(Ciphertext, SharedSecret)>
pub fn encapsulate_with_rng( &self, public_key: &EncryptionKey, rng: impl CryptoRng, ) -> FrodoResult<(Ciphertext, SharedSecret)>
Encapsulate a random value to generate a SharedSecret and a Ciphertext.
Sourcepub fn try_encapsulate_with_rng(
&self,
public_key: &EncryptionKey,
rng: impl TryCryptoRng,
) -> FrodoResult<(Ciphertext, SharedSecret)>
pub fn try_encapsulate_with_rng( &self, public_key: &EncryptionKey, rng: impl TryCryptoRng, ) -> FrodoResult<(Ciphertext, SharedSecret)>
Try to encapsulate a random value to generate a SharedSecret and a Ciphertext.
Sourcepub fn decapsulate(
&self,
secret_key: &DecryptionKey,
ciphertext: &Ciphertext,
) -> FrodoResult<(SharedSecret, Vec<u8>)>
pub fn decapsulate( &self, secret_key: &DecryptionKey, ciphertext: &Ciphertext, ) -> FrodoResult<(SharedSecret, Vec<u8>)>
Decapsulate the Ciphertext to return the SharedSecret and
message generated during encapsulation.
Trait Implementations§
Source§impl ConstantTimeEq for Algorithm
impl ConstantTimeEq for Algorithm
Source§impl<'de> Deserialize<'de> for Algorithm
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Algorithm
serde only.