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.ndncKey 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 bytesImplementations§
Source§impl FilePib
impl FilePib
Sourcepub fn new(root: impl Into<PathBuf>) -> Result<Self, PibError>
pub fn new(root: impl Into<PathBuf>) -> Result<Self, PibError>
Create or open a PIB at root, creating the directory tree if needed.
Sourcepub fn open(root: impl Into<PathBuf>) -> Result<Self, PibError>
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.
Sourcepub fn generate_ed25519(
&self,
key_name: &Name,
) -> Result<Ed25519Signer, PibError>
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.
Sourcepub fn get_signer(&self, key_name: &Name) -> Result<Ed25519Signer, PibError>
pub fn get_signer(&self, key_name: &Name) -> Result<Ed25519Signer, PibError>
Load the signer for key_name from the PIB.
Sourcepub fn delete_key(&self, key_name: &Name) -> Result<(), PibError>
pub fn delete_key(&self, key_name: &Name) -> Result<(), PibError>
Delete a key and its associated certificate from the PIB.
Sourcepub fn store_cert(
&self,
key_name: &Name,
cert: &Certificate,
) -> Result<(), PibError>
pub fn store_cert( &self, key_name: &Name, cert: &Certificate, ) -> Result<(), PibError>
Persist a certificate for key_name in its key directory.
Sourcepub fn get_cert(&self, key_name: &Name) -> Result<Certificate, PibError>
pub fn get_cert(&self, key_name: &Name) -> Result<Certificate, PibError>
Load the certificate for key_name.
Sourcepub fn add_trust_anchor(
&self,
key_name: &Name,
cert: &Certificate,
) -> Result<(), PibError>
pub fn add_trust_anchor( &self, key_name: &Name, cert: &Certificate, ) -> Result<(), PibError>
Persist a certificate as a trust anchor.
Sourcepub fn remove_trust_anchor(&self, key_name: &Name) -> Result<(), PibError>
pub fn remove_trust_anchor(&self, key_name: &Name) -> Result<(), PibError>
Remove a trust anchor from the PIB.
Sourcepub fn trust_anchors(&self) -> Result<Vec<Certificate>, PibError>
pub fn trust_anchors(&self) -> Result<Vec<Certificate>, PibError>
Load all trust anchor certificates from the PIB.