diff --git a/sha1/Cargo.toml b/sha1/Cargo.toml index 09b0bfc5..a5f40e99 100644 --- a/sha1/Cargo.toml +++ b/sha1/Cargo.toml @@ -18,7 +18,7 @@ block-buffer = "0.7" fake-simd = "0.1" sha1-asm = { version = "0.4", optional = true } opaque-debug = "0.2" -libc = { version = "0.2", optional = true } +libc = { version = "0.2.68", optional = true } [dev-dependencies] digest = { version = "0.8", features = ["dev"] } diff --git a/sha1/src/aarch64.rs b/sha1/src/aarch64.rs index d3cffecd..16907404 100644 --- a/sha1/src/aarch64.rs +++ b/sha1/src/aarch64.rs @@ -1,9 +1,7 @@ -// TODO: Import those from libc, see https://github.com/rust-lang/libc/pull/1638 -const AT_HWCAP: u64 = 16; -const HWCAP_SHA1: u64 = 32; +use libc::{getauxval, AT_HWCAP, HWCAP_SHA1}; #[inline(always)] pub fn sha1_supported() -> bool { - let hwcaps: u64 = unsafe { ::libc::getauxval(AT_HWCAP) }; + let hwcaps: u64 = unsafe { getauxval(AT_HWCAP) }; (hwcaps & HWCAP_SHA1) != 0 } diff --git a/sha2/Cargo.toml b/sha2/Cargo.toml index 0c858aad..99b5f9f9 100644 --- a/sha2/Cargo.toml +++ b/sha2/Cargo.toml @@ -15,7 +15,7 @@ block-buffer = "0.7" fake-simd = "0.1" opaque-debug = "0.2" sha2-asm = { version="0.5", optional=true } -libc = { version = "0.2", optional = true } +libc = { version = "0.2.68", optional = true } [dev-dependencies] digest = { version = "0.8", features = ["dev"] } diff --git a/sha2/src/aarch64.rs b/sha2/src/aarch64.rs index 089a8f64..7cba7651 100644 --- a/sha2/src/aarch64.rs +++ b/sha2/src/aarch64.rs @@ -1,9 +1,7 @@ -// TODO: Import those from libc, see https://github.com/rust-lang/libc/pull/1638 -const AT_HWCAP: u64 = 16; -const HWCAP_SHA2: u64 = 64; +use libc::{getauxval, AT_HWCAP, HWCAP_SHA2}; #[inline(always)] pub fn sha2_supported() -> bool { - let hwcaps: u64 = unsafe { ::libc::getauxval(AT_HWCAP) }; + let hwcaps: u64 = unsafe { getauxval(AT_HWCAP) }; (hwcaps & HWCAP_SHA2) != 0 }