BLE security question

Nice to meet you, I am an engineer living in Japan.

【Development environment】
"PCA10040 (nRF52832)" x 2 (center/periphery)
"SDK: 17.1.0"
"IDE: Segger Embedded Studio for ARM7.10a"

I have a question about BLE security.
I built a test environment using "PCA10040" for the central and peripheral, and tried simple communication.

I installed an app called "BLE Scanner" on my smartphone.
When I started the app, the device name advertised by the peripheral device was displayed, so when I clicked the "Connect" button, I was able to connect to the peripheral device from "BLE Scanner".

I don't want to connect my smartphone to a peripheral without entering a "password" or "passkey", so I want to increase security.

It turns out that there are four methods for authentication processing of BLE Central and Peripheral: "Just Works", "Passkey Entry", "Numeric comparison", and "Out Of Band".
I think that "Just Works" is good for this product because it is communication between devices without a screen.

question)
Please tell me the sample program of the authentication method using "Just Works".

It would be helpful if you could tell me the program code.
If there is any other better way, please let me know.

Parents
  • Hello,

    I suggest you try the Heart Rate sensor and BLE Heart Rate Collector Example. These examples support LE secure connections pairing with Just works which provides protection against passive eavesdropping (i.e. BT sniffers). Just remember to increase the security level of your Bluetooth characteristics to limit access to paired clients only. 

    Increasing the security levels of the Bluetooth characteristics in the heart rate example:

    diff --git a/main.c b/main.c
    index cc98734..9434a82 100644
    --- a/main.c
    +++ b/main.c
    @@ -493,8 +493,8 @@ static void services_init(void)
         hrs_init.p_body_sensor_location      = &body_sensor_location;
     
         // Here the sec level for the Heart Rate Service can be changed/increased.
    -    hrs_init.hrm_cccd_wr_sec = SEC_OPEN;
    -    hrs_init.bsl_rd_sec      = SEC_OPEN;
    +    hrs_init.hrm_cccd_wr_sec = SEC_JUST_WORKS;
    +    hrs_init.bsl_rd_sec      = SEC_JUST_WORKS;
     
         err_code = ble_hrs_init(&m_hrs, &hrs_init);
         APP_ERROR_CHECK(err_code);
    @@ -508,9 +508,9 @@ static void services_init(void)
         bas_init.initial_batt_level   = 100;
     
         // Here the sec level for the Battery Service can be changed/increased.
    -    bas_init.bl_rd_sec        = SEC_OPEN;
    -    bas_init.bl_cccd_wr_sec   = SEC_OPEN;
    -    bas_init.bl_report_rd_sec = SEC_OPEN;
    +    bas_init.bl_rd_sec        = SEC_JUST_WORKS;
    +    bas_init.bl_cccd_wr_sec   = SEC_JUST_WORKS;
    +    bas_init.bl_report_rd_sec = SEC_JUST_WORKS;
     
         err_code = ble_bas_init(&m_bas, &bas_init);
         APP_ERROR_CHECK(err_code);

    Best regards,

    Vidar

Reply
  • Hello,

    I suggest you try the Heart Rate sensor and BLE Heart Rate Collector Example. These examples support LE secure connections pairing with Just works which provides protection against passive eavesdropping (i.e. BT sniffers). Just remember to increase the security level of your Bluetooth characteristics to limit access to paired clients only. 

    Increasing the security levels of the Bluetooth characteristics in the heart rate example:

    diff --git a/main.c b/main.c
    index cc98734..9434a82 100644
    --- a/main.c
    +++ b/main.c
    @@ -493,8 +493,8 @@ static void services_init(void)
         hrs_init.p_body_sensor_location      = &body_sensor_location;
     
         // Here the sec level for the Heart Rate Service can be changed/increased.
    -    hrs_init.hrm_cccd_wr_sec = SEC_OPEN;
    -    hrs_init.bsl_rd_sec      = SEC_OPEN;
    +    hrs_init.hrm_cccd_wr_sec = SEC_JUST_WORKS;
    +    hrs_init.bsl_rd_sec      = SEC_JUST_WORKS;
     
         err_code = ble_hrs_init(&m_hrs, &hrs_init);
         APP_ERROR_CHECK(err_code);
    @@ -508,9 +508,9 @@ static void services_init(void)
         bas_init.initial_batt_level   = 100;
     
         // Here the sec level for the Battery Service can be changed/increased.
    -    bas_init.bl_rd_sec        = SEC_OPEN;
    -    bas_init.bl_cccd_wr_sec   = SEC_OPEN;
    -    bas_init.bl_report_rd_sec = SEC_OPEN;
    +    bas_init.bl_rd_sec        = SEC_JUST_WORKS;
    +    bas_init.bl_cccd_wr_sec   = SEC_JUST_WORKS;
    +    bas_init.bl_report_rd_sec = SEC_JUST_WORKS;
     
         err_code = ble_bas_init(&m_bas, &bas_init);
         APP_ERROR_CHECK(err_code);

    Best regards,

    Vidar

Children
Related