BlueHeron.SMP (blue_heron v0.4.1) View Source

A behaviour module for implementing BLE Security Manager Protocol.

Link to this section Summary

Functions

Bluetooth LE c1() key generation function.

Returns a specification to start this module under a supervisor.

Diversifying function d1

Mask generation function dm

Inform the Security Manager about changes in the encryption.

Link key conversion function

Returns true if the current connection is authenticated.

Handle Long Term Key Request event.

Bluetooth LE s1() key generation function.

Set connection information.

Link to this section Functions

Link to this function

c1(k, r, preq, pres, iat, rat, ia, ra)

View Source

Bluetooth LE c1() key generation function.

The function parameters can be encoded by the following example:

k is the random generated TK displayed on the device r is the random number generated by the SM preq is the data exchanged during pairing request pres is the data exchanged during pairing response iat is the initaitors device type (0x00 or 0x01) rat is the receiver device type (0x00 or 0x01) ia is the initaitors device address ra is the receiver device address

Example from BLE specifications:

k = <<0::integer-size(128)>> r = <<0x57, 0x83, 0xD5, 0x21, 0x56, 0xAD, 0x6F, 0x0E, 0x63, 0x88, 0x27, 0x4E, 0xC6, 0x70, 0x2E, 0xE0>> ia = <<0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6>> ra = <<0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6>> iat = 1 rat = 0 pres = <<0x05, 0x00, 0x08, 0x00, 0x00, 0x03, 0x02>> preq = <<0x07, 0x07, 0x10, 0x00, 0x00, 0x01, 0x01>> <<0x1E, 0x1E, 0x3F, 0xEF, 0x87, 0x89, 0x88, 0xEA, 0xD2, 0xA7, 0x4D, 0xC5, 0xBE, 0xF1, 0x3B, 0x86>> = BlueHeron.SMP.Server.c1(k, r, preq, pres, iat, rat, ia, ra)

Returns a specification to start this module under a supervisor.

See Supervisor.

Diversifying function d1

Mask generation function dm

Link to this function

encryption_change(smp, event)

View Source

Inform the Security Manager about changes in the encryption.

Link key conversion function

The function h6 is used to convert keys of a given size from one key type to another key type with equivalent strength. The definition of the h6 function makes use of the hashing function AES- CMAC W with 128-bit key W.

Exmple test vectors from Bluetooth spec:

w = Base.decode16!("EC0234A357C8AD05341010A60A397D9B") key_id = Base.decode16!("6C656272") # ASCII "lebr" "2D9AE102E76DC91CE8D3A9E280B16399" = Base.encode16(BlueHeron.SMP.Server.h6(w, key_id)

Returns true if the current connection is authenticated.

Link to this function

long_term_key_request(smp, msg)

View Source

Handle Long Term Key Request event.

This function returns a Long Term Key Request Response or nil.

Bluetooth LE s1() key generation function.

k is the random generated TK displayed on the device r1 is the random generated by the responding device r2 is the random generated by the initiating device

Example from BLE specifictation:

k = <<0::integer-size(128)>> r1 = Base.decode16!("000F0E0D0C0B0A091122334455667788") r2 = Base.decode16!("010203040506070899AABBCCDDEEFF00") "9A1FE1F0E8B0F49B5B4216AE796DA062" = Base.encode16(BlueHeron.SMP.Server.s1(k, r1, r2))

Link to this function

set_bd_address(smp, addr)

View Source

Set BR_ADDR.

Link to this function

set_connection(smp, con)

View Source

Set connection information.

The information is needed for key generation.