Skip to main content

Algorithm

Enum Algorithm 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

pub const fn enabled_algorithms() -> &'static [Algorithm]

Every parameter set enabled in this build, in a stable order.

Source§

impl Algorithm

Source

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

Source

pub const fn name(&self) -> &'static str

The lowercase parameter set name, e.g. mceliece6960119f.

Source

pub const fn params(&self) -> AlgorithmParams

The parameters underlying this parameter set.

Source

pub fn generate_keypair( &self, rng: impl CryptoRng, ) -> (EncapsulationKey, DecapsulationKey)

Generate a key pair, drawing a fresh seed from rng.

Source

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.

Source

pub fn encapsulate( &self, key: &EncapsulationKey, rng: impl CryptoRng, ) -> McElieceResult<(Ciphertext, SharedSecret)>

Encapsulate to key, producing a ciphertext and the shared secret it transports.

Source

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.

Source

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.

Source

pub fn encapsulation_key_from_bytes( &self, value: &[u8], ) -> McElieceResult<EncapsulationKey>

Parse bytes as an encapsulation key for this parameter set.

Source

pub fn decapsulation_key_from_bytes( &self, value: &[u8], ) -> McElieceResult<DecapsulationKey>

Parse bytes as a decapsulation key for this parameter set.

Source

pub fn ciphertext_from_bytes(&self, value: &[u8]) -> McElieceResult<Ciphertext>

Parse bytes as a ciphertext for this parameter set.

Source

pub fn shared_secret_from_bytes( &self, value: &[u8], ) -> McElieceResult<SharedSecret>

Parse bytes as a shared secret for this parameter set.

Trait Implementations§

Source§

impl Clone for Algorithm

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Algorithm

Source§

impl CtEq for Algorithm

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if self is equal to other in constant-time.
Source§

fn ct_ne(&self, other: &Rhs) -> Choice

Determine if self is NOT equal to other in constant-time.
Source§

impl Debug for Algorithm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Algorithm

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Algorithm

Available on crate feature serde only.
Source§

fn deserialize<D>(d: D) -> Result<Algorithm, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Algorithm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Algorithm

Source§

impl From<Algorithm> for u8

Source§

fn from(algorithm: Algorithm) -> u8

Converts to this type from the input type.
Source§

impl From<Algorithm> for u16

Source§

fn from(algorithm: Algorithm) -> Self

Converts to this type from the input type.
Source§

impl From<Algorithm> for u32

Source§

fn from(algorithm: Algorithm) -> Self

Converts to this type from the input type.
Source§

impl From<Algorithm> for u64

Source§

fn from(algorithm: Algorithm) -> Self

Converts to this type from the input type.
Source§

impl From<Algorithm> for u128

Source§

fn from(algorithm: Algorithm) -> Self

Converts to this type from the input type.
Source§

impl From<Algorithm> for usize

Source§

fn from(algorithm: Algorithm) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Algorithm

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Algorithm

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Algorithm

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Algorithm

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Algorithm

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Algorithm

Available on crate feature serde only.
Source§

fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Algorithm

Source§

impl TryFrom<u8> for Algorithm

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u16> for Algorithm

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: u16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u32> for Algorithm

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u64> for Algorithm

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u128> for Algorithm

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<usize> for Algorithm

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.