make compilable on aarch64 (M1)

This commit is contained in:
raphjaph 2023-05-21 15:14:25 -04:00
parent 0406085ed5
commit 700f6e1d6f
2 changed files with 5 additions and 8 deletions

View File

@ -60,11 +60,11 @@ base64 = "0.13"
# Used for generating mnemonics
getrandom = "0.2"
# Used for the hot signer
bip39 = "2.0"
# Additional entropy for generating mnemonics
[target.'cfg(target_arch = "x86")'.dependencies]
rdrand = "0.8"
[target.'cfg(target_arch = "x86_64")'.dependencies]
rdrand = "0.8"
# Used for the hot signer
bip39 = "2.0"

View File

@ -41,11 +41,6 @@ fn cpu_randomness() -> Result<Option<[u8; 32]>, RandomnessError> {
}
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn hardware_randomness() -> Result<Option<[u8; 32]>, RandomnessError> {
Ok(None)
}
// OS-generated randomness. See https://docs.rs/getrandom/latest/getrandom/#supported-targets
// (basically this calls `getrandom()` or polls `/dev/urandom` on Linux, `BCryptGenRandom` on
// Windows, and `getentropy()` / `/dev/random` on Mac.
@ -82,9 +77,11 @@ fn additional_data() -> Result<[u8; 32], RandomnessError> {
pub fn random_bytes() -> Result<[u8; 32], RandomnessError> {
let mut engine = sha256::HashEngine::default();
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
if let Some(bytes) = cpu_randomness()? {
engine.input(&bytes);
}
engine.input(&system_randomness()?);
engine.input(&additional_data()?);
// TODO: add more sources of randomness