pub struct ShaBackend<'d> { /* private fields */ }Expand description
CPU-driven SHA processing backend.
§Example
use esp_hal::sha::{Sha1Context, ShaBackend};
let mut sha = ShaBackend::new(peripherals.SHA);
// Start the backend, which allows processing SHA operations.
let _backend = sha.start();
// Create a new context to hash data with SHA-1.
let mut sha1_ctx = Sha1Context::new();
// SHA-1 outputs a 20-byte digest.
let mut digest: [u8; 20] = [0; 20];
// Process data. The `update` function returns a handle which can be used to wait
// for the operation to finish.
sha1_ctx.update(b"input data").wait_blocking();
sha1_ctx.update(b"input data").wait_blocking();
sha1_ctx.update(b"input data").wait_blocking();
// Extract the final hash. This resets the context.
sha1_ctx.finalize(&mut digest).wait_blocking();
// digest now contains the SHA-1 hash of the input.Implementations§
Source§impl<'d> ShaBackend<'d>
 
impl<'d> ShaBackend<'d>
Sourcepub fn new(sha: SHA<'d>) -> Self
 
pub fn new(sha: SHA<'d>) -> Self
Creates a new SHA backend.
The backend needs to be started before it can execute SHA operations.
Sourcepub fn start(&mut self) -> ShaWorkQueueDriver<'_, 'd>
 
pub fn start(&mut self) -> ShaWorkQueueDriver<'_, 'd>
Registers the CPU-driven SHA driver to process SHA operations.
The driver stops operating when the returned object is dropped.