Skip to content

Commit 07fa72f

Browse files
committed
Enable AArch64 feature detection
1 parent a3e0bc5 commit 07fa72f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+352
-336
lines changed

pqcrypto-classicmceliece/build.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ macro_rules! build_clean {
99
let internals_include_path = &std::env::var("DEP_PQCRYPTO_INTERNALS_INCLUDEPATH").unwrap();
1010
let common_dir = Path::new("pqclean/common");
1111

12+
let implementation_dir = "clean";
13+
1214
let mut builder = cc::Build::new();
13-
let target_dir: PathBuf = ["pqclean", "crypto_kem", $variant, "clean"]
15+
let target_dir: PathBuf = ["pqclean", "crypto_kem", $variant, implementation_dir]
1416
.iter()
1517
.collect();
1618

@@ -41,8 +43,12 @@ macro_rules! build_avx2 {
4143
let internals_include_path = &std::env::var("DEP_PQCRYPTO_INTERNALS_INCLUDEPATH").unwrap();
4244
let common_dir = Path::new("pqclean/common");
4345

46+
let implementation_dir = "avx2";
47+
4448
let mut builder = cc::Build::new();
45-
let target_dir: PathBuf = ["pqclean", "crypto_kem", $variant, "avx2"].iter().collect();
49+
let target_dir: PathBuf = ["pqclean", "crypto_kem", $variant, implementation_dir]
50+
.iter()
51+
.collect();
4652

4753
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
4854
if target_os == "wasi" {
@@ -86,6 +92,8 @@ fn main() {
8692
#[allow(unused_variables)]
8793
let neon_enabled = env::var("CARGO_FEATURE_NEON").is_ok();
8894
#[allow(unused_variables)]
95+
let aarch64_sha3_enabled = env::var("CARGO_FEATURE_AARCH64_SHA3").is_ok();
96+
#[allow(unused_variables)]
8997
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
9098
#[allow(unused_variables)]
9199
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();

pqcrypto-classicmceliece/src/mceliece348864.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ macro_rules! gen_keypair {
132132
pub fn keypair() -> (PublicKey, SecretKey) {
133133
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
134134
{
135-
if std::is_x86_feature_detected!("avx2") {
135+
if std::arch::is_x86_feature_detected!("avx2") {
136136
return gen_keypair!(PQCLEAN_MCELIECE348864_AVX2_crypto_kem_keypair);
137137
}
138138
}
@@ -155,7 +155,7 @@ macro_rules! encap {
155155
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
156156
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
157157
{
158-
if std::is_x86_feature_detected!("avx2") {
158+
if std::arch::is_x86_feature_detected!("avx2") {
159159
return encap!(PQCLEAN_MCELIECE348864_AVX2_crypto_kem_enc, pk);
160160
}
161161
}
@@ -177,7 +177,7 @@ macro_rules! decap {
177177
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
178178
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
179179
{
180-
if std::is_x86_feature_detected!("avx2") {
180+
if std::arch::is_x86_feature_detected!("avx2") {
181181
return decap!(PQCLEAN_MCELIECE348864_AVX2_crypto_kem_dec, ct, sk);
182182
}
183183
}

pqcrypto-classicmceliece/src/mceliece348864f.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! gen_keypair {
135135
pub fn keypair() -> (PublicKey, SecretKey) {
136136
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
137137
{
138-
if std::is_x86_feature_detected!("avx2") {
138+
if std::arch::is_x86_feature_detected!("avx2") {
139139
return gen_keypair!(PQCLEAN_MCELIECE348864F_AVX2_crypto_kem_keypair);
140140
}
141141
}
@@ -158,7 +158,7 @@ macro_rules! encap {
158158
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
159159
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
160160
{
161-
if std::is_x86_feature_detected!("avx2") {
161+
if std::arch::is_x86_feature_detected!("avx2") {
162162
return encap!(PQCLEAN_MCELIECE348864F_AVX2_crypto_kem_enc, pk);
163163
}
164164
}
@@ -180,7 +180,7 @@ macro_rules! decap {
180180
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
181181
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
182182
{
183-
if std::is_x86_feature_detected!("avx2") {
183+
if std::arch::is_x86_feature_detected!("avx2") {
184184
return decap!(PQCLEAN_MCELIECE348864F_AVX2_crypto_kem_dec, ct, sk);
185185
}
186186
}

pqcrypto-classicmceliece/src/mceliece460896.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ macro_rules! gen_keypair {
132132
pub fn keypair() -> (PublicKey, SecretKey) {
133133
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
134134
{
135-
if std::is_x86_feature_detected!("avx2") {
135+
if std::arch::is_x86_feature_detected!("avx2") {
136136
return gen_keypair!(PQCLEAN_MCELIECE460896_AVX2_crypto_kem_keypair);
137137
}
138138
}
@@ -155,7 +155,7 @@ macro_rules! encap {
155155
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
156156
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
157157
{
158-
if std::is_x86_feature_detected!("avx2") {
158+
if std::arch::is_x86_feature_detected!("avx2") {
159159
return encap!(PQCLEAN_MCELIECE460896_AVX2_crypto_kem_enc, pk);
160160
}
161161
}
@@ -177,7 +177,7 @@ macro_rules! decap {
177177
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
178178
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
179179
{
180-
if std::is_x86_feature_detected!("avx2") {
180+
if std::arch::is_x86_feature_detected!("avx2") {
181181
return decap!(PQCLEAN_MCELIECE460896_AVX2_crypto_kem_dec, ct, sk);
182182
}
183183
}

pqcrypto-classicmceliece/src/mceliece460896f.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! gen_keypair {
135135
pub fn keypair() -> (PublicKey, SecretKey) {
136136
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
137137
{
138-
if std::is_x86_feature_detected!("avx2") {
138+
if std::arch::is_x86_feature_detected!("avx2") {
139139
return gen_keypair!(PQCLEAN_MCELIECE460896F_AVX2_crypto_kem_keypair);
140140
}
141141
}
@@ -158,7 +158,7 @@ macro_rules! encap {
158158
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
159159
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
160160
{
161-
if std::is_x86_feature_detected!("avx2") {
161+
if std::arch::is_x86_feature_detected!("avx2") {
162162
return encap!(PQCLEAN_MCELIECE460896F_AVX2_crypto_kem_enc, pk);
163163
}
164164
}
@@ -180,7 +180,7 @@ macro_rules! decap {
180180
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
181181
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
182182
{
183-
if std::is_x86_feature_detected!("avx2") {
183+
if std::arch::is_x86_feature_detected!("avx2") {
184184
return decap!(PQCLEAN_MCELIECE460896F_AVX2_crypto_kem_dec, ct, sk);
185185
}
186186
}

pqcrypto-classicmceliece/src/mceliece6688128.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! gen_keypair {
135135
pub fn keypair() -> (PublicKey, SecretKey) {
136136
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
137137
{
138-
if std::is_x86_feature_detected!("avx2") {
138+
if std::arch::is_x86_feature_detected!("avx2") {
139139
return gen_keypair!(PQCLEAN_MCELIECE6688128_AVX2_crypto_kem_keypair);
140140
}
141141
}
@@ -158,7 +158,7 @@ macro_rules! encap {
158158
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
159159
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
160160
{
161-
if std::is_x86_feature_detected!("avx2") {
161+
if std::arch::is_x86_feature_detected!("avx2") {
162162
return encap!(PQCLEAN_MCELIECE6688128_AVX2_crypto_kem_enc, pk);
163163
}
164164
}
@@ -180,7 +180,7 @@ macro_rules! decap {
180180
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
181181
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
182182
{
183-
if std::is_x86_feature_detected!("avx2") {
183+
if std::arch::is_x86_feature_detected!("avx2") {
184184
return decap!(PQCLEAN_MCELIECE6688128_AVX2_crypto_kem_dec, ct, sk);
185185
}
186186
}

pqcrypto-classicmceliece/src/mceliece6688128f.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! gen_keypair {
135135
pub fn keypair() -> (PublicKey, SecretKey) {
136136
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
137137
{
138-
if std::is_x86_feature_detected!("avx2") {
138+
if std::arch::is_x86_feature_detected!("avx2") {
139139
return gen_keypair!(PQCLEAN_MCELIECE6688128F_AVX2_crypto_kem_keypair);
140140
}
141141
}
@@ -158,7 +158,7 @@ macro_rules! encap {
158158
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
159159
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
160160
{
161-
if std::is_x86_feature_detected!("avx2") {
161+
if std::arch::is_x86_feature_detected!("avx2") {
162162
return encap!(PQCLEAN_MCELIECE6688128F_AVX2_crypto_kem_enc, pk);
163163
}
164164
}
@@ -180,7 +180,7 @@ macro_rules! decap {
180180
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
181181
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
182182
{
183-
if std::is_x86_feature_detected!("avx2") {
183+
if std::arch::is_x86_feature_detected!("avx2") {
184184
return decap!(PQCLEAN_MCELIECE6688128F_AVX2_crypto_kem_dec, ct, sk);
185185
}
186186
}

pqcrypto-classicmceliece/src/mceliece6960119.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! gen_keypair {
135135
pub fn keypair() -> (PublicKey, SecretKey) {
136136
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
137137
{
138-
if std::is_x86_feature_detected!("avx2") {
138+
if std::arch::is_x86_feature_detected!("avx2") {
139139
return gen_keypair!(PQCLEAN_MCELIECE6960119_AVX2_crypto_kem_keypair);
140140
}
141141
}
@@ -158,7 +158,7 @@ macro_rules! encap {
158158
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
159159
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
160160
{
161-
if std::is_x86_feature_detected!("avx2") {
161+
if std::arch::is_x86_feature_detected!("avx2") {
162162
return encap!(PQCLEAN_MCELIECE6960119_AVX2_crypto_kem_enc, pk);
163163
}
164164
}
@@ -180,7 +180,7 @@ macro_rules! decap {
180180
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
181181
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
182182
{
183-
if std::is_x86_feature_detected!("avx2") {
183+
if std::arch::is_x86_feature_detected!("avx2") {
184184
return decap!(PQCLEAN_MCELIECE6960119_AVX2_crypto_kem_dec, ct, sk);
185185
}
186186
}

pqcrypto-classicmceliece/src/mceliece6960119f.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! gen_keypair {
135135
pub fn keypair() -> (PublicKey, SecretKey) {
136136
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
137137
{
138-
if std::is_x86_feature_detected!("avx2") {
138+
if std::arch::is_x86_feature_detected!("avx2") {
139139
return gen_keypair!(PQCLEAN_MCELIECE6960119F_AVX2_crypto_kem_keypair);
140140
}
141141
}
@@ -158,7 +158,7 @@ macro_rules! encap {
158158
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
159159
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
160160
{
161-
if std::is_x86_feature_detected!("avx2") {
161+
if std::arch::is_x86_feature_detected!("avx2") {
162162
return encap!(PQCLEAN_MCELIECE6960119F_AVX2_crypto_kem_enc, pk);
163163
}
164164
}
@@ -180,7 +180,7 @@ macro_rules! decap {
180180
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
181181
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
182182
{
183-
if std::is_x86_feature_detected!("avx2") {
183+
if std::arch::is_x86_feature_detected!("avx2") {
184184
return decap!(PQCLEAN_MCELIECE6960119F_AVX2_crypto_kem_dec, ct, sk);
185185
}
186186
}

pqcrypto-classicmceliece/src/mceliece8192128.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! gen_keypair {
135135
pub fn keypair() -> (PublicKey, SecretKey) {
136136
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
137137
{
138-
if std::is_x86_feature_detected!("avx2") {
138+
if std::arch::is_x86_feature_detected!("avx2") {
139139
return gen_keypair!(PQCLEAN_MCELIECE8192128_AVX2_crypto_kem_keypair);
140140
}
141141
}
@@ -158,7 +158,7 @@ macro_rules! encap {
158158
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
159159
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
160160
{
161-
if std::is_x86_feature_detected!("avx2") {
161+
if std::arch::is_x86_feature_detected!("avx2") {
162162
return encap!(PQCLEAN_MCELIECE8192128_AVX2_crypto_kem_enc, pk);
163163
}
164164
}
@@ -180,7 +180,7 @@ macro_rules! decap {
180180
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
181181
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
182182
{
183-
if std::is_x86_feature_detected!("avx2") {
183+
if std::arch::is_x86_feature_detected!("avx2") {
184184
return decap!(PQCLEAN_MCELIECE8192128_AVX2_crypto_kem_dec, ct, sk);
185185
}
186186
}

pqcrypto-classicmceliece/src/mceliece8192128f.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ macro_rules! gen_keypair {
135135
pub fn keypair() -> (PublicKey, SecretKey) {
136136
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
137137
{
138-
if std::is_x86_feature_detected!("avx2") {
138+
if std::arch::is_x86_feature_detected!("avx2") {
139139
return gen_keypair!(PQCLEAN_MCELIECE8192128F_AVX2_crypto_kem_keypair);
140140
}
141141
}
@@ -158,7 +158,7 @@ macro_rules! encap {
158158
pub fn encapsulate(pk: &PublicKey) -> (SharedSecret, Ciphertext) {
159159
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
160160
{
161-
if std::is_x86_feature_detected!("avx2") {
161+
if std::arch::is_x86_feature_detected!("avx2") {
162162
return encap!(PQCLEAN_MCELIECE8192128F_AVX2_crypto_kem_enc, pk);
163163
}
164164
}
@@ -180,7 +180,7 @@ macro_rules! decap {
180180
pub fn decapsulate(ct: &Ciphertext, sk: &SecretKey) -> SharedSecret {
181181
#[cfg(all(enable_x86_avx2, feature = "avx2"))]
182182
{
183-
if std::is_x86_feature_detected!("avx2") {
183+
if std::arch::is_x86_feature_detected!("avx2") {
184184
return decap!(PQCLEAN_MCELIECE8192128F_AVX2_crypto_kem_dec, ct, sk);
185185
}
186186
}

pqcrypto-falcon/build.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ macro_rules! build_clean {
99
let internals_include_path = &std::env::var("DEP_PQCRYPTO_INTERNALS_INCLUDEPATH").unwrap();
1010
let common_dir = Path::new("pqclean/common");
1111

12+
let implementation_dir = "clean";
13+
1214
let mut builder = cc::Build::new();
13-
let target_dir: PathBuf = ["pqclean", "crypto_sign", $variant, "clean"]
15+
let target_dir: PathBuf = ["pqclean", "crypto_sign", $variant, implementation_dir]
1416
.iter()
1517
.collect();
1618

@@ -41,8 +43,10 @@ macro_rules! build_avx2 {
4143
let internals_include_path = &std::env::var("DEP_PQCRYPTO_INTERNALS_INCLUDEPATH").unwrap();
4244
let common_dir = Path::new("pqclean/common");
4345

46+
let implementation_dir = "avx2";
47+
4448
let mut builder = cc::Build::new();
45-
let target_dir: PathBuf = ["pqclean", "crypto_sign", $variant, "avx2"]
49+
let target_dir: PathBuf = ["pqclean", "crypto_sign", $variant, implementation_dir]
4650
.iter()
4751
.collect();
4852

@@ -85,8 +89,10 @@ macro_rules! build_aarch64 {
8589
let internals_include_path = &std::env::var("DEP_PQCRYPTO_INTERNALS_INCLUDEPATH").unwrap();
8690
let common_dir = Path::new("pqclean/common");
8791

92+
let implementation_dir = "aarch64";
93+
8894
let mut builder = cc::Build::new();
89-
let target_dir: PathBuf = ["pqclean", "crypto_sign", $variant, "aarch64"]
95+
let target_dir: PathBuf = ["pqclean", "crypto_sign", $variant, implementation_dir]
9096
.iter()
9197
.collect();
9298

@@ -121,6 +127,8 @@ fn main() {
121127
#[allow(unused_variables)]
122128
let neon_enabled = env::var("CARGO_FEATURE_NEON").is_ok();
123129
#[allow(unused_variables)]
130+
let aarch64_sha3_enabled = env::var("CARGO_FEATURE_AARCH64_SHA3").is_ok();
131+
#[allow(unused_variables)]
124132
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
125133
#[allow(unused_variables)]
126134
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();

0 commit comments

Comments
 (0)