BLE-Stack APIs  3.00.00
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
sm.h File Reference

Detailed Description

This file contains the interface to the SM.


Go to the source code of this file.

Data Structures

struct  authReq_t
 
struct  keyDist_t
 
struct  smDhKeyEvt_t
 
struct  smEccKeys_t
 
struct  smEccKeysEvt_t
 
struct  smEventHdr_t
 
struct  smIdentityInfo_t
 
struct  smLinkSecurityReq_t
 
struct  smNewRandKeyEvent_t
 
struct  smSecurityInfo_t
 
struct  smSigningInfo_t
 

Macros

#define DISPLAY_ONLY   0x00
 Display Only Device.
 
#define DISPLAY_YES_NO   0x01
 Display and Yes and No Capable.
 
#define KEYBOARD_DISPLAY   0x04
 Both Keyboard and Display Capable.
 
#define KEYBOARD_ONLY   0x02
 Keyboard Only.
 
#define NO_INPUT_NO_OUTPUT   0x03
 No Display or Input Device.
 
#define PASSKEY_LEN   6
 
#define SM_AUTH_MITM_MASK(a)   (((a) & 0x04) >> 2)
 
#define SM_AUTH_REQ_BONDING   0x01
 Bonding.
 
#define SM_AUTH_REQ_NO_BONDING   0x00
 No bonding.
 
#define SM_AUTH_STATE_AUTHENTICATED   0x04
 
#define SM_AUTH_STATE_BONDING   0x01
 
#define SM_AUTH_STATE_SECURECONNECTION   0x08
 
#define SM_DH_KEY_EVENT   0x01
 
#define SM_ECC_KEY_LEN   32
 
#define SM_ECC_KEYS_EVENT   0x00
 
#define SM_ECC_KEYS_NOT_AVAILABLE   0xFF
 
#define SM_ECC_KEYS_REGENERATE_ALWAYS   0x00
 
#define SM_ECC_KEYS_REGNENERATE_NEVER   0xFF
 
#define SM_PASSKEY_TYPE_DISPLAY   0x02
 Display the passkey.
 
#define SM_PASSKEY_TYPE_INPUT   0x01
 Input the passkey.
 

Typedefs

typedef void(* smCB_t )(uint8 *secretKey, uint8 *publicKeyX, uint8 *publicKeyY)
 

Functions

bStatus_t SM_CalcRandomAddr (uint8 *pIRK, uint8 *pNewAddr)
 Calculate a new Private Resolvable address. More...
 
void SM_dhKeyCB (hciEvt_BLEGenDHKeyComplete_t *pDhKey)
 
bStatus_t SM_Encrypt (uint8 *pKey, uint8 *pPlainText, uint8 *pResult)
 Encrypt the plain text data with the key.. More...
 
bStatus_t SM_GenerateAuthenSig (uint8 *pData, uint16 len, uint8 *pAuthenSig)
 Generate an outgoing Authentication Signature. More...
 
bStatus_t SM_GetDHKey (uint8 *secretKey, uint8 *publicKeyX, uint8 *publicKeyY)
 
bStatus_t SM_GetEccKeys (void)
 Get ECC private and public keys. Keys are returned through the callback registered in SM_RegisterCb. More...
 
bStatus_t SM_GetScConfirmOob (uint8 *publicKey, uint8 *oob, uint8 *pOut)
 
void SM_Init (uint8 task_id)
 
bStatus_t SM_InitiatorInit (void)
 Initialize SM Initiator on a master device. More...
 
bStatus_t SM_NewRandKey (uint8 taskID)
 Generate a key with a random value. More...
 
void SM_p256KeyCB (hciEvt_BLEReadP256PublicKeyComplete_t *pK, uint8 *privateKey)
 
bStatus_t SM_PasskeyUpdate (uint8 *pPasskey, uint16 connectionHandle)
 Update the passkey for the pairing process. More...
 
uint16 SM_ProcessEvent (uint8 task_id, uint16 events)
 
void SM_RegisterTask (uint8 taskID)
 
bStatus_t SM_ResolveRandomAddrs (uint8 *pIRK, uint8 *pAddr)
 Resolve a Private Resolvable Address. More...
 
bStatus_t SM_ResponderInit (void)
 Initialize SM Responder on a slave device. More...
 
void SM_SetECCRegenerationCount (uint8 count)
 Update the regeneration count for ECC key re-usage. More...
 
bStatus_t SM_StartEncryption (uint16 connHandle, uint8 *pLTK, uint16 div, uint8 *pRandNum, uint8 keyLen)
 Send Start Encrypt through HCI. More...
 
bStatus_t SM_StartPairing (uint8 initiator, uint8 taskID, uint16 connectionHandle, smLinkSecurityReq_t *pSecReqs)
 Start the pairing process. This function is also called if the device is already bound. More...
 
bStatus_t SM_VerifyAuthenSig (uint16 connHandle, uint8 authentication, uint8 *pData, uint16 len, uint8 *pAuthenSig)
 Verify an Authentication Signature. More...
 

Typedef Documentation

typedef void(* smCB_t)(uint8 *secretKey, uint8 *publicKeyX, uint8 *publicKeyY)

Application callback to the SM for ECC keys and Diffie-Hellman Shared Secret (ECDH).

Function Documentation

bStatus_t SM_CalcRandomAddr ( uint8 *  pIRK,
uint8 *  pNewAddr 
)

Calculate a new Private Resolvable address.

Parameters
pIRK- Identity Root Key.
pNewAddr- pointer to place to put new calc'd address
Returns
SUCCESS - if started,
INVALIDPARAMETER
bStatus_t SM_Encrypt ( uint8 *  pKey,
uint8 *  pPlainText,
uint8 *  pResult 
)

Encrypt the plain text data with the key..

Parameters
pKey- key data
pPlainText- Plain text data
pResult- place to put the encrypted result
Returns
SUCCESS - if started,
INVALIDPARAMETER - one of the parameters are NULL,
bleAlreadyInRequestedMode,
bleMemAllocError
bStatus_t SM_GenerateAuthenSig ( uint8 *  pData,
uint16  len,
uint8 *  pAuthenSig 
)

Generate an outgoing Authentication Signature.

Parameters
pData- message data
len- length of pData
pAuthenSig- place to put new signature
Returns
SUCCESS - signature authentication generated,
INVALIDPARAMETER - pData or pAuthenSig is NULL,
bleMemAllocError
bStatus_t SM_GetEccKeys ( void  )

Get ECC private and public keys. Keys are returned through the callback registered in SM_RegisterCb.

Returns
SUCCESS if processing, FAILURE if SM is pairing or
HCI_ERROR_CODE_MEM_CAP_EXCEEDED if out of heap memory.
bStatus_t SM_InitiatorInit ( void  )

Initialize SM Initiator on a master device.

Returns
SUCCESS
bStatus_t SM_NewRandKey ( uint8  taskID)

Generate a key with a random value.

Parameters
taskID- task ID to send results.
Returns
SUCCESS,
bleNotReady,
bleMemAllocError,
FAILURE
bStatus_t SM_PasskeyUpdate ( uint8 *  pPasskey,
uint16  connectionHandle 
)

Update the passkey for the pairing process.

Parameters
pPasskey- pointer to the 6 digit passkey
connectionHandle- connection handle to link.
Returns
SUCCESS,
bleIncorrectMode - Not pairing,
INVALIDPARAMETER - link is incorrect
bStatus_t SM_ResolveRandomAddrs ( uint8 *  pIRK,
uint8 *  pAddr 
)

Resolve a Private Resolvable Address.

Parameters
pIRK- pointer to the IRK
pAddr- pointer to the random address
Returns
SUCCESS - match,
FAILURE - don't match,
INVALIDPARAMETER - parameters invalid
bStatus_t SM_ResponderInit ( void  )

Initialize SM Responder on a slave device.

Returns
SUCCESS
void SM_SetECCRegenerationCount ( uint8  count)

Update the regeneration count for ECC key re-usage.

Parameters
count- number of times a keypair can be reused before regeneration.
Returns
None
bStatus_t SM_StartEncryption ( uint16  connHandle,
uint8 *  pLTK,
uint16  div,
uint8 *  pRandNum,
uint8  keyLen 
)

Send Start Encrypt through HCI.

Parameters
connHandle- Connection Handle
pLTK- pointer to 16 byte lkt
div- div or ediv
pRandNum- pointer to 8 byte random number
keyLen- length of LTK (bytes)
Returns
SUCCESS,
INVALIDPARAMETER,
other from HCI/LL
bStatus_t SM_StartPairing ( uint8  initiator,
uint8  taskID,
uint16  connectionHandle,
smLinkSecurityReq_t pSecReqs 
)

Start the pairing process. This function is also called if the device is already bound.

NOTE: Only one pairing process at a time per device.

Parameters
initiator- TRUE to start pairing as Initiator.
taskID- task ID to send results.
connectionHandle- Link's connection handle
pSecReqs- Security parameters for pairing
Returns
SUCCESS,
INVALIDPARAMETER,
bleAlreadyInRequestedMode
bStatus_t SM_VerifyAuthenSig ( uint16  connHandle,
uint8  authentication,
uint8 *  pData,
uint16  len,
uint8 *  pAuthenSig 
)

Verify an Authentication Signature.

Parameters
connHandle- connection to verify against.
authentication- TRUE if requires an authenticated CSRK, FALSE if not
pData- message data
len- length of pData
pAuthenSig- message signature to verify
Returns
SUCCESS - signature authentication verified,
FAILURE - if not verified,
bleNotConnected - Connection not found,
INVALIDPARAMETER - pData or pAuthenSig is NULL, or signCounter is invalid,
bleMemAllocError
Copyright 2016, Texas Instruments Incorporated