Skip to main content

NodeIdentity

Struct NodeIdentity 

Source
pub struct NodeIdentity { /* private fields */ }
Expand description

Keys the node holds. Persisted as two 0600 files in the node’s own state directory.

Implementations§

Source§

impl NodeIdentity

Source

pub fn generate() -> Result<Self, EnrollError>

Source

pub fn from_seeds(identity_seed: [u8; 32], wg_seed: [u8; 32]) -> Self

Deterministic construction for tests.

Source

pub fn identity_public_key(&self) -> String

Source

pub fn wg_public_key(&self) -> String

Source

pub fn identity_path(dir: &Path) -> PathBuf

Paths of the key files inside dir.

Source

pub fn wg_path(dir: &Path) -> PathBuf

The WireGuard private key file, in the base64 format wg and the node’s GATE4AGENT_WG_PRIVATE_KEY path expect.

Source

pub fn load_or_create(dir: &Path) -> Result<Self, EnrollError>

Load the keys from dir, or generate and store them (directory 0700, files 0600).

Source

pub fn load_signing_only(dir: &Path) -> Result<Self, EnrollError>

Load only the signing identity (for a node whose tunnel is set up by a privileged helper and which therefore never needs, or reads, the WireGuard private key). The returned identity carries a throwaway WireGuard secret that is never written anywhere.

Source

pub fn sign_bytes(&self, message: &[u8]) -> String

Sign arbitrary bytes with the node identity (callers add their own domain prefix).

Source

pub fn sign_request( &self, node_id: &str, kind: NodeKind, code: Option<&str>, now_ms: u64, ) -> Result<EnrollmentRequest, EnrollError>

Build and sign an enrollment request.

Source

pub fn answer_challenge( &self, node_id: &str, challenge_frame: &[u8; 68], ) -> Result<([u8; 96], String), EnrollError>

Answer a call-home challenge. Returns the answer frame and the session token.

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