#[non_exhaustive]pub enum Algorithm {
Show 18 variants
McEliece348864,
McEliece348864f,
McEliece460896,
McEliece460896f,
McEliece460896pc,
McEliece460896pcf,
McEliece6688128,
McEliece6688128f,
McEliece6688128pc,
McEliece6688128pcf,
McEliece6960119,
McEliece6960119f,
McEliece6960119pc,
McEliece6960119pcf,
McEliece8192128,
McEliece8192128f,
McEliece8192128pc,
McEliece8192128pcf,
}Expand description
A Classic McEliece parameter set, selected at run time.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
McEliece348864
mceliece348864: NIST category 1. In the NIST submission only.
McEliece348864f
mceliece348864f: mceliece348864 with faster semi-systematic key generation.
McEliece460896
mceliece460896: NIST category 3.
McEliece460896f
mceliece460896f: mceliece460896 with faster semi-systematic key generation.
McEliece460896pc
mceliece460896pc: mceliece460896 with plaintext confirmation. ISO only.
McEliece460896pcf
mceliece460896pcf: plaintext confirmation and semi-systematic key generation.
McEliece6688128
mceliece6688128: NIST category 5.
McEliece6688128f
mceliece6688128f: mceliece6688128 with faster semi-systematic key generation.
McEliece6688128pc
mceliece6688128pc: mceliece6688128 with plaintext confirmation. ISO only.
McEliece6688128pcf
mceliece6688128pcf: plaintext confirmation and semi-systematic key generation.
McEliece6960119
mceliece6960119: NIST category 5.
McEliece6960119f
mceliece6960119f: mceliece6960119 with faster semi-systematic key generation.
McEliece6960119pc
mceliece6960119pc: mceliece6960119 with plaintext confirmation. ISO only.
McEliece6960119pcf
mceliece6960119pcf: plaintext confirmation and semi-systematic key generation.
McEliece8192128
mceliece8192128: NIST category 5.
McEliece8192128f
mceliece8192128f: mceliece8192128 with faster semi-systematic key generation.
McEliece8192128pc
mceliece8192128pc: mceliece8192128 with plaintext confirmation. ISO only.
McEliece8192128pcf
mceliece8192128pcf: plaintext confirmation and semi-systematic key generation.
Implementations§
Source§impl Algorithm
impl Algorithm
Sourcepub const fn enabled_algorithms() -> &'static [Algorithm]
pub const fn enabled_algorithms() -> &'static [Algorithm]
Every parameter set enabled in this build, in a stable order.
Source§impl Algorithm
impl Algorithm
Sourcepub const RECOMMENDED: Algorithm = Algorithm::McEliece6960119f
pub const RECOMMENDED: Algorithm = Algorithm::McEliece6960119f
The parameter set to use when nothing else decides it: McEliece6960119f.
The Classic McEliece team recommends the mceliece6* sizes for long-term
security, and mceliece6960119 is the
original 1978-lineage size among them; the f variant generates keys faster and
draws them from the same distribution. See the crate documentation’s Choosing a
parameter set section for how the alternatives compare, and why mceliece348864
is for research rather than production.
Source§impl Algorithm
impl Algorithm
Sourcepub const fn name(&self) -> &'static str
pub const fn name(&self) -> &'static str
The lowercase parameter set name, e.g. mceliece6960119f.
Sourcepub const fn params(&self) -> AlgorithmParams
pub const fn params(&self) -> AlgorithmParams
The parameters underlying this parameter set.
Sourcepub fn generate_keypair(
&self,
rng: impl CryptoRng,
) -> (EncapsulationKey, DecapsulationKey)
pub fn generate_keypair( &self, rng: impl CryptoRng, ) -> (EncapsulationKey, DecapsulationKey)
Generate a key pair, drawing a fresh seed from rng.
Sourcepub fn generate_keypair_from_seed<B: AsRef<[u8]>>(
&self,
seed: B,
) -> McElieceResult<(EncapsulationKey, DecapsulationKey)>
pub fn generate_keypair_from_seed<B: AsRef<[u8]>>( &self, seed: B, ) -> McElieceResult<(EncapsulationKey, DecapsulationKey)>
Generate a key pair deterministically from a 32-byte seed.
The seed must come from a cryptographically secure source and is exactly as sensitive as the resulting private key.
Sourcepub fn encapsulate(
&self,
key: &EncapsulationKey,
rng: impl CryptoRng,
) -> McElieceResult<(Ciphertext, SharedSecret)>
pub fn encapsulate( &self, key: &EncapsulationKey, rng: impl CryptoRng, ) -> McElieceResult<(Ciphertext, SharedSecret)>
Encapsulate to key, producing a ciphertext and the shared secret it transports.
Sourcepub fn decapsulate(
&self,
key: &DecapsulationKey,
ciphertext: &Ciphertext,
) -> McElieceResult<SharedSecret>
pub fn decapsulate( &self, key: &DecapsulationKey, ciphertext: &Ciphertext, ) -> McElieceResult<SharedSecret>
Recover the shared secret from ciphertext.
A ciphertext that does not decode is not reported as an error. Classic McEliece rejects implicitly: the returned secret is derived from the private key’s rejection string, so it is unpredictable without the private key and identical every time the same bad ciphertext is presented.
Sourcepub fn encapsulation_key_from_decapsulation_key(
&self,
key: &DecapsulationKey,
) -> McElieceResult<EncapsulationKey>
pub fn encapsulation_key_from_decapsulation_key( &self, key: &DecapsulationKey, ) -> McElieceResult<EncapsulationKey>
Recover an encapsulation key from a decapsulation key.
The key must belong to this parameter set. Parameter sets within a size family share their private-key length, so without this check a key from a sibling set would be accepted, rerunning key generation under the wrong variant and yielding a public key that does not match the private key.
Sourcepub fn encapsulation_key_from_bytes(
&self,
value: &[u8],
) -> McElieceResult<EncapsulationKey>
pub fn encapsulation_key_from_bytes( &self, value: &[u8], ) -> McElieceResult<EncapsulationKey>
Parse bytes as an encapsulation key for this parameter set.
Sourcepub fn decapsulation_key_from_bytes(
&self,
value: &[u8],
) -> McElieceResult<DecapsulationKey>
pub fn decapsulation_key_from_bytes( &self, value: &[u8], ) -> McElieceResult<DecapsulationKey>
Parse bytes as a decapsulation key for this parameter set.
Sourcepub fn ciphertext_from_bytes(&self, value: &[u8]) -> McElieceResult<Ciphertext>
pub fn ciphertext_from_bytes(&self, value: &[u8]) -> McElieceResult<Ciphertext>
Parse bytes as a ciphertext for this parameter set.
Parse bytes as a shared secret for this parameter set.
Trait Implementations§
impl Copy for Algorithm
Source§impl<'de> Deserialize<'de> for Algorithm
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Algorithm
serde only.