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.
 
 
 
 

183 regels
6.9 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief WINC Application Interface Internal Types.
  6. *
  7. * Copyright (c) 2017-2018 Atmel Corporation. All rights reserved.
  8. *
  9. * \asf_license_start
  10. *
  11. * \page License
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. *
  23. * 3. The name of Atmel may not be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  27. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  28. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  29. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  30. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  34. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  35. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * \asf_license_stop
  39. *
  40. */
  41. /**@defgroup SSLAPI SSL
  42. */
  43. #ifndef __M2M_SSL_H__
  44. #define __M2M_SSL_H__
  45. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  46. INCLUDES
  47. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  48. #include "common/include/nm_common.h"
  49. #include "driver/include/m2m_types.h"
  50. #include "driver/source/nmdrv.h"
  51. #include "ecc_types.h"
  52. #include "socket/include/socket.h"
  53. /**@defgroup SSLEnums Enumeration/Typedefs
  54. * @ingroup SSLAPI
  55. * @{*/
  56. /*!
  57. @typedef \
  58. void (*tpfAppSslCb) (uint8 u8MsgType, void * pvMsg);
  59. @brief A callback to get SSL notifications.
  60. @param[in] u8MsgType
  61. @param[in] pvMsg A structure to provide notification payload.
  62. */
  63. typedef void (*tpfAppSSLCb)(uint8 u8MsgType, void *pvMsg);
  64. /**@}
  65. */
  66. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  67. FUNCTION PROTOTYPES
  68. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  69. /** \defgroup SSLFUNCTIONS Functions
  70. * @ingroup SSLAPI
  71. */
  72. /**@{*/
  73. /*!
  74. @fn \ m2m_ssl_init(tpfAppSslCb pfAppSslCb);
  75. @brief Initializes the SSL layer.
  76. @param [in] pfAppSslCb
  77. Application SSL callback function.
  78. @return The function SHALL return 0 for success and a negative value otherwise.
  79. */
  80. NMI_API sint8 m2m_ssl_init(tpfAppSSLCb pfAppSSLCb);
  81. /*!
  82. @fn \ NMI_API sint8 m2m_ssl_handshake_rsp(tstrEccReqInfo* strECCResp, uint8* pu8RspDataBuff, uint16 u16RspDataSz)
  83. @brief Sends ECC responses to the WINC
  84. @param [in] strECCResp
  85. ECC Response struct.
  86. @param [in] pu8RspDataBuffe
  87. Pointer of the response data to be sent.
  88. @param [in] u16RspDataSz
  89. Response data size.
  90. @return The function SHALL return 0 for success and a negative value otherwise.
  91. */
  92. NMI_API sint8 m2m_ssl_handshake_rsp(tstrEccReqInfo *strECCResp, uint8 *pu8RspDataBuff, uint16 u16RspDataSz);
  93. /*!
  94. @fn \ NMI_API sint8 m2m_ssl_send_certs_to_winc(uint8* pu8Buffer, uint32 u32BufferSz)
  95. @brief Sends certificates to the WINC
  96. @param [in] pu8Buffer
  97. Pointer to the certificates.
  98. @param [in] u32BufferSz
  99. Size of the certificates.
  100. @return The function SHALL return 0 for success and a negative value otherwise.
  101. */
  102. NMI_API sint8 m2m_ssl_send_certs_to_winc(uint8 *pu8Buffer, uint32 u32BufferSz);
  103. /*!
  104. @fn \ NMI_API sint8 m2m_ssl_retrieve_cert(uint16* pu16CurveType, uint8* pu8Hash, uint8* pu8Sig, tstrECPoint*
  105. pu8Key)
  106. @brief Retrieve the certificate to be verified from the WINC
  107. @param [in] pu16CurveType
  108. Pointer to the certificate curve type.
  109. @param [in] pu8Hash
  110. Pointer to the certificate hash.
  111. @param [in] pu8Sig
  112. Pointer to the certificate signature.
  113. @param [in] pu8Key
  114. Pointer to the certificate Key.
  115. @return The function SHALL return 0 for success and a negative value otherwise.
  116. */
  117. NMI_API sint8 m2m_ssl_retrieve_cert(uint16 *pu16CurveType, uint8 *pu8Hash, uint8 *pu8Sig, tstrECPoint *pu8Key);
  118. /*!
  119. @fn \ NMI_API sint8 m2m_ssl_retrieve_hash(uint8* pu8Hash, uint16 u16HashSz)
  120. @brief Retrieve the certificate hash
  121. @param [in] pu8Hash
  122. Pointer to the certificate hash.
  123. @param [in] u16HashSz
  124. Hash size.
  125. @return The function SHALL return 0 for success and a negative value otherwise.
  126. */
  127. NMI_API sint8 m2m_ssl_retrieve_hash(uint8 *pu8Hash, uint16 u16HashSz);
  128. /*!
  129. @fn \ NMI_API void m2m_ssl_stop_processing_certs(void)
  130. @brief Allow ssl driver to tidy up in case application does not read all available certificates.
  131. @warning This API must only be called if some certificates are left unread.
  132. @return None.
  133. */
  134. NMI_API void m2m_ssl_stop_processing_certs(void);
  135. /*!
  136. @fn \ NMI_API void m2m_ssl_ecc_process_done(void)
  137. @brief Allow ssl driver to tidy up after application has finished processing ecc message.
  138. @warning This API must be called after receiving a SSL callback with type @ref M2M_SSL_REQ_ECC
  139. @return None.
  140. */
  141. NMI_API void m2m_ssl_ecc_process_done(void);
  142. /*!
  143. @fn \
  144. NMI_API sint8 m2m_ssl_set_active_ciphersuites(uint32 u32SslCsBMP);
  145. Override the default Active SSL ciphers in the SSL module with a certain combination selected by the caller in the
  146. form of a bitmap containing the required ciphers to be on. There is no need to call this function if the application
  147. will not change the default ciphersuites.
  148. @param [in] u32SslCsBMP
  149. Bitmap containing the desired ciphers to be enabled for the SSL module. The ciphersuites are defined in
  150. @ref SSLCipherSuiteID.
  151. The default ciphersuites are all ciphersuites supported by the firmware with the exception of ECC
  152. ciphersuites. The caller can override the default with any desired combination, except for combinations involving both
  153. RSA and ECC; if any RSA ciphersuite is enabled, then firmware will disable all ECC ciphersuites. If u32SslCsBMP does not
  154. contain any ciphersuites supported by firmware, then the current active list will not be changed.
  155. @return
  156. - [SOCK_ERR_NO_ERROR](@ref SOCK_ERR_NO_ERROR)
  157. - [SOCK_ERR_INVALID_ARG](@ref SOCK_ERR_INVALID_ARG)
  158. */
  159. sint8 m2m_ssl_set_active_ciphersuites(uint32 u32SslCsBMP);
  160. /**@}*/
  161. #endif /* __M2M_SSL_H__ */