rustls::crypto::hash

Trait Context

Source
pub trait Context: Send + Sync {
    // Required methods
    fn fork_finish(&self) -> Output;
    fn fork(&self) -> Box<dyn Context>;
    fn finish(self: Box<Self>) -> Output;
    fn update(&mut self, data: &[u8]);
}
Expand description

How to incrementally compute a hash.

Required Methods§

Source

fn fork_finish(&self) -> Output

Finish the computation, returning the resulting output.

The computation remains valid, and more data can be added later with Context::update().

Compare with Context::finish() which consumes the computation and prevents any further data being added. This can be more efficient because it avoids a hash context copy to apply Merkle-Damgård padding (if required).

Source

fn fork(&self) -> Box<dyn Context>

Fork the computation, producing another context that has the same prefix as this one.

Source

fn finish(self: Box<Self>) -> Output

Terminate and finish the computation, returning the resulting output.

Further data cannot be added after this, because the context is consumed. Compare Context::fork_finish().

Source

fn update(&mut self, data: &[u8])

Add data to computation.

Implementors§