nrf_crypto_ecdh_backend.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /**
  2. * Copyright (c) 2018, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef NRF_CRYPTO_ECDH_BACKEND_H__
  41. #define NRF_CRYPTO_ECDH_BACKEND_H__
  42. #if !defined(__SDK_DOXYGEN__)
  43. #include <stdint.h>
  44. #include <stddef.h>
  45. #include "sdk_errors.h"
  46. #include "sdk_config.h"
  47. #include "nrf_crypto_ecc.h"
  48. #include "nrf_crypto_ecdh_shared.h"
  49. // Include all backends
  50. #include "cc310_backend_ecdh.h"
  51. #include "cc310_bl_backend_ecdh.h"
  52. #include "mbedtls_backend_ecdh.h"
  53. #include "oberon_backend_ecdh.h"
  54. #include "micro_ecc_backend_ecdh.h"
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. #if !NRF_CRYPTO_ECC_SECP160R1_ENABLED
  59. // Dummy typedef for disabled context
  60. typedef uint32_t nrf_crypto_backend_secp160r1_ecdh_context_t;
  61. // Backend implementation is NULL to indicate feature not supported
  62. #define nrf_crypto_backend_secp160r1_ecdh_compute NULL
  63. #endif
  64. #if !NRF_CRYPTO_ECC_SECP160R2_ENABLED
  65. // Dummy typedef for disabled context
  66. typedef uint32_t nrf_crypto_backend_secp160r2_ecdh_context_t;
  67. // Backend implementation is NULL to indicate feature not supported
  68. #define nrf_crypto_backend_secp160r2_ecdh_compute NULL
  69. #endif
  70. #if !NRF_CRYPTO_ECC_SECP192R1_ENABLED
  71. // Dummy typedef for disabled context
  72. typedef uint32_t nrf_crypto_backend_secp192r1_ecdh_context_t;
  73. // Backend implementation is NULL to indicate feature not supported
  74. #define nrf_crypto_backend_secp192r1_ecdh_compute NULL
  75. #endif
  76. #if !NRF_CRYPTO_ECC_SECP224R1_ENABLED
  77. // Dummy typedef for disabled context
  78. typedef uint32_t nrf_crypto_backend_secp224r1_ecdh_context_t;
  79. // Backend implementation is NULL to indicate feature not supported
  80. #define nrf_crypto_backend_secp224r1_ecdh_compute NULL
  81. #endif
  82. #if !NRF_CRYPTO_ECC_SECP256R1_ENABLED
  83. // Dummy typedef for disabled context
  84. typedef uint32_t nrf_crypto_backend_secp256r1_ecdh_context_t;
  85. // Backend implementation is NULL to indicate feature not supported
  86. #define nrf_crypto_backend_secp256r1_ecdh_compute NULL
  87. #endif
  88. #if !NRF_CRYPTO_ECC_SECP384R1_ENABLED
  89. // Dummy typedef for disabled context
  90. typedef uint32_t nrf_crypto_backend_secp384r1_ecdh_context_t;
  91. // Backend implementation is NULL to indicate feature not supported
  92. #define nrf_crypto_backend_secp384r1_ecdh_compute NULL
  93. #endif
  94. #if !NRF_CRYPTO_ECC_SECP521R1_ENABLED
  95. // Dummy typedef for disabled context
  96. typedef uint32_t nrf_crypto_backend_secp521r1_ecdh_context_t;
  97. // Backend implementation is NULL to indicate feature not supported
  98. #define nrf_crypto_backend_secp521r1_ecdh_compute NULL
  99. #endif
  100. #if !NRF_CRYPTO_ECC_SECP160K1_ENABLED
  101. // Dummy typedef for disabled context
  102. typedef uint32_t nrf_crypto_backend_secp160k1_ecdh_context_t;
  103. // Backend implementation is NULL to indicate feature not supported
  104. #define nrf_crypto_backend_secp160k1_ecdh_compute NULL
  105. #endif
  106. #if !NRF_CRYPTO_ECC_SECP192K1_ENABLED
  107. // Dummy typedef for disabled context
  108. typedef uint32_t nrf_crypto_backend_secp192k1_ecdh_context_t;
  109. // Backend implementation is NULL to indicate feature not supported
  110. #define nrf_crypto_backend_secp192k1_ecdh_compute NULL
  111. #endif
  112. #if !NRF_CRYPTO_ECC_SECP224K1_ENABLED
  113. // Dummy typedef for disabled context
  114. typedef uint32_t nrf_crypto_backend_secp224k1_ecdh_context_t;
  115. // Backend implementation is NULL to indicate feature not supported
  116. #define nrf_crypto_backend_secp224k1_ecdh_compute NULL
  117. #endif
  118. #if !NRF_CRYPTO_ECC_SECP256K1_ENABLED
  119. // Dummy typedef for disabled context
  120. typedef uint32_t nrf_crypto_backend_secp256k1_ecdh_context_t;
  121. // Backend implementation is NULL to indicate feature not supported
  122. #define nrf_crypto_backend_secp256k1_ecdh_compute NULL
  123. #endif
  124. #if !NRF_CRYPTO_ECC_BP256R1_ENABLED
  125. // Dummy typedef for disabled context
  126. typedef uint32_t nrf_crypto_backend_bp256r1_ecdh_context_t;
  127. // Backend implementation is NULL to indicate feature not supported
  128. #define nrf_crypto_backend_bp256r1_ecdh_compute NULL
  129. #endif
  130. #if !NRF_CRYPTO_ECC_BP384R1_ENABLED
  131. // Dummy typedef for disabled context
  132. typedef uint32_t nrf_crypto_backend_bp384r1_ecdh_context_t;
  133. // Backend implementation is NULL to indicate feature not supported
  134. #define nrf_crypto_backend_bp384r1_ecdh_compute NULL
  135. #endif
  136. #if !NRF_CRYPTO_ECC_BP512R1_ENABLED
  137. // Dummy typedef for disabled context
  138. typedef uint32_t nrf_crypto_backend_bp512r1_ecdh_context_t;
  139. // Backend implementation is NULL to indicate feature not supported
  140. #define nrf_crypto_backend_bp512r1_ecdh_compute NULL
  141. #endif
  142. #if !NRF_CRYPTO_ECC_CURVE25519_ENABLED
  143. // Dummy typedef for disabled context
  144. typedef uint32_t nrf_crypto_backend_curve25519_ecdh_context_t;
  145. // Backend implementation is NULL to indicate feature not supported
  146. #define nrf_crypto_backend_curve25519_ecdh_compute NULL
  147. #endif
  148. #if !NRF_CRYPTO_ECC_ED25519_ENABLED
  149. // Dummy typedef for disabled context
  150. typedef uint32_t nrf_crypto_backend_ed25519_ecdh_context_t;
  151. // Backend implementation is NULL to indicate feature not supported
  152. #define nrf_crypto_backend_ed25519_ecdh_compute NULL
  153. #endif
  154. #ifdef __cplusplus
  155. }
  156. #endif
  157. #endif // !defined(__SDK_DOXYGEN__)
  158. #endif // NRF_CRYPTO_ECDH_BACKEND_H__