pub trait HashHal {
// Required methods
fn hmac_sha256(
&mut self,
key: &[u8],
message: &[u8],
output: &mut [u8; 32],
) -> impl Future<Output = Result<(), HalError>>;
fn sha256(
&mut self,
message: &[u8],
output: &mut [u8; 32],
) -> impl Future<Output = Result<(), HalError>>;
}Expand description
Hash/HMAC hardware abstraction.
Provides cryptographic hash functions. Implementations may use hardware accelerators or software implementations depending on platform capabilities.
§Example
ⓘ
async fn compute_hash<H: HashHal>(hash: &mut H, data: &[u8]) -> Result<[u8; 32], HalError> {
let mut output = [0u8; 32];
hash.sha256(data, &mut output).await?;
Ok(output)
}Required Methods§
Sourcefn hmac_sha256(
&mut self,
key: &[u8],
message: &[u8],
output: &mut [u8; 32],
) -> impl Future<Output = Result<(), HalError>>
fn hmac_sha256( &mut self, key: &[u8], message: &[u8], output: &mut [u8; 32], ) -> impl Future<Output = Result<(), HalError>>
Compute HMAC-SHA256.
Computes Hash-based Message Authentication Code using SHA256. Useful for message authentication and key derivation.
§Arguments
key- Secret key for HMAC.message- Data to authenticate.output- Output buffer for 32-byte HMAC result.
§Returns
Ok(()) on success with result in output, or an error on failure.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".