#![no_std]
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")))]
compile_error!("crate can only be used on x86, x86-64 and aarch64 architectures");
#[cfg(target_os = "windows")]
compile_error!("crate does not support Windows targets");
#[link(name = "sha256", kind = "static")]
extern "C" {
fn sha256_compress(state: &mut [u32; 8], block: &[u8; 64]);
}
#[inline]
pub fn compress256(state: &mut [u32; 8], blocks: &[[u8; 64]]) {
for block in blocks {
unsafe { sha256_compress(state, block) }
}
}
#[cfg(not(target_arch = "aarch64"))]
#[link(name = "sha512", kind = "static")]
extern "C" {
fn sha512_compress(state: &mut [u64; 8], block: &[u8; 128]);
}
#[cfg(not(target_arch = "aarch64"))]
#[inline]
pub fn compress512(state: &mut [u64; 8], blocks: &[[u8; 128]]) {
for block in blocks {
unsafe { sha512_compress(state, block) }
}
}