選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

495 行
20 KiB

  1. /*******************************************************************************
  2. File Name:
  3. m2m_ssl.c
  4. Summary:
  5. WINC SSL Interface.
  6. Description:
  7. WINC SSL Interface.
  8. *******************************************************************************/
  9. //DOM-IGNORE-BEGIN
  10. /*******************************************************************************
  11. * Copyright (C) 2021 Microchip Technology Inc. and its subsidiaries.
  12. *
  13. * Subject to your compliance with these terms, you may use Microchip software
  14. * and any derivatives exclusively with Microchip products. It is your
  15. * responsibility to comply with third party license terms applicable to your
  16. * use of third party software (including open source software) that may
  17. * accompany Microchip software.
  18. *
  19. * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
  20. * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
  21. * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
  22. * PARTICULAR PURPOSE.
  23. *
  24. * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
  25. * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
  26. * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
  27. * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
  28. * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
  29. * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
  30. * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
  31. *******************************************************************************/
  32. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  33. INCLUDES
  34. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  35. #include "m2m_ssl.h"
  36. #include "m2m_hif.h"
  37. #include "nmasic.h"
  38. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  39. MACROS
  40. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  41. #define min(a,b) (((a) < (b)) ? (a) : (b))
  42. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  43. DATA TYPES
  44. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  45. static tpfAppSSLCb gpfAppSSLCb = NULL;
  46. static uint32_t gu32HIFAddr = 0;
  47. static tenuTlsFlashStatus genuStatus = TLS_FLASH_ERR_UNKNOWN;
  48. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  49. FUNCTION PROTOTYPES
  50. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  51. /*!
  52. @fn void m2m_ssl_cb(uint8_t u8OpCode, uint16_t u16DataSize, uint32_t u32Addr)
  53. @brief Internal SSL callback function.
  54. @param [in] u8OpCode
  55. HIF Opcode type.
  56. @param [in] u16DataSize
  57. HIF data length.
  58. @param [in] u32Addr
  59. HIF address.
  60. */
  61. static void m2m_ssl_cb(uint8_t u8OpCode, uint16_t u16DataSize, uint32_t u32Addr)
  62. {
  63. int8_t s8tmp = M2M_SUCCESS;
  64. switch(u8OpCode)
  65. {
  66. case M2M_SSL_REQ_ECC:
  67. {
  68. tstrEccReqInfo strEccREQ;
  69. s8tmp = hif_receive(u32Addr, (uint8_t *)&strEccREQ, sizeof(tstrEccReqInfo), 0);
  70. if(s8tmp == M2M_SUCCESS)
  71. {
  72. if(gpfAppSSLCb)
  73. {
  74. gu32HIFAddr = u32Addr + sizeof(tstrEccReqInfo);
  75. gpfAppSSLCb(M2M_SSL_REQ_ECC, &strEccREQ);
  76. }
  77. }
  78. }
  79. break;
  80. case M2M_SSL_RESP_SET_CS_LIST:
  81. {
  82. tstrSslSetActiveCsList strCsList;
  83. s8tmp = hif_receive(u32Addr, (uint8_t *)&strCsList, sizeof(tstrSslSetActiveCsList), 0);
  84. if(s8tmp == M2M_SUCCESS)
  85. {
  86. if(gpfAppSSLCb)
  87. gpfAppSSLCb(M2M_SSL_RESP_SET_CS_LIST, &strCsList);
  88. }
  89. }
  90. break;
  91. case M2M_SSL_RESP_WRITE_OWN_CERTS:
  92. {
  93. tstrTlsSrvChunkHdr strTlsSrvChunkRsp;
  94. uint8_t bCallApp = 1;
  95. s8tmp = hif_receive(u32Addr, (uint8_t *)&strTlsSrvChunkRsp, sizeof(tstrTlsSrvChunkHdr), 0);
  96. if(s8tmp == M2M_SUCCESS)
  97. {
  98. uint16_t offset = strTlsSrvChunkRsp.u16Offset32;
  99. uint16_t chunk_size = strTlsSrvChunkRsp.u16Size32;
  100. uint16_t total_size = strTlsSrvChunkRsp.u16TotalSize32;
  101. tenuTlsFlashStatus status = (tenuTlsFlashStatus)(strTlsSrvChunkRsp.u16Sig);
  102. /* If first chunk, reset status. */
  103. if(offset == 0)
  104. genuStatus = TLS_FLASH_OK_NO_CHANGE;
  105. /* Only send status to app when processing last chunk. */
  106. if(offset + chunk_size != total_size)
  107. bCallApp = 0;
  108. switch(status)
  109. {
  110. case TLS_FLASH_OK:
  111. // Good flash write. Update status if no errors yet.
  112. if(genuStatus == TLS_FLASH_OK_NO_CHANGE)
  113. genuStatus = status;
  114. break;
  115. case TLS_FLASH_OK_NO_CHANGE:
  116. // No change, don't update status.
  117. break;
  118. case TLS_FLASH_ERR_CORRUPT:
  119. // Corrupt. Always update status.
  120. genuStatus = status;
  121. break;
  122. case TLS_FLASH_ERR_NO_CHANGE:
  123. // Failed flash write. Update status if no more serious error.
  124. if((genuStatus != TLS_FLASH_ERR_CORRUPT) && (genuStatus != TLS_FLASH_ERR_UNKNOWN))
  125. genuStatus = status;
  126. break;
  127. default:
  128. // Don't expect any other case. Ensure we don't mask a previous corrupt error.
  129. if(genuStatus != TLS_FLASH_ERR_CORRUPT)
  130. genuStatus = TLS_FLASH_ERR_UNKNOWN;
  131. break;
  132. }
  133. }
  134. if(bCallApp && gpfAppSSLCb)
  135. gpfAppSSLCb(M2M_SSL_RESP_WRITE_OWN_CERTS, &genuStatus);
  136. }
  137. break;
  138. }
  139. if(s8tmp != M2M_SUCCESS)
  140. {
  141. M2M_ERR("Error receiving SSL from the HIF\n");
  142. }
  143. }
  144. /*!
  145. @fn int8_t m2m_ssl_init(tpfAppSSLCb pfAppSSLCb)
  146. @brief Initializes the SSL layer.
  147. @param [in] pfAppSslCb
  148. Application SSL callback function.
  149. @return The function returns @ref M2M_SUCCESS for success and a negative value otherwise.
  150. */
  151. int8_t m2m_ssl_init(tpfAppSSLCb pfAppSSLCb)
  152. {
  153. int8_t s8Ret = M2M_SUCCESS;
  154. gpfAppSSLCb = pfAppSSLCb;
  155. gu32HIFAddr = 0;
  156. genuStatus = TLS_FLASH_ERR_UNKNOWN;
  157. s8Ret = hif_register_cb(M2M_REQ_GROUP_SSL, m2m_ssl_cb);
  158. if(s8Ret != M2M_SUCCESS)
  159. {
  160. M2M_ERR("hif_register_cb() failed with ret=%d", s8Ret);
  161. }
  162. return s8Ret;
  163. }
  164. /*!
  165. @fn int8_t m2m_ssl_handshake_rsp(tstrEccReqInfo* strECCResp, uint8_t* pu8RspDataBuff, uint16_t u16RspDataSz)
  166. @brief Sends ECC responses to the WINC.
  167. @param[in] strECCResp
  168. ECC Response struct.
  169. @param[in] pu8RspDataBuff
  170. Pointer of the response data to be sent.
  171. @param[in] u16RspDataSz
  172. Response data size.
  173. @return The function returns @ref M2M_SUCCESS for success and a negative value otherwise.
  174. */
  175. int8_t m2m_ssl_handshake_rsp(tstrEccReqInfo *strECCResp, uint8_t *pu8RspDataBuff, uint16_t u16RspDataSz)
  176. {
  177. int8_t s8Ret = M2M_SUCCESS;
  178. s8Ret = hif_send(M2M_REQ_GROUP_SSL, (M2M_SSL_RESP_ECC | M2M_REQ_DATA_PKT), (uint8_t *)strECCResp, sizeof(tstrEccReqInfo), pu8RspDataBuff, u16RspDataSz, sizeof(tstrEccReqInfo));
  179. return s8Ret;
  180. }
  181. /*!
  182. @fn int8_t m2m_ssl_send_certs_to_winc(uint8_t *pu8Buffer, uint32_t u32BufferSz)
  183. @brief Sends certificates to the WINC
  184. @param[in] pu8Buffer
  185. Pointer to the certificates.
  186. @param[in] u32BufferSz
  187. Size of the certificates.
  188. @return The function returns @ref M2M_SUCCESS for success and a negative value otherwise.
  189. */
  190. int8_t m2m_ssl_send_certs_to_winc(uint8_t *pu8Buffer, uint32_t u32BufferSz)
  191. {
  192. int8_t s8Ret = M2M_SUCCESS;
  193. #define TXLIMIT (256 * 6)
  194. if(u32BufferSz <= TXLIMIT)
  195. {
  196. // set chunk header for one chunk
  197. tstrTlsSrvChunkHdr *pchkhdr = (tstrTlsSrvChunkHdr *)pu8Buffer;
  198. pchkhdr->u16Sig = TLS_CERTS_CHUNKED_SIG_VALUE;
  199. pchkhdr->u16TotalSize32 = (u32BufferSz + 3) >> 2;
  200. pchkhdr->u16Offset32 = 0;
  201. pchkhdr->u16Size32 = (u32BufferSz + 3) >> 2;
  202. s8Ret = hif_send(M2M_REQ_GROUP_SSL, (M2M_SSL_REQ_WRITE_OWN_CERTS | M2M_REQ_DATA_PKT), NULL, 0, pu8Buffer, u32BufferSz, 0);
  203. M2M_INFO("Transferred %" PRIu32 " bytes of cert data NON-CHUNKED\r\n", u32BufferSz);
  204. }
  205. else
  206. {
  207. // chunk it
  208. // We are sneaking in a header - tstrTlsSrvChunkHdr
  209. #define CHUNKHDRSZ (sizeof(tstrTlsSrvChunkHdr))
  210. #define CHUNKSZ (TXLIMIT - 256) // divisible by 4
  211. uint8_t saveblob[CHUNKHDRSZ];
  212. uint32_t ofs = 0;
  213. uint32_t thischunksz = 0;
  214. // first is special - over writing our header
  215. memcpy(saveblob, &pu8Buffer[ofs], CHUNKHDRSZ);
  216. thischunksz = min(CHUNKSZ, u32BufferSz-ofs); // no need to round up to quad words this time
  217. tstrTlsSrvChunkHdr *pchkhdr = (tstrTlsSrvChunkHdr *)&pu8Buffer[ofs];
  218. pchkhdr->u16Sig = TLS_CERTS_CHUNKED_SIG_VALUE;
  219. pchkhdr->u16TotalSize32 = ((u32BufferSz + 3) >> 2);
  220. pchkhdr->u16Offset32 = ((ofs + 3) >> 2);
  221. pchkhdr->u16Size32 = ((thischunksz + 3) >> 2);
  222. s8Ret = hif_send(M2M_REQ_GROUP_SSL, (M2M_SSL_REQ_WRITE_OWN_CERTS | M2M_REQ_DATA_PKT), NULL, 0, &pu8Buffer[ofs], thischunksz, 0);
  223. M2M_INFO("Transferred %" PRIu32 " bytes of cert data CHUNKED to offset %" PRIu32 " total %" PRIu32 "\r\n", thischunksz, ofs, u32BufferSz);
  224. memcpy(&pu8Buffer[ofs], saveblob, CHUNKHDRSZ);
  225. ofs += thischunksz;
  226. while(ofs < u32BufferSz)
  227. {
  228. // Subsequent chunks write header before and send a little more
  229. memcpy(saveblob, &pu8Buffer[ofs-CHUNKHDRSZ], CHUNKHDRSZ);
  230. thischunksz = min(CHUNKSZ, u32BufferSz-ofs);
  231. thischunksz = (thischunksz + 3) & 0xFFFFFFFC; // needs to round up to quad word length
  232. pchkhdr = (tstrTlsSrvChunkHdr *)&pu8Buffer[ofs - CHUNKHDRSZ];
  233. pchkhdr->u16Sig = TLS_CERTS_CHUNKED_SIG_VALUE;
  234. pchkhdr->u16TotalSize32 = ((u32BufferSz + 3) >> 2);
  235. pchkhdr->u16Offset32 = ((ofs + 3) >> 2);
  236. pchkhdr->u16Size32 = ((thischunksz + 3) >> 2);
  237. s8Ret = hif_send(M2M_REQ_GROUP_SSL, (M2M_SSL_REQ_WRITE_OWN_CERTS | M2M_REQ_DATA_PKT), NULL, 0, &pu8Buffer[ofs - CHUNKHDRSZ], thischunksz + CHUNKHDRSZ, 0);
  238. M2M_INFO("Transferred %" PRIu32 " bytes of cert data CHUNKED to offset %" PRIu32 " total %" PRIu32 "\n", thischunksz, ofs, u32BufferSz);
  239. memcpy(&pu8Buffer[ofs - CHUNKHDRSZ], saveblob, CHUNKHDRSZ);
  240. ofs += thischunksz;
  241. }
  242. }
  243. return s8Ret;
  244. }
  245. /*!
  246. @fn int8_t m2m_ssl_retrieve_next_for_verifying(tenuEcNamedCurve *penuCurve, uint8_t *pu8Value, uint16_t *pu16ValueSz, uint8_t *pu8Sig, uint16_t *pu16SigSz, tstrECPoint *pstrKey);
  247. @brief Retrieve the next set of information from the WINC for ECDSA verification.
  248. @param[out] penuCurve
  249. The named curve.
  250. @param[out] pu8Value
  251. Value retrieved for verification. This is the digest of the message, truncated/prepended to the appropriate size.
  252. @param[inout] pu16ValueSz
  253. in: Size of value buffer provided by caller.
  254. out: Size of value retrieved (provided for convenience; the value size is in fact determined by the curve).
  255. @param[out] pu8Sig
  256. Signature retrieved for verification.
  257. @param[inout] pu16SigSz
  258. in: Size of signature buffer provided by caller.
  259. out: Size of signature retrieved (provided for convenience; the signature size is in fact determined by the curve).
  260. @param[out] pstrKey
  261. Public key retrieved for verification.
  262. @return The function returns @ref M2M_SUCCESS for success and a negative value otherwise.
  263. @pre This function should only be called after the application has been notified that
  264. verification information is ready via @ref ECC_REQ_SIGN_VERIFY.
  265. @warning If this function returns @ref M2M_ERR_FAIL, then any remaining verification info from
  266. the WINC is lost.
  267. */
  268. int8_t m2m_ssl_retrieve_next_for_verifying(tenuEcNamedCurve *penuCurve, uint8_t *pu8Value, uint16_t *pu16ValueSz, uint8_t *pu8Sig, uint16_t *pu16SigSz, tstrECPoint *pstrKey)
  269. {
  270. int8_t s8Ret = M2M_ERR_FAIL;
  271. uint16_t u16HashSz, u16SigSz, u16KeySz;
  272. if(gu32HIFAddr == 0) return M2M_ERR_FAIL;
  273. if((NULL == penuCurve) || (NULL == pu8Value) || (NULL == pu16ValueSz) || (NULL == pu8Sig) || (NULL == pu16SigSz) || (NULL == pstrKey))
  274. {
  275. s8Ret = M2M_ERR_INVALID_ARG;
  276. goto __ERR;
  277. }
  278. if(hif_receive(gu32HIFAddr, (uint8_t *)&u16KeySz, 2, 0) != M2M_SUCCESS) goto __ERR;
  279. *penuCurve = _htons(u16KeySz);
  280. gu32HIFAddr += 2;
  281. if(hif_receive(gu32HIFAddr, (uint8_t *)&u16KeySz, 2, 0) != M2M_SUCCESS) goto __ERR;
  282. u16KeySz = _htons(u16KeySz);
  283. if(u16KeySz > sizeof(pstrKey->X)) goto __ERR;
  284. pstrKey->u16Size = u16KeySz;
  285. gu32HIFAddr += 2;
  286. if(hif_receive(gu32HIFAddr, (uint8_t *)&u16HashSz, 2, 0) != M2M_SUCCESS) goto __ERR;
  287. u16HashSz = _htons(u16HashSz);
  288. if(u16HashSz > *pu16ValueSz) goto __ERR;
  289. *pu16ValueSz = u16HashSz;
  290. gu32HIFAddr += 2;
  291. if(hif_receive(gu32HIFAddr, (uint8_t *)&u16SigSz, 2, 0) != M2M_SUCCESS) goto __ERR;
  292. u16SigSz = _htons(u16SigSz);
  293. if(u16SigSz > *pu16SigSz) goto __ERR;
  294. *pu16SigSz = u16SigSz;
  295. gu32HIFAddr += 2;
  296. if(hif_receive(gu32HIFAddr, pstrKey->X, u16KeySz, 0) != M2M_SUCCESS) goto __ERR;
  297. gu32HIFAddr += u16KeySz;
  298. if(hif_receive(gu32HIFAddr, pstrKey->Y, u16KeySz, 0) != M2M_SUCCESS) goto __ERR;
  299. gu32HIFAddr += u16KeySz;
  300. if(hif_receive(gu32HIFAddr, pu8Value, u16HashSz, 0) != M2M_SUCCESS) goto __ERR;
  301. gu32HIFAddr += u16HashSz;
  302. if(hif_receive(gu32HIFAddr, pu8Sig, u16SigSz, 0) != M2M_SUCCESS) goto __ERR;
  303. gu32HIFAddr += u16SigSz;
  304. return M2M_SUCCESS;
  305. __ERR:
  306. hif_receive(0, NULL, 0, 1);
  307. return s8Ret;
  308. }
  309. /*!
  310. @fn int8_t m2m_ssl_retrieve_cert(uint16_t *pu16Curve, uint8_t *pu8Value, uint8_t *pu8Sig, tstrECPoint *pstrKey);
  311. @brief Retrieve the next set of information from the WINC for ECDSA verification.
  312. @param[out] pu16Curve
  313. The named curve, to be cast to type @ref tenuEcNamedCurve.
  314. @param[out] pu8Value
  315. Value retrieved for verification. This is the digest of the message, truncated/prepended to the appropriate size.
  316. The size of the value is equal to the field size of the curve, hence is determined by pu16Curve.
  317. @param[out] pu8Sig
  318. Signature retrieved for verification.
  319. The size of the signature is equal to twice the field size of the curve, hence is determined by pu16Curve.
  320. @param[out] pstrKey
  321. Public key retrieved for verification.
  322. @return The function returns @ref M2M_SUCCESS for success and a negative value otherwise.
  323. @pre This function should only be called after the application has been notified that
  324. verification information is ready via @ref ECC_REQ_SIGN_VERIFY.
  325. @warning If this function returns @ref M2M_ERR_FAIL, then any remaining verification info from
  326. the WINC is lost.
  327. @warning This API has been deprecated and is kept for legacy purposes only. It is recommended
  328. that @ref m2m_ssl_retrieve_next_for_verifying is used instead.
  329. */
  330. int8_t m2m_ssl_retrieve_cert(uint16_t *pu16Curve, uint8_t *pu8Value, uint8_t *pu8Sig, tstrECPoint *pstrKey)
  331. {
  332. uint16_t u16ValueSz = 32, u16SigSz = 64;
  333. return m2m_ssl_retrieve_next_for_verifying((tenuEcNamedCurve *)pu16Curve, pu8Value, &u16ValueSz, pu8Sig, &u16SigSz, pstrKey);
  334. }
  335. /*!
  336. @fn int8_t m2m_ssl_retrieve_hash(uint8_t *pu8Value, uint16_t u16ValueSz)
  337. @brief Retrieve the value from the WINC for ECDSA signing.
  338. @param[out] pu8Value
  339. Value retrieved for signing. This is the digest of the message, truncated/prepended to the appropriate size.
  340. @param[in] u16ValueSz
  341. Size of value to be retrieved. (The application should obtain this information,
  342. along with the curve, from the associated @ref ECC_REQ_SIGN_GEN notification.)
  343. @return The function returns @ref M2M_SUCCESS for success and a negative value otherwise.
  344. @pre This function should only be called after the application has been notified that
  345. signing information is ready via @ref ECC_REQ_SIGN_GEN.
  346. @warning If this function returns @ref M2M_ERR_FAIL, then the value for signing is lost.
  347. */
  348. int8_t m2m_ssl_retrieve_hash(uint8_t *pu8Value, uint16_t u16ValueSz)
  349. {
  350. int8_t s8Ret = M2M_ERR_FAIL;
  351. if(gu32HIFAddr == 0) return M2M_ERR_FAIL;
  352. if(NULL == pu8Value)
  353. {
  354. s8Ret = M2M_ERR_INVALID_ARG;
  355. goto __ERR;
  356. }
  357. if(hif_receive(gu32HIFAddr, pu8Value, u16ValueSz, 0) != M2M_SUCCESS) goto __ERR;
  358. return M2M_SUCCESS;
  359. __ERR:
  360. hif_receive(0, NULL, 0, 1);
  361. return s8Ret;
  362. }
  363. /*!
  364. @fn void m2m_ssl_stop_retrieving(void);
  365. @brief Allow SSL driver to tidy up when the application chooses not to retrieve all available
  366. information.
  367. @return None.
  368. @warning The application must call this function if it has been notified (via
  369. @ref ECC_REQ_SIGN_GEN or @ref ECC_REQ_SIGN_VERIFY) that information is available for
  370. retrieving from the WINC, but chooses not to retrieve it all.
  371. The application must not call this function if it has retrieved all the available
  372. information, or if a retrieve function returned @ref M2M_ERR_FAIL indicating that any
  373. remaining information has been lost.
  374. @see m2m_ssl_retrieve_next_for_verifying\n
  375. m2m_ssl_retrieve_cert\n
  376. m2m_ssl_retrieve_hash
  377. */
  378. void m2m_ssl_stop_retrieving(void)
  379. {
  380. hif_receive(0, NULL, 0, 1);
  381. }
  382. /*!
  383. @fn void m2m_ssl_stop_processing_certs(void);
  384. @brief Allow SSL driver to tidy up in case application does not read all available certificates.
  385. @return None.
  386. @warning This API has been deprecated and is kept for legacy purposes only. It is recommended
  387. that @ref m2m_ssl_stop_retrieving is used instead.
  388. */
  389. void m2m_ssl_stop_processing_certs(void)
  390. {
  391. m2m_ssl_stop_retrieving();
  392. }
  393. /*!
  394. @fn void m2m_ssl_ecc_process_done(void);
  395. @brief Allow SSL driver to tidy up after application has finished processing ECC message.
  396. @return None.
  397. @warning The application should call this function after receiving an SSL callback with message
  398. type @ref M2M_SSL_REQ_ECC, after retrieving any related information, and before
  399. calling @ref m2m_ssl_handshake_rsp.
  400. */
  401. void m2m_ssl_ecc_process_done(void)
  402. {
  403. gu32HIFAddr = 0;
  404. }
  405. /*!
  406. @fn int8_t m2m_ssl_set_active_ciphersuites(uint32_t u32SslCsBMP)
  407. @brief Sets the active ciphersuites.
  408. @details Override the default Active SSL ciphers in the SSL module with a certain combination selected by the caller in the form of
  409. a bitmap containing the required ciphers to be on.
  410. There is no need to call this function if the application will not change the default ciphersuites.
  411. @param [in] u32SslCsBMP
  412. Bitmap containing the desired ciphers to be enabled for the SSL module. The ciphersuites are defined in
  413. @ref SSLCipherSuiteID.
  414. The default ciphersuites are all ciphersuites supported by the firmware with the exception of ECC ciphersuites.
  415. The caller can override the default with any desired combination.
  416. If u32SslCsBMP does not contain any ciphersuites supported by firmware, then the current active list will not
  417. change.
  418. @return
  419. - @ref SOCK_ERR_NO_ERROR
  420. - @ref SOCK_ERR_INVALID_ARG
  421. */
  422. int8_t m2m_ssl_set_active_ciphersuites(uint32_t u32SslCsBMP)
  423. {
  424. int8_t s8Ret = M2M_SUCCESS;
  425. tstrSslSetActiveCsList strCsList;
  426. strCsList.u32CsBMP = u32SslCsBMP;
  427. s8Ret = hif_send(M2M_REQ_GROUP_SSL, M2M_SSL_REQ_SET_CS_LIST, (uint8_t *)&strCsList, sizeof(tstrSslSetActiveCsList), NULL, 0, 0);
  428. return s8Ret;
  429. }
  430. //DOM-IGNORE-END