FilePib

Struct FilePib 

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

File-based Public Info Base (PIB) for persistent key and certificate storage.

§Directory layout

<root>/
  keys/<sha256>/
    name.uri          # NDN name in URI form (human-readable)
    private.key       # 32-byte raw Ed25519 seed
    cert.ndnc         # NDNC-format certificate (optional)
  anchors/<sha256>/
    name.uri
    cert.ndnc

Key directories are named by the SHA-256 of the canonical name bytes to avoid filesystem special-character issues. The name.uri file provides the human-readable name for list operations.

§Certificate format (NDNC v1)

[4]  magic "NDNC"
[1]  version = 1
[8]  valid_from  (u64 be, nanoseconds since Unix epoch)
[8]  valid_until (u64 be, nanoseconds since Unix epoch; u64::MAX = never)
[4]  pk_len      (u32 be)
[pk_len] public key bytes

Implementations§

Source§

impl FilePib

Source

pub fn new(root: impl Into<PathBuf>) -> Result<Self, PibError>

Create or open a PIB at root, creating the directory tree if needed.

Source

pub fn open(root: impl Into<PathBuf>) -> Result<Self, PibError>

Open an existing PIB without creating it. Returns an error if root does not contain an initialised PIB.

Source

pub fn root(&self) -> &Path

Return the root directory of this PIB.

Source

pub fn generate_ed25519( &self, key_name: &Name, ) -> Result<Ed25519Signer, PibError>

Generate a new Ed25519 key using a cryptographically random seed and persist it to the PIB. Returns the signer so the caller can immediately issue a certificate without re-reading from disk.

Source

pub fn get_signer(&self, key_name: &Name) -> Result<Ed25519Signer, PibError>

Load the signer for key_name from the PIB.

Source

pub fn delete_key(&self, key_name: &Name) -> Result<(), PibError>

Delete a key and its associated certificate from the PIB.

Source

pub fn list_keys(&self) -> Result<Vec<Name>, PibError>

List all key names stored in the PIB.

Source

pub fn store_cert( &self, key_name: &Name, cert: &Certificate, ) -> Result<(), PibError>

Persist a certificate for key_name in its key directory.

Source

pub fn get_cert(&self, key_name: &Name) -> Result<Certificate, PibError>

Load the certificate for key_name.

Source

pub fn add_trust_anchor( &self, key_name: &Name, cert: &Certificate, ) -> Result<(), PibError>

Persist a certificate as a trust anchor.

Source

pub fn remove_trust_anchor(&self, key_name: &Name) -> Result<(), PibError>

Remove a trust anchor from the PIB.

Source

pub fn trust_anchors(&self) -> Result<Vec<Certificate>, PibError>

Load all trust anchor certificates from the PIB.

Source

pub fn list_anchors(&self) -> Result<Vec<Name>, PibError>

List all trust anchor names stored in the PIB.

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.
§

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

§

fn vzip(self) -> V