CMakeLists.txt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. set(SRC libsodium/src/libsodium)
  2. # Derived from libsodium/src/libsodium/Makefile.am
  3. # (ignoring the !MINIMAL set)
  4. set(srcs
  5. "${SRC}/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c"
  6. "${SRC}/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c"
  7. "${SRC}/crypto_auth/crypto_auth.c"
  8. "${SRC}/crypto_auth/hmacsha256/auth_hmacsha256.c"
  9. "${SRC}/crypto_auth/hmacsha512/auth_hmacsha512.c"
  10. "${SRC}/crypto_auth/hmacsha512256/auth_hmacsha512256.c"
  11. "${SRC}/crypto_box/crypto_box.c"
  12. "${SRC}/crypto_box/crypto_box_easy.c"
  13. "${SRC}/crypto_box/crypto_box_seal.c"
  14. "${SRC}/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c"
  15. "${SRC}/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c"
  16. "${SRC}/crypto_core/curve25519/ref10/curve25519_ref10.c"
  17. "${SRC}/crypto_core/hchacha20/core_hchacha20.c"
  18. "${SRC}/crypto_core/hsalsa20/core_hsalsa20.c"
  19. "${SRC}/crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c"
  20. "${SRC}/crypto_core/salsa/ref/core_salsa_ref.c"
  21. "${SRC}/crypto_generichash/crypto_generichash.c"
  22. "${SRC}/crypto_generichash/blake2b/generichash_blake2.c"
  23. "${SRC}/crypto_generichash/blake2b/ref/blake2b-compress-avx2.c"
  24. "${SRC}/crypto_generichash/blake2b/ref/blake2b-compress-ref.c"
  25. "${SRC}/crypto_generichash/blake2b/ref/blake2b-compress-sse41.c"
  26. "${SRC}/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.c"
  27. "${SRC}/crypto_generichash/blake2b/ref/blake2b-ref.c"
  28. "${SRC}/crypto_generichash/blake2b/ref/generichash_blake2b.c"
  29. "${SRC}/crypto_hash/crypto_hash.c"
  30. "${SRC}/crypto_hash/sha256/hash_sha256.c"
  31. "${SRC}/crypto_hash/sha256/cp/hash_sha256_cp.c"
  32. "${SRC}/crypto_hash/sha512/hash_sha512.c"
  33. "${SRC}/crypto_hash/sha512/cp/hash_sha512_cp.c"
  34. "${SRC}/crypto_kdf/crypto_kdf.c"
  35. "${SRC}/crypto_kdf/blake2b/kdf_blake2b.c"
  36. "${SRC}/crypto_kx/crypto_kx.c"
  37. "${SRC}/crypto_onetimeauth/crypto_onetimeauth.c"
  38. "${SRC}/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c"
  39. "${SRC}/crypto_onetimeauth/poly1305/donna/poly1305_donna.c"
  40. "${SRC}/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c"
  41. "${SRC}/crypto_pwhash/crypto_pwhash.c"
  42. "${SRC}/crypto_pwhash/argon2/argon2-core.c"
  43. "${SRC}/crypto_pwhash/argon2/argon2-encoding.c"
  44. "${SRC}/crypto_pwhash/argon2/argon2-fill-block-ref.c"
  45. "${SRC}/crypto_pwhash/argon2/argon2-fill-block-ssse3.c"
  46. "${SRC}/crypto_pwhash/argon2/argon2.c"
  47. "${SRC}/crypto_pwhash/argon2/blake2b-long.c"
  48. "${SRC}/crypto_pwhash/argon2/pwhash_argon2i.c"
  49. "${SRC}/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c"
  50. "${SRC}/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c"
  51. "${SRC}/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c"
  52. "${SRC}/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c"
  53. "${SRC}/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c"
  54. "${SRC}/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c"
  55. "${SRC}/crypto_scalarmult/crypto_scalarmult.c"
  56. "${SRC}/crypto_scalarmult/curve25519/scalarmult_curve25519.c"
  57. "${SRC}/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c"
  58. "${SRC}/crypto_scalarmult/curve25519/ref10/x25519_ref10.c"
  59. "${SRC}/crypto_scalarmult/curve25519/sandy2x/consts.S"
  60. "${SRC}/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.c"
  61. "${SRC}/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c"
  62. "${SRC}/crypto_scalarmult/curve25519/sandy2x/fe51_mul.S"
  63. "${SRC}/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S"
  64. "${SRC}/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S"
  65. "${SRC}/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c"
  66. "${SRC}/crypto_scalarmult/curve25519/sandy2x/ladder.S"
  67. "${SRC}/crypto_scalarmult/curve25519/sandy2x/ladder_base.S"
  68. "${SRC}/crypto_scalarmult/curve25519/sandy2x/sandy2x.S"
  69. "${SRC}/crypto_secretbox/crypto_secretbox.c"
  70. "${SRC}/crypto_secretbox/crypto_secretbox_easy.c"
  71. "${SRC}/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c"
  72. "${SRC}/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c"
  73. "${SRC}/crypto_shorthash/crypto_shorthash.c"
  74. "${SRC}/crypto_shorthash/siphash24/shorthash_siphash24.c"
  75. "${SRC}/crypto_shorthash/siphash24/shorthash_siphashx24.c"
  76. "${SRC}/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c"
  77. "${SRC}/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c"
  78. "${SRC}/crypto_sign/crypto_sign.c"
  79. "${SRC}/crypto_sign/ed25519/sign_ed25519.c"
  80. "${SRC}/crypto_sign/ed25519/ref10/keypair.c"
  81. "${SRC}/crypto_sign/ed25519/ref10/obsolete.c"
  82. "${SRC}/crypto_sign/ed25519/ref10/open.c"
  83. "${SRC}/crypto_sign/ed25519/ref10/sign.c"
  84. "${SRC}/crypto_stream/crypto_stream.c"
  85. "${SRC}/crypto_stream/aes128ctr/stream_aes128ctr.c"
  86. "${SRC}/crypto_stream/aes128ctr/nacl/afternm_aes128ctr.c"
  87. "${SRC}/crypto_stream/aes128ctr/nacl/beforenm_aes128ctr.c"
  88. "${SRC}/crypto_stream/aes128ctr/nacl/consts_aes128ctr.c"
  89. "${SRC}/crypto_stream/aes128ctr/nacl/int128_aes128ctr.c"
  90. "${SRC}/crypto_stream/aes128ctr/nacl/stream_aes128ctr_nacl.c"
  91. "${SRC}/crypto_stream/aes128ctr/nacl/xor_afternm_aes128ctr.c"
  92. "${SRC}/crypto_stream/chacha20/stream_chacha20.c"
  93. "${SRC}/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-avx2.c"
  94. "${SRC}/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-ssse3.c"
  95. "${SRC}/crypto_stream/chacha20/ref/chacha20_ref.c"
  96. "${SRC}/crypto_stream/salsa20/stream_salsa20.c"
  97. "${SRC}/crypto_stream/salsa20/ref/salsa20_ref.c"
  98. "${SRC}/crypto_stream/salsa20/xmm6/salsa20_xmm6-asm.S"
  99. "${SRC}/crypto_stream/salsa20/xmm6/salsa20_xmm6.c"
  100. "${SRC}/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-avx2.c"
  101. "${SRC}/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-sse2.c"
  102. "${SRC}/crypto_stream/salsa2012/stream_salsa2012.c"
  103. "${SRC}/crypto_stream/salsa2012/ref/stream_salsa2012_ref.c"
  104. "${SRC}/crypto_stream/salsa208/stream_salsa208.c"
  105. "${SRC}/crypto_stream/salsa208/ref/stream_salsa208_ref.c"
  106. "${SRC}/crypto_stream/xchacha20/stream_xchacha20.c"
  107. "${SRC}/crypto_stream/xsalsa20/stream_xsalsa20.c"
  108. "${SRC}/crypto_verify/sodium/verify.c"
  109. "${SRC}/randombytes/randombytes.c"
  110. "${SRC}/randombytes/nativeclient/randombytes_nativeclient.c"
  111. "${SRC}/randombytes/salsa20/randombytes_salsa20_random.c"
  112. "${SRC}/randombytes/sysrandom/randombytes_sysrandom.c"
  113. "${SRC}/sodium/core.c"
  114. "${SRC}/sodium/runtime.c"
  115. "${SRC}/sodium/utils.c"
  116. "${SRC}/sodium/version.c"
  117. "port/randombytes_esp32.c")
  118. if(CONFIG_LIBSODIUM_USE_MBEDTLS_SHA)
  119. list(APPEND srcs
  120. "port/crypto_hash_mbedtls/crypto_hash_sha256_mbedtls.c"
  121. "port/crypto_hash_mbedtls/crypto_hash_sha512_mbedtls.c")
  122. else()
  123. list(APPEND srcs
  124. "${SRC}/crypto_hash/sha256/cp/hash_sha256_cp.c"
  125. "${SRC}/crypto_hash/sha512/cp/hash_sha512_cp.c")
  126. endif()
  127. set(include_dirs ${SRC}/include port_include)
  128. set(priv_include_dirs ${SRC}/include/sodium port_include/sodium port)
  129. idf_component_register(SRCS "${srcs}"
  130. INCLUDE_DIRS "${include_dirs}"
  131. PRIV_INCLUDE_DIRS "${priv_include_dirs}"
  132. REQUIRES mbedtls)
  133. target_compile_definitions(${COMPONENT_LIB} PRIVATE
  134. CONFIGURED
  135. NATIVE_LITTLE_ENDIAN
  136. HAVE_WEAK_SYMBOLS
  137. __STDC_LIMIT_MACROS
  138. __STDC_CONSTANT_MACROS
  139. )
  140. # patch around warnings in third-party files
  141. set_source_files_properties(
  142. ${SRC}/crypto_pwhash/argon2/pwhash_argon2i.c
  143. ${SRC}/crypto_pwhash/argon2/argon2-core.c
  144. ${SRC}/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
  145. PROPERTIES COMPILE_FLAGS
  146. -Wno-type-limits
  147. )
  148. set_source_files_properties(
  149. ${SRC}/sodium/utils.c
  150. PROPERTIES COMPILE_FLAGS
  151. -Wno-unused-variable
  152. )
  153. set_source_files_properties(
  154. ${SRC}/crypto_pwhash/argon2/argon2-fill-block-ref.c
  155. PROPERTIES COMPILE_FLAGS
  156. -Wno-unknown-pragmas
  157. )
  158. # Temporary suppress "fallthrough" warnings until they are fixed in libsodium repo
  159. set_source_files_properties(
  160. ${SRC}/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c
  161. ${SRC}/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c
  162. PROPERTIES COMPILE_FLAGS
  163. -Wno-implicit-fallthrough
  164. )
  165. set_source_files_properties(
  166. ${SRC}/randombytes/randombytes.c
  167. PROPERTIES COMPILE_FLAGS
  168. -DRANDOMBYTES_DEFAULT_IMPLEMENTATION
  169. )