Skip to content

Commit b6c875f

Browse files
authored
Disable strict aliasing on SPHINCS+-SHAKE (#2264)
* Disable strict aliasing on SPHINCS+-SHAKE Fixes #2210 Signed-off-by: Douglas Stebila <dstebila@uwaterloo.ca> * Missed a few variants Signed-off-by: Douglas Stebila <dstebila@uwaterloo.ca> --------- Signed-off-by: Douglas Stebila <dstebila@uwaterloo.ca>
1 parent bb60b41 commit b6c875f

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

scripts/copy_from_upstream/patches/pqclean-sphincs.patch

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ diff --git a/crypto_sign/sphincs-sha2-128f-simple/META.yml b/crypto_sign/sphincs
33
index 7ee7508..5bf3613 100644
44
--- a/crypto_sign/sphincs-sha2-128f-simple/META.yml
55
+++ b/crypto_sign/sphincs-sha2-128f-simple/META.yml
6-
@@ -34,3 +34,6 @@ implementations:
6+
@@ -34,3 +34,7 @@ implementations:
7+
+ compile_opts: "-fno-strict-aliasing"
78
supported_platforms:
89
- architecture: x86_64
910
required_flags: ['avx2']
@@ -14,7 +15,8 @@ diff --git a/crypto_sign/sphincs-sha2-128s-simple/META.yml b/crypto_sign/sphincs
1415
index 2db71af..36938ad 100644
1516
--- a/crypto_sign/sphincs-sha2-128s-simple/META.yml
1617
+++ b/crypto_sign/sphincs-sha2-128s-simple/META.yml
17-
@@ -34,3 +34,6 @@ implementations:
18+
@@ -34,3 +34,7 @@ implementations:
19+
+ compile_opts: "-fno-strict-aliasing"
1820
supported_platforms:
1921
- architecture: x86_64
2022
required_flags: ['avx2']
@@ -25,7 +27,8 @@ diff --git a/crypto_sign/sphincs-sha2-192f-simple/META.yml b/crypto_sign/sphincs
2527
index f0c007f..f3885d2 100644
2628
--- a/crypto_sign/sphincs-sha2-192f-simple/META.yml
2729
+++ b/crypto_sign/sphincs-sha2-192f-simple/META.yml
28-
@@ -34,3 +34,6 @@ implementations:
30+
@@ -34,3 +34,7 @@ implementations:
31+
+ compile_opts: "-fno-strict-aliasing"
2932
supported_platforms:
3033
- architecture: x86_64
3134
required_flags: ['avx2']
@@ -36,7 +39,8 @@ diff --git a/crypto_sign/sphincs-sha2-192s-simple/META.yml b/crypto_sign/sphincs
3639
index 0e51697..7645aa2 100644
3740
--- a/crypto_sign/sphincs-sha2-192s-simple/META.yml
3841
+++ b/crypto_sign/sphincs-sha2-192s-simple/META.yml
39-
@@ -34,3 +34,6 @@ implementations:
42+
@@ -34,3 +34,7 @@ implementations:
43+
+ compile_opts: "-fno-strict-aliasing"
4044
supported_platforms:
4145
- architecture: x86_64
4246
required_flags: ['avx2']
@@ -47,7 +51,8 @@ diff --git a/crypto_sign/sphincs-sha2-256f-simple/META.yml b/crypto_sign/sphincs
4751
index e0f57c7..7627901 100644
4852
--- a/crypto_sign/sphincs-sha2-256f-simple/META.yml
4953
+++ b/crypto_sign/sphincs-sha2-256f-simple/META.yml
50-
@@ -34,3 +34,6 @@ implementations:
54+
@@ -34,3 +34,7 @@ implementations:
55+
+ compile_opts: "-fno-strict-aliasing"
5156
supported_platforms:
5257
- architecture: x86_64
5358
required_flags: ['avx2']
@@ -58,7 +63,8 @@ diff --git a/crypto_sign/sphincs-sha2-256s-simple/META.yml b/crypto_sign/sphincs
5863
index c06a39e..01d4efe 100644
5964
--- a/crypto_sign/sphincs-sha2-256s-simple/META.yml
6065
+++ b/crypto_sign/sphincs-sha2-256s-simple/META.yml
61-
@@ -34,3 +34,6 @@ implementations:
66+
@@ -34,3 +34,7 @@ implementations:
67+
+ compile_opts: "-fno-strict-aliasing"
6268
supported_platforms:
6369
- architecture: x86_64
6470
required_flags: ['avx2']
@@ -69,7 +75,8 @@ diff --git a/crypto_sign/sphincs-shake-128f-simple/META.yml b/crypto_sign/sphinc
6975
index 6eb6f96..4a934ae 100644
7076
--- a/crypto_sign/sphincs-shake-128f-simple/META.yml
7177
+++ b/crypto_sign/sphincs-shake-128f-simple/META.yml
72-
@@ -34,6 +34,9 @@ implementations:
78+
@@ -34,6 +34,10 @@ implementations:
79+
+ compile_opts: "-fno-strict-aliasing"
7380
supported_platforms:
7481
- architecture: x86_64
7582
required_flags: ['avx2']
@@ -328,7 +335,8 @@ diff --git a/crypto_sign/sphincs-shake-128s-simple/META.yml b/crypto_sign/sphinc
328335
index 3b8c5f3..b40d0f1 100644
329336
--- a/crypto_sign/sphincs-shake-128s-simple/META.yml
330337
+++ b/crypto_sign/sphincs-shake-128s-simple/META.yml
331-
@@ -34,6 +34,9 @@ implementations:
338+
@@ -34,6 +34,10 @@ implementations:
339+
+ compile_opts: "-fno-strict-aliasing"
332340
supported_platforms:
333341
- architecture: x86_64
334342
required_flags: ['avx2']
@@ -587,7 +595,8 @@ diff --git a/crypto_sign/sphincs-shake-192f-simple/META.yml b/crypto_sign/sphinc
587595
index f14a505..a6bbcd8 100644
588596
--- a/crypto_sign/sphincs-shake-192f-simple/META.yml
589597
+++ b/crypto_sign/sphincs-shake-192f-simple/META.yml
590-
@@ -34,6 +34,9 @@ implementations:
598+
@@ -34,6 +34,10 @@ implementations:
599+
+ compile_opts: "-fno-strict-aliasing"
591600
supported_platforms:
592601
- architecture: x86_64
593602
required_flags: ['avx2']
@@ -846,7 +855,8 @@ diff --git a/crypto_sign/sphincs-shake-192s-simple/META.yml b/crypto_sign/sphinc
846855
index adc9279..0aad230 100644
847856
--- a/crypto_sign/sphincs-shake-192s-simple/META.yml
848857
+++ b/crypto_sign/sphincs-shake-192s-simple/META.yml
849-
@@ -34,6 +34,9 @@ implementations:
858+
@@ -34,6 +34,10 @@ implementations:
859+
+ compile_opts: "-fno-strict-aliasing"
850860
supported_platforms:
851861
- architecture: x86_64
852862
required_flags: ['avx2']
@@ -1105,7 +1115,8 @@ diff --git a/crypto_sign/sphincs-shake-256f-simple/META.yml b/crypto_sign/sphinc
11051115
index fe03dea..03a32c3 100644
11061116
--- a/crypto_sign/sphincs-shake-256f-simple/META.yml
11071117
+++ b/crypto_sign/sphincs-shake-256f-simple/META.yml
1108-
@@ -34,6 +34,9 @@ implementations:
1118+
@@ -34,6 +34,10 @@ implementations:
1119+
+ compile_opts: "-fno-strict-aliasing"
11091120
supported_platforms:
11101121
- architecture: x86_64
11111122
required_flags: ['avx2']
@@ -1364,7 +1375,8 @@ diff --git a/crypto_sign/sphincs-shake-256s-simple/META.yml b/crypto_sign/sphinc
13641375
index 0709bb4..2457d36 100644
13651376
--- a/crypto_sign/sphincs-shake-256s-simple/META.yml
13661377
+++ b/crypto_sign/sphincs-shake-256s-simple/META.yml
1367-
@@ -34,6 +34,9 @@ implementations:
1378+
@@ -34,6 +34,10 @@ implementations:
1379+
+ compile_opts: "-fno-strict-aliasing"
13681380
supported_platforms:
13691381
- architecture: x86_64
13701382
required_flags: ['avx2']

src/sig/sphincs/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_128f_simple_avx2)
1717
target_include_directories(sphincs_sha2_128f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-128f-simple_avx2)
1818
target_include_directories(sphincs_sha2_128f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
1919
target_compile_options(sphincs_sha2_128f_simple_avx2 PRIVATE -mavx2)
20+
target_compile_options(sphincs_sha2_128f_simple_avx2 PUBLIC -fno-strict-aliasing)
2021
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_128f_simple_avx2>)
2122
endif()
2223

@@ -32,6 +33,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_128s_simple_avx2)
3233
target_include_directories(sphincs_sha2_128s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-128s-simple_avx2)
3334
target_include_directories(sphincs_sha2_128s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
3435
target_compile_options(sphincs_sha2_128s_simple_avx2 PRIVATE -mavx2)
36+
target_compile_options(sphincs_sha2_128s_simple_avx2 PUBLIC -fno-strict-aliasing)
3537
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_128s_simple_avx2>)
3638
endif()
3739

@@ -47,6 +49,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_192f_simple_avx2)
4749
target_include_directories(sphincs_sha2_192f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-192f-simple_avx2)
4850
target_include_directories(sphincs_sha2_192f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
4951
target_compile_options(sphincs_sha2_192f_simple_avx2 PRIVATE -mavx2)
52+
target_compile_options(sphincs_sha2_192f_simple_avx2 PUBLIC -fno-strict-aliasing)
5053
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_192f_simple_avx2>)
5154
endif()
5255

@@ -62,6 +65,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_192s_simple_avx2)
6265
target_include_directories(sphincs_sha2_192s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-192s-simple_avx2)
6366
target_include_directories(sphincs_sha2_192s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
6467
target_compile_options(sphincs_sha2_192s_simple_avx2 PRIVATE -mavx2)
68+
target_compile_options(sphincs_sha2_192s_simple_avx2 PUBLIC -fno-strict-aliasing)
6569
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_192s_simple_avx2>)
6670
endif()
6771

@@ -77,6 +81,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_256f_simple_avx2)
7781
target_include_directories(sphincs_sha2_256f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-256f-simple_avx2)
7882
target_include_directories(sphincs_sha2_256f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
7983
target_compile_options(sphincs_sha2_256f_simple_avx2 PRIVATE -mavx2)
84+
target_compile_options(sphincs_sha2_256f_simple_avx2 PUBLIC -fno-strict-aliasing)
8085
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_256f_simple_avx2>)
8186
endif()
8287

@@ -92,6 +97,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_256s_simple_avx2)
9297
target_include_directories(sphincs_sha2_256s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-256s-simple_avx2)
9398
target_include_directories(sphincs_sha2_256s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
9499
target_compile_options(sphincs_sha2_256s_simple_avx2 PRIVATE -mavx2)
100+
target_compile_options(sphincs_sha2_256s_simple_avx2 PUBLIC -fno-strict-aliasing)
95101
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_256s_simple_avx2>)
96102
endif()
97103

@@ -107,6 +113,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_128f_simple_avx2)
107113
target_include_directories(sphincs_shake_128f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-128f-simple_avx2)
108114
target_include_directories(sphincs_shake_128f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
109115
target_compile_options(sphincs_shake_128f_simple_avx2 PRIVATE -mavx2)
116+
target_compile_options(sphincs_shake_128f_simple_avx2 PUBLIC -fno-strict-aliasing)
110117
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_128f_simple_avx2>)
111118
endif()
112119

@@ -122,6 +129,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_128s_simple_avx2)
122129
target_include_directories(sphincs_shake_128s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-128s-simple_avx2)
123130
target_include_directories(sphincs_shake_128s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
124131
target_compile_options(sphincs_shake_128s_simple_avx2 PRIVATE -mavx2)
132+
target_compile_options(sphincs_shake_128s_simple_avx2 PUBLIC -fno-strict-aliasing)
125133
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_128s_simple_avx2>)
126134
endif()
127135

@@ -137,6 +145,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_192f_simple_avx2)
137145
target_include_directories(sphincs_shake_192f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-192f-simple_avx2)
138146
target_include_directories(sphincs_shake_192f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
139147
target_compile_options(sphincs_shake_192f_simple_avx2 PRIVATE -mavx2)
148+
target_compile_options(sphincs_shake_192f_simple_avx2 PUBLIC -fno-strict-aliasing)
140149
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_192f_simple_avx2>)
141150
endif()
142151

@@ -152,6 +161,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_192s_simple_avx2)
152161
target_include_directories(sphincs_shake_192s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-192s-simple_avx2)
153162
target_include_directories(sphincs_shake_192s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
154163
target_compile_options(sphincs_shake_192s_simple_avx2 PRIVATE -mavx2)
164+
target_compile_options(sphincs_shake_192s_simple_avx2 PUBLIC -fno-strict-aliasing)
155165
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_192s_simple_avx2>)
156166
endif()
157167

@@ -167,6 +177,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_256f_simple_avx2)
167177
target_include_directories(sphincs_shake_256f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-256f-simple_avx2)
168178
target_include_directories(sphincs_shake_256f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
169179
target_compile_options(sphincs_shake_256f_simple_avx2 PRIVATE -mavx2)
180+
target_compile_options(sphincs_shake_256f_simple_avx2 PUBLIC -fno-strict-aliasing)
170181
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_256f_simple_avx2>)
171182
endif()
172183

@@ -182,6 +193,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_256s_simple_avx2)
182193
target_include_directories(sphincs_shake_256s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-256s-simple_avx2)
183194
target_include_directories(sphincs_shake_256s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
184195
target_compile_options(sphincs_shake_256s_simple_avx2 PRIVATE -mavx2)
196+
target_compile_options(sphincs_shake_256s_simple_avx2 PUBLIC -fno-strict-aliasing)
185197
set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_256s_simple_avx2>)
186198
endif()
187199

0 commit comments

Comments
 (0)