Struct trust_graph::Certificate
source · pub struct Certificate {
pub chain: Vec<Trust>,
}
Expand description
Chain of trusts started from self-signed root trust.
Fields§
§chain: Vec<Trust>
Implementations§
source§impl Certificate
impl Certificate
pub fn new_unverified(chain: Vec<Trust>) -> Self
pub fn new_from_root_trust( root_trust: Trust, issued_trust: Trust, cur_time: Duration ) -> Result<Self, CertificateError>
pub fn issue_with_trust( issued_by: PublicKey, trust: Trust, extend_cert: &Certificate, cur_time: Duration ) -> Result<Self, CertificateError>
sourcepub fn issue_root(
root_kp: &KeyPair,
for_pk: PublicKey,
expires_at: Duration,
issued_at: Duration
) -> Self
pub fn issue_root( root_kp: &KeyPair, for_pk: PublicKey, expires_at: Duration, issued_at: Duration ) -> Self
Creates new certificate with root trust (self-signed public key) from a key pair.
sourcepub fn issue(
issued_by: &KeyPair,
for_pk: PublicKey,
extend_cert: &Certificate,
expires_at: Duration,
issued_at: Duration,
cur_time: Duration
) -> Result<Self, CertificateError>
pub fn issue( issued_by: &KeyPair, for_pk: PublicKey, extend_cert: &Certificate, expires_at: Duration, issued_at: Duration, cur_time: Duration ) -> Result<Self, CertificateError>
Adds a new trust into chain of trust in certificate.
sourcepub fn verify(
cert: &Certificate,
trusted_roots: &[PublicKey],
cur_time: Duration
) -> Result<(), CertificateError>
pub fn verify( cert: &Certificate, trusted_roots: &[PublicKey], cur_time: Duration ) -> Result<(), CertificateError>
Verifies that a certificate is valid and you trust to this certificate.
sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Convert certificate to byte format 2 format + 4 version + 1 trusts number + ((1 trust size byte + trust) for each trust)
pub fn decode(arr: &[u8]) -> Result<Self, CertificateError>
Trait Implementations§
source§impl Clone for Certificate
impl Clone for Certificate
source§fn clone(&self) -> Certificate
fn clone(&self) -> Certificate
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Certificate
impl Debug for Certificate
source§impl Display for Certificate
impl Display for Certificate
source§impl FromStr for Certificate
impl FromStr for Certificate
source§impl PartialEq for Certificate
impl PartialEq for Certificate
source§fn eq(&self, other: &Certificate) -> bool
fn eq(&self, other: &Certificate) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for Certificate
impl StructuralEq for Certificate
impl StructuralPartialEq for Certificate
Auto Trait Implementations§
impl RefUnwindSafe for Certificate
impl Send for Certificate
impl Sync for Certificate
impl Unpin for Certificate
impl UnwindSafe for Certificate
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more