nrf_crypto_ecdh_backend.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. * Copyright (c) 2018 - 2020, 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. #include "optiga_backend_ecdh.h"
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59. #if !NRF_CRYPTO_ECC_SECP160R1_ENABLED
  60. // Dummy typedef for disabled context
  61. typedef uint32_t nrf_crypto_backend_secp160r1_ecdh_context_t;
  62. // Backend implementation is NULL to indicate feature not supported
  63. #define nrf_crypto_backend_secp160r1_ecdh_compute NULL
  64. #endif
  65. #if !NRF_CRYPTO_ECC_SECP160R2_ENABLED
  66. // Dummy typedef for disabled context
  67. typedef uint32_t nrf_crypto_backend_secp160r2_ecdh_context_t;
  68. // Backend implementation is NULL to indicate feature not supported
  69. #define nrf_crypto_backend_secp160r2_ecdh_compute NULL
  70. #endif
  71. #if !NRF_CRYPTO_ECC_SECP192R1_ENABLED
  72. // Dummy typedef for disabled context
  73. typedef uint32_t nrf_crypto_backend_secp192r1_ecdh_context_t;
  74. // Backend implementation is NULL to indicate feature not supported
  75. #define nrf_crypto_backend_secp192r1_ecdh_compute NULL
  76. #endif
  77. #if !NRF_CRYPTO_ECC_SECP224R1_ENABLED
  78. // Dummy typedef for disabled context
  79. typedef uint32_t nrf_crypto_backend_secp224r1_ecdh_context_t;
  80. // Backend implementation is NULL to indicate feature not supported
  81. #define nrf_crypto_backend_secp224r1_ecdh_compute NULL
  82. #endif
  83. #if !NRF_CRYPTO_ECC_SECP256R1_ENABLED
  84. // Dummy typedef for disabled context
  85. typedef uint32_t nrf_crypto_backend_secp256r1_ecdh_context_t;
  86. // Backend implementation is NULL to indicate feature not supported
  87. #define nrf_crypto_backend_secp256r1_ecdh_compute NULL
  88. #endif
  89. #if !NRF_CRYPTO_ECC_SECP384R1_ENABLED
  90. // Dummy typedef for disabled context
  91. typedef uint32_t nrf_crypto_backend_secp384r1_ecdh_context_t;
  92. // Backend implementation is NULL to indicate feature not supported
  93. #define nrf_crypto_backend_secp384r1_ecdh_compute NULL
  94. #endif
  95. #if !NRF_CRYPTO_ECC_SECP521R1_ENABLED
  96. // Dummy typedef for disabled context
  97. typedef uint32_t nrf_crypto_backend_secp521r1_ecdh_context_t;
  98. // Backend implementation is NULL to indicate feature not supported
  99. #define nrf_crypto_backend_secp521r1_ecdh_compute NULL
  100. #endif
  101. #if !NRF_CRYPTO_ECC_SECP160K1_ENABLED
  102. // Dummy typedef for disabled context
  103. typedef uint32_t nrf_crypto_backend_secp160k1_ecdh_context_t;
  104. // Backend implementation is NULL to indicate feature not supported
  105. #define nrf_crypto_backend_secp160k1_ecdh_compute NULL
  106. #endif
  107. #if !NRF_CRYPTO_ECC_SECP192K1_ENABLED
  108. // Dummy typedef for disabled context
  109. typedef uint32_t nrf_crypto_backend_secp192k1_ecdh_context_t;
  110. // Backend implementation is NULL to indicate feature not supported
  111. #define nrf_crypto_backend_secp192k1_ecdh_compute NULL
  112. #endif
  113. #if !NRF_CRYPTO_ECC_SECP224K1_ENABLED
  114. // Dummy typedef for disabled context
  115. typedef uint32_t nrf_crypto_backend_secp224k1_ecdh_context_t;
  116. // Backend implementation is NULL to indicate feature not supported
  117. #define nrf_crypto_backend_secp224k1_ecdh_compute NULL
  118. #endif
  119. #if !NRF_CRYPTO_ECC_SECP256K1_ENABLED
  120. // Dummy typedef for disabled context
  121. typedef uint32_t nrf_crypto_backend_secp256k1_ecdh_context_t;
  122. // Backend implementation is NULL to indicate feature not supported
  123. #define nrf_crypto_backend_secp256k1_ecdh_compute NULL
  124. #endif
  125. #if !NRF_CRYPTO_ECC_BP256R1_ENABLED
  126. // Dummy typedef for disabled context
  127. typedef uint32_t nrf_crypto_backend_bp256r1_ecdh_context_t;
  128. // Backend implementation is NULL to indicate feature not supported
  129. #define nrf_crypto_backend_bp256r1_ecdh_compute NULL
  130. #endif
  131. #if !NRF_CRYPTO_ECC_BP384R1_ENABLED
  132. // Dummy typedef for disabled context
  133. typedef uint32_t nrf_crypto_backend_bp384r1_ecdh_context_t;
  134. // Backend implementation is NULL to indicate feature not supported
  135. #define nrf_crypto_backend_bp384r1_ecdh_compute NULL
  136. #endif
  137. #if !NRF_CRYPTO_ECC_BP512R1_ENABLED
  138. // Dummy typedef for disabled context
  139. typedef uint32_t nrf_crypto_backend_bp512r1_ecdh_context_t;
  140. // Backend implementation is NULL to indicate feature not supported
  141. #define nrf_crypto_backend_bp512r1_ecdh_compute NULL
  142. #endif
  143. #if !NRF_CRYPTO_ECC_CURVE25519_ENABLED
  144. // Dummy typedef for disabled context
  145. typedef uint32_t nrf_crypto_backend_curve25519_ecdh_context_t;
  146. // Backend implementation is NULL to indicate feature not supported
  147. #define nrf_crypto_backend_curve25519_ecdh_compute NULL
  148. #endif
  149. #if !NRF_CRYPTO_ECC_ED25519_ENABLED
  150. // Dummy typedef for disabled context
  151. typedef uint32_t nrf_crypto_backend_ed25519_ecdh_context_t;
  152. // Backend implementation is NULL to indicate feature not supported
  153. #define nrf_crypto_backend_ed25519_ecdh_compute NULL
  154. #endif
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif // !defined(__SDK_DOXYGEN__)
  159. #endif // NRF_CRYPTO_ECDH_BACKEND_H__