Skip to main content

KariRecipient

Struct KariRecipient 

Source
pub struct KariRecipient {
    pub issuer_der: Vec<u8>,
    pub serial: Vec<u8>,
    pub curve: KariCurve,
    pub kdf: KariKdf,
    pub recipient_pub_bytes: Vec<u8>,
    pub ephemeral_scalar: Vec<u8>,
}
Expand description

One KARI recipient slot the writer will emit. The recipient is identified by their X.509 certificate (issuer + serial — KARI RecipientEncryptedKey IAS form), and recipient_pub_bytes carries their public key in the curve’s encoded form (SEC1 uncompressed for P-256 / P-384 / P-521, raw 32-byte u-coordinate for X25519).

Fields§

§issuer_der: Vec<u8>

Recipient certificate’s issuer DER (a SEQUENCE — same shape as super::cms_build::RecipientIdRef::IssuerAndSerial::issuer_der).

§serial: Vec<u8>

Recipient cert’s serial number INTEGER body bytes.

§curve: KariCurve

Curve the recipient’s keypair lives on. Determines the ECDH primitive + ephemeral keypair shape the writer will emit.

§kdf: KariKdf

KDF binding the writer will encode in KeyAgreeRecipientInfo.keyEncryptionAlgorithm. Defaults via the per-curve constructors to super::kari::KariCurve::default_kdf: RFC 5753 §7.1.4 X9.63 with the matching hash for NIST curves; RFC 8418 §2.1 X9.63-SHA-256 for X25519. Use the x25519_hkdf_* constructors to switch X25519 to the modern RFC 8418 §2.2 HKDF binding.

§recipient_pub_bytes: Vec<u8>

Recipient’s encoded public key. SEC1 uncompressed point for NIST curves; raw 32-byte u-coordinate for X25519.

§ephemeral_scalar: Vec<u8>

Ephemeral private scalar used for THIS recipient’s wrap. Each recipient gets its own ephemeral keypair so the writer can mix curves across recipients in a single envelope (one KARI per curve / ephemeral). Tests pin to a deterministic value; production callers should use a fresh random scalar per recipient.

Implementations§

Source§

impl KariRecipient

Source

pub fn p256( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_sec1: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Build a P-256 recipient (X9.63-SHA-256 KDF per RFC 5753 §7.1.4).

Source

pub fn p384( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_sec1: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Build a P-384 recipient (X9.63-SHA-384 KDF per RFC 5753 §7.1.4).

Source

pub fn p521( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_sec1: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Round-16: build a P-521 recipient (X9.63-SHA-512 KDF per RFC 5753 §7.1.4 — dhSinglePass-stdDH-sha512kdf-scheme, OID 1.3.132.1.11.3).

Source

pub fn x25519( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_x25519: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Build an X25519 recipient with the legacy X9.63-SHA-256 KDF binding (RFC 8418 §2.1).

Source

pub fn x25519_hkdf_sha256( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_x25519: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Round-16: build an X25519 recipient with the modern HKDF-SHA-256 KDF binding (RFC 8418 §2.2 — dhSinglePass-stdDH-hkdf-sha256-scheme, smime-alg 19).

Source

pub fn x25519_hkdf_sha384( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_x25519: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Round-16: build an X25519 recipient with HKDF-SHA-384 (RFC 8418 §2.2 — dhSinglePass-stdDH-hkdf-sha384-scheme, smime-alg 20).

Source

pub fn x25519_hkdf_sha512( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_x25519: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Round-16: build an X25519 recipient with HKDF-SHA-512 (RFC 8418 §2.2 — dhSinglePass-stdDH-hkdf-sha512-scheme, smime-alg 21).

Source

pub fn x448( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_x448: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Round-24: build an X448 recipient with the default X9.63-SHA-512 KDF binding (RFC 8418 §2.1 — dhSinglePass-stdDH-sha512kdf-scheme). recipient_pub_x448 is the recipient’s 56-byte raw u-coordinate; ephemeral_scalar is the 56-byte ephemeral private key (RFC 7748 §5 clamping is applied by the underlying x448 crate at scalar load).

Source

pub fn x448_hkdf_sha256( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_x448: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Round-24: build an X448 recipient with the modern HKDF-SHA-256 KDF binding (RFC 8418 §2.2 — dhSinglePass-stdDH-hkdf-sha256-scheme, smime-alg 19). Same shape as Self::x448 but with the HKDF flavour swapped in.

Source

pub fn x448_hkdf_sha384( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_x448: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Round-24: build an X448 recipient with HKDF-SHA-384 (RFC 8418 §2.2 — dhSinglePass-stdDH-hkdf-sha384-scheme, smime-alg 20).

Source

pub fn x448_hkdf_sha512( issuer_der: Vec<u8>, serial: Vec<u8>, recipient_pub_x448: Vec<u8>, ephemeral_scalar: Vec<u8>, ) -> Self

Round-24: build an X448 recipient with HKDF-SHA-512 (RFC 8418 §2.2 — dhSinglePass-stdDH-hkdf-sha512-scheme, smime-alg 21 — the security-strength match for X448’s 224-bit level under HKDF).

Trait Implementations§

Source§

impl Clone for KariRecipient

Source§

fn clone(&self) -> KariRecipient

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 Debug for KariRecipient

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V