CoseEncryptCipher

Trait CoseEncryptCipher 

Source
pub trait CoseEncryptCipher: CoseCipher {
    // Required methods
    fn encrypt(
        key: &CoseKey,
        plaintext: &[u8],
        aad: &[u8],
        protected_header: &Header,
        unprotected_header: &Header,
    ) -> Vec<u8> ;
    fn decrypt(
        key: &CoseKey,
        ciphertext: &[u8],
        aad: &[u8],
        unprotected_header: &Header,
        protected_header: &ProtectedHeader,
    ) -> Result<Vec<u8>, CoseCipherError<Self::Error>>;
}
Expand description

Provides basic operations for encrypting and decrypting COSE structures.

This will be used by encrypt_access_token and decrypt_access_token (as well as the variants for multiple recipients: encrypt_access_token_multiple and decrypt_access_token_multiple) to apply the corresponding cryptographic operations to the constructed token bytestring. The set_headers method can be used to set parameters this cipher requires to be set.

Required Methods§

Source

fn encrypt( key: &CoseKey, plaintext: &[u8], aad: &[u8], protected_header: &Header, unprotected_header: &Header, ) -> Vec<u8>

Encrypts the plaintext and aad with the given key, returning the result.

Source

fn decrypt( key: &CoseKey, ciphertext: &[u8], aad: &[u8], unprotected_header: &Header, protected_header: &ProtectedHeader, ) -> Result<Vec<u8>, CoseCipherError<Self::Error>>

Decrypts the ciphertext and aad with the given key, returning the result.

§Errors

If the ciphertext and aad are invalid, i.e., can’t be decrypted.

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.

Implementors§