Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Gatt Read/write and insufficient key size error

Hi

When a GATT Table is created using the softdevice api, how do specify that a service or characteristic shall have a minimum key size of X so that if the current encrytion was done with a key <X size, then it will read with the  BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC_KEY_SIZE  error.

For that error to result, I would have to specify the minimum key size when a add a characteristic (or service) but I cannot find the relevant api to specify that.

I will be most grateful to any pointers.

Look forward to hearing from you

Kind regards
Mahendra

Parents
  • Hi Mahendra, 

    Currently our stack doesn't have an option to set the key size requirement for each attribute. You can set the security level but not the key size, by the stack. 

    What you need to do is to handle that by the application.

    You can return BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE ( not BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC_KEY_SIZE as it's for L2CAP channel )  when there is an authorized read request or write request. 

Reply
  • Hi Mahendra, 

    Currently our stack doesn't have an option to set the key size requirement for each attribute. You can set the security level but not the key size, by the stack. 

    What you need to do is to handle that by the application.

    You can return BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE ( not BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC_KEY_SIZE as it's for L2CAP channel )  when there is an authorized read request or write request. 

Children
Related