Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/sha2/src/sha512.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / sha2 / src / sha512.rs` 45 lines ยท 1550 bytes Raw Blame History 1 use digest::{generic_array::GenericArray, typenum::U128}; 2 3 cfg_if::cfg_if! { 4 if #[cfg(feature = "force-soft-compact")] { 5 mod soft_compact; 6 use soft_compact::compress; 7 } else if #[cfg(feature = "force-soft")] { 8 mod soft; 9 use soft::compress; 10 } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { 11 #[cfg(not(feature = "asm"))] 12 mod soft; 13 #[cfg(feature = "asm")] 14 mod soft { 15 pub(crate) fn compress(state: &mut [u64; 8], blocks: &[[u8; 128]]) { 16 sha2_asm::compress512(state, blocks); 17 } 18 } 19 mod x86; 20 use x86::compress; 21 } else if #[cfg(all(feature = "asm", target_arch = "aarch64"))] { 22 mod soft; 23 mod aarch64; 24 use aarch64::compress; 25 } else if #[cfg(all(feature = "loongarch64_asm", target_arch = "loongarch64"))] { 26 mod loongarch64_asm; 27 use loongarch64_asm::compress; 28 } else { 29 mod soft; 30 use soft::compress; 31 } 32 } 33 34 /// Raw SHA-512 compression function. 35 /// 36 /// This is a low-level "hazmat" API which provides direct access to the core 37 /// functionality of SHA-512. 38 #[cfg_attr(docsrs, doc(cfg(feature = "compress")))] 39 pub fn compress512(state: &mut [u64; 8], blocks: &[GenericArray]) { 40 // SAFETY: GenericArray and [u8; 64] have 41 // exactly the same memory layout 42 let p = blocks.as_ptr() as *const [u8; 128]; 43 let blocks = unsafe { core::slice::from_raw_parts(p, blocks.len()) }; 44 compress(state, blocks) 45 }