ZDSecMgr.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. /**************************************************************************************************
  2. Filename: ZDSecMgr.h
  3. Revised: $Date: 2009-03-12 16:25:22 -0700 (Thu, 12 Mar 2009) $
  4. Revision: $Revision: 19404 $
  5. Description: This file contains the interface to the ZigBee Device Security Manager.
  6. Copyright 2005-2007 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef ZDSECMGR_H
  34. #define ZDSECMGR_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /******************************************************************************
  40. * INCLUDES
  41. */
  42. #include "ZComDef.h"
  43. #include "ZDApp.h"
  44. /******************************************************************************
  45. * TYPEDEFS
  46. */
  47. // Authentication options
  48. typedef enum
  49. {
  50. ZDSecMgr_Not_Authenticated = 0, // The device has not been authenticated
  51. ZDSecMgr_Authenticated_CBCK, // The devcie has been authenticated using CBKE
  52. ZDSecMgr_Authenticated_EA // The device has been authenticated using EA
  53. }ZDSecMgr_Authentication_Option;
  54. /******************************************************************************
  55. * PUBLIC FUNCTIONS
  56. */
  57. /******************************************************************************
  58. * @fn ZDSecMgrInit
  59. *
  60. * @brief Initialize ZigBee Device Security Manager.
  61. *
  62. * @param none
  63. *
  64. * @return none
  65. */
  66. extern void ZDSecMgrInit( void );
  67. /******************************************************************************
  68. * @fn ZDSecMgrConfig
  69. *
  70. * @brief Configure ZigBee Device Security Manager.
  71. *
  72. * @param none
  73. *
  74. * @return none
  75. */
  76. extern void ZDSecMgrConfig( void );
  77. /******************************************************************************
  78. * @fn ZDSecMgrPermitJoining
  79. *
  80. * @brief Process request to change joining permissions.
  81. *
  82. * @param duration - [in] timed duration for join in seconds
  83. * - 0x00 not allowed
  84. * - 0xFF allowed without timeout
  85. *
  86. * @return uint8 - success(TRUE:FALSE)
  87. */
  88. extern uint8 ZDSecMgrPermitJoining( uint8 duration );
  89. /******************************************************************************
  90. * @fn ZDSecMgrPermitJoiningTimeout
  91. *
  92. * @brief Process permit joining timeout
  93. *
  94. * @param none
  95. *
  96. * @return none
  97. */
  98. extern void ZDSecMgrPermitJoiningTimeout( void );
  99. /******************************************************************************
  100. * @fn ZDSecMgrNewDeviceEvent
  101. *
  102. * @brief Process a the new device event, if found reset new device
  103. * event/timer.
  104. *
  105. * @param none
  106. *
  107. * @return uint8 - found(TRUE:FALSE)
  108. */
  109. extern uint8 ZDSecMgrNewDeviceEvent( void );
  110. /******************************************************************************
  111. * @fn ZDSecMgrEvent
  112. *
  113. * @brief Handle ZDO Security Manager event/timer(ZDO_SECMGR_EVENT).
  114. *
  115. * @param none
  116. *
  117. * @return none
  118. */
  119. extern void ZDSecMgrEvent( void );
  120. /******************************************************************************
  121. * @fn ZDSecMgrEstablishKeyCfm
  122. *
  123. * @brief Process the ZDO_EstablishKeyCfm_t message.
  124. *
  125. * @param cfm - [in] ZDO_EstablishKeyCfm_t confirmation
  126. *
  127. * @return none
  128. */
  129. extern void ZDSecMgrEstablishKeyCfm( ZDO_EstablishKeyCfm_t* cfm );
  130. /******************************************************************************
  131. * @fn ZDSecMgrEstablishKeyInd
  132. *
  133. * @brief Process the ZDO_EstablishKeyInd_t message.
  134. *
  135. * @param ind - [in] ZDO_EstablishKeyInd_t indication
  136. *
  137. * @return none
  138. */
  139. extern void ZDSecMgrEstablishKeyInd( ZDO_EstablishKeyInd_t* ind );
  140. /******************************************************************************
  141. * @fn ZDSecMgrTransportKeyInd
  142. *
  143. * @brief Process the ZDO_TransportKeyInd_t message.
  144. *
  145. * @param ind - [in] ZDO_TransportKeyInd_t indication
  146. *
  147. * @return none
  148. */
  149. extern void ZDSecMgrTransportKeyInd( ZDO_TransportKeyInd_t* ind );
  150. /******************************************************************************
  151. * @fn ZDSecMgrUpdateDeviceInd
  152. *
  153. * @brief Process the ZDO_UpdateDeviceInd_t message.
  154. *
  155. * @param ind - [in] ZDO_UpdateDeviceInd_t indication
  156. *
  157. * @return none
  158. */
  159. extern void ZDSecMgrUpdateDeviceInd( ZDO_UpdateDeviceInd_t* ind );
  160. /******************************************************************************
  161. * @fn ZDSecMgrRemoveDeviceInd
  162. *
  163. * @brief Process the ZDO_RemoveDeviceInd_t message.
  164. *
  165. * @param ind - [in] ZDO_RemoveDeviceInd_t indication
  166. *
  167. * @return none
  168. */
  169. extern void ZDSecMgrRemoveDeviceInd( ZDO_RemoveDeviceInd_t* ind );
  170. /******************************************************************************
  171. * @fn ZDSecMgrRequestKeyInd
  172. *
  173. * @brief Process the ZDO_RequestKeyInd_t message.
  174. *
  175. * @param ind - [in] ZDO_RequestKeyInd_t indication
  176. *
  177. * @return none
  178. */
  179. extern void ZDSecMgrRequestKeyInd( ZDO_RequestKeyInd_t* ind );
  180. /******************************************************************************
  181. * @fn ZDSecMgrSwitchKeyInd
  182. *
  183. * @brief Process the ZDO_SwitchKeyInd_t message.
  184. *
  185. * @param ind - [in] ZDO_SwitchKeyInd_t indication
  186. *
  187. * @return none
  188. */
  189. extern void ZDSecMgrSwitchKeyInd( ZDO_SwitchKeyInd_t* ind );
  190. /******************************************************************************
  191. * @fn ZDSecMgrAuthenticateInd
  192. *
  193. * @brief Process the ZDO_AuthenticateInd_t message.
  194. *
  195. * @param ind - [in] ZDO_AuthenticateInd_t indication
  196. *
  197. * @return none
  198. */
  199. extern void ZDSecMgrAuthenticateInd( ZDO_AuthenticateInd_t* ind );
  200. /******************************************************************************
  201. * @fn ZDSecMgrAuthenticateCfm
  202. *
  203. * @brief Process the ZDO_AuthenticateCfm_t message.
  204. *
  205. * @param cfm - [in] ZDO_AuthenticateCfm_t confirmation
  206. *
  207. * @return none
  208. */
  209. extern void ZDSecMgrAuthenticateCfm( ZDO_AuthenticateCfm_t* cfm );
  210. /******************************************************************************
  211. * @fn ZDSecMgrUpdateNwkKey
  212. *
  213. * @brief Load a new NWK key and trigger a network wide update.
  214. *
  215. * @param key - [in] new NWK key
  216. * @param keySeqNum - [in] new NWK key sequence number
  217. *
  218. * @return ZStatus_t
  219. */
  220. extern ZStatus_t ZDSecMgrUpdateNwkKey( uint8* key, uint8 keySeqNum, uint16 dstAddr );
  221. /******************************************************************************
  222. * @fn ZDSecMgrSwitchNwkKey
  223. *
  224. * @brief Causes the NWK key to switch via a network wide command.
  225. *
  226. * @param keySeqNum - [in] new NWK key sequence number
  227. *
  228. * @return ZStatus_t
  229. */
  230. extern ZStatus_t ZDSecMgrSwitchNwkKey( uint8 keySeqNum, uint16 dstAddr );
  231. /******************************************************************************
  232. * @fn ZDSecMgrRequestAppKey
  233. *
  234. * @brief Request an application key with partner.
  235. *
  236. * @param partNwkAddr - [in] partner network address
  237. *
  238. * @return ZStatus_t
  239. */
  240. ZStatus_t ZDSecMgrRequestAppKey( uint16 partNwkAddr );
  241. /******************************************************************************
  242. * @fn ZDSecMgrSetupPartner
  243. *
  244. * @brief Setup for application key partner.
  245. *
  246. * @param partNwkAddr - [in] partner network address
  247. * @param partExtAddr - [in] partner extended address
  248. *
  249. * @return ZStatus_t
  250. */
  251. ZStatus_t ZDSecMgrSetupPartner( uint16 partNwkAddr, uint8* partExtAddr );
  252. /******************************************************************************
  253. * @fn ZDSecMgrAppKeyTypeSet
  254. *
  255. * @brief Set application key type.
  256. *
  257. * @param keyType - [in] application key type (KEY_TYPE_APP_MASTER@2 or
  258. * KEY_TYPE_APP_LINK@3
  259. *
  260. * @return ZStatus_t
  261. */
  262. ZStatus_t ZDSecMgrAppKeyTypeSet( uint8 keyType );
  263. /******************************************************************************
  264. * @fn ZDSecMgrAddLinkKey
  265. *
  266. * @brief Add the application link key to ZDSecMgr.
  267. *
  268. * @param shortAddr - [in] short address of the partner device
  269. * @param extAddr - [in] extended address of the partner device
  270. * @param key - [in] link key
  271. *
  272. * @return none
  273. */
  274. extern void ZDSecMgrAddLinkKey( uint16 shortAddr, uint8 *extAddr, uint8 *key);
  275. /*********************************************************************
  276. * @fn ZDSecMgrWriteNV()
  277. *
  278. * @brief Save off the link key list to NV
  279. *
  280. * @param none
  281. *
  282. * @return none
  283. */
  284. extern void ZDSecMgrWriteNV( void );
  285. /******************************************************************************
  286. * @fn ZDSecMgrRestoreFromNV
  287. *
  288. * @brief Restore the SecMgr entry data from NV.
  289. *
  290. * @param none
  291. *
  292. * @return ZStatus_t
  293. */
  294. extern ZStatus_t ZDSecMgrRestoreFromNV( void );
  295. /******************************************************************************
  296. * @fn ZDSecMgrInitNV
  297. *
  298. * @brief Initialize the SecMgr entry data in NV.
  299. *
  300. * @param none
  301. *
  302. * @return uint8 - <osal_nv_item_init> return codes
  303. */
  304. extern uint8 ZDSecMgrInitNV( void );
  305. /******************************************************************************
  306. * @fn ZDSecMgrSetDefaultNV
  307. *
  308. * @brief Set default SecMgr entry data in NV.
  309. *
  310. * @param none
  311. *
  312. * @return none
  313. */
  314. void ZDSecMgrSetDefaultNV( void );
  315. /******************************************************************************
  316. * @fn ZDSecMgrAPSRemove
  317. *
  318. * @brief Remove device from network.
  319. *
  320. * @param nwkAddr - device's NWK address
  321. * @param extAddr - device's Extended address
  322. * @param parentAddr - parent's NWK address
  323. *
  324. * @return ZStatus_t
  325. */
  326. ZStatus_t ZDSecMgrAPSRemove( uint16 nwkAddr, uint8 *extAddr, uint16 parentAddr );
  327. /******************************************************************************
  328. * @fn ZDSecMgrAuthenticationCheck
  329. *
  330. * @brief Check if the specific device has been authenticated or not
  331. *
  332. * @param shortAddr - [in] short address
  333. *
  334. * @return uint8 - TRUE @ authenticated
  335. * FALSE @ not authenticated
  336. */
  337. uint8 ZDSecMgrAuthenticationCheck( uint16 shortAddr );
  338. /******************************************************************************
  339. ******************************************************************************/
  340. #ifdef __cplusplus
  341. }
  342. #endif
  343. #endif /* ZDSECMGR_H */