@pinkparrot/qsafe-mayo-wasm 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/.gitmodules +3 -0
  2. package/.vscode/launch.json +12 -0
  3. package/LICENSE +201 -0
  4. package/bridge/mayo1_bridge.c +26 -0
  5. package/bridge/mayo2_bridge.c +26 -0
  6. package/bridge/randombytes_inject.c +44 -0
  7. package/build_mayo1.ps1 +36 -0
  8. package/build_mayo2.ps1 +36 -0
  9. package/dist/mayo.browser.min.js +216 -0
  10. package/dist/mayo1.js +0 -0
  11. package/dist/mayo2.js +0 -0
  12. package/dist/mayo_api.js +139 -0
  13. package/dist/package.json +1 -0
  14. package/gitignore +2 -0
  15. package/index.mjs +1 -0
  16. package/mayo-c/.astylerc +16 -0
  17. package/mayo-c/.cmake/flags.cmake +45 -0
  18. package/mayo-c/.cmake/sanitizers.cmake +81 -0
  19. package/mayo-c/.cmake/target.cmake +71 -0
  20. package/mayo-c/.github/workflows/ci_clang.yml +61 -0
  21. package/mayo-c/.github/workflows/ci_gcc.yml +60 -0
  22. package/mayo-c/.github/workflows/cmake.yml +160 -0
  23. package/mayo-c/.github/workflows/macos_m1.yml +68 -0
  24. package/mayo-c/CMakeLists.txt +35 -0
  25. package/mayo-c/KAT/PQCsignKAT_24_MAYO_1.req +900 -0
  26. package/mayo-c/KAT/PQCsignKAT_24_MAYO_1.rsp +902 -0
  27. package/mayo-c/KAT/PQCsignKAT_24_MAYO_2.req +900 -0
  28. package/mayo-c/KAT/PQCsignKAT_24_MAYO_2.rsp +902 -0
  29. package/mayo-c/KAT/PQCsignKAT_32_MAYO_3.req +900 -0
  30. package/mayo-c/KAT/PQCsignKAT_32_MAYO_3.rsp +902 -0
  31. package/mayo-c/KAT/PQCsignKAT_40_MAYO_5.req +900 -0
  32. package/mayo-c/KAT/PQCsignKAT_40_MAYO_5.rsp +902 -0
  33. package/mayo-c/LICENSE +202 -0
  34. package/mayo-c/META/MAYO-1_META.yml +52 -0
  35. package/mayo-c/META/MAYO-2_META.yml +52 -0
  36. package/mayo-c/META/MAYO-3_META.yml +52 -0
  37. package/mayo-c/META/MAYO-5_META.yml +52 -0
  38. package/mayo-c/NOTICE +13 -0
  39. package/mayo-c/README.md +183 -0
  40. package/mayo-c/apps/CMakeLists.txt +31 -0
  41. package/mayo-c/apps/PQCgenKAT_sign.c +281 -0
  42. package/mayo-c/apps/example.c +151 -0
  43. package/mayo-c/apps/example_nistapi.c +124 -0
  44. package/mayo-c/include/mayo.h +442 -0
  45. package/mayo-c/include/mem.h +25 -0
  46. package/mayo-c/include/randombytes.h +31 -0
  47. package/mayo-c/scripts/contstants.py +141 -0
  48. package/mayo-c/scripts/find_irred_poly.sage +39 -0
  49. package/mayo-c/src/AVX2/arithmetic_common.h +159 -0
  50. package/mayo-c/src/AVX2/echelon_form.h +91 -0
  51. package/mayo-c/src/AVX2/echelon_form_loop.h +58 -0
  52. package/mayo-c/src/AVX2/shuffle_arithmetic.h +442 -0
  53. package/mayo-c/src/CMakeLists.txt +98 -0
  54. package/mayo-c/src/arithmetic.c +128 -0
  55. package/mayo-c/src/arithmetic.h +124 -0
  56. package/mayo-c/src/common/aes128ctr.c +293 -0
  57. package/mayo-c/src/common/aes_c.c +741 -0
  58. package/mayo-c/src/common/aes_ctr.h +32 -0
  59. package/mayo-c/src/common/aes_neon.c +201 -0
  60. package/mayo-c/src/common/debug_bench_tools.h +69 -0
  61. package/mayo-c/src/common/fips202.c +1093 -0
  62. package/mayo-c/src/common/fips202.h +12 -0
  63. package/mayo-c/src/common/mem.c +19 -0
  64. package/mayo-c/src/common/randombytes_ctrdrbg.c +141 -0
  65. package/mayo-c/src/common/randombytes_system.c +399 -0
  66. package/mayo-c/src/generic/arithmetic_dynamic.h +68 -0
  67. package/mayo-c/src/generic/arithmetic_fixed.h +84 -0
  68. package/mayo-c/src/generic/echelon_form.h +152 -0
  69. package/mayo-c/src/generic/ef_inner_loop.h +56 -0
  70. package/mayo-c/src/generic/generic_arithmetic.h +294 -0
  71. package/mayo-c/src/mayo.c +675 -0
  72. package/mayo-c/src/mayo_1/api.c +46 -0
  73. package/mayo-c/src/mayo_1/api.h +43 -0
  74. package/mayo-c/src/mayo_2/api.c +46 -0
  75. package/mayo-c/src/mayo_2/api.h +43 -0
  76. package/mayo-c/src/mayo_3/api.c +46 -0
  77. package/mayo-c/src/mayo_3/api.h +43 -0
  78. package/mayo-c/src/mayo_5/api.c +46 -0
  79. package/mayo-c/src/mayo_5/api.h +43 -0
  80. package/mayo-c/src/neon/arithmetic_common.h +132 -0
  81. package/mayo-c/src/neon/echelon_form.h +55 -0
  82. package/mayo-c/src/neon/echelon_form_loop.h +58 -0
  83. package/mayo-c/src/neon/shuffle_arithmetic.h +462 -0
  84. package/mayo-c/src/params.c +42 -0
  85. package/mayo-c/src/simple_arithmetic.h +138 -0
  86. package/mayo-c/test/CMakeLists.txt +51 -0
  87. package/mayo-c/test/bench.c +166 -0
  88. package/mayo-c/test/m1cycles.c +155 -0
  89. package/mayo-c/test/m1cycles.h +13 -0
  90. package/mayo-c/test/test_kat.c +271 -0
  91. package/mayo-c/test/test_mayo.c +139 -0
  92. package/mayo-c/test/test_sample_solution.c +75 -0
  93. package/mayo-c/test/test_various.c +680 -0
  94. package/package.json +39 -0
  95. package/publish.bat +22 -0
  96. package/readme.md +80 -0
  97. package/test/test.mjs +42 -0
@@ -0,0 +1,81 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ # AddressSanitizer
4
+ set(CMAKE_C_FLAGS_ASAN
5
+ "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
6
+ CACHE STRING "Flags used by the C compiler during AddressSanitizer builds."
7
+ FORCE)
8
+
9
+ # LeakSanitizer
10
+ set(CMAKE_C_FLAGS_LSAN
11
+ "-fsanitize=leak -fno-omit-frame-pointer -g -O1"
12
+ CACHE STRING "Flags used by the C compiler during LeakSanitizer builds."
13
+ FORCE)
14
+
15
+ # MemorySanitizer
16
+ set(CMAKE_C_FLAGS_MSAN
17
+ "-fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O1"
18
+ CACHE STRING "Flags used by the C compiler during MemorySanitizer builds."
19
+ FORCE)
20
+
21
+ # UndefinedBehaviour
22
+ set(CMAKE_C_FLAGS_UBSAN
23
+ "-fsanitize=undefined"
24
+ CACHE STRING "Flags used by the C compiler during UndefinedBehaviourSanitizer builds."
25
+ FORCE)
26
+
27
+ set(CMAKE_C_FLAGS_COVERAGE
28
+ "-fprofile-arcs -ftest-coverage"
29
+ CACHE STRING "Flags used by the C compiler during Coverage builds."
30
+ FORCE)
31
+
32
+ # CT-testing configs
33
+ set(CMAKE_C_FLAGS_CTOS
34
+ "-Os -gdwarf-4"
35
+ CACHE STRING "Flags used by the C compiler during CT builds."
36
+ FORCE)
37
+
38
+ set(CMAKE_C_FLAGS_CTO0
39
+ "-O0 -gdwarf-4"
40
+ CACHE STRING "Flags used by the C compiler during CT builds."
41
+ FORCE)
42
+
43
+ set(CMAKE_C_FLAGS_CTO1
44
+ "-O1 -gdwarf-4"
45
+ CACHE STRING "Flags used by the C compiler during CT builds."
46
+ FORCE)
47
+
48
+ set(CMAKE_C_FLAGS_CTO2
49
+ "-O2 -gdwarf-4"
50
+ CACHE STRING "Flags used by the C compiler during CT builds."
51
+ FORCE)
52
+
53
+ set(CMAKE_C_FLAGS_CTO3
54
+ "-O3 -gdwarf-4"
55
+ CACHE STRING "Flags used by the C compiler during CT builds."
56
+ FORCE)
57
+
58
+ set(CMAKE_C_FLAGS_CTOSNOVEC
59
+ "-Os -fno-vectorize -gdwarf-4"
60
+ CACHE STRING "Flags used by the C compiler during CT builds."
61
+ FORCE)
62
+
63
+ set(CMAKE_C_FLAGS_CTO0NOVEC
64
+ "-O0 -fno-vectorize -gdwarf-4"
65
+ CACHE STRING "Flags used by the C compiler during CT builds."
66
+ FORCE)
67
+
68
+ set(CMAKE_C_FLAGS_CTO1NOVEC
69
+ "-O1 -fno-vectorize -gdwarf-4"
70
+ CACHE STRING "Flags used by the C compiler during CT builds."
71
+ FORCE)
72
+
73
+ set(CMAKE_C_FLAGS_CTO2NOVEC
74
+ "-O2 -fno-vectorize -gdwarf-4"
75
+ CACHE STRING "Flags used by the C compiler during CT builds."
76
+ FORCE)
77
+
78
+ set(CMAKE_C_FLAGS_CTO3NOVEC
79
+ "-O3 -fno-vectorize -gdwarf-4"
80
+ CACHE STRING "Flags used by the C compiler during CT builds."
81
+ FORCE)
@@ -0,0 +1,71 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
4
+ add_definitions(-DTARGET_ARM64)
5
+ elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
6
+ add_definitions(-DTARGET_ARM)
7
+ elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
8
+ add_definitions(-DTARGET_AMD64)
9
+ elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686")
10
+ add_definitions(-DTARGET_X86)
11
+ elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(s390x.*|S390X.*)")
12
+ add_definitions(-DTARGET_S390X)
13
+ add_definitions(-DTARGET_BIG_ENDIAN)
14
+ else()
15
+ add_definitions(-DTARGET_OTHER)
16
+ endif()
17
+
18
+ if (APPLE)
19
+ add_definitions(-DTARGET_OS_MAC)
20
+ elseif (UNIX)
21
+ add_definitions(-DTARGET_OS_UNIX)
22
+ else()
23
+ add_definitions(-DTARGET_OS_OTHER)
24
+ endif()
25
+
26
+ set(G_C_OPT_FLAGS "")
27
+
28
+ if ((NOT DEFINED MAYO_BUILD_TYPE))
29
+ set(MAYO_BUILD_TYPE opt)
30
+ endif()
31
+
32
+
33
+ if (DEFINED MAYO_MARCH)
34
+ list(APPEND G_C_OPT_FLAGS
35
+ ${MAYO_MARCH})
36
+ endif()
37
+
38
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64"))
39
+ if (NOT DEFINED MAYO_MARCH)
40
+ list(APPEND G_C_OPT_FLAGS
41
+ -march=native)
42
+ endif()
43
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
44
+ option(ENABLE_AESNI "Use AESni" ON)
45
+ endif()
46
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
47
+ if (NOT DEFINED MAYO_MARCH)
48
+ list(APPEND G_C_OPT_FLAGS
49
+ -mcpu=apple-m1)
50
+ endif()
51
+ option(ENABLE_AESNI "Use AESni" OFF)
52
+ option(ENABLE_AESNEON "Use AES-NEON" ON)
53
+ endif()
54
+
55
+
56
+ if (${MAYO_BUILD_TYPE} MATCHES "ref")
57
+ option(ENABLE_AESNI "Use AESni" OFF)
58
+ option(ENABLE_PARAMS_DYNAMIC "Use dynamic parameters" ON)
59
+ add_definitions(-DMAYO_BUILD_TYPE_REF)
60
+ elseif(${MAYO_BUILD_TYPE} MATCHES "opt")
61
+ add_definitions(-DMAYO_BUILD_TYPE_OPT)
62
+ option(ENABLE_PARAMS_DYNAMIC "Use dynamic parameters" OFF)
63
+ elseif(${MAYO_BUILD_TYPE} MATCHES "avx2")
64
+ add_definitions(-DMAYO_BUILD_TYPE_AVX2)
65
+ option(ENABLE_PARAMS_DYNAMIC "Use dynamic parameters" OFF)
66
+ elseif(${MAYO_BUILD_TYPE} MATCHES "neon")
67
+ add_definitions(-DMAYO_BUILD_TYPE_NEON)
68
+ option(ENABLE_PARAMS_DYNAMIC "Use dynamic parameters" OFF)
69
+ endif()
70
+
71
+ separate_arguments(C_OPT_FLAGS UNIX_COMMAND "${G_C_OPT_FLAGS}")
@@ -0,0 +1,61 @@
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: CT-tests (clang, clang-14 and clang-18)
4
+
5
+ # Controls when the workflow will run
6
+ on:
7
+ # Triggers the workflow on push or pull request events but only for the "github" branch
8
+ push:
9
+ branches: [ '*' ]
10
+ pull_request:
11
+ branches: [ "main" ]
12
+
13
+ # Allows you to run this workflow manually from the Actions tab
14
+ workflow_dispatch:
15
+
16
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
17
+ jobs:
18
+ # This workflow contains a single job called "build"
19
+ ct:
20
+ # The type of runner that the job will run on
21
+ runs-on: ubuntu-latest
22
+ strategy:
23
+ matrix:
24
+ clang_config: [CTOS, CTO0, CTO2, CTO3, CTOSNOVEC, CTO0NOVEC, CTO2NOVEC, CTO3NOVEC]
25
+ # Note: valgrind seems buggy with CT01 and CT01NOVEC, we skip them
26
+ clang_version: [clang, clang-15, clang-18]
27
+ mayo_build_type: [ref, opt, avx2]
28
+
29
+
30
+ # Steps represent a sequence of tasks that will be executed as part of the job
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - name: Set up Python 3.10
34
+ uses: actions/setup-python@v5
35
+ with:
36
+ python-version: "3.10"
37
+
38
+ - name: Install dependencies
39
+ run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && wget https://apt.llvm.org/llvm.sh && sudo bash ./llvm.sh 18 && sudo apt update && sudo apt -y install build-essential valgrind cmake libboost-tools-dev libpthread-stubs0-dev libssl-dev clang-15 clang-18 clang gcc gcc-12
40
+
41
+ - name: CT-Test (clang)
42
+ run: |
43
+ ldd --version
44
+ rm -rf build && mkdir build && cd build && cmake -DENABLE_CT_TESTING=ON -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=${{ matrix.clang_version }} -DCMAKE_BUILD_TYPE=${{ matrix.clang_config }} -DMAYO_MARCH="-march=haswell -maes" .. && make -j
45
+ valgrind --max-stackframe=3190968 --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme_MAYO_1
46
+ valgrind --max-stackframe=3190968 --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme_MAYO_2
47
+ valgrind --max-stackframe=3190968 --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme_MAYO_3
48
+ valgrind --max-stackframe=3190968 --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme_MAYO_5
49
+ cd ..
50
+ if: (matrix.mayo_build_type == 'opt' || matrix.mayo_build_type == 'avx2') && !(matrix.clang_config == 'CTO3' && matrix.mayo_build_type == 'opt')
51
+
52
+ - name: CT-Test (clang)
53
+ run: |
54
+ ldd --version
55
+ rm -rf build && mkdir build && cd build && cmake -DENABLE_CT_TESTING=ON -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=${{ matrix.clang_version }} -DCMAKE_BUILD_TYPE=${{ matrix.clang_config }} -DMAYO_MARCH="-march=haswell -maes" .. && make -j
56
+ valgrind --max-stackframe=3190968 --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme MAYO-1
57
+ valgrind --max-stackframe=3190968 --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme MAYO-2
58
+ valgrind --max-stackframe=3190968 --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme MAYO-3
59
+ valgrind --max-stackframe=3190968 --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme MAYO-5
60
+ cd ..
61
+ if: matrix.mayo_build_type == 'ref'
@@ -0,0 +1,60 @@
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: CT-tests (gcc and gcc-12)
4
+
5
+ # Controls when the workflow will run
6
+ on:
7
+ # Triggers the workflow on push or pull request events but only for the "github" branch
8
+ push:
9
+ branches: [ '*' ]
10
+ pull_request:
11
+ branches: [ "main" ]
12
+
13
+ # Allows you to run this workflow manually from the Actions tab
14
+ workflow_dispatch:
15
+
16
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
17
+ jobs:
18
+ # This workflow contains a single job called "build"
19
+ ct:
20
+ # The type of runner that the job will run on
21
+ runs-on: ubuntu-latest
22
+ strategy:
23
+ matrix:
24
+ gcc_config: [CTOS, CTO0, CTO1, CTO2, CTO3]
25
+ gcc_version: [gcc, gcc-12]
26
+ mayo_build_type: [ref, opt, avx2]
27
+
28
+
29
+ # Steps represent a sequence of tasks that will be executed as part of the job
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ - name: Set up Python 3.10
33
+ uses: actions/setup-python@v5
34
+ with:
35
+ python-version: "3.10"
36
+
37
+ - name: Install dependencies
38
+ run: sudo apt update && sudo apt -y install build-essential valgrind cmake libboost-tools-dev libpthread-stubs0-dev libssl-dev clang-15 clang gcc gcc-12
39
+
40
+ - name: CT-Test (gcc)
41
+ run: |
42
+ ldd --version
43
+ rm -rf build && mkdir build && cd build && cmake -DENABLE_CT_TESTING=ON -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=${{ matrix.gcc_version }} -DCMAKE_BUILD_TYPE=${{ matrix.gcc_config }} -DMAYO_MARCH="-march=haswell -maes" .. && make -j
44
+ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme_MAYO_1
45
+ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme_MAYO_2
46
+ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme_MAYO_3
47
+ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme_MAYO_5
48
+ cd ..
49
+ if: matrix.mayo_build_type == 'opt' || matrix.mayo_build_type == 'avx2'
50
+
51
+ - name: CT-Test (clang)
52
+ run: |
53
+ ldd --version
54
+ rm -rf build && mkdir build && cd build && cmake -DENABLE_CT_TESTING=ON -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=${{ matrix.gcc_version }} -DCMAKE_BUILD_TYPE=${{ matrix.gcc_config }} -DMAYO_MARCH="-march=haswell -maes" .. && make -j
55
+ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme MAYO-1
56
+ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme MAYO-2
57
+ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme MAYO-3
58
+ valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes test/mayo_test_scheme MAYO-5
59
+ cd ..
60
+ if: matrix.mayo_build_type == 'ref'
@@ -0,0 +1,160 @@
1
+ name: CMake
2
+
3
+ on:
4
+ push:
5
+ branches: [ '*' ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ env:
10
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11
+ BUILD_TYPE: Debug
12
+
13
+ jobs:
14
+ build_test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ mayo_build_type: [ref, opt, avx2]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+ - name: Set up Python 3.10
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.10"
26
+
27
+ - name: Install xsltproc
28
+ run: sudo apt-get install -y xsltproc
29
+
30
+ - name: Install Valgrind
31
+ run: |
32
+ sudo apt-get update && sudo apt install valgrind
33
+ echo "Valgrind installed"
34
+
35
+ - name: Install Valgrind dependencies
36
+ run: |
37
+ python -m pip install --upgrade pip
38
+ pip install ValgrindCI
39
+
40
+ # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
41
+ # You can convert this to a matrix build if you need cross-platform coverage.
42
+ # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
43
+
44
+ - name: Configure CMake
45
+ # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
46
+ # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
47
+ run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }}
48
+
49
+ - name: Build
50
+ # Build your program with the given configuration
51
+ run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
52
+
53
+ - name: Test
54
+ working-directory: ${{github.workspace}}/build
55
+ # Execute tests defined by the CMake configuration.
56
+ # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
57
+ run: ctest -C ${{env.BUILD_TYPE}}
58
+
59
+ - name: Examples (opt/avx2)
60
+ working-directory: ${{github.workspace}}/build/apps
61
+ run: |
62
+ ./PQCgenKAT_sign_mayo_1
63
+ ./PQCgenKAT_sign_mayo_2
64
+ ./PQCgenKAT_sign_mayo_3
65
+ ./PQCgenKAT_sign_mayo_5
66
+ ./example_mayo_1
67
+ ./example_mayo_2
68
+ ./example_mayo_3
69
+ ./example_mayo_5
70
+ ./example_nistapi_mayo_1
71
+ ./example_nistapi_mayo_2
72
+ ./example_nistapi_mayo_3
73
+ ./example_nistapi_mayo_5
74
+ if: matrix.mayo_build_type == 'opt' || matrix.mayo_build_type == 'avx2'
75
+
76
+ - name: Examples (ref)
77
+ working-directory: ${{github.workspace}}/build/apps
78
+ run: |
79
+ ./PQCgenKAT_sign_mayo_1
80
+ ./PQCgenKAT_sign_mayo_2
81
+ ./PQCgenKAT_sign_mayo_3
82
+ ./PQCgenKAT_sign_mayo_5
83
+ ./example_mayo
84
+ ./example_nistapi_mayo_1
85
+ ./example_nistapi_mayo_2
86
+ ./example_nistapi_mayo_3
87
+ ./example_nistapi_mayo_5
88
+ if: matrix.mayo_build_type == 'ref'
89
+
90
+ - name: CT-Tests
91
+ run: |
92
+ rm -rf build
93
+ cmake -Bbuild -DENABLE_CT_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DMAYO_MARCH="-march=haswell -maes"
94
+ cmake --build build
95
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme_MAYO_1
96
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme_MAYO_2
97
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme_MAYO_3
98
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme_MAYO_5
99
+ if: matrix.mayo_build_type == 'opt' || matrix.mayo_build_type == 'avx2'
100
+
101
+ - name: CT-Tests
102
+ run: |
103
+ rm -rf build
104
+ cmake -Bbuild -DENABLE_CT_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DMAYO_MARCH="-march=haswell -maes"
105
+ cmake --build build
106
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme MAYO-1
107
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme MAYO-2
108
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme MAYO-3
109
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme MAYO-5
110
+ if: matrix.mayo_build_type == 'ref'
111
+
112
+ - name: Memcheck
113
+ run: |
114
+ rm -rf build
115
+ cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DMAYO_MARCH="-march=haswell -maes"
116
+ cmake --build build
117
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme MAYO-1
118
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme MAYO-2
119
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme MAYO-3
120
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme MAYO-5
121
+ if: matrix.mayo_build_type == 'ref'
122
+
123
+ - name: Memcheck
124
+ run: |
125
+ rm -rf build
126
+ cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DMAYO_MARCH="-march=haswell -maes"
127
+ cmake --build build
128
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme_MAYO_1
129
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme_MAYO_2
130
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme_MAYO_3
131
+ valgrind --error-exitcode=1 --track-origins=yes build/test/mayo_test_scheme_MAYO_5
132
+ if: matrix.mayo_build_type == 'opt' || matrix.mayo_build_type == 'avx2'
133
+
134
+ - name: Address Sanitizer ASAN
135
+ run: |
136
+ rm -rf build
137
+ cmake -Bbuild -DCMAKE_BUILD_TYPE=ASAN -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=clang
138
+ cmake --build build
139
+ ctest -V --test-dir build
140
+
141
+ - name: Memory Sanitizer MSAN
142
+ run: |
143
+ rm -rf build
144
+ cmake -Bbuild -DCMAKE_BUILD_TYPE=MSAN -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=clang
145
+ cmake --build build
146
+ ctest -V --test-dir build
147
+
148
+ - name: Leak Sanitizer LSAN
149
+ run: |
150
+ rm -rf build
151
+ cmake -Bbuild -DCMAKE_BUILD_TYPE=LSAN -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=clang
152
+ cmake --build build
153
+ ctest -V --test-dir build
154
+
155
+ - name: Undefined Behavior Sanitizer UBSAN
156
+ run: |
157
+ rm -rf build
158
+ cmake -Bbuild -DCMAKE_BUILD_TYPE=UBSAN -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=clang
159
+ cmake --build build
160
+ ctest -V --test-dir build
@@ -0,0 +1,68 @@
1
+ name: CMake (macos-neon)
2
+
3
+ on:
4
+ push:
5
+ branches: [ '*' ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ env:
10
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11
+ BUILD_TYPE: Debug
12
+
13
+ jobs:
14
+ build_test:
15
+ runs-on: macos-latest
16
+ strategy:
17
+ matrix:
18
+ mayo_build_type: [neon]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+ - name: Set up Python 3.10
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.10"
26
+
27
+ # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
28
+ # You can convert this to a matrix build if you need cross-platform coverage.
29
+ # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
30
+
31
+ - name: Configure CMake
32
+ # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
33
+ # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
34
+ run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }}
35
+
36
+ - name: Build
37
+ # Build your program with the given configuration
38
+ run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
39
+
40
+ - name: Test
41
+ working-directory: ${{github.workspace}}/build
42
+ # Execute tests defined by the CMake configuration.
43
+ # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
44
+ run: ctest -C ${{env.BUILD_TYPE}}
45
+
46
+ - name: Examples (neon)
47
+ working-directory: ${{github.workspace}}/build/apps
48
+ run: |
49
+ ./PQCgenKAT_sign_mayo_1
50
+ ./PQCgenKAT_sign_mayo_2
51
+ ./PQCgenKAT_sign_mayo_3
52
+ ./PQCgenKAT_sign_mayo_5
53
+ ./example_mayo_1
54
+ ./example_mayo_2
55
+ ./example_mayo_3
56
+ ./example_mayo_5
57
+ ./example_nistapi_mayo_1
58
+ ./example_nistapi_mayo_2
59
+ ./example_nistapi_mayo_3
60
+ ./example_nistapi_mayo_5
61
+ if: matrix.mayo_build_type == 'neon'
62
+
63
+ - name: Address Sanitizer ASAN
64
+ run: |
65
+ rm -rf build
66
+ cmake -Bbuild -DCMAKE_BUILD_TYPE=ASAN -DMAYO_BUILD_TYPE=${{ matrix.mayo_build_type }} -DCMAKE_C_COMPILER=clang
67
+ cmake --build build
68
+ ctest -V --test-dir build
@@ -0,0 +1,35 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ cmake_minimum_required(VERSION 3.10)
4
+ project(MAYO VERSION 1.0 LANGUAGES C CXX ASM)
5
+
6
+ set(MAYO_SO_VERSION "0")
7
+ set(CMAKE_C_STANDARD 99)
8
+
9
+ set(MEMORYCHECK_COMMAND_OPTIONS "--error-exitcode=1")
10
+ include(CTest)
11
+
12
+ option(ENABLE_STRICT "Build with strict compile options." ON)
13
+
14
+ if(ENABLE_STRICT)
15
+ message("Enable strict flag ON")
16
+ endif()
17
+
18
+ option(ENABLE_TESTS "Enable compilation of tests." ON)
19
+ option(ENABLE_CT_TESTING "Enable compilation for constant time testing." OFF)
20
+ option(SOURCE_PATH "Where the source code is stored, default in the building tree" OFF)
21
+ #option(ENABLE_PARAMS_DYNAMIC "Enable dynamic use of MAYO parameters" OFF)
22
+
23
+ SET(MVARIANT_S "MAYO_1;MAYO_2;MAYO_3;MAYO_5")
24
+
25
+ include(.cmake/flags.cmake)
26
+ include(.cmake/sanitizers.cmake)
27
+ include(.cmake/target.cmake)
28
+
29
+ add_subdirectory(src)
30
+ add_subdirectory(apps)
31
+
32
+ if(ENABLE_TESTS)
33
+ enable_testing()
34
+ add_subdirectory(test)
35
+ endif()