1#![no_std]
13#[cfg(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")))]
14compile_error!("crate can only be used on x86, x86-64 and aarch64 architectures");
15
16#[cfg(target_os = "windows")]
17compile_error!("crate does not support Windows targets");
18
19#[link(name = "sha256", kind = "static")]
20extern "C" {
21 fn sha256_compress(state: &mut [u32; 8], block: &[u8; 64]);
22}
23
24#[inline]
26pub fn compress256(state: &mut [u32; 8], blocks: &[[u8; 64]]) {
27 for block in blocks {
28 unsafe { sha256_compress(state, block) }
29 }
30}
31
32#[cfg(not(target_arch = "aarch64"))]
33#[link(name = "sha512", kind = "static")]
34extern "C" {
35 fn sha512_compress(state: &mut [u64; 8], block: &[u8; 128]);
36}
37
38#[cfg(not(target_arch = "aarch64"))]
42#[inline]
43pub fn compress512(state: &mut [u64; 8], blocks: &[[u8; 128]]) {
44 for block in blocks {
45 unsafe { sha512_compress(state, block) }
46 }
47}