[][src]Trait bdrck::crypto::key::AbstractKey

pub trait AbstractKey {
    fn get_digest(&self) -> Digest;
fn encrypt(
        &self,
        plaintext: &[u8],
        nonce: Option<Nonce>
    ) -> Result<(Option<Nonce>, Vec<u8>), Error>;
fn decrypt(
        &self,
        nonce: Option<&Nonce>,
        ciphertext: &[u8]
    ) -> Result<Vec<u8>, Error>; }

An AbstractKey is any cryptographic structure which supports encryption and decryption.

Required methods

fn get_digest(&self) -> Digest

Return a digest/signature computed from this key.

fn encrypt(
    &self,
    plaintext: &[u8],
    nonce: Option<Nonce>
) -> Result<(Option<Nonce>, Vec<u8>), Error>

Encrypt the given plaintext with this key. This function optionally takes a nonce as an argument. If this key's encryption algorithm utilizes a nonce, the provided one will be used.

This function returns the ciphertext, as well as a Nonce (if one was used for encryption). If a Nonce was provided, that same Nonce is returned.

fn decrypt(
    &self,
    nonce: Option<&Nonce>,
    ciphertext: &[u8]
) -> Result<Vec<u8>, Error>

Decrypt the given ciphertext using this key and the nonce which was generated at encryption time (if any), returning the plaintext.

Loading content...

Implementations on Foreign Types

impl AbstractKey for Box<dyn AbstractKey>[src]

Loading content...

Implementors

impl AbstractKey for Key[src]

Loading content...