pub struct Network<S>where
S: Store,{ /* private fields */ }
Expand description
A certification network.
Implementations§
Source§impl<'a, S> Network<S>
The lifetimes 'a
and 'b
have the same meaning as for
Store
: 'a
is the lifetime of the object on the backend, 'b
is the lifetime of the reference to the object, and the object
('a
) must outlive the reference ('b
).
impl<'a, S> Network<S>
The lifetimes 'a
and 'b
have the same meaning as for
Store
: 'a
is the lifetime of the object on the backend, 'b
is the lifetime of the reference to the object, and the object
('a
) must outlive the reference ('b
).
Sourcepub fn path<U>(
&self,
khs: &[KeyHandle],
userid: U,
required_amount: usize,
policy: &dyn Policy,
) -> Result<Path>
pub fn path<U>( &self, khs: &[KeyHandle], userid: U, required_amount: usize, policy: &dyn Policy, ) -> Result<Path>
Authenticates a path in the network.
This checks that there are valid certifications from the first
certificate in khs
to the last over the User ID, userid
for the specified trust amount.
This function will return Ok
if a path with the required
trust amount can be found.
Unlike Network::lint_path
, this function returns as soon
as an error is encountered.
This function requires that the Network
object implement
Backend
in addition to Store
. This is technically
needed by Network::lint_path
to provide better diagnostics,
but it is not strictly required by Network::path
, which
only needs active certifications. This requirement exists,
because Network::path
and Network::lint_path
share a
fair amount of code. This bound may be lifted in the future.
Sourcepub fn lint_path<U>(
&self,
khs: &[KeyHandle],
userid: U,
required_amount: usize,
policy: &dyn Policy,
) -> Result<PathLints<'a>>
pub fn lint_path<U>( &self, khs: &[KeyHandle], userid: U, required_amount: usize, policy: &dyn Policy, ) -> Result<PathLints<'a>>
Lints a path in the network.
This checks that the there are valid certifications from the
first certificate in khs
to the last over the User ID,
userid
.
This function almost always returns Ok
; it only returns an
error in an extraordinary circumstance.
Unlike Network::path
, this function does extra work to
identify reasons why a path is invalid. For instance, if
there is no valid certification for a path segment, but there
is an expired certification that is expired, this function
will indicate that.
Source§impl<S> Network<S>where
S: Store,
impl<S> Network<S>where
S: Store,
Sourcepub fn new<R>(store: S, roots: R) -> Result<Self>
pub fn new<R>(store: S, roots: R) -> Result<Self>
Returns a rooted Network.
By default, the Network
is an authentication network. In
this mode of operation, plain certifications are only
considered certifications, and the target is not considered to
be a trusted introducer. An alternative mode of operation is
a certification network. This can be configured using
NetworkBuilder::certification_network
.
Source§impl<'a: 'policy, 'policy> Network<CertStore<'a, 'policy, Certs<'a>>>
impl<'a: 'policy, 'policy> Network<CertStore<'a, 'policy, Certs<'a>>>
Sourcepub fn from_certs<I, C, T, R>(
certs: I,
policy: &'policy dyn Policy,
t: T,
roots: R,
) -> Result<Self>
pub fn from_certs<I, C, T, R>( certs: I, policy: &'policy dyn Policy, t: T, roots: R, ) -> Result<Self>
Builds a web of trust network from a set of certificates.
If a certificate is invalid according to the policy, the certificate is silently ignored.
Sourcepub fn from_cert_refs<I, C, T, R>(
certs: I,
policy: &'policy dyn Policy,
t: T,
roots: R,
) -> Result<Self>
pub fn from_cert_refs<I, C, T, R>( certs: I, policy: &'policy dyn Policy, t: T, roots: R, ) -> Result<Self>
Builds a web of trust network from a set of certificates.
If a certificate is invalid according to the policy, the certificate is silently ignored.
Sourcepub fn from_bytes<T, R>(
certs: &'a [u8],
policy: &'policy dyn Policy,
t: T,
roots: R,
) -> Result<Self>
pub fn from_bytes<T, R>( certs: &'a [u8], policy: &'policy dyn Policy, t: T, roots: R, ) -> Result<Self>
Builds a web of trust network from a keyring.
If a certificate is invalid according to the policy, the certificate is silently ignored.
Source§impl<'a> Network<SynopsisSlice<'a>>
impl<'a> Network<SynopsisSlice<'a>>
Sourcepub fn from_synopses<R>(
certs: &'a [CertSynopsis],
certifications: &'a [Certification],
t: SystemTime,
roots: R,
) -> Result<Self>
pub fn from_synopses<R>( certs: &'a [CertSynopsis], certifications: &'a [Certification], t: SystemTime, roots: R, ) -> Result<Self>
Builds a web of trust network from a set of certificates.
If a certificate is invalid according to the policy, the certificate is silently ignored.
Source§impl<S> Network<S>where
S: Store,
impl<S> Network<S>where
S: Store,
Sourcepub fn is_root<F>(&self, fpr: F) -> boolwhere
F: Borrow<Fingerprint>,
pub fn is_root<F>(&self, fpr: F) -> boolwhere
F: Borrow<Fingerprint>,
Returns whether the specified certificate is a root.
Sourcepub fn root<F>(&self, fpr: F) -> Option<&Root>where
F: Borrow<Fingerprint>,
pub fn root<F>(&self, fpr: F) -> Option<&Root>where
F: Borrow<Fingerprint>,
Returns the specified root.
Sourcepub fn certification_network(&self) -> bool
pub fn certification_network(&self) -> bool
Returns whether the Network
is a certification network.
See NetworkBuilder::certification_network
for
details.
Sourcepub fn authentication_network(&self) -> bool
pub fn authentication_network(&self) -> bool
Returns whether the Network
is an authentication network.
See NetworkBuilder::certification_network
for
details.
Sourcepub fn maximum_depth(&mut self) -> Option<usize>
pub fn maximum_depth(&mut self) -> Option<usize>
Returns the maximum depth.
With the depth limited to 0
, the maximum lengths of paths
will be two, with the paths containing the certifier and the
target).
Sourcepub fn authenticate<U, F>(
&self,
target_userid: U,
target_fpr: F,
target_trust_amount: usize,
) -> Paths
pub fn authenticate<U, F>( &self, target_userid: U, target_fpr: F, target_trust_amount: usize, ) -> Paths
Authenticates the specified binding.
Enough independent paths are gotten to satisfy
target_trust_amount
. A fully trusted authentication is 120.
If you require that a binding be double authenticated, you can
specify 240.
Sourcepub fn gossip<U, F>(&self, target_fpr: F, target_userid: U) -> Paths
pub fn gossip<U, F>(&self, target_fpr: F, target_userid: U) -> Paths
Gets gossip about the specified binding.
This is like Network::authenticate
, but it also includes
all unauthenticated paths to the target binding. The
aggregate trust amount is accurate.
Note: the paths are dedup based on whether they are a suffix
of another path. That is, if A -> B -> C
is a valid gossip
path, then so is B -> C
.