DA14531 - RPA and IRK

I am going to use non connectable advertisement with RPA and unique IRK

I need configure like my RPA must change very advertisement and my central will hold the same IRK and decrypt the mac address and verify the message in the manufacture data how can I do this process in my da14531 chip

Parents
  • HI Stanly,

    Thank you for posting your question online.

    I am going to use non connectable advertisement with RPA and unique IRK

    I need configure like my RPA must change very advertisement and my central will hold the same IRK and decrypt the mac address and verify the message in the manufacture data how can I do this process in my da14531 chip

    What is the point of the unique IRK if you have non connectable advertising from the Peripheral side?
    The IRK will be exchanged during connection. If there is no connection then there is no point in this security feature.

    Please refer on DA1453x Tutorial BLE Security — DA1453x&DA1458x Tutorial BLE security (renesas.com)
    On user_config.h file you set your RPA:

    /*************************************************************************
     * Privacy Capabilities and address configuration of local device:
     * - APP_CFG_ADDR_PUB               No Privacy, Public BDA
     * - APP_CFG_ADDR_STATIC            No Privacy, Random Static BDA
     * - APP_CFG_HOST_PRIV_RPA          Host Privacy, RPA, Public Identity
     * - APP_CFG_HOST_PRIV_NRPA         Host Privacy, NRPA (non-connectable ONLY)
     * - APP_CFG_CNTL_PRIV_RPA_PUB      Controller Privacy, RPA or PUB, Public Identity
     * - APP_CFG_CNTL_PRIV_RPA_RAND     Controller Privacy, RPA, Public Identity
     *
     * Select only one option for privacy / addressing configuration.
     **************************************************************************
     */
    #define USER_CFG_ADDRESS_MODE       APP_CFG_ADDR_PUB


    Regarding the IRK implementation:
    On user_config.h file you can find the gapm_configuration struct which contains the IRK:
    /*
     ****************************************************************************************
     *
     * GAPM configuration
     *
     ****************************************************************************************
     */
    static const struct gapm_configuration user_gapm_conf = {
        /// Device Role: Central, Peripheral, Observer, Broadcaster or All roles. (@see enum gap_role)
        .role = GAP_ROLE_PERIPHERAL,
    
        /// Maximal MTU. Shall be set to 23 if Legacy Pairing is used, 65 if Secure Connection is used,
        /// more if required by the application
        .max_mtu = 65,
    
        /// Device Address Type
        .addr_type = APP_CFG_ADDR_TYPE(USER_CFG_ADDRESS_MODE),
        /// Duration before regenerating the Random Private Address when privacy is enabled
        .renew_dur = 15000,    // 15000 * 10ms = 150s is the minimum value
    
        /***********************
         * Privacy configuration
         ***********************
         */
    
        /// Random Static address
        // NOTE: The address shall comply with the following requirements:
        // - the two most significant bits of the address shall be equal to 1,
        // - all the remaining bits of the address shall NOT be equal to 1,
        // - all the remaining bits of the address shall NOT be equal to 0.
        // In case the {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} null address is used, a
        // random static address will be automatically generated.
        .addr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    
        /// Device IRK used for Resolvable Private Address generation (LSB first)
        .irk = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
    
        /****************************
         * ATT database configuration
         ****************************
         */
    
        /// Attribute database configuration (@see enum gapm_att_cfg_flag)
        ///    7     6    5     4     3    2    1    0
        /// +-----+-----+----+-----+-----+----+----+----+
        /// | DBG | RFU | SC | PCP | APP_PERM |NAME_PERM|
        /// +-----+-----+----+-----+-----+----+----+----+
        /// - Bit [0-1]: Device Name write permission requirements for peer device (@see device_name_write_perm)
        /// - Bit [2-3]: Device Appearance write permission requirements for peer device (@see device_appearance_write_perm)
        /// - Bit [4]  : Slave Preferred Connection Parameters present
        /// - Bit [5]  : Service change feature present in GATT attribute database.
        /// - Bit [6]  : Reserved
        /// - Bit [7]  : Enable Debug Mode
        .att_cfg = GAPM_MASK_ATT_SVC_CHG_EN,
    
        /// GAP service start handle
        .gap_start_hdl = 0,
    
        /// GATT service start handle
        .gatt_start_hdl = 0,
    
        /**************************************************
         * Data packet length extension configuration (4.2)
         **************************************************
         */
    
        /// Maximal MPS
        .max_mps = 0,
    
        /// Maximal Tx octets (connInitialMaxTxOctets value, as defined in 4.2 Specification)
        .max_txoctets = 251,
    
        /// Maximal Tx time (connInitialMaxTxTime value, as defined in 4.2 Specification)
        .max_txtime = 2120,
    };

    The IRK is being configured during the app_on_set_dev_config_complete callback function (please check on user_callback_config.h file)
    The default operation can be found below:

    void default_app_on_set_dev_config_complete(void)
    {
    #if !defined (__DA14531_01__) && !defined (__DA14535__)
    #if (USER_CFG_ADDRESS_MODE == APP_CFG_CNTL_PRIV_RPA_RAND)
        // Add local device info in RAL. Do not wait for completion event
        struct gap_ral_dev_info dev_info;
        memcpy(&dev_info.addr, &(gapm_env.addr), BD_ADDR_LEN*sizeof(uint8_t));
        dev_info.addr_type = ((GAPM_F_GET(gapm_env.cfg_flags, ADDR_TYPE) == GAPM_CFG_ADDR_PUBLIC) ? ADDR_PUBLIC : ADDR_RAND);
        memset(&dev_info.peer_irk, 0, KEY_LEN * sizeof(uint8_t));
        memcpy(&dev_info.local_irk, user_gapm_conf.irk, KEY_LEN * sizeof(uint8_t));
        app_easy_security_ral_op(APP_ADD_DEV_IN_RAL, &dev_info);
    #endif
    #if (USER_CFG_ADDRESS_MODE == APP_CFG_CNTL_PRIV_RPA_PUB) || (USER_CFG_ADDRESS_MODE == APP_CFG_CNTL_PRIV_RPA_RAND)
        app_easy_security_ral_sync_with_bdb();
    #endif
    #endif // does not apply to DA14531-01, DA14535
        // Add the first required service in the database
        if (app_db_init_start())
        {
            // No more service to add, start advertising
            CALLBACK_ARGS_0(user_default_app_operations.default_operation_adv)
        }
    }

    You will need to create your own custom callback function for app_on_set_dev_config_complete  callback and handle the IRK inside there. 
    In order to create a unique IRK, please refer on the implementation for unique BDA:
    void default_app_generate_unique_static_random_addr(struct bd_addr *addr)
    {
        uint32_t timestamp;
        uint32_t tester;
    
        // Initialize OTP controller
        hw_otpc_init();
    
    #if defined (__DA14531__)
        hw_otpc_enter_mode(HW_OTPC_MODE_READ);
    #else
        hw_otpc_manual_read_on(false);
    #endif
    
        // Read OTP values
    #if defined (__DA14531__)
        timestamp = GetWord32(OTP_HDR_TIMESTAMP_ADDR);
        tester = GetWord32(OTP_HDR_TESTER_ADDR);
    #else
        timestamp = GetWord32(OTP_TIMESTAMP_ADDR);
        tester = GetWord32(OTP_SITE_ID_ADDR);
    #endif
    
        hw_otpc_disable();
    
        create_bd_addr(timestamp, tester, addr);
    }

    We are taking some information from the OTP and create the unique BDA. WIth a similar approach you can create a unique IRK.

    Best Regards,
    OV_Renesas

  • can you able to suggest me a security implementation for non-connectable advertisement because my device will advertise for 3 seconds when the button is pressed and goes to sleep mode until the button is pressed  

  • Hi Stanly,

    Thank you for the reply.

    can you able to suggest me a security implementation for non-connectable advertisement because my device will advertise for 3 seconds when the button is pressed and goes to sleep mode until the button is pressed  

    The Security features on BLE are establish during a connection.
    When you have non-connectable advertising, all the Central devices scanning can receive those advertisements. 

    There are however 2 options, if you do not want every Central device to have access on your data.
    1) If you know the Central device Bluetooth Address then you can WhiteList it. That would mean, that only the Central device that you have included in White List will be able to see your advertising data.
    Please refer here: 4. User Guides — DA14585/DA14531 SW Platform Reference Manual (renesas.com)

    2) You can encrypt the Advertising data before you start advertising. Everyone can access your advertising data, but only devices that knows the encryption key can actually decrypt the advertising data.
    Please refer here: 4. User Guides — DA14585/DA14531 SW Platform Reference Manual (renesas.com)


    Best Regards,
    OV_Renesas

Reply Children
No Data