]> git.feebdaed.xyz Git - 0xmirror/liboqs.git/commitdiff
Disable strict aliasing on SPHINCS+-SHAKE (#2264)
authorDouglas Stebila <dstebila@users.noreply.github.com>
Tue, 23 Sep 2025 12:42:11 +0000 (08:42 -0400)
committerGitHub <noreply@github.com>
Tue, 23 Sep 2025 12:42:11 +0000 (08:42 -0400)
* 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>
scripts/copy_from_upstream/patches/pqclean-sphincs.patch
src/sig/sphincs/CMakeLists.txt

index fedefc678a72bbd530bd621727af584065b95c06..bd1c1d5f7d2f8de2a411113e8207f58b4855dcdb 100644 (file)
@@ -3,7 +3,8 @@ diff --git a/crypto_sign/sphincs-sha2-128f-simple/META.yml b/crypto_sign/sphincs
 index 7ee7508..5bf3613 100644
 --- a/crypto_sign/sphincs-sha2-128f-simple/META.yml
 +++ b/crypto_sign/sphincs-sha2-128f-simple/META.yml
-@@ -34,3 +34,6 @@ implementations:
+@@ -34,3 +34,7 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -14,7 +15,8 @@ diff --git a/crypto_sign/sphincs-sha2-128s-simple/META.yml b/crypto_sign/sphincs
 index 2db71af..36938ad 100644
 --- a/crypto_sign/sphincs-sha2-128s-simple/META.yml
 +++ b/crypto_sign/sphincs-sha2-128s-simple/META.yml
-@@ -34,3 +34,6 @@ implementations:
+@@ -34,3 +34,7 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -25,7 +27,8 @@ diff --git a/crypto_sign/sphincs-sha2-192f-simple/META.yml b/crypto_sign/sphincs
 index f0c007f..f3885d2 100644
 --- a/crypto_sign/sphincs-sha2-192f-simple/META.yml
 +++ b/crypto_sign/sphincs-sha2-192f-simple/META.yml
-@@ -34,3 +34,6 @@ implementations:
+@@ -34,3 +34,7 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -36,7 +39,8 @@ diff --git a/crypto_sign/sphincs-sha2-192s-simple/META.yml b/crypto_sign/sphincs
 index 0e51697..7645aa2 100644
 --- a/crypto_sign/sphincs-sha2-192s-simple/META.yml
 +++ b/crypto_sign/sphincs-sha2-192s-simple/META.yml
-@@ -34,3 +34,6 @@ implementations:
+@@ -34,3 +34,7 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -47,7 +51,8 @@ diff --git a/crypto_sign/sphincs-sha2-256f-simple/META.yml b/crypto_sign/sphincs
 index e0f57c7..7627901 100644
 --- a/crypto_sign/sphincs-sha2-256f-simple/META.yml
 +++ b/crypto_sign/sphincs-sha2-256f-simple/META.yml
-@@ -34,3 +34,6 @@ implementations:
+@@ -34,3 +34,7 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -58,7 +63,8 @@ diff --git a/crypto_sign/sphincs-sha2-256s-simple/META.yml b/crypto_sign/sphincs
 index c06a39e..01d4efe 100644
 --- a/crypto_sign/sphincs-sha2-256s-simple/META.yml
 +++ b/crypto_sign/sphincs-sha2-256s-simple/META.yml
-@@ -34,3 +34,6 @@ implementations:
+@@ -34,3 +34,7 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -69,7 +75,8 @@ diff --git a/crypto_sign/sphincs-shake-128f-simple/META.yml b/crypto_sign/sphinc
 index 6eb6f96..4a934ae 100644
 --- a/crypto_sign/sphincs-shake-128f-simple/META.yml
 +++ b/crypto_sign/sphincs-shake-128f-simple/META.yml
-@@ -34,6 +34,9 @@ implementations:
+@@ -34,6 +34,10 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -328,7 +335,8 @@ diff --git a/crypto_sign/sphincs-shake-128s-simple/META.yml b/crypto_sign/sphinc
 index 3b8c5f3..b40d0f1 100644
 --- a/crypto_sign/sphincs-shake-128s-simple/META.yml
 +++ b/crypto_sign/sphincs-shake-128s-simple/META.yml
-@@ -34,6 +34,9 @@ implementations:
+@@ -34,6 +34,10 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -587,7 +595,8 @@ diff --git a/crypto_sign/sphincs-shake-192f-simple/META.yml b/crypto_sign/sphinc
 index f14a505..a6bbcd8 100644
 --- a/crypto_sign/sphincs-shake-192f-simple/META.yml
 +++ b/crypto_sign/sphincs-shake-192f-simple/META.yml
-@@ -34,6 +34,9 @@ implementations:
+@@ -34,6 +34,10 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -846,7 +855,8 @@ diff --git a/crypto_sign/sphincs-shake-192s-simple/META.yml b/crypto_sign/sphinc
 index adc9279..0aad230 100644
 --- a/crypto_sign/sphincs-shake-192s-simple/META.yml
 +++ b/crypto_sign/sphincs-shake-192s-simple/META.yml
-@@ -34,6 +34,9 @@ implementations:
+@@ -34,6 +34,10 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -1105,7 +1115,8 @@ diff --git a/crypto_sign/sphincs-shake-256f-simple/META.yml b/crypto_sign/sphinc
 index fe03dea..03a32c3 100644
 --- a/crypto_sign/sphincs-shake-256f-simple/META.yml
 +++ b/crypto_sign/sphincs-shake-256f-simple/META.yml
-@@ -34,6 +34,9 @@ implementations:
+@@ -34,6 +34,10 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
@@ -1364,7 +1375,8 @@ diff --git a/crypto_sign/sphincs-shake-256s-simple/META.yml b/crypto_sign/sphinc
 index 0709bb4..2457d36 100644
 --- a/crypto_sign/sphincs-shake-256s-simple/META.yml
 +++ b/crypto_sign/sphincs-shake-256s-simple/META.yml
-@@ -34,6 +34,9 @@ implementations:
+@@ -34,6 +34,10 @@ implementations:
++    compile_opts: "-fno-strict-aliasing"
      supported_platforms:
        - architecture: x86_64
          required_flags: ['avx2']
index 10f9852cf5b3911541391b9a17e512822a346761..9c558ea035e5e5af7e597f1e74a153b48e1e86b3 100644 (file)
@@ -17,6 +17,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_128f_simple_avx2)
     target_include_directories(sphincs_sha2_128f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-128f-simple_avx2)
     target_include_directories(sphincs_sha2_128f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_sha2_128f_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_sha2_128f_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_128f_simple_avx2>)
 endif()
 
@@ -32,6 +33,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_128s_simple_avx2)
     target_include_directories(sphincs_sha2_128s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-128s-simple_avx2)
     target_include_directories(sphincs_sha2_128s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_sha2_128s_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_sha2_128s_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_128s_simple_avx2>)
 endif()
 
@@ -47,6 +49,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_192f_simple_avx2)
     target_include_directories(sphincs_sha2_192f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-192f-simple_avx2)
     target_include_directories(sphincs_sha2_192f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_sha2_192f_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_sha2_192f_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_192f_simple_avx2>)
 endif()
 
@@ -62,6 +65,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_192s_simple_avx2)
     target_include_directories(sphincs_sha2_192s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-192s-simple_avx2)
     target_include_directories(sphincs_sha2_192s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_sha2_192s_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_sha2_192s_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_192s_simple_avx2>)
 endif()
 
@@ -77,6 +81,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_256f_simple_avx2)
     target_include_directories(sphincs_sha2_256f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-256f-simple_avx2)
     target_include_directories(sphincs_sha2_256f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_sha2_256f_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_sha2_256f_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_256f_simple_avx2>)
 endif()
 
@@ -92,6 +97,7 @@ if(OQS_ENABLE_SIG_sphincs_sha2_256s_simple_avx2)
     target_include_directories(sphincs_sha2_256s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-sha2-256s-simple_avx2)
     target_include_directories(sphincs_sha2_256s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_sha2_256s_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_sha2_256s_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_sha2_256s_simple_avx2>)
 endif()
 
@@ -107,6 +113,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_128f_simple_avx2)
     target_include_directories(sphincs_shake_128f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-128f-simple_avx2)
     target_include_directories(sphincs_shake_128f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_shake_128f_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_shake_128f_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_128f_simple_avx2>)
 endif()
 
@@ -122,6 +129,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_128s_simple_avx2)
     target_include_directories(sphincs_shake_128s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-128s-simple_avx2)
     target_include_directories(sphincs_shake_128s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_shake_128s_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_shake_128s_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_128s_simple_avx2>)
 endif()
 
@@ -137,6 +145,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_192f_simple_avx2)
     target_include_directories(sphincs_shake_192f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-192f-simple_avx2)
     target_include_directories(sphincs_shake_192f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_shake_192f_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_shake_192f_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_192f_simple_avx2>)
 endif()
 
@@ -152,6 +161,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_192s_simple_avx2)
     target_include_directories(sphincs_shake_192s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-192s-simple_avx2)
     target_include_directories(sphincs_shake_192s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_shake_192s_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_shake_192s_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_192s_simple_avx2>)
 endif()
 
@@ -167,6 +177,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_256f_simple_avx2)
     target_include_directories(sphincs_shake_256f_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-256f-simple_avx2)
     target_include_directories(sphincs_shake_256f_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_shake_256f_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_shake_256f_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_256f_simple_avx2>)
 endif()
 
@@ -182,6 +193,7 @@ if(OQS_ENABLE_SIG_sphincs_shake_256s_simple_avx2)
     target_include_directories(sphincs_shake_256s_simple_avx2 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pqclean_sphincs-shake-256s-simple_avx2)
     target_include_directories(sphincs_shake_256s_simple_avx2 PRIVATE ${PROJECT_SOURCE_DIR}/src/common/pqclean_shims)
     target_compile_options(sphincs_shake_256s_simple_avx2 PRIVATE -mavx2)
+    target_compile_options(sphincs_shake_256s_simple_avx2 PUBLIC -fno-strict-aliasing)
     set(_SPHINCS_OBJS ${_SPHINCS_OBJS} $<TARGET_OBJECTS:sphincs_shake_256s_simple_avx2>)
 endif()