//! Pinnacle's cryptography, written here and checked against the standards' //! test vectors: SHA-256 and SHA-512 (FIPS 180-4), HMAC and HKDF (RFC 2104, //! RFC 5869), ChaCha20-Poly1305 (RFC 8439), X25519 (RFC 7748) and Ed25519 //! (RFC 8032); AES with GCM, CCM, CMAC and SIV, and key wrap (RFC 3394); //! P-256 ECDH; SHA-1 only for HMAC and PBKDF2, as WPA2 needs. //! //! Secret-dependent work avoids secret-dependent branches and memory //! indices: the field and scalar arithmetic selects with masks. P-256 is //! the exception, said in its module. #![no_std] // A program on Pinnacle's std asks the kernel what its core has (`hw`). #[cfg(target_os = "pinnacle")] extern crate std; pub mod aead; pub mod aes; pub mod bignum; pub mod ecdsa; pub mod ed25519; mod field; pub mod hw; pub mod p256; pub mod rsa; mod scalar; pub mod sha1; pub mod sha2; pub mod x25519; /// Compares in time independent of where the inputs differ. pub fn equal(a: &[u8], b: &[u8]) -> bool { if a.len() != b.len() { return false; } a.iter().zip(b).fold(0u8, |acc, (x, y)| acc | (x ^ y)) == 0 } #[cfg(test)] mod tests;