BLE Secure
This module includes functions that control BLE Secure (TLS over BLE) communication.
Summary
This module includes functions that implement TCAT communication.
The functions in this module are available when BLE Secure API feature (OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
) is enabled.
The functions in this module are available when TCAT feature (OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
) is enabled.
Typedefs |
|
---|---|
otHandleBleSecureConnect)(otInstance *aInstance, bool aConnected, bool aBleConnectionOpen, void *aContext)
|
typedefvoid(*
Pointer to call when ble secure connection state changes. |
otHandleBleSecureReceive
|
typedef Pointer to call when data was received over a BLE Secure TLS connection. |
otHandleTcatApplicationDataReceive)(otInstance *aInstance, const otMessage *aMessage, int32_t aOffset, otTcatApplicationProtocol aTcatApplicationProtocol, void *aContext)
|
typedefvoid(*
Pointer to call when application data or vendor-specific data was received over a TCAT TLS connection. |
otHandleTcatJoin)(otError aError, void *aContext)
|
typedefvoid(*
Pointer to call to notify the completion of a network join/leave operation performed under guidance of a TCAT Commissioner. |
otTcatAdvertisedDeviceId
|
typedefstruct otTcatAdvertisedDeviceId
|
otTcatAdvertisedDeviceIdType
|
typedef Represents Advertised Device ID type. |
otTcatApplicationProtocol
|
typedef Represents TCAT application protocol options. |
otTcatCommandClass
|
typedefenum otTcatCommandClass
Represents a TCAT command class. |
otTcatGeneralDeviceId
|
typedefstruct otTcatGeneralDeviceId
Represents General Device ID type. |
otTcatStatusCode
|
typedefenum otTcatStatusCode
Represents TCAT status code. |
otTcatVendorInfo
|
typedefstruct otTcatVendorInfo
This structure represents a TCAT vendor information. |
Functions |
|
---|---|
otBleSecureConnect(otInstance *aInstance)
|
Initializes TLS session with a peer using an already open BLE connection.
|
otBleSecureDisconnect(otInstance *aInstance)
|
void
Stops the BLE and TLS connections.
|
otBleSecureFlush(otInstance *aInstance)
|
Flushes the send buffer.
|
otBleSecureGetInstallCodeVerifyStatus(otInstance *aInstance)
|
bool
Gets the Install Code Verify Status during the current session.
|
otBleSecureGetPeerCertificateBase64(otInstance *aInstance, unsigned char *aPeerCert, size_t *aCertLength)
|
Returns the peer x509 certificate base64 encoded.
|
otBleSecureGetPeerCertificateDer(otInstance *aInstance, unsigned char *aPeerCert, size_t *aCertLength)
|
Returns the DER encoded peer x509 certificate.
|
otBleSecureGetPeerSubjectAttributeByOid(otInstance *aInstance, const char *aOid, size_t aOidLength, uint8_t *aAttributeBuffer, size_t *aAttributeLength, int *aAsn1Type)
|
Returns an attribute value identified by its OID from the subject of the peer x509 certificate.
|
otBleSecureGetThreadAttributeFromOwnCertificate(otInstance *aInstance, int aThreadOidDescriptor, uint8_t *aAttributeBuffer, size_t *aAttributeLength)
|
Returns an attribute value for the OID 1.3.6.1.4.1.44970.x from the v3 extensions of the own x509 certificate, where the last digit x is set to aThreadOidDescriptor.
|
otBleSecureGetThreadAttributeFromPeerCertificate(otInstance *aInstance, int aThreadOidDescriptor, uint8_t *aAttributeBuffer, size_t *aAttributeLength)
|
Returns an attribute value for the OID 1.3.6.1.4.1.44970.x from the v3 extensions of the peer x509 certificate, where the last digit x is set to aThreadOidDescriptor.
|
otBleSecureIsCommandClassAuthorized(otInstance *aInstance, otTcatCommandClass aCommandClass)
|
bool
Indicates whether or not a TCAT command class is authorized for the current TCAT Commissioner.
|
otBleSecureIsConnected(otInstance *aInstance)
|
bool
Indicates whether or not the TLS session is connected.
|
otBleSecureIsConnectionActive(otInstance *aInstance)
|
bool
Indicates whether or not the TLS session is active (connected or connecting).
|
otBleSecureIsTcatAgentStarted(otInstance *aInstance)
|
bool
Indicates whether or not the TCAT agent is started over BLE secure.
|
otBleSecureSend(otInstance *aInstance, uint8_t *aBuf, uint16_t aLength)
|
Sends a secure BLE data packet.
|
otBleSecureSendApplicationTlv(otInstance *aInstance, otTcatApplicationProtocol aApplicationProtocol, uint8_t *aBuf, uint16_t aLength)
|
Sends a secure BLE data packet containing application data directed to the application layer
aApplicationProtocol or a response to the latest received application data packet. |
otBleSecureSendMessage(otInstance *aInstance, otMessage *aMessage)
|
Sends a secure BLE message.
|
otBleSecureSetCaCertificateChain(otInstance *aInstance, const uint8_t *aX509CaCertificateChain, uint32_t aX509CaCertChainLength)
|
void
Sets the trusted top level CAs.
|
otBleSecureSetCertificate(otInstance *aInstance, const uint8_t *aX509Cert, uint32_t aX509Length, const uint8_t *aPrivateKey, uint32_t aPrivateKeyLength)
|
void
Sets the local device's X509 certificate and corresponding private key.
|
otBleSecureSetPsk(otInstance *aInstance, const uint8_t *aPsk, uint16_t aPskLength, const uint8_t *aPskIdentity, uint16_t aPskIdLength)
|
void
Sets the Pre-Shared Key (PSK) and cipher suite TLS_PSK_WITH_AES_128_CCM_8.
|
otBleSecureSetSslAuthMode(otInstance *aInstance, bool aVerifyPeerCertificate)
|
void
Sets the authentication mode for the BLE secure connection.
|
otBleSecureSetTcatAgentState(otInstance *aInstance, bool aActive, uint32_t aDelayMs, uint32_t aDurationMs)
|
Sets the TCAT agent over BLE Secure into active or standby state.
|
otBleSecureSetTcatVendorInfo(otInstance *aInstance, const otTcatVendorInfo *aVendorInfo)
|
Sets TCAT vendor info.
|
otBleSecureStart(otInstance *aInstance, otHandleBleSecureConnect aConnectHandler, otHandleBleSecureReceive aReceiveHandler, bool aTlvMode, void *aContext)
|
Starts the BLE Secure service.
|
otBleSecureStop(otInstance *aInstance)
|
void
Stops the BLE Secure server.
|
otBleSecureTcatStart(otInstance *aInstance, otHandleTcatJoin aJoinHandler)
|
Enables the TCAT protocol over BLE Secure.
|
Macros |
|
---|---|
OT_TCAT_ADVERTISEMENT_MAX_LEN 29
|
Maximum length of TCAT advertisement.
|
OT_TCAT_APPLICATION_LAYER_MAX_COUNT 4
|
Maximum number of application layer service names supported.
|
OT_TCAT_MAX_ADVERTISED_DEVICEID_SIZE 5
|
TCAT max size of any type of advertised Device ID.
|
OT_TCAT_MAX_DEVICEID_SIZE 64
|
TCAT max size of device ID.
|
OT_TCAT_OPCODE 0x2
|
TCAT Advertisement Operation Code.
|
OT_TCAT_SERVICE_NAME_MAX_LENGTH 15
|
Maximum string length of a UDP or TCP service name (does not include null char).
|
Structs |
|
---|---|
otTcatAdvertisedDeviceId | |
otTcatGeneralDeviceId |
Represents General Device ID type. |
otTcatVendorInfo |
This structure represents a TCAT vendor information. |
Enumerations
otTcatAdvertisedDeviceIdType
otTcatAdvertisedDeviceIdType
Represents Advertised Device ID type.
Used during TCAT advertisement.
otTcatApplicationProtocol
otTcatApplicationProtocol
Represents TCAT application protocol options.
otTcatCommandClass
otTcatCommandClass
Represents a TCAT command class.
otTcatStatusCode
otTcatStatusCode
Represents TCAT status code.
Typedefs
otHandleBleSecureConnect
void(* otHandleBleSecureConnect)(otInstance *aInstance, bool aConnected, bool aBleConnectionOpen, void *aContext)
Pointer to call when ble secure connection state changes.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
otHandleBleSecureReceive
otHandleTcatApplicationDataReceive otHandleBleSecureReceive
Pointer to call when data was received over a BLE Secure TLS connection.
When TCAT has been started, the TCAT agent automatically responds with status OT_TCAT_STATUS_UNSUPPORTED if no response has been generated or no handler is defined. The application may generate a response to incoming TCAT application data or vendor-specific data by calling otBleSecureSendApplicationTlv.
otHandleTcatApplicationDataReceive
void(* otHandleTcatApplicationDataReceive)(otInstance *aInstance, const otMessage *aMessage, int32_t aOffset, otTcatApplicationProtocol aTcatApplicationProtocol, void *aContext)
Pointer to call when application data or vendor-specific data was received over a TCAT TLS connection.
The application may generate a response to an incoming TCAT application data packet. The TCAT agent automatically responds with status OT_TCAT_STATUS_UNSUPPORTED if no response has been generated or no handler is defined.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
otHandleTcatJoin
void(* otHandleTcatJoin)(otError aError, void *aContext)
Pointer to call to notify the completion of a network join/leave operation performed under guidance of a TCAT Commissioner.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otTcatAdvertisedDeviceId
struct otTcatAdvertisedDeviceId otTcatAdvertisedDeviceId
otTcatAdvertisedDeviceIdType
enum otTcatAdvertisedDeviceIdType otTcatAdvertisedDeviceIdType
Represents Advertised Device ID type.
Used during TCAT advertisement.
otTcatApplicationProtocol
enum otTcatApplicationProtocol otTcatApplicationProtocol
Represents TCAT application protocol options.
otTcatGeneralDeviceId
struct otTcatGeneralDeviceId otTcatGeneralDeviceId
Represents General Device ID type.
otTcatVendorInfo
struct otTcatVendorInfo otTcatVendorInfo
This structure represents a TCAT vendor information.
The content of this structure MUST persist and remain unchanged while a TCAT session is running.
Functions
otBleSecureConnect
otError otBleSecureConnect( otInstance *aInstance )
Initializes TLS session with a peer using an already open BLE connection.
Details | |||
---|---|---|---|
Parameters |
|
||
Return Values |
|
otBleSecureDisconnect
void otBleSecureDisconnect( otInstance *aInstance )
Stops the BLE and TLS connections.
Details | |||
---|---|---|---|
Parameters |
|
otBleSecureFlush
otError otBleSecureFlush( otInstance *aInstance )
Flushes the send buffer.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otBleSecureGetInstallCodeVerifyStatus
bool otBleSecureGetInstallCodeVerifyStatus( otInstance *aInstance )
Gets the Install Code Verify Status during the current session.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otBleSecureGetPeerCertificateBase64
otError otBleSecureGetPeerCertificateBase64( otInstance *aInstance, unsigned char *aPeerCert, size_t *aCertLength )
Returns the peer x509 certificate base64 encoded.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otBleSecureGetPeerCertificateDer
otError otBleSecureGetPeerCertificateDer( otInstance *aInstance, unsigned char *aPeerCert, size_t *aCertLength )
Returns the DER encoded peer x509 certificate.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otBleSecureGetPeerSubjectAttributeByOid
otError otBleSecureGetPeerSubjectAttributeByOid( otInstance *aInstance, const char *aOid, size_t aOidLength, uint8_t *aAttributeBuffer, size_t *aAttributeLength, int *aAsn1Type )
Returns an attribute value identified by its OID from the subject of the peer x509 certificate.
The peer OID is provided in binary format. The attribute length is set if the attribute was successfully read or zero if unsuccessful. The ASN.1 type as is set as defineded in the ITU-T X.690 standard if the attribute was successfully read.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Return Values |
|
otBleSecureGetThreadAttributeFromOwnCertificate
otError otBleSecureGetThreadAttributeFromOwnCertificate( otInstance *aInstance, int aThreadOidDescriptor, uint8_t *aAttributeBuffer, size_t *aAttributeLength )
Returns an attribute value for the OID 1.3.6.1.4.1.44970.x from the v3 extensions of the own x509 certificate, where the last digit x is set to aThreadOidDescriptor.
The attribute length is set if the attribute was successfully read or zero if unsuccessful. Requires a connection to be active.
Details | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||||
Return Values |
|
otBleSecureGetThreadAttributeFromPeerCertificate
otError otBleSecureGetThreadAttributeFromPeerCertificate( otInstance *aInstance, int aThreadOidDescriptor, uint8_t *aAttributeBuffer, size_t *aAttributeLength )
Returns an attribute value for the OID 1.3.6.1.4.1.44970.x from the v3 extensions of the peer x509 certificate, where the last digit x is set to aThreadOidDescriptor.
The attribute length is set if the attribute was successfully read or zero if unsuccessful. Requires a connection to be active.
Details | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||||
Return Values |
|
otBleSecureIsCommandClassAuthorized
bool otBleSecureIsCommandClassAuthorized( otInstance *aInstance, otTcatCommandClass aCommandClass )
Indicates whether or not a TCAT command class is authorized for the current TCAT Commissioner.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otBleSecureIsConnected
bool otBleSecureIsConnected( otInstance *aInstance )
Indicates whether or not the TLS session is connected.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otBleSecureIsConnectionActive
bool otBleSecureIsConnectionActive( otInstance *aInstance )
Indicates whether or not the TLS session is active (connected or connecting).
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otBleSecureIsTcatAgentStarted
bool otBleSecureIsTcatAgentStarted( otInstance *aInstance )
Indicates whether or not the TCAT agent is started over BLE secure.
Details | |||||
---|---|---|---|---|---|
Return Values |
|
otBleSecureSend
otError otBleSecureSend( otInstance *aInstance, uint8_t *aBuf, uint16_t aLength )
Sends a secure BLE data packet.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Return Values |
|
otBleSecureSendApplicationTlv
otError otBleSecureSendApplicationTlv( otInstance *aInstance, otTcatApplicationProtocol aApplicationProtocol, uint8_t *aBuf, uint16_t aLength )
Sends a secure BLE data packet containing application data directed to the application layer aApplicationProtocol
or a response to the latest received application data packet.
Only a single response can be sent while executing the otHandleBleSecureReceive
handler. If no (further) response is expected OT_ERROR_REJECTED
is returned.
For responses with a payload aApplicationProtocol
shall be set to OT_TCAT_APPLICATION_PROTOCOL_PAYLOAD
. For responses with a status aApplicationProtocol
shall be OT_TCAT_APPLICATION_PROTOCOL_STATUS
and @ aBuf shall contain a single byte otTcatStatusCode
value.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otBleSecureSendMessage
otError otBleSecureSendMessage( otInstance *aInstance, otMessage *aMessage )
Sends a secure BLE message.
If the return value is OT_ERROR_NONE, OpenThread takes ownership of aMessage
, and the caller should no longer reference aMessage
. If the return value is not OT_ERROR_NONE, the caller retains ownership of aMessage
, including freeing aMessage
if the message buffer is no longer needed.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Details | |||||||
---|---|---|---|---|---|---|---|
Return Values |
|
otBleSecureSetCaCertificateChain
void otBleSecureSetCaCertificateChain( otInstance *aInstance, const uint8_t *aX509CaCertificateChain, uint32_t aX509CaCertChainLength )
Sets the trusted top level CAs.
It is needed for validating the certificate of the peer via TLS.
Used for TLS sessions with cipher suite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
otBleSecureSetCertificate
void otBleSecureSetCertificate( otInstance *aInstance, const uint8_t *aX509Cert, uint32_t aX509Length, const uint8_t *aPrivateKey, uint32_t aPrivateKeyLength )
Sets the local device's X509 certificate and corresponding private key.
Used for TLS sessions with cipher suite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
otBleSecureSetPsk
void otBleSecureSetPsk( otInstance *aInstance, const uint8_t *aPsk, uint16_t aPskLength, const uint8_t *aPskIdentity, uint16_t aPskIdLength )
Sets the Pre-Shared Key (PSK) and cipher suite TLS_PSK_WITH_AES_128_CCM_8.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
otBleSecureSetSslAuthMode
void otBleSecureSetSslAuthMode( otInstance *aInstance, bool aVerifyPeerCertificate )
Sets the authentication mode for the BLE secure connection.
Disable or enable the verification of peer certificate. Must be called before start.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
otBleSecureSetTcatAgentState
otError otBleSecureSetTcatAgentState( otInstance *aInstance, bool aActive, uint32_t aDelayMs, uint32_t aDurationMs )
Sets the TCAT agent over BLE Secure into active or standby state.
In standby state, no BLE advertisements are sent and TCAT Commissioners can't connect. TCAT can be automatically enabled via a TMF message while in standby.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
otBleSecureSetTcatVendorInfo
otError otBleSecureSetTcatVendorInfo( otInstance *aInstance, const otTcatVendorInfo *aVendorInfo )
Sets TCAT vendor info.
The vendor info is used for advertising in TCAT Advertisements, as well as for responding to particular TCAT commands that supply vendor info to the TCAT Commissioner.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Return Values |
|
otBleSecureStart
otError otBleSecureStart( otInstance *aInstance, otHandleBleSecureConnect aConnectHandler, otHandleBleSecureReceive aReceiveHandler, bool aTlvMode, void *aContext )
Starts the BLE Secure service.
When TLV mode is active, the function aReceiveHandler
will be called once a complete TLV or line was received and the message offset points to the TLV value.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Return Values |
|
otBleSecureStop
void otBleSecureStop( otInstance *aInstance )
Stops the BLE Secure server.
If the TCAT agent is active, it is also stopped and any ongoing connection is forcibly ended.
Details | |||
---|---|---|---|
Parameters |
|
otBleSecureTcatStart
otError otBleSecureTcatStart( otInstance *aInstance, otHandleTcatJoin aJoinHandler )
Enables the TCAT protocol over BLE Secure.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Return Values |
|
Macros
OT_TCAT_ADVERTISEMENT_MAX_LEN
OT_TCAT_ADVERTISEMENT_MAX_LEN 29
Maximum length of TCAT advertisement.
OT_TCAT_APPLICATION_LAYER_MAX_COUNT
OT_TCAT_APPLICATION_LAYER_MAX_COUNT 4
Maximum number of application layer service names supported.
OT_TCAT_MAX_ADVERTISED_DEVICEID_SIZE
OT_TCAT_MAX_ADVERTISED_DEVICEID_SIZE 5
TCAT max size of any type of advertised Device ID.
OT_TCAT_MAX_DEVICEID_SIZE
OT_TCAT_MAX_DEVICEID_SIZE 64
TCAT max size of device ID.
OT_TCAT_OPCODE
OT_TCAT_OPCODE 0x2
TCAT Advertisement Operation Code.
OT_TCAT_SERVICE_NAME_MAX_LENGTH
OT_TCAT_SERVICE_NAME_MAX_LENGTH 15
Maximum string length of a UDP or TCP service name (does not include null char).
Resources
OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.