Trait PublicKeyTrait

Source
pub trait PublicKeyTrait: Debug {
    // Required methods
    fn version(&self) -> KeyVersion;
    fn fingerprint(&self) -> Fingerprint;
    fn key_id(&self) -> KeyId;
    fn algorithm(&self) -> PublicKeyAlgorithm;
    fn created_at(&self) -> &DateTime<Utc>;
    fn expiration(&self) -> Option<u16>;
    fn verify_signature(
        &self,
        hash: HashAlgorithm,
        data: &[u8],
        sig: &SignatureBytes,
    ) -> Result<()>;
    fn encrypt<R: CryptoRng + Rng>(
        &self,
        rng: R,
        plain: &[u8],
        typ: EskType,
    ) -> Result<PkeskBytes>;
    fn serialize_for_hashing(&self, writer: &mut impl Write) -> Result<()>;
    fn public_params(&self) -> &PublicParams;

    // Provided methods
    fn is_signing_key(&self) -> bool { ... }
    fn is_encryption_key(&self) -> bool { ... }
}

Required Methods§

Source

fn version(&self) -> KeyVersion

Source

fn fingerprint(&self) -> Fingerprint

Source

fn key_id(&self) -> KeyId

Returns the Key ID of the associated primary key.

Source

fn algorithm(&self) -> PublicKeyAlgorithm

Source

fn created_at(&self) -> &DateTime<Utc>

Source

fn expiration(&self) -> Option<u16>

Source

fn verify_signature( &self, hash: HashAlgorithm, data: &[u8], sig: &SignatureBytes, ) -> Result<()>

Verify a signed message. Data will be hashed using hash, before verifying.

Source

fn encrypt<R: CryptoRng + Rng>( &self, rng: R, plain: &[u8], typ: EskType, ) -> Result<PkeskBytes>

Encrypt the given plain for this key.

Source

fn serialize_for_hashing(&self, writer: &mut impl Write) -> Result<()>

This is the data used for hashing in a signature. Only uses the public portion of the key.

Source

fn public_params(&self) -> &PublicParams

Provided Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, T: PublicKeyTrait> PublicKeyTrait for &'a T

Source§

fn key_id(&self) -> KeyId

Returns the Key ID of the associated primary key.

Source§

fn verify_signature( &self, hash: HashAlgorithm, data: &[u8], sig: &SignatureBytes, ) -> Result<()>

Source§

fn encrypt<R: CryptoRng + Rng>( &self, rng: R, plain: &[u8], typ: EskType, ) -> Result<PkeskBytes>

Source§

fn serialize_for_hashing(&self, writer: &mut impl Write) -> Result<()>

Source§

fn public_params(&self) -> &PublicParams

Source§

fn version(&self) -> KeyVersion

Source§

fn fingerprint(&self) -> Fingerprint

Source§

fn algorithm(&self) -> PublicKeyAlgorithm

Source§

fn expiration(&self) -> Option<u16>

Source§

fn created_at(&self) -> &DateTime<Utc>

Implementors§