Trait tink_core::Mac

source ·
pub trait Mac: MacBoxClone {
    // Required method
    fn compute_mac(&self, data: &[u8]) -> Result<Vec<u8>, TinkError>;

    // Provided method
    fn verify_mac(&self, mac: &[u8], data: &[u8]) -> Result<(), TinkError> { ... }
}
Expand description

Mac is the interface for MACs (Message Authentication Codes). This interface should be used for authentication only, and not for other purposes (for example, it should not be used to generate pseudorandom bytes).

Required Methods§

source

fn compute_mac(&self, data: &[u8]) -> Result<Vec<u8>, TinkError>

Compute message authentication code (MAC) for code data.

Provided Methods§

source

fn verify_mac(&self, mac: &[u8], data: &[u8]) -> Result<(), TinkError>

Returns () if mac is a correct authentication code (MAC) for data, otherwise it returns an error.

Trait Implementations§

source§

impl From<Primitive> for Box<dyn Mac>

source§

fn from(p: Primitive) -> Box<dyn Mac>

Converts to this type from the input type.

Implementors§