BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
bluetoe::link_layer::scheduled_radio_with_encryption< TransmitSize, ReceiveSize, CallBack > Class Template Reference

extension of a scheduled_radio with functions to support encryption More...

#include <bluetoe/link_layer/scheduled_radio.hpp>

Inheritance diagram for bluetoe::link_layer::scheduled_radio_with_encryption< TransmitSize, ReceiveSize, CallBack >:
bluetoe::link_layer::scheduled_radio< TransmitSize, ReceiveSize, CallBack > bluetoe::link_layer::ll_data_pdu_buffer< TransmitSize, ReceiveSize, scheduled_radio< TransmitSize, ReceiveSize, CallBack > >

Public Member Functions

bluetoe::details::uint128_t create_srand ()
 Function to create the Srand according to 2.3.5.5 Part H, Vol 3, Core Spec.
 
bluetoe::details::longterm_key_t create_long_term_key ()
 Function to create a random long term key and random Rand and EDIV values to identify this newly created key.
 
bluetoe::details::uint128_t c1 (const bluetoe::details::uint128_t &temp_key, const bluetoe::details::uint128_t &rand, const bluetoe::details::uint128_t &p1, const bluetoe::details::uint128_t &p2) const
 Confirm value generation function c1 for LE Legacy Pairing.
 
bluetoe::details::uint128_t s1 (const bluetoe::details::uint128_t &temp_key, const bluetoe::details::uint128_t &prand, const bluetoe::details::uint128_t &crand)
 Key generation function s1 for LE Legacy Pairing.
 
std::pair< std::uint64_t, std::uint32_t > setup_encryption (bluetoe::details::uint128_t key, std::uint64_t skdm, std::uint32_t ivm)
 setup the hardware with all data required for encryption
 
bool is_valid_public_key (const std::uint8_t *public_key) const
 
std::pair< bluetoe::details::ecdh_public_key_t, bluetoe::details::ecdh_private_key_t > generate_keys ()
 generate public private key pair for DH
 
bluetoe::details::uint128_t select_random_nonce ()
 random nonce required for LESC pairing
 
bluetoe::details::ecdh_shared_secret_t p256 (const std::uint8_t *private_key, const std::uint8_t *public_key)
 p256() security toolbox function, as specified in the core spec
 
bluetoe::details::uint128_t f4 (const std::uint8_t *u, const std::uint8_t *v, const std::array< std::uint8_t, 16 > &k, std::uint8_t z)
 f4() security toolbox function, as specified in the core spec
 
std::pair< bluetoe::details::uint128_t, bluetoe::details::uint128_t > f5 (const bluetoe::details::ecdh_shared_secret_t dh_key, const bluetoe::details::uint128_t &nonce_central, const bluetoe::details::uint128_t &nonce_periperal, const bluetoe::link_layer::device_address &addr_controller, const bluetoe::link_layer::device_address &addr_peripheral)
 f5() security toolbox function, as specified in the core spec
 
bluetoe::details::uint128_t f6 (const bluetoe::details::uint128_t &key, const bluetoe::details::uint128_t &n1, const bluetoe::details::uint128_t &n2, const bluetoe::details::uint128_t &r, const bluetoe::details::io_capabilities_t &io_caps, const bluetoe::link_layer::device_address &addr_controller, const bluetoe::link_layer::device_address &addr_peripheral)
 f6() security toolbox function, as specified in the core spec
 
std::uint32_t g2 (const std::uint8_t *u, const std::uint8_t *v, const bluetoe::details::uint128_t &x, const bluetoe::details::uint128_t &y)
 g2() security toolbox function, as specified in the core spec
 
bluetoe::details::uint128_t create_passkey ()
 
void start_receive_encrypted ()
 start the encryption of received PDUs with the next connection event.
 
void start_transmit_encrypted ()
 start to encrypt transmitted PDUs with the next connection event.
 
void stop_receive_encrypted ()
 stop receiving encrypted with the next connection event.
 
void stop_transmit_encrypted ()
 stop transmitting encrypted with the next connection event.
 

Static Public Attributes

static constexpr bool hardware_supports_lesc_pairing = false
 indicates the support for LESC pairing
 
static constexpr bool hardware_supports_legacy_pairing = true
 indicates the support for legacy pairing
 
static constexpr bool hardware_supports_encryption = hardware_supports_lesc_pairing || hardware_supports_legacy_pairing
 indication no support for encryption
 

Additional Inherited Members

Detailed Description

template<std::size_t TransmitSize, std::size_t ReceiveSize, typename CallBack>
class bluetoe::link_layer::scheduled_radio_with_encryption< TransmitSize, ReceiveSize, CallBack >

extension of a scheduled_radio with functions to support encryption

To allow the utilization of hardware support for certain cryptographical functions, this interface abstracts at a quite high level.

Member Function Documentation

◆ c1()

template<std::size_t TransmitSize, std::size_t ReceiveSize, typename CallBack >
bluetoe::details::uint128_t bluetoe::link_layer::scheduled_radio_with_encryption< TransmitSize, ReceiveSize, CallBack >::c1 ( const bluetoe::details::uint128_t &  temp_key,
const bluetoe::details::uint128_t &  rand,
const bluetoe::details::uint128_t &  p1,
const bluetoe::details::uint128_t &  p2 
) const

Confirm value generation function c1 for LE Legacy Pairing.

Parameters
temp_keythe temporary key from the LE legacy pairing algorithm
randthe value created by create_srand() or the
p1p1 = pres || preq || rat’ || iat’ (see 2.3.3 Confirm value generation function c1 for LE Legacy Pairing)
p2p2 = padding || ia || ra (see 2.3.3 Confirm value generation function c1 for LE Legacy Pairing)

The function calculates the confirm value based on the peripherals or centrals random value (Srand or Mrand), the temporary key and the data in the pairing request and response.

◆ create_passkey()

template<std::size_t TransmitSize, std::size_t ReceiveSize, typename CallBack >
bluetoe::details::uint128_t bluetoe::link_layer::scheduled_radio_with_encryption< TransmitSize, ReceiveSize, CallBack >::create_passkey ( )

Functions required by IO capabilties

◆ is_valid_public_key()

template<std::size_t TransmitSize, std::size_t ReceiveSize, typename CallBack >
bool bluetoe::link_layer::scheduled_radio_with_encryption< TransmitSize, ReceiveSize, CallBack >::is_valid_public_key ( const std::uint8_t *  public_key) const

features required for LESC

◆ s1()

template<std::size_t TransmitSize, std::size_t ReceiveSize, typename CallBack >
bluetoe::details::uint128_t bluetoe::link_layer::scheduled_radio_with_encryption< TransmitSize, ReceiveSize, CallBack >::s1 ( const bluetoe::details::uint128_t &  temp_key,
const bluetoe::details::uint128_t &  prand,
const bluetoe::details::uint128_t &  crand 
)

Key generation function s1 for LE Legacy Pairing.

The key generation function s1 is used to generate the STK during the LE legacy pairing process.

Parameters
temp_keythe temporary key from the LE legacy pairing algorithm
prandThe peripheral random value (Prand).
crandThe central random value (Crand).

◆ setup_encryption()

template<std::size_t TransmitSize, std::size_t ReceiveSize, typename CallBack >
std::pair< std::uint64_t, std::uint32_t > bluetoe::link_layer::scheduled_radio_with_encryption< TransmitSize, ReceiveSize, CallBack >::setup_encryption ( bluetoe::details::uint128_t  key,
std::uint64_t  skdm,
std::uint32_t  ivm 
)

setup the hardware with all data required for encryption

The encryption is prepaired but not started jet.

Parameters
keylong term or short term key to be used for encryption
skdmThe central's portion of the session key diversifier.
ivmThe IVm field contains the central portion of the initialization vector.

The function returns SKDs and IVs (the peripherals portion of the session key diversifier and initialization vector), to be send to the central.


The documentation for this class was generated from the following file: