Skip to main content

UserKey

Enum UserKey 

Source
pub enum UserKey {
    X25519(Identity),
    Pq(Identity),
}
Expand description

One user’s encryption key (the private half).

Variants§

§

X25519(Identity)

An age X25519 key: classic, for classic repositories (the opt-out).

§

Pq(Identity)

age’s hybrid ML-KEM-768 + X25519 key, for quantum-safe repositories: what a new key is unless asked otherwise (Level::NEW).

Implementations§

Source§

impl UserKey

Source

pub fn generate(level: Level) -> Result<UserKey, UserKeyError>

A new user key for repositories of level (Level::NEW unless the person asked for a classic one).

Source

pub fn public(&self) -> String

The public half: what a members line and the server hold (age1…, or age1pq1…).

Source

pub fn level(&self) -> Level

The level of repositories this key can be a member of.

Source

pub fn identity(&self) -> &dyn Identity

As an age identity: what opens a repository’s key ring.

Source

pub fn wrap_to(&self, recipient: &dyn Recipient) -> Result<String, UserKeyError>

Wrap this key to one unlock method’s age recipient: one armored age file, to be stored on the server as the method’s wrap.

Source

pub fn wrap_to_security_key( &self, recipient: &str, ) -> Result<String, UserKeyError>

Wrap this key to a security key’s recipient (the age1… string security_key::recipient gave at enrolment).

Source

pub fn wrap_to_security_key_v2( &self, prf_output: &[u8; 32], credential_id: &[u8], ) -> Result<String, UserKeyError>

Wrap this key to a security key, v2 (CRYPT-PQ-SK): a fresh 32-byte salt, HKDF-SHA256(salt, prf_output, "gunnar-crypt user-key wrap v2") as the key, XChaCha20-Poly1305 with a fresh nonce over the key’s payload, the credential id bound in the associated data. Symmetric, so quantum-safe; no X25519 step.

Source

pub fn wrap_to_recovery_code(&self, code: &str) -> Result<String, UserKeyError>

Wrap this key to a printed recovery code: age’s scrypt stanza at the FIXED work factor recovery_code::LOG_N (scrypt N = 2^18, r = 8, p = 1: about 256 MiB and a second), on top of the code’s 160 random bits.

Source

pub fn wrap_to_ssh(&self, public_key: &str) -> Result<String, UserKeyError>

Wrap this key to an SSH public key line (ssh-ed25519 …, ssh-rsa …). The wrap is age’s SSH stanza (X25519 for ed25519, RSA-OAEP for RSA): CLASSICAL, also for a quantum-safe key (SSH_WRAP_IS_CLASSICAL).

Source

pub fn wrap_to_pq(&self, public_key: &str) -> Result<String, UserKeyError>

Wrap this key to an age1pq1… key (a key file made by gunnar crypt keygen).

Trait Implementations§

Source§

impl Debug for UserKey

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

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

Source§

fn vzip(self) -> V