pub trait CredStore {
type CredHandle: 'static + Creds;
type ExportedCreds: 'static + Serialize + DeserializeOwned;
// Required methods
fn node_creds(&self) -> Result<Self::CredHandle>;
fn root_creds(&self, password: &str) -> Result<Self::CredHandle>;
fn storage_key(&self) -> Result<AsymKeyPub<Encrypt>>;
fn export_root_creds(
&self,
root_creds: &Self::CredHandle,
password: &str,
new_parent: &AsymKeyPub<Encrypt>
) -> Result<Self::ExportedCreds>;
}
Expand description
A trait for types which store credentials.
Required Associated Types§
sourcetype CredHandle: 'static + Creds
type CredHandle: 'static + Creds
The type of the credential handle returned by this store.
sourcetype ExportedCreds: 'static + Serialize + DeserializeOwned
type ExportedCreds: 'static + Serialize + DeserializeOwned
The type of the exported credentials returned by this store.
Required Methods§
sourcefn node_creds(&self) -> Result<Self::CredHandle>
fn node_creds(&self) -> Result<Self::CredHandle>
Returns the node credentials. If credentials haven’t been generated, they are generated stored and returned.
sourcefn root_creds(&self, password: &str) -> Result<Self::CredHandle>
fn root_creds(&self, password: &str) -> Result<Self::CredHandle>
Returns the root credentials. If no root credentials have been generated, or the provided password is incorrect, then an error is returned.
sourcefn storage_key(&self) -> Result<AsymKeyPub<Encrypt>>
fn storage_key(&self) -> Result<AsymKeyPub<Encrypt>>
Returns a public key which can be used to encrypt data intended only to be accessed by this
node. The returned key can be given as the new_parent
parameter to the
CredStore::export_root_creds method.
sourcefn export_root_creds(
&self,
root_creds: &Self::CredHandle,
password: &str,
new_parent: &AsymKeyPub<Encrypt>
) -> Result<Self::ExportedCreds>
fn export_root_creds( &self, root_creds: &Self::CredHandle, password: &str, new_parent: &AsymKeyPub<Encrypt> ) -> Result<Self::ExportedCreds>
Exports the root credentials. These can be serialized and persisted external to the
application and later loaded and deserialized and passed to the
CredStoreMut::import_root_creds method.
The password
argument must match the value provided when the CredStore::root_creds
method was called. The new_parent
argument is the public key of the node that is to import
the root key, which can be obtained using the CredStoreMut::gen_root_creds method on the
importing node.