Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

175 lignes
6.4 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief WINC3400 SSL Interface.
  6. *
  7. * Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
  8. *
  9. * \asf_license_start
  10. *
  11. * \page License
  12. *
  13. * Subject to your compliance with these terms, you may use Microchip
  14. * software and any derivatives exclusively with Microchip products.
  15. * It is your responsibility to comply with third party license terms applicable
  16. * to your use of third party software (including open source software) that
  17. * may accompany Microchip software.
  18. *
  19. * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
  20. * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
  21. * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
  22. * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
  23. * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
  24. * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
  25. * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
  26. * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
  27. * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
  28. * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
  29. * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
  30. *
  31. * \asf_license_stop
  32. *
  33. */
  34. /**@defgroup SSLAPI SSL
  35. */
  36. #ifndef __M2M_SSL_H__
  37. #define __M2M_SSL_H__
  38. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  39. INCLUDES
  40. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  41. #include "common/include/nm_common.h"
  42. #include "driver/include/m2m_types.h"
  43. #include "driver/source/nmdrv.h"
  44. #include "ecc_types.h"
  45. #include "socket/include/socket.h"
  46. /**@defgroup SSLEnums Enumeration/Typedefs
  47. * @ingroup SSLAPI
  48. * @{*/
  49. /*!
  50. @typedef \
  51. void (*tpfAppSSLCb) (uint8 u8MsgType, void * pvMsg);
  52. @brief A callback to get SSL notifications.
  53. @param[in] u8MsgType
  54. @param[in] pvMsg A structure to provide notification payload.
  55. */
  56. typedef void (*tpfAppSSLCb) (uint8 u8MsgType, void * pvMsg);
  57. /**@}
  58. */
  59. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  60. FUNCTION PROTOTYPES
  61. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  62. /** \defgroup SSLFUNCTIONS Functions
  63. * @ingroup SSLAPI
  64. */
  65. /**@{*/
  66. /*!
  67. @fn \ NMI_API sint8 m2m_ssl_init(tpfAppSslCb pfAppSslCb);
  68. @brief Initializes the SSL layer.
  69. @param [in] pfAppSslCb
  70. Application SSL callback function.
  71. @return The function SHALL return 0 for success and a negative value otherwise.
  72. */
  73. NMI_API sint8 m2m_ssl_init(tpfAppSSLCb pfAppSSLCb);
  74. /*!
  75. @fn \ NMI_API sint8 m2m_ssl_handshake_rsp(tstrEccReqInfo* strECCResp, uint8* pu8RspDataBuff, uint16 u16RspDataSz)
  76. @brief Sends ECC responses to the WINC
  77. @param [in] strECCResp
  78. ECC Response struct.
  79. @param [in] pu8RspDataBuff
  80. Pointer of the response data to be sent.
  81. @param [in] u16RspDataSz
  82. Response data size.
  83. @return The function SHALL return 0 for success and a negative value otherwise.
  84. */
  85. NMI_API sint8 m2m_ssl_handshake_rsp(tstrEccReqInfo* strECCResp, uint8* pu8RspDataBuff, uint16 u16RspDataSz);
  86. /*!
  87. @fn \ NMI_API sint8 m2m_ssl_send_certs_to_winc(uint8* pu8Buffer, uint32 u32BufferSz)
  88. @brief Sends certificates to the WINC
  89. @param [in] pu8Buffer
  90. Pointer to the certificates. The buffer format must match the format of @ref tstrTlsSrvSecHdr
  91. @param [in] u32BufferSz
  92. Size of the certificates.
  93. @return The function SHALL return 0 for success and a negative value otherwise.
  94. */
  95. NMI_API sint8 m2m_ssl_send_certs_to_winc(uint8* pu8Buffer, uint32 u32BufferSz);
  96. /*!
  97. @fn \ NMI_API sint8 m2m_ssl_retrieve_cert(uint16* pu16CurveType, uint8* pu8Hash, uint8* pu8Sig, tstrECPoint* pu8Key)
  98. @brief Retrieve the ECDSA certificate to be verified from the WINC
  99. @param [out] pu16CurveType
  100. Pointer to the certificate curve type.
  101. @param [out] pu8Hash
  102. Pointer to the certificate hash.
  103. @param [out] pu8Sig
  104. Pointer to the certificate signature.
  105. @param [out] pu8Key
  106. Pointer to the certificate Key.
  107. @return The function SHALL return 0 for success and a negative value otherwise.
  108. */
  109. NMI_API sint8 m2m_ssl_retrieve_cert(uint16* pu16CurveType, uint8* pu8Hash, uint8* pu8Sig, tstrECPoint* pu8Key);
  110. /*!
  111. @fn \ NMI_API sint8 m2m_ssl_retrieve_hash(uint8* pu8Hash, uint16 u16HashSz)
  112. @brief Retrieve the certificate hash
  113. @param [out] pu8Hash
  114. Pointer to the certificate hash.
  115. @param [in] u16HashSz
  116. Hash size.
  117. @return The function SHALL return 0 for success and a negative value otherwise.
  118. */
  119. NMI_API sint8 m2m_ssl_retrieve_hash(uint8* pu8Hash, uint16 u16HashSz);
  120. /*!
  121. @fn \ NMI_API void m2m_ssl_stop_processing_certs(void)
  122. @brief Allow ssl driver to tidy up in case application does not read all available certificates.
  123. @warning This API must only be called if some certificates are left unread.
  124. @return None.
  125. */
  126. NMI_API void m2m_ssl_stop_processing_certs(void);
  127. /*!
  128. @fn \ NMI_API void m2m_ssl_ecc_process_done(void)
  129. @brief Allow ssl driver to tidy up after application has finished processing ecc message.
  130. @warning This API must be called after receiving a SSL callback with type @ref M2M_SSL_REQ_ECC
  131. @return None.
  132. */
  133. NMI_API void m2m_ssl_ecc_process_done(void);
  134. /*!
  135. @fn \
  136. NMI_API sint8 m2m_ssl_set_active_ciphersuites(uint32 u32SslCsBMP);
  137. Override the default Active SSL ciphers in the SSL module with a certain combination selected by the caller in the form of
  138. a bitmap containing the required ciphers to be on.
  139. There is no need to call this function if the application will not change the default ciphersuites.
  140. @param [in] u32SslCsBMP
  141. Bitmap containing the desired ciphers to be enabled for the SSL module. The ciphersuites are defined in
  142. @ref SSLCipherSuiteID.
  143. The default ciphersuites are all ciphersuites supported by the firmware with the exception of ECC ciphersuites.
  144. The caller can override the default with any desired combination, except for combinations involving both RSA
  145. and ECC; if any RSA ciphersuite is enabled, then firmware will disable all ECC ciphersuites.
  146. If u32SslCsBMP does not contain any ciphersuites supported by firmware, then the current active list will not
  147. be changed.
  148. @return
  149. - [SOCK_ERR_NO_ERROR](@ref SOCK_ERR_NO_ERROR)
  150. - [SOCK_ERR_INVALID_ARG](@ref SOCK_ERR_INVALID_ARG)
  151. */
  152. sint8 m2m_ssl_set_active_ciphersuites(uint32 u32SslCsBMP);
  153. /**@}*/
  154. #endif /* __M2M_SSL_H__ */