Cert

Struct Cert 

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

The certificate struct. It is either public or secret.

Public certificate means that it does not contain secret keys. Whereas a secret certificate is fully featured - it contains secret keys and public keys.

Each certificate has a user id (Cert::user_id) and a (hopefully) unique fingerprint (Cert::fingerprint).

§Serialization

Certificates implement serde::Serialize and serde::Deserialize traits, which allow for serialization and deserialization using any serde format. Additionally for human readable formats certificates serialize bytes as hex encoded strings to please the users’ eyes.

§A note on equality

Two certificates are equal if they have the same secrecy and serialized public forms are equal. Usually comparing fingerprints should be enough, but the blake3 hashing algorithm used for fingerprints may not be fully collision proof. Thus adding the public keys into the mix ensures equality.

Implementations§

Source§

impl Cert

Source

pub fn new(uid: &str) -> Self

Generates a new certificate with the given uid.

Source

pub fn fingerprint(&self) -> &Fingerprint

Returns the certificate’s fingerprint.

Source

pub fn user_id(&self) -> &str

Returns the user id of the certificate.

Source

pub fn encryption_public(&self) -> &PublicKey

Returns the encryption public key of this certificate.

Source

pub fn signing_public(&self) -> &VerifyingKey

Returns the signing public key of this certificate.

Source

pub fn encryption_secret(&self) -> Option<&StaticSecret>

Returns the encryption secret key of this certificate if Some.

Source

pub fn signing_secret(&self) -> Option<&SecretKey>

Returns the signing secret key of this certificate if Some.

Source

pub fn is_secret(&self) -> bool

Checks whether the certificate is a secret certificate.

Source

pub fn strip_secrets(self) -> Self

Consumes self and returns a public version of the certificate. When used on a public certificate, does nothing.

Trait Implementations§

Source§

impl Clone for Cert

Source§

fn clone(&self) -> Cert

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cert

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Cert

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Cert

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Cert

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for Cert

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Cert

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Cert

§

impl RefUnwindSafe for Cert

§

impl Send for Cert

§

impl Sync for Cert

§

impl Unpin for Cert

§

impl UnwindSafe for Cert

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,