This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

[nRF52840 + zigbee] About install codes

Hi,

I will add feature "installation codes".

I guess that security API do work.

At coordinator side, zb_secur_ic_add, zb_set_installcode_policy functions 

At end device side, zb_secur_ic_set and zb_set_installcode_policy functions

Questions

1. My understanding is correct ?

2. At zigbee router, how can activate installation codes ? 

(Router shall call zb_secur_ic_add or not ?)

3. zb_secur_ic_add and zb_secur_ic_set function save installation infromation into flash ??

4. Where can i find examples using security features?

Thanks.

Parents
  • Hi.

    You can take a look at how installation codes are used in the CLI, you can find the code in the SDK under components\zigbee\cli\zigbee_cli_cmd_bdb.c.

    /** @brief Set install code on the device, add information about the install code
     *  on the trust center, set the trust center install code policy.
     *
     * @code
     * bdb ic add <h:install code> <h:eui64>
     * bdb ic set <h:install code>
     * bdb ic policy <enable|disable>
     * @endcode
     *
     * @pre Setting and defining policy only before @ref start "bdb start".
     * Adding only after @ref start "bdb start".
     * 
     * <tt>bdb ic set</tt> must only be used on a joining device.
     *
     * <tt>bdb ic add</tt> must only be used on a coordinator.
     *
     * <tt>bdb ic policy</tt> must only be used on a coordinator.
     *
     * Provide the install code as an ASCII-encoded hex including CRC16.
     *
     * For production devices, an install code must be installed by the production
     * configuration present in flash.
     *
     *
     * Example:
     * @code
     * > bdb ic add 83FED3407A939723A5C639B26916D505C3B5 0B010E2F79E9DBFA
     * Done
     * @endcode
     */
    static void cmd_zb_install_code(nrf_cli_t const * p_cli, size_t argc, char **argv)
    {
        const char *   p_err_msg = NULL;
        zb_ieee_addr_t addr;
        zb_uint8_t     ic[ZB_CCM_KEY_SIZE + 2]; // +2 for CRC16
    
        if (nrf_cli_help_requested(p_cli) || (argc == 1))
        {
            print_usage(p_cli, argv[0],
                        "ic - set or add install code. Enable IC policy.\r\n"
                        "ic set <h:install code> - set the ic code to <install_code>\r\n"
                        "ic add <h:install code> <h:eui64> - add ic for device with given eui43\r\n"
                        "ic policy - set Trust Center install code policy");
            return;
        }
    
        if ((argc == 2) && (strcmp(argv[0], "set") == 0))
        {
            if (!parse_hex_str(argv[1], ic, 2*sizeof(ic), false))
            {
                p_err_msg = "Failed to parse IC";
                goto exit;
            }
    
            if (zb_secur_ic_set(ic) != RET_OK)
            {
                p_err_msg = "Failed to set IC";
                goto exit;
            }
        }
        else if ((argc == 3) && (strcmp(argv[0], "add") == 0))
        {
            if (!parse_hex_str(argv[1], ic, 2*sizeof(ic), false))
            {
                p_err_msg = "Failed to parse IC";
                goto exit;
            }
    
            if (!parse_long_address(argv[2], addr))
            {
                p_err_msg = "Failed to parse eui64";
                goto exit;
            }
    
            if (zb_secur_ic_add(addr, ic) != RET_OK)
            {
                p_err_msg = "Failed to add IC";
                goto exit;
            }
        }
        else if ((argc == 2) && (strcmp(argv[0], "policy") == 0))
        {
            if (strcmp(argv[1], "enable") == 0)
            {
                zb_set_installcode_policy(ZB_TRUE);
            }
            else if (strcmp(argv[1], "disable") == 0)
            {
                zb_set_installcode_policy(ZB_FALSE);
            }
            else
            {
                p_err_msg = "Syntax error";
                goto exit;
            }
        }
        else
        {
            p_err_msg ="Syntax error";
        }
    
    exit:
        if (p_err_msg)
        {
            print_error(p_cli, p_err_msg);
        }
        else
        {
            print_done(p_cli, ZB_FALSE);
        }
    }

    You have to run zb_secur_ic_set at the client side (the side without TC) and you have to run zb_secur_ic_add at the ZC (the side with TC).

    Best regards,

    Andreas

  • Thanks for reply.

    I have  more questionㄴ.

    1. At ZR(router) side, what to do for security ?

    2. using 

    "zb_secur_ic_set" and

    "zb_secur_ic_add" 

    Information is saved in flash ? or volatile ?

    Best reguards.

  • Hi.

    1.

    The router is a joining device before it becomes a router, so you should use zb_secur_ic_set.

    2.

    The information is stored in NVRAM.

    Best regards,

    Andreas

Reply Children
Related