diff --git a/backends/concrete-cpu/Cargo.toml b/backends/concrete-cpu/Cargo.toml index 887565b99..373d89fb3 100644 --- a/backends/concrete-cpu/Cargo.toml +++ b/backends/concrete-cpu/Cargo.toml @@ -39,6 +39,8 @@ std = [ csprng = ["concrete-csprng"] parallel = ["rayon"] nightly = ["pulp/nightly"] +x86_64 = ["concrete-csprng/generator_x86_64_aesni"] +aarch64 = ["concrete-csprng/generator_aarch64_aes"] [build-dependencies] cbindgen = "0.24" diff --git a/backends/concrete-cpu/src/c_api/csprng.rs b/backends/concrete-cpu/src/c_api/csprng.rs index 1f4add847..7dda82c3e 100644 --- a/backends/concrete-cpu/src/c_api/csprng.rs +++ b/backends/concrete-cpu/src/c_api/csprng.rs @@ -1,12 +1,16 @@ use std::io::Read; use super::types::{Csprng, CsprngVtable, Uint128}; -use concrete_csprng::generators::{RandomGenerator, SoftwareRandomGenerator}; +#[cfg(feature = "x86_64")] +use concrete_csprng::generators::AesniRandomGenerator as Generator; +#[cfg(feature = "aarch64")] +use concrete_csprng::generators::NeonAesRandomGenerator as Generator; +use concrete_csprng::generators::RandomGenerator; +#[cfg(all(not(feature = "aarch64"), not(feature = "x86_64")))] +use concrete_csprng::generators::SoftwareRandomGenerator as Generator; use concrete_csprng::seeders::Seed; use libc::c_int; -type Generator = SoftwareRandomGenerator; - #[no_mangle] pub static CONCRETE_CSPRNG_VTABLE: CsprngVtable = CsprngVtable { remaining_bytes: {