Expand description
SHA-2 and the legacy SHA-1 digest algorithm.
If all the data is available in a single contiguous slice then the digest
function should be used. Otherwise, the digest can be calculated in
multiple steps using Context
.
§Example
use aws_lc_rs::digest;
// Using `digest::digest`
let one_shot = digest::digest(&digest::SHA384, b"hello, world");
// Using `digest::Context`
let mut ctx = digest::Context::new(&digest::SHA384);
ctx.update(b"hello");
ctx.update(b", ");
ctx.update(b"world");
let multi_part = ctx.finish();
assert_eq!(&one_shot.as_ref(), &multi_part.as_ref());
Structs§
- Algorithm
- A digest algorithm.
- Context
- A context for multi-step (Init-Update-Finish) digest calculations.
- Digest
- A calculated digest value.
Constants§
- MAX_
BLOCK_ LEN - The maximum block length (
Algorithm::block_len
) of all the algorithms in this module. - MAX_
CHAINING_ LEN - The maximum chaining length (
Algorithm::chaining_len
) of all the algorithms in this module. - MAX_
OUTPUT_ LEN - The maximum output length (
Algorithm::output_len
) of all the algorithms in this module. - SHA1_
OUTPUT_ LEN - The length of the output of SHA-1, in bytes.
- SHA224_
OUTPUT_ LEN - The length of the output of SHA-224, in bytes.
- SHA256_
OUTPUT_ LEN - The length of the output of SHA-256, in bytes.
- SHA384_
OUTPUT_ LEN - The length of the output of SHA-384, in bytes.
- SHA512_
256_ OUTPUT_ LEN - The length of the output of SHA-512/256, in bytes.
- SHA512_
OUTPUT_ LEN - The length of the output of SHA-512, in bytes.
Statics§
- SHA1_
FOR_ LEGACY_ USE_ ONLY - SHA-1 as specified in FIPS 180-4. Deprecated.
- SHA3_
256 - SHA3-256 as specified in FIPS 202.
- SHA3_
384 - SHA3-384 as specified in FIPS 202.
- SHA3_
512 - SHA3-512 as specified in FIPS 202.
- SHA224
- SHA-224 as specified in FIPS 180-4.
- SHA256
- SHA-256 as specified in FIPS 180-4.
- SHA384
- SHA-384 as specified in FIPS 180-4.
- SHA512
- SHA-512 as specified in FIPS 180-4.
- SHA512_
256 - SHA-512/256 as specified in FIPS 180-4.
Functions§
- digest
- Returns the digest of
data
using the given digest algorithm.