/**************************************************************************************************
Filename: ZDSecMgr.c
Revised: $Date: 2010-01-08 13:29:59 -0800 (Fri, 08 Jan 2010) $
Revision: $Revision: 21465 $
Description: The ZigBee Device Security Manager.
Copyright 2005-2009 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/******************************************************************************
* INCLUDES
*/
#include "ZComdef.h"
#include "OSAL.h"
#include "OSAL_NV.h"
#include "ZGlobals.h"
#include "ssp.h"
#include "nwk_globals.h"
#include "nwk.h"
#include "NLMEDE.h"
#include "AddrMgr.h"
#include "AssocList.h"
#include "APSMEDE.h"
#include "AF.h"
#include "ZDConfig.h"
#include "ZDApp.h"
#include "ZDSecMgr.h"
/******************************************************************************
* CONSTANTS
*/
// maximum number of devices managed by this Security Manager
#if !defined ( ZDSECMGR_DEVICE_MAX )
#define ZDSECMGR_DEVICE_MAX 3
#endif
// total number of preconfigured devices (EXT address, MASTER key)
//devtag.pro.security
//#define ZDSECMGR_PRECONFIG_MAX ZDSECMGR_DEVICE_MAX
#define ZDSECMGR_PRECONFIG_MAX 0
// maximum number of MASTER keys this device may hold
#define ZDSECMGR_MASTERKEY_MAX ZDSECMGR_DEVICE_MAX
// maximum number of LINK keys this device may store
#define ZDSECMGR_ENTRY_MAX ZDSECMGR_DEVICE_MAX
// total number of devices under control - authentication, SKKE, etc.
#define ZDSECMGR_CTRL_MAX ZDSECMGR_DEVICE_MAX
// total number of stored devices
#if !defined ( ZDSECMGR_STORED_DEVICES )
#define ZDSECMGR_STORED_DEVICES 3
#endif
// Total number of preconfigured trust center link key
#if !defined ( ZDSECMGR_TC_DEVICE_MAX )
#define ZDSECMGR_TC_DEVICE_MAX 1
#endif
#if ( ZDSECMGR_TC_DEVICE_MAX < 1 ) || ( ZDSECMGR_TC_DEVICE_MAX > 255 )
#error "ZDSECMGR_TC_DEVICE_MAX shall be between 1 and 255 !"
#endif
#define ZDSECMGR_CTRL_NONE 0
#define ZDSECMGR_CTRL_INIT 1
#define ZDSECMGR_CTRL_TK_MASTER 2
#define ZDSECMGR_CTRL_SKKE_INIT 3
#define ZDSECMGR_CTRL_SKKE_WAIT 4
#define ZDSECMGR_CTRL_SKKE_DONE 5
#define ZDSECMGR_CTRL_SKKE_FAIL 6
#define ZDSECMGR_CTRL_TK_NWK 7
#define ZDSECMGR_CTRL_BASE_CNTR 1
#define ZDSECMGR_CTRL_SKKE_INIT_CNTR 1
#define ZDSECMGR_CTRL_TK_NWK_CNTR 1
// set SKA slot maximum
#define ZDSECMGR_SKA_SLOT_MAX 1
// APSME Stub Implementations
#define ZDSecMgrMasterKeyGet APSME_MasterKeyGet
#define ZDSecMgrLinkKeySet APSME_LinkKeySet
#define ZDSecMgrLinkKeyDataGet APSME_LinkKeyDataGet
#define ZDSecMgrKeyFwdToChild APSME_KeyFwdToChild
#if !defined( MAX_APS_FRAMECOUNTER_CHANGES )
// The number of times the frame counter can change before
// saving to NV
#define MAX_APS_FRAMECOUNTER_CHANGES 10
#endif
/******************************************************************************
* TYPEDEFS
*/
typedef struct
{
uint8 extAddr[Z_EXTADDR_LEN];
uint8 key[SEC_KEY_LEN];
} ZDSecMgrPreConfigData_t;
typedef struct
{
uint16 ami;
uint8 key[SEC_KEY_LEN];
} ZDSecMgrMasterKeyData_t;
//should match APSME_LinkKeyData_t;
typedef struct
{
uint8 key[SEC_KEY_LEN];
APSME_LinkKeyData_t apsmelkd;
} ZDSecMgrLinkKeyData_t;
typedef struct
{
uint16 ami;
ZDSecMgrLinkKeyData_t lkd;
ZDSecMgr_Authentication_Option authenticateOption;
} ZDSecMgrEntry_t;
typedef struct
{
ZDSecMgrEntry_t* entry;
uint16 parentAddr;
uint8 secure;
uint8 state;
uint8 cntr;
//uint8 next;
} ZDSecMgrCtrl_t;
typedef struct
{
uint16 nwkAddr;
uint8* extAddr;
uint16 parentAddr;
uint8 secure;
uint8 devStatus;
ZDSecMgrCtrl_t* ctrl;
} ZDSecMgrDevice_t;
/******************************************************************************
* LOCAL VARIABLES
*/
#if 0 // Taken out because the following functionality is only used for test
// purpose. A more efficient (above) way is used. It can be put
// back in if customers request for a white/black list feature.
uint8 ZDSecMgrStoredDeviceList[ZDSECMGR_STORED_DEVICES][Z_EXTADDR_LEN] =
{
{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
#endif
uint8 ZDSecMgrTCExtAddr[Z_EXTADDR_LEN]=
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
uint8 ZDSecMgrTCMasterKey[SEC_KEY_LEN] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x89,0x67,0x45,0x23,0x01,0xEF,0xCD,0xAB};
uint8 ZDSecMgrTCAuthenticated = FALSE;
uint8 ZDSecMgrTCDataLoaded = FALSE;
//devtag.pro.security - remove this
#if ( ZDSECMGR_PRECONFIG_MAX != 0 )
const ZDSecMgrPreConfigData_t ZDSecMgrPreConfigData[ZDSECMGR_PRECONFIG_MAX] =
{
//---------------------------------------------------------------------------
// DEVICE A
//---------------------------------------------------------------------------
{
// extAddr
{0x7C,0x01,0x12,0x13,0x14,0x15,0x16,0x17},
// key
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
},
//---------------------------------------------------------------------------
// DEVICE B
//---------------------------------------------------------------------------
{
// extAddr
{0x84,0x03,0x00,0x00,0x00,0x4B,0x12,0x00},
// key
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
},
//---------------------------------------------------------------------------
// DEVICE C
//---------------------------------------------------------------------------
{
// extAddr
{0x3E,0x01,0x12,0x13,0x14,0x15,0x16,0x17},
// key
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
ZStack-CC2530-2.3.0-1.4.0
4星 · 超过85%的资源 需积分: 35 41 浏览量
2015-04-09
13:11:43
上传
评论
收藏 41.23MB ZIP 举报
xpgu2012
- 粉丝: 0
- 资源: 2
最新资源
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
- 基于matlab+DWT的图像水印项目,数字水印+源代码+文档说明+图片+报告pdf
- (优秀毕业设计)基于python实现的数字图像可视化水印系统的设计与实现,多种数字算法实现+源代码+文档说明+理论演示pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈