This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530加密失败

您好:

为什么配置了加密后还是没有产生加密的感觉

然后让协调器和路由器通信,修改协调器的key后为什么二者还可以通信,理论上是不行的。

不清楚应该修改哪个key才能测试是否加了密

/* Default security key. */
-DDEFAULT_KEY="{0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0D}"

这个?


// This is the default pre-configured Trust Center Link key,
// change this to make a unique key, SEC_KEY_LEN is defined in ssp.h.
CONST byte defaultTCLinkKey[SEC_KEY_LEN] =
{
  0x56, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
  0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77
};

这个?

CONST byte defaultKey[SEC_KEY_LEN] =
{
#if defined ( APP_TP ) || defined ( APP_TP2 )
  // Key for ZigBee Conformance Testing
  0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
//  0xb1, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
  0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
#else
  // Key for In-House Testing
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
#endif
};

还是这个?

谢谢指导

另外请假一下关于AES加密的API调用问题,这方面没有什么资料

  • 你上传的图片看不到,如果没有使能uint8 zgPreConfigKeys = FALSE;的话,那么节点在入网的时候,Key是有父设备发送给子设备的。

    所以你协调器改了,路由也会改,也可以通信。

    加密和解密是有硬件完成的。

  • 您好,已使能zgPreConfigKeys

    说一下我的配置吧。

    @@@@@@@@@@@@@@@@@@@@@

    /* Set to 0 for no security, otherwise non-0 */
    //-DSECURE=0
    -DZG_SECURE_DYNAMIC=0
    -DSECURE=1
    //-DZG_SECURE_DYNAMIC=1

    @@@@@@@@@@@@@@@@@@@@@

    // If true, preConfigKey should be configured on all devices on the network
    // If false, it is configured only on the coordinator and sent to other
    // devices upon joining.
    //uint8 zgPreConfigKeys = FALSE;// TRUE;
    uint8 zgPreConfigKeys = TRUE;

    @@@@@@@@@@@@@@@@@@@@@

    // This is the default pre-configured key,
    // change this to make a unique key
    // SEC_KEY_LEN is defined in ssp.h.
    CONST byte defaultKey[SEC_KEY_LEN] =
    {
    #if defined ( APP_TP ) || defined ( APP_TP2 )
      // Key for ZigBee Conformance Testing
      0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
    //  0xb1, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
      0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
    #else
      // Key for In-House Testing
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    //    0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
    #endif
    };

    // This is the default pre-configured Trust Center Link key,
    // change this to make a unique key, SEC_KEY_LEN is defined in ssp.h.
    CONST byte defaultTCLinkKey[SEC_KEY_LEN] =
    {
    //  0x56, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
      0x57, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
      0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77
    };

    @@@@@@@@@@@@@@@@@@@@@

    其他没动,这有什么问题么。现在的问题是,配置了之后,就算两者密码不同,还是能正确通信。

    还是很多宏定义

    如NONWK,#if defined ( APP_TP ) || defined ( APP_TP2 ),

    //--------------------------------------------------------------------
    // Security modes
    //--------------------------------------------------------------------
    #define ZG_SECURITY_NONE         0
    #define ZG_SECURITY_RESIDENTIAL  1
    #define ZG_SECURITY_PRO_STANDARD 1  // For now, same as residential
    #define ZG_SECURITY_PRO_HIGH     3
    #define ZG_SECURITY_SE_STANDARD 4

    #if ( SECURE == 0 )
      #undef ZG_SECURITY_MODE
      #define ZG_SECURITY_MODE ZG_SECURITY_NONE
    #else
      #if !defined ( ZG_SECURITY_MODE )
        #if defined ( SE_PROFILE )
          #define ZG_SECURITY_MODE ZG_SECURITY_SE_STANDARD
        #else
          #if !defined ( ZIGBEEPRO )
            #define ZG_SECURITY_MODE ZG_SECURITY_RESIDENTIAL
          #else
    //        #define ZG_SECURITY_MODE ZG_SECURITY_PRO_HIGH
            #define ZG_SECURITY_MODE ZG_SECURITY_PRO_STANDARD  // Default for Pro Release is Standard (residential)
          #endif
        #endif
      #endif
    #endif

    这些宏定义的意思都不是很了解。TI官方有协议栈的API及宏定义的使用手册么,感觉TI这方面做的不是很好,

    我们使用的时候都是在猜或上网看其他人写,这个API或许是对的,或许又不对,又没有官方的编程手册。难道真心是让用户猜么?

    求解答,谢了。求官方正确的配置过程,谢了。

  • 第一次在客户那里听到说TI在文档在文档方面做的不好,呵呵!

    #if defined ( DEFAULT_KEY )
    CONST uint8 defaultKey[SEC_KEY_LEN] = DEFAULT_KEY;
    #else
    CONST uint8 defaultKey[SEC_KEY_LEN] =
    {
    #if defined ( APP_TP ) || defined ( APP_TP2 )
    // Key for ZigBee Conformance Testing
    0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
    0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
    #else
    // Key for In-House Testing
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
    #endif
    };
    #endif

    代码里面有个宏定义DEFAULT_KEY,如果已经定义了这个的话,那么就不在使用下面的数组了。

    DEFAULT_KEY定义在f8wconfig.cfg文档里面

    /* Default security key. */
    -DDEFAULT_KEY="{0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0D}"

    所有的API的文档,宏定义的解释都在协议栈安装目录下Documents里面。

  • 我是按着你们这么说的设置的,但设置完后,协调器和终端之间,不能实现组网,是个新手,不太明白问题出在哪里

  • 多年前的问题,刚刚遇到,也解决不了

  • 我也遇到这个问题,所有以上相关配置也做好同样的修改,组网成功可是在连续发送数据失败后就断开连接,无法正常通讯。反之把zgPreConfigKeys改回FALSE就可以通讯,这问题困扰我一个月了,求解。