Skip to main content

KeyAlgorithm

Enum KeyAlgorithm 

Source
pub enum KeyAlgorithm {
    Rsa,
    EcdsaP256,
    EcdsaP384,
    MlDsa44,
    MlDsa65,
    MlDsa87,
    MlKem512,
    MlKem768,
    MlKem1024,
    Unknown(String),
}
Expand description

Key algorithm detected from SubjectPublicKeyInfo in a CSR.

Per RFC 2986 §4.1, the SubjectPublicKeyInfo field contains an AlgorithmIdentifier that specifies the key algorithm and any algorithm-specific parameters (e.g., named curves for ECDSA).

Variants§

§

Rsa

RSA (OID 1.2.840.113549.1.1.1).

§

EcdsaP256

ECDSA P-256 (OID 1.2.840.10045.2.1 + namedCurve 1.2.840.10045.3.1.7).

§

EcdsaP384

ECDSA P-384 (OID 1.2.840.10045.2.1 + namedCurve 1.3.132.0.34).

§

MlDsa44

ML-DSA-44 (OID 2.16.840.1.101.3.4.3.17) per FIPS 204.

§

MlDsa65

ML-DSA-65 (OID 2.16.840.1.101.3.4.3.18) per FIPS 204.

§

MlDsa87

ML-DSA-87 (OID 2.16.840.1.101.3.4.3.19) per FIPS 204.

§

MlKem512

ML-KEM-512 (OID 2.16.840.1.101.3.4.4.1) per FIPS 203.

§

MlKem768

ML-KEM-768 (OID 2.16.840.1.101.3.4.4.2) per FIPS 203.

§

MlKem1024

ML-KEM-1024 (OID 2.16.840.1.101.3.4.4.3) per FIPS 203.

§

Unknown(String)

Unknown algorithm with the given OID string.

Implementations§

Source§

impl KeyAlgorithm

Source

pub fn from_oid(oid: &str) -> Self

Parse a key algorithm from its OID string.

For EC keys, the caller must also supply the named curve OID via KeyAlgorithm::from_ec_oid.

Source

pub fn from_ec_oid(curve_oid: &str) -> Self

Refine an EC public key algorithm using the named curve OID.

Per RFC 5480 §2.1.1, the AlgorithmIdentifier for EC keys includes the namedCurve parameter that identifies the specific curve.

Source

pub fn oid(&self) -> &str

Returns the OID string for this algorithm.

Trait Implementations§

Source§

impl Clone for KeyAlgorithm

Source§

fn clone(&self) -> KeyAlgorithm

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyAlgorithm

Source§

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

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

impl PartialEq for KeyAlgorithm

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for KeyAlgorithm

Source§

impl StructuralPartialEq for KeyAlgorithm

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.