Skip to main content

Crate ic_hash

Crate ic_hash 

Source
Expand description

§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.

Re-exports§

pub use blake2::blake2b_long;
pub use blake2::Blake2b;
pub use sp800_185::CShake128;
pub use sp800_185::CShake256;
pub use sp800_185::ParallelHash128;
pub use sp800_185::ParallelHash256;
pub use sp800_185::TupleHash128;
pub use sp800_185::TupleHash256;

Modules§

blake2
RFC 7693 BLAKE2b.
sp800_185
SP 800-185: the string encodings, and cSHAKE.

Structs§

Sha3_224
FIPS 202 SHA3-224.
Sha3_256
FIPS 202 SHA3-256.
Sha3_384
FIPS 202 SHA3-384.
Sha3_512
FIPS 202 SHA3-512.
Sha224
FIPS 180-4 SHA-224.
Sha256
FIPS 180-4 SHA-256.
Sha384
FIPS 180-4 SHA-384.
Sha512
FIPS 180-4 SHA-512.
Sha512_224
FIPS 180-4 SHA-512/224.
Sha512_256
FIPS 180-4 SHA-512/256.
Shake128
FIPS 202 SHAKE128 extendable-output function.
Shake256
FIPS 202 SHAKE256 extendable-output function.
XofReader
A finished sponge that can be squeezed repeatedly.

Constants§

DIGEST_IDS
Dynamic identifiers for the digests in this crate, as used by the ontology and the agent-facing dispatch layer.
XOF_IDS
Dynamic identifiers for the extendable-output functions in this crate.