Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

184 lines
5.2 KiB

  1. /**
  2. * @file strobe_config.h
  3. * @copyright
  4. * Copyright (c) 2016 Cryptography Research, Inc. \n
  5. * Released under the MIT License. See LICENSE.txt for license information.
  6. * @author Mike Hamburg
  7. * @brief Configuration for STROBE code.
  8. */
  9. #ifndef __STROBE_CONFIG_H__
  10. #define __STROBE_CONFIG_H__
  11. /****************************************************************/
  12. /* STROBE */
  13. /****************************************************************/
  14. #ifndef STROBE_INTEROP_F_BITS
  15. /** INTEROP: STROBE bit size. Default is Keccak-F800. */
  16. #define STROBE_INTEROP_F_BITS 800
  17. #endif
  18. #ifndef STROBE_INTEROP_V_MAJOR
  19. /** INTEROP: STROBE major version number. */
  20. #define STROBE_INTEROP_V_MAJOR 1
  21. #endif
  22. #ifndef STROBE_INTEROP_V_MINOR
  23. /** INTEROP: STROBE minor version number. */
  24. #define STROBE_INTEROP_V_MINOR 0
  25. #endif
  26. #ifndef STROBE_INTEROP_V_PATCH
  27. /** INTEROP: STROBE patch version number. */
  28. #define STROBE_INTEROP_V_PATCH 2
  29. #endif
  30. #ifndef STROBE_INTEROP_SECURITY_BITS
  31. /**
  32. * INTEROP: STROBE nominal security strength, in bits.
  33. *
  34. * The capacity of the sponge will be 2*STROBE_INTEROP_SECURITY_BITS
  35. * long. Therefore certain security properties will scale better
  36. * than the 128-bit security level implies. In particular, if you
  37. * use 256-bit keys at a 128-bit security level, the 128-bit security
  38. * holds even if the attacker acquires enormous amounts of data.
  39. */
  40. #define STROBE_INTEROP_SECURITY_BITS 128
  41. #endif
  42. #ifndef STROBE_INTEROP_RATCHET_BYTES
  43. /** INTEROP: number of bytes used by default ratchet operations */
  44. #define STROBE_INTEROP_RATCHET_BYTES (STROBE_INTEROP_SECURITY_BITS/8)
  45. #endif
  46. #ifndef STROBE_SINGLE_THREAD
  47. /**
  48. * If set, assert that STROBE functions (in particular, strobe_randomize)
  49. * will only ever be called by a single thread, so that thread-safety is not
  50. * required.
  51. */
  52. #define STROBE_SINGLE_THREAD 0
  53. #endif
  54. #ifndef STROBE_IO_CTX_HAS_FD
  55. /** IO contexts has a "file descriptor" pointer (for sockets on a non-embedded system) */
  56. #define STROBE_IO_CTX_HAS_FD 1
  57. #endif
  58. #ifndef STROBE_OPT_FOR_SIZE
  59. /** Global: optimize STROBE code for size at the expense of speed. */
  60. #define STROBE_OPT_FOR_SIZE 0
  61. #endif
  62. #ifndef STROBE_OPT_FOR_SPEED
  63. /** Global: optimize STROBE code for speed at the expense of size. */
  64. #define STROBE_OPT_FOR_SPEED 0
  65. #endif
  66. #ifndef STROBE_SANITY_CHECK_FLAGS
  67. /** On each operation, sanity-check that the flags requested are actually
  68. * implemented, eg that the caller isn't using the MORE flag when the callee
  69. * ifdef'd it out.
  70. */
  71. #define STROBE_SANITY_CHECK_FLAGS 1
  72. #endif
  73. #ifndef STROBE_SUPPORT_PRNG
  74. /** Support pseudorandom generator.
  75. * Required by A New Hope, convenience ECDH, nondeterministic signing.
  76. */
  77. #define STROBE_SUPPORT_PRNG 1
  78. #endif
  79. #ifndef STROBE_SUPPORT_FLAG_POST
  80. /** Support experimental post-op flags FLAG_POST_RATCHET, FLAG_POST_MAC */
  81. #define STROBE_SUPPORT_FLAG_POST 1
  82. #endif
  83. #ifndef STROBE_INTEROP_MAC_BYTES
  84. /** The MAC length, used by MAC convenience functions */
  85. #define STROBE_INTEROP_MAC_BYTES 16
  86. #endif
  87. #ifndef STROBE_CW_MAX_LENGTH_BYTES
  88. /** Maximum number of bytes in a length field */
  89. #define STROBE_CW_MAX_LENGTH_BYTES 4
  90. #endif
  91. #ifndef STROBE_CONVENIENCE_ECDH
  92. /** Support convenient strobe_eph_ecdh function.
  93. *
  94. * You might not want this even if you're using ECDH, because
  95. * it implies a particular message flow.
  96. */
  97. #define STROBE_CONVENIENCE_ECDH 1
  98. #endif
  99. /****************************************************************/
  100. /* X25519 */
  101. /****************************************************************/
  102. #ifndef X25519_SUPPORT_SIGN
  103. /** Support creation of X25519 signatures. NB: these are different from Ed25519 signatures! */
  104. #define X25519_SUPPORT_SIGN 1
  105. #endif
  106. #ifndef X25519_DETERMINISTIC_SIGS
  107. /** Make X25519 signatures deterministic */
  108. #define X25519_DETERMINISTIC_SIGS 1
  109. #endif
  110. #ifndef X25519_SUPPORT_VERIFY
  111. /** Support verification of X25519 signatures. */
  112. #define X25519_SUPPORT_VERIFY X25519_SUPPORT_SIGN
  113. #endif
  114. #ifndef STROBE_EC_SIGN_P1
  115. /** Default sign and verify algorithms. */
  116. #if X25519_SUPPORT_SIGN
  117. #define STROBE_EC_SIGN_P1 x25519_base_uniform
  118. #define STROBE_EC_SIGN_P2 x25519_sign_p2
  119. #endif
  120. #if X25519_SUPPORT_VERIFY
  121. #define STROBE_EC_VERIFY x25519_verify_p2
  122. #endif
  123. #endif
  124. #ifndef STROBE_SUPPORT_CERT_VERIFY
  125. /** Support certificate verify */
  126. #define STROBE_SUPPORT_CERT_VERIFY X25519_SUPPORT_VERIFY
  127. #endif
  128. #ifndef X25519_USE_POWER_CHAIN
  129. /** Use less time and more code for inversion in X25519 */
  130. #define X25519_USE_POWER_CHAIN (!STROBE_OPT_FOR_SIZE)
  131. #endif
  132. #ifndef X25519_WBITS
  133. /** Curve25519: Internal word width for implementation. Should be
  134. * set to the target machine's word size. Supported 16, 32, 64.
  135. */
  136. #ifdef __SIZEOF_INT128__
  137. #define X25519_WBITS 64
  138. #else
  139. #define X25519_WBITS 32
  140. #endif
  141. #endif
  142. #ifndef X25519_MEMCPY_PARAMS
  143. /** Copy parameters in and out instead of referencing them.
  144. * Required on big-endian systems and those with strong alignment constraints.
  145. */
  146. #if __ARMEL__ && defined(__ARM_FEATURE_UNALIGNED) && __ARM_FEATURE_UNALIGNED == 0
  147. #define X25519_MEMCPY_PARAMS 1
  148. #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  149. #define X25519_MEMCPY_PARAMS 0
  150. #else
  151. #define X25519_MEMCPY_PARAMS 1
  152. #endif
  153. #endif
  154. #endif // __STROBE_CONFIG_H__