1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! # ic-hash — FIPS 180-4 and FIPS 202 hash functions
//!
//! Pure-Rust, `no_std`, allocation-free implementations of the SHA-2 and SHA-3
//! families plus the SHAKE extendable-output functions.
//!
//! ```
//! use ic_hash::Sha256;
//! use ic_core::traits::Digest;
//!
//! let d = Sha256::digest(b"abc");
//! assert_eq!(
//! ic_core::codec::hex(d.as_ref()),
//! "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
//! );
//! ```
//!
//! Every type here implements [`ic_core::traits::Digest`] (or [`ic_core::traits::Xof`])
//! and [`ic_core::traits::SelfTest`], so `ic-fips` can drive their known-answer
//! tests generically.
// `deny` rather than `forbid`, and the difference is the point: one module is
// allowed unsafe and every other line in this crate is a compile error. The
// allowance below marks the only place a CPU intrinsic is called. This crate
// forbade it outright until SHA-256 gained a SHA-NI backend, which was worth
// roughly seven times the throughput on hardware that has it and cannot be
// written any other way.
// SHA-NI, behind runtime detection. See `sha2::x86`.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Dynamic identifiers for the digests in this crate, as used by the ontology
/// and the agent-facing dispatch layer.
pub const DIGEST_IDS: & = &;
/// Dynamic identifiers for the extendable-output functions in this crate.
pub const XOF_IDS: & = &;