use crate::algorithms::hmac::{HmacSha256Algo, HmacSha512Algo};
use crate::traits::{MacAlgorithmAdapter, MacParams};
use crate::AlgorithmError;
use crypto_core::MacAlgorithm;
pub fn mac_authenticate(
alg: MacAlgorithm,
params: &MacParams<'_>,
message: &[u8],
) -> Result<Vec<u8>, AlgorithmError> {
match alg {
MacAlgorithm::HmacSha256 => HmacSha256Algo::authenticate(params, message),
MacAlgorithm::HmacSha512 => HmacSha512Algo::authenticate(params, message),
}
}
pub fn mac_verify(
alg: MacAlgorithm,
params: &MacParams<'_>,
message: &[u8],
tag: &[u8],
) -> Result<(), AlgorithmError> {
match alg {
MacAlgorithm::HmacSha256 => HmacSha256Algo::verify(params, message, tag),
MacAlgorithm::HmacSha512 => HmacSha512Algo::verify(params, message, tag),
}
}