extern crate alloc;
pub use mbedtls::hash::{Md, Type as MdType};
pub fn digest32(md: MdType, data: &[u8]) -> crate::crypto::Result<[u8; 32]> {
let mut out = [0u8; 32];
Md::hash(md, data, &mut out).map_err(map_mbedtls_err)?;
Ok(out)
}
pub(crate) fn map_mbedtls_err(e: mbedtls::Error) -> crate::crypto::CryptoError {
crate::crypto::CryptoError::Message(alloc::format!("mbedtls: {e:?}"))
}