Reference implementations of PQC
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

CMakeLists.txt 9.0 KiB

há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. cmake_minimum_required(VERSION 3.13)
  2. project(cryptocore NONE)
  3. enable_language(C)
  4. enable_language(CXX)
  5. enable_language(ASM)
  6. set(CMAKE_VERBOSE_MAKEFILE ON)
  7. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "~/.cmake/Modules")
  8. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "3rd/cmake-modules")
  9. set(CMAKE_CXX_STANDARD 11)
  10. set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  11. string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
  12. if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
  13. set(ARCH "ARCH_x86_64")
  14. elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
  15. set(ARCH "ARCH_x86_64")
  16. elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
  17. set(ARCH "ARCH_x86_64")
  18. elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
  19. set(ARCH "ARCH_x86")
  20. elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
  21. set(ARCH "ARCH_x86")
  22. elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
  23. set(ARCH "ARCH_x86")
  24. elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
  25. set(ARCH "ARCH_aarch64")
  26. elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
  27. set(ARCH "ARCH_aarch64")
  28. else()
  29. message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
  30. endif()
  31. add_subdirectory(3rd/gtest)
  32. # Arch settings
  33. if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  34. set(MACOSX TRUE)
  35. endif()
  36. if(CMAKE_C_COMPILER_ID MATCHES "Clang")
  37. set(CLANG 1)
  38. endif()
  39. if (MACOSX)
  40. set(CMAKE_C_COMPILER /usr/bin/cc CACHE PATH "" FORCE)
  41. set(CMAKE_CXX_COMPILER /usr/bin/c++ CACHE PATH "" FORCE)
  42. endif()
  43. # Global configuration
  44. set(C_CXX_FLAGS
  45. "-Wno-ignored-qualifiers \
  46. -Wall \
  47. -Werror \
  48. -Wextra \
  49. -Wpedantic \
  50. -Wshadow \
  51. -Wno-variadic-macros \
  52. -Wundef \
  53. -Wunused-result")
  54. if(CLANG)
  55. set(C_CXX_FLAGS
  56. "-Wconditional-uninitialized \
  57. -Wmissing-variable-declarations")
  58. endif()
  59. include(.cmake/common.mk)
  60. # Control Debug/Release mode
  61. if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
  62. set(C_CXX_FLAGS "${C_CXX_FLAGS} -g3 -O0 -Wno-unused")
  63. else()
  64. set(C_CXX_FLAGS "${C_CXX_FLAGS} -O3")
  65. endif()
  66. include_directories(
  67. public
  68. src/common/
  69. src
  70. )
  71. set_property(GLOBAL PROPERTY obj_libs "")
  72. # Set CPU architecture
  73. set(CMAKE_C_FLAGS "${C_CXX_FLAGS} -D${ARCH}")
  74. set(CMAKE_CXX_FLAGS "${C_CXX_FLAGS} -D${ARCH}")
  75. if(PQC_WEAK_RANDOMBYTES)
  76. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPQC_WEAK_RANDOMBYTES")
  77. endif()
  78. # Define sources of the components
  79. add_subdirectory(src/sign/dilithium/dilithium2/clean)
  80. add_subdirectory(src/sign/dilithium/dilithium3/clean)
  81. add_subdirectory(src/sign/dilithium/dilithium5/clean)
  82. add_subdirectory(src/sign/falcon/falcon-1024/clean)
  83. add_subdirectory(src/sign/falcon/falcon-512/clean)
  84. add_subdirectory(src/sign/rainbow/rainbowV-classic/clean)
  85. add_subdirectory(src/sign/rainbow/rainbowI-classic/clean)
  86. add_subdirectory(src/sign/rainbow/rainbowIII-classic/clean)
  87. add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-simple/clean)
  88. add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-simple/clean)
  89. add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-robust/clean)
  90. add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-simple/clean)
  91. add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-simple/clean)
  92. add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-simple/clean)
  93. add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-robust/clean)
  94. add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-robust/clean)
  95. add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-robust/clean)
  96. add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-robust/clean)
  97. add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-robust/clean)
  98. add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-simple/clean)
  99. add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-simple/clean)
  100. add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-robust/clean)
  101. add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-simple/clean)
  102. add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-simple/clean)
  103. add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-simple/clean)
  104. add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-robust/clean)
  105. add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-robust/clean)
  106. add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-simple/clean)
  107. add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-robust/clean)
  108. add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-robust/clean)
  109. add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-simple/clean)
  110. add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-robust/clean)
  111. add_subdirectory(src/kem/kyber/kyber512/clean)
  112. add_subdirectory(src/kem/kyber/kyber768/clean)
  113. add_subdirectory(src/kem/kyber/kyber1024/clean)
  114. add_subdirectory(src/kem/saber/lightsaber/clean)
  115. add_subdirectory(src/kem/saber/firesaber/clean)
  116. add_subdirectory(src/kem/saber/saber/clean)
  117. add_subdirectory(src/kem/frodo/frodokem640shake/clean)
  118. add_subdirectory(src/kem/frodo/frodokem976shake/clean)
  119. add_subdirectory(src/kem/frodo/frodokem1344shake/clean)
  120. add_subdirectory(src/kem/ntru/ntruhps4096821/clean)
  121. add_subdirectory(src/kem/ntru/ntruhps2048509/clean)
  122. add_subdirectory(src/kem/ntru/ntruhrss701/clean)
  123. add_subdirectory(src/kem/ntru/ntruhps2048677/clean)
  124. add_subdirectory(src/kem/ntru_prime/ntrulpr761/clean)
  125. add_subdirectory(src/kem/ntru_prime/ntrulpr653/clean)
  126. add_subdirectory(src/kem/ntru_prime/ntrulpr857/clean)
  127. add_subdirectory(src/kem/hqc/hqc-rmrs-128/clean)
  128. add_subdirectory(src/kem/hqc/hqc-rmrs-192/clean)
  129. add_subdirectory(src/kem/hqc/hqc-rmrs-256/clean)
  130. add_subdirectory(src/kem/sike)
  131. # Hardware optimized targets
  132. if(${ARCH} STREQUAL "ARCH_x86_64")
  133. set(CMAKE_C_FLAGS
  134. "${CMAKE_C_FLAGS} -march=native -mtune=native")
  135. set(SRC_COMMON_AVX2
  136. src/common/keccak4x/KeccakP-1600-times4-SIMD256.c
  137. )
  138. # Sign
  139. add_subdirectory(src/sign/falcon/falcon-512/avx2)
  140. add_subdirectory(src/sign/falcon/falcon-1024/avx2)
  141. add_subdirectory(src/sign/dilithium/dilithium2/avx2)
  142. add_subdirectory(src/sign/dilithium/dilithium3/avx2)
  143. add_subdirectory(src/sign/dilithium/dilithium5/avx2)
  144. add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-simple/avx2)
  145. add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-robust/avx2)
  146. add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-robust/avx2)
  147. add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-simple/avx2)
  148. add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-simple/avx2)
  149. add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-robust/avx2)
  150. add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-robust/avx2)
  151. add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-simple/avx2)
  152. add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-robust/avx2)
  153. add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-simple/avx2)
  154. add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-simple/avx2)
  155. add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-robust/avx2)
  156. add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-robust/avx2)
  157. add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-simple/avx2)
  158. add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-robust/avx2)
  159. add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-simple/avx2)
  160. add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-simple/avx2)
  161. add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-simple/avx2)
  162. add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-robust/avx2)
  163. add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-robust/avx2)
  164. add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-simple/avx2)
  165. add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-robust/avx2)
  166. add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-simple/avx2)
  167. add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-robust/avx2)
  168. # KEMs
  169. add_subdirectory(src/kem/kyber/kyber512/avx2)
  170. add_subdirectory(src/kem/kyber/kyber768/avx2)
  171. add_subdirectory(src/kem/kyber/kyber1024/avx2)
  172. add_subdirectory(src/kem/saber/lightsaber/avx2)
  173. add_subdirectory(src/kem/saber/firesaber/avx2)
  174. add_subdirectory(src/kem/saber/saber/avx2)
  175. add_subdirectory(src/kem/ntru/ntruhps4096821/avx2)
  176. add_subdirectory(src/kem/ntru/ntruhps2048509/avx2)
  177. add_subdirectory(src/kem/ntru/ntruhrss701/avx2)
  178. add_subdirectory(src/kem/ntru/ntruhps2048677/avx2)
  179. add_subdirectory(src/kem/ntru_prime/ntrulpr761/avx2)
  180. add_subdirectory(src/kem/ntru_prime/ntrulpr653/avx2)
  181. add_subdirectory(src/kem/ntru_prime/ntrulpr857/avx2)
  182. add_subdirectory(src/kem/hqc/hqc-rmrs-128/avx2)
  183. add_subdirectory(src/kem/hqc/hqc-rmrs-192/avx2)
  184. add_subdirectory(src/kem/hqc/hqc-rmrs-256/avx2)
  185. endif()
  186. # The rest of the library
  187. set(SRC_COMMON_GENERIC
  188. src/common/aes.c
  189. src/common/fips202.c
  190. src/common/sp800-185.c
  191. src/common/randombytes.c
  192. src/common/sha2.c
  193. src/common/nistseedexpander.c
  194. src/capi/pqapi.c
  195. )
  196. add_library(
  197. common
  198. OBJECT
  199. ${SRC_COMMON_GENERIC}
  200. ${SRC_COMMON_AVX2}
  201. )
  202. add_library(
  203. pqc
  204. SHARED
  205. )
  206. add_library(
  207. pqc_s
  208. STATIC
  209. )
  210. get_property(OBJ_LIBS GLOBAL PROPERTY obj_libs)
  211. target_link_libraries(
  212. pqc
  213. common
  214. ${OBJ_LIBS}
  215. )
  216. target_link_libraries(
  217. pqc_s
  218. common
  219. ${OBJ_LIBS}
  220. )
  221. add_executable(
  222. ut
  223. test/ut.cpp
  224. )
  225. target_link_libraries(
  226. ut
  227. gtest
  228. gtest_main
  229. pqc_s)
  230. target_include_directories(
  231. ut PRIVATE
  232. ${CMAKE_SOURCE_DIR})
  233. install(TARGETS pqc pqc_s
  234. PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE
  235. LIBRARY DESTINATION lib
  236. ARCHIVE DESTINATION lib)
  237. install(FILES
  238. ${QRS_PUBLIC_INC}
  239. DESTINATION include/pqc)