Skip to main content

CryptoType

Enum CryptoType 

Source
#[non_exhaustive]
pub enum CryptoType { ElGamal, EciesP256, EciesX25519, EciesMlkem512X25519, EciesMlkem768X25519, EciesMlkem1024X25519, }
Expand description

An encryption algorithm a destination’s LeaseSet2 can advertise as usable – see I2pRouter::create_persistent_destination’s encryption_types parameter.

Values are libi2pd’s protocol-level CryptoKeyType (libi2pd/Identity.h). This covers only the advertised encryption capability, never the identity certificate, which is ElGamal either way (see I2pRouter::generate_keys).

An empty encryption_types slice already gets libi2pd’s hybrid default (ElGamal + ECIES-X25519, plus ML-KEM-768 on a post-quantum-capable backend); explicit values only ever narrow that. The EciesMlkem* variants are new enough that older peers may not understand a destination advertising one, so they trade reachability for long-term confidentiality.

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.
§

ElGamal

The original ElGamal scheme. For old persisted keys only.

§

EciesP256

ECIES on the P-256 curve with AES-256-CBC. Not widely used on the I2P network.

§

EciesX25519

ECIES-X25519-AEAD (ChaCha20/Poly1305). The I2P network’s current default.

§

EciesMlkem512X25519

ECIES-X25519-AEAD hybridized with ML-KEM-512 (NIST PQC category 1).

§

EciesMlkem768X25519

ECIES-X25519-AEAD hybridized with ML-KEM-768 (NIST PQC category 3).

§

EciesMlkem1024X25519

ECIES-X25519-AEAD hybridized with ML-KEM-1024 (NIST PQC category 5).

Implementations§

Source§

impl CryptoType

Source

pub fn is_supported(self) -> bool

Whether the linked crypto backend can actually perform this algorithm. Always true for the classical types; for the EciesMlkem* ones it runs a real generate/encapsulate/decapsulate round trip through libi2pd’s MLKEMKeys rather than checking a feature flag. Sub-millisecond but not free – cache it, don’t call it per connection. Needs no running router.

Check this before naming an EciesMlkem* type in create_persistent_destination: a LeaseSet2 advertising only algorithms this router cannot perform leaves the destination unreachable, with nothing in the address or the creation result to say so.

Trait Implementations§

Source§

impl Clone for CryptoType

Source§

fn clone(&self) -> CryptoType

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 CryptoType

Source§

impl Debug for CryptoType

Source§

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

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

impl Default for CryptoType

Source§

fn default() -> CryptoType

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

impl Eq for CryptoType

Source§

impl PartialEq for CryptoType

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CryptoType

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> 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.