1#![no_std]
4
5#[cfg(not(target_arch = "spirv"))]
7mod const_fn;
8#[cfg(not(target_arch = "spirv"))]
10mod platform;
11mod portable;
12mod single_block;
13#[cfg(not(target_arch = "spirv"))]
15mod single_chunk;
16
17#[cfg(not(target_arch = "spirv"))]
19pub use const_fn::{const_derive_key, const_hash, const_keyed_hash};
20#[cfg(not(target_arch = "spirv"))]
22pub use platform::{le_bytes_from_words_32, words_from_le_bytes_32, words_from_le_bytes_64};
23pub use single_block::single_block_hash_portable_words;
24#[cfg(not(target_arch = "spirv"))]
26pub use single_block::{
27 single_block_derive_key, single_block_hash, single_block_hash_many_exact,
28 single_block_keyed_hash, single_block_keyed_hash_many_exact,
29};
30#[cfg(not(target_arch = "spirv"))]
32pub use single_chunk::{single_chunk_derive_key, single_chunk_hash, single_chunk_keyed_hash};
33
34pub const OUT_LEN: usize = 32;
36pub const KEY_LEN: usize = 32;
38pub const BLOCK_LEN: usize = 64;
40
41#[cfg(not(target_arch = "spirv"))]
47const CHUNK_LEN: usize = 1024;
48
49type CVWords = [u32; 8];
55#[cfg(not(target_arch = "spirv"))]
57type CVBytes = [u8; 32]; #[cfg(not(target_arch = "spirv"))]
61type BlockBytes = [u8; BLOCK_LEN];
62type BlockWords = [u32; 16];
63
64const IV: &CVWords = &[
65 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19,
66];
67
68const MSG_SCHEDULE: [[usize; 16]; 7] = [
69 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
70 [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8],
71 [3, 4, 10, 12, 13, 2, 7, 14, 6, 5, 9, 0, 11, 15, 8, 1],
72 [10, 7, 12, 9, 14, 3, 13, 15, 4, 0, 11, 2, 5, 8, 1, 6],
73 [12, 13, 9, 11, 15, 10, 14, 8, 7, 2, 5, 3, 0, 1, 6, 4],
74 [9, 14, 11, 5, 8, 12, 15, 1, 13, 3, 0, 10, 2, 6, 4, 7],
75 [11, 15, 5, 0, 1, 9, 8, 6, 14, 10, 2, 12, 3, 4, 7, 13],
76];
77
78const CHUNK_START: u8 = 1 << 0;
83const CHUNK_END: u8 = 1 << 1;
84#[cfg(not(target_arch = "spirv"))]
86const PARENT: u8 = 1 << 2;
87const ROOT: u8 = 1 << 3;
88#[cfg(not(target_arch = "spirv"))]
90const KEYED_HASH: u8 = 1 << 4;
91#[cfg(not(target_arch = "spirv"))]
93const DERIVE_KEY_CONTEXT: u8 = 1 << 5;
94#[cfg(not(target_arch = "spirv"))]
96const DERIVE_KEY_MATERIAL: u8 = 1 << 6;