STM32WB-WBA Filter Accept List

Revision as of 11:52, 30 March 2022 by Registered User (Copied from Connectivity:STM32WB - BLE security, revision 20453)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Under construction.png Coming soon

1. STM32WB - BLE security

Vocabulary and BLE security configuration. Legacy Pairing and Secure Connection

The BLE security model includes 5 security features:

  • Pairing: process for creating one or more shared secret keys.
  • Bonding: act of storing the keys created during pairing for use in subsequent connections in order to form a trusted device pair.
  • Device authentication: verification that the two devices have the same keys.
  • Encryption: provides message confidentiality.
  • Message integrity: protects against fake messages.(4 bytes Message Integrity Check MIC)

BLE uses 2 security levels:

  • Legacy Pairing – Short Temporary Key (STK). STK will be created to encrypt connection. Then, if bonding, LTK will be used for subsequent connections.
  • Secure Connection – Long Term Key (LTK). LTK will be created to encrypt connection.

Initialization (when no link is established)

Set the IO capability of the device with aci_gap_set_io_capability

  • Parameter: IO capability
0x00: IO_CAP_DISPLAY_ONLY
0x01: IO_CAP_DISPLAY_YES_NO
0x02: IO_CAP_KEYBOARD_ONLY
0x03: IO_CAP_NO_INPUT_NO_OUTPUT
0x04: IO_CAP_KEYBOARD_DISPLAY

Set the authentication requirements for the device with aci_gap_set_authentication_req

  • Parameters: Bonding_mode
0x00: No-bonding mode
0x01: Bonding mode
  • mitm_mode
0x00: MITM protection not required
0x01: MITM protection required
  • sc_support
0x00: Secure Connections Pairing not supported
0x01: Secure Connections Pairing supported but optional
0x02: Secure Connections Pairing supported and mandatory (SC Only Mode)
  • keypress notification
0x00: Keypress notification not supported
0x01: Keypress notification supported
  • min_encryption_key_size
Minimum encryption key size to be used during pairing
  • max_encryption_key_size
Maximum encryption key size to be used during pairing
  • use_fixed_pin
0x00: use a fixed pin
0x01: do not use a fixed pin
  • fixed_pin
0 ... 999999
  • identity_address_type
0x00: Public Identity Address
0x01: Random (static) Identity Address

1.1. Legacy pairing and no fixed pin

aci_gap_set_io_capability(0x04) (IO_CAP_KEYBOARD_DISPLAY)

aci_gap_set_authentication_req(0,1,0,0,7,16,1,111111,0)

(no bonding, MITM, secure connection pairing not supported, keypress notification not supported, min encryption key size, max encryption key size, no use of fixed pin, fixed pin (not used), public address type)


1.2. Legacy pairing and fixed pin

initiated by the peripheral

aci_gap_set_io_capability(0x00) (IO_CAP_DISPLAY_ONLY)

aci_gap_set_authentication_req(0,0,0,0,7,16,0 (use fixed pin), 111111 (used fixed pin),0)

(no bonding, no MITM, secure connection pairing not supported, keypress notification not supported, min encryption key size, max encryption key size, use of fixed pin, fixed pin (used), public address type)


1.3. Secure connection

aci_gap_set_io_capability(0x04) (IO_CAP_KEYBOARD_DISPLAY)

aci_gap_set_authentication_req(0,1,1,1,7,16,1,111111, 0)

(no bonding, MITM, secure connection pairing not supported, keypress notification not supported, min encryption key size, max encryption key size, no use of fixed pin, fixed pin (not used), public address type)

2. Additional information - BLE characteristics and security permissions

2.1. STM32WB - BLE GATT characteristic

When a characteristic is created (aci_gatt_add_char), following security permissions could be given:

  • 0x00: none
  • 0x01: AUTHEN_READ (need authentication to read)
  • 0x02: AUTHOR_READ (need authorization to read)
  • 0x04: ENCRY_READ (need encryption to read)
  • 0x08: AUTHEN_WRITE (need authentication to write)
  • 0x10: AUTHOR_WRITE (need authorization to write)
  • 0x20: ENCRY_WRITE (need encryption to write)

2.1.1. READ and WRITE properties

A characteristic is created with properties READ and WRITE

2.2. AUTHEN_READ and AUTHEN_WRITE security permissions

After the discovery of services and characteristics, if the client tries to read or write this characteristic, an error is returned (ACI_GATT_ERROR_RESP_EVENT) with error_code=0x05 (insufficient authentication)

Set MITM (in aci_gap_set_authentication_requirement) is necessary and need of start pairing to be able to read/write the characteristic with 'need authentication' permissions.

Security permission 'need authentication' is more restrictive than 'need encryption'.

2.3. ENCRY_READ and ENCRY_WRITE security permissions

After the discovery of service and characteristic, if the client tries to read or write this characteristic, an error is returned (ACI_GATT_ERROR_RESP_EVENT) with error_code=0x0F (insufficient encryption)

If the devices are paired and encryption is started, read and write operations can be done. No need to set MITM and need of starting pairing to be able to read/write the characteristic with 'need encryption' permissions

2.4. AUTHOR_READ and AUTHOR_WRITE security permissions

The way to use characteristic with 'need authorization' permissions: after the connection_complete_event, the server sends the command aci_gap_set_authorization_requirement (for current connection handle) the master initiates pairing. When the pairing is complete, ACI_GAP_AUTHORIZATION_REQ_EVENT is generated on server side which sends aci_gap_authorization_resp(conn_handle, authorize) then the client can read/write the characteristic.

2.5. References