TI BLE5-Stack API Documentation  3.03.01.00
gapbondmgr.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Group: WCS, BTS
4  $Target Device: DEVICES $
5 
6  ******************************************************************************
7  $License: BSD3 2010 $
8  ******************************************************************************
9  $Release Name: PACKAGE NAME $
10  $Release Date: PACKAGE RELEASE DATE $
11  *****************************************************************************/
12 
21 #ifndef GAPBONDMGR_H
22 #define GAPBONDMGR_H
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 /*-------------------------------------------------------------------
30  * INCLUDES
31  */
32 #include "gap.h"
33 
34 /*-------------------------------------------------------------------
35  * CONSTANTS
36  */
37 
43 // This is a common file for the legacy and sysconfig examples,
44 // the parameters under ifndef SYSCFG are defined in this file for
45 // the legacy examples and generated using the sysconfig tool for
46 // the sysconfig examples
47 #ifndef SYSCFG
48 #if !defined ( GAP_BONDINGS_MAX )
49 #ifdef CC23X0
51 #define GAP_BONDINGS_MAX 5
52 #else
53 #define GAP_BONDINGS_MAX 10
54 #endif // CC23X0
55 #endif
56 
57 
58 #if !defined ( GAP_CHAR_CFG_MAX )
59 #define GAP_CHAR_CFG_MAX 4
61 #endif
62 #endif //SYSCFG
63 
83 #define GAPBOND_PAIRING_MODE 0x400
84 
94 #define GAPBOND_MITM_PROTECTION 0x402
95 
105 #define GAPBOND_IO_CAPABILITIES 0x403
106 
116 #define GAPBOND_OOB_ENABLED 0x404
117 
128 #define GAPBOND_OOB_DATA 0x405
129 
139 #define GAPBOND_BONDING_ENABLED 0x406
140 
153 #define GAPBOND_KEY_DIST_LIST 0x407
154 
160 #define GAPBOND_ERASE_ALLBONDS 0x409
161 
163 #define GAPBOND_AUTO_FAIL_PAIRING 0x40A
164 #define GAPBOND_AUTO_FAIL_REASON 0x40B
165 
176 #define GAPBOND_KEYSIZE 0x40C
177 
191 #define GAPBOND_AUTO_SYNC_AL 0x40D
192 
200 #define GAPBOND_BOND_COUNT 0x40E
201 
212 #define GAPBOND_BOND_FAIL_ACTION 0x40F
213 
226 #define GAPBOND_ERASE_SINGLEBOND 0x410
227 
241 #define GAPBOND_SECURE_CONNECTION 0x411
242 
261 #define GAPBOND_ECCKEY_REGEN_POLICY 0x412
262 
284 #define GAPBOND_ECC_KEYS 0x413
285 
295 #define GAPBOND_SC_HOST_DEBUG 0x414
296 
313 #define GAPBOND_ERASE_BOND_IN_CONN 0x415
314 
332 #define GAPBOND_ALLOW_DEBUG_KEYS 0x416
333 
347 #define GAPBOND_LRU_BOND_REPLACEMENT 0x418
348 
357 #define GAPBOND_ERASE_LOCAL_INFO 0x41A
358 
368 #define GAPBOND_AUTHEN_PAIRING_ONLY 0x41B
369 
380 #define GAPBOND_SAME_IRK_OPTION 0x41C
381 
393 #define GAPBOND_PAIRING_MODE_NO_PAIRING 0x00
395 #define GAPBOND_PAIRING_MODE_WAIT_FOR_REQ 0x01
397 #define GAPBOND_PAIRING_MODE_INITIATE 0x02
399 
405 #define GAPBOND_IO_CAP_DISPLAY_ONLY 0x00
407 #define GAPBOND_IO_CAP_DISPLAY_YES_NO 0x01
409 #define GAPBOND_IO_CAP_KEYBOARD_ONLY 0x02
411 #define GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT 0x03
413 #define GAPBOND_IO_CAP_KEYBOARD_DISPLAY 0x04
415 
421 #define GAPBOND_KEYDIST_PENCKEY 0x01
423 #define GAPBOND_KEYDIST_PIDKEY 0x02
425 #define GAPBOND_KEYDIST_PSIGN 0x04
427 #define GAPBOND_KEYDIST_PLINK 0x08
429 #define GAPBOND_KEYDIST_CENCKEY 0x10
431 #define GAPBOND_KEYDIST_CIDKEY 0x20
433 #define GAPBOND_KEYDIST_CSIGN 0x40
435 #define GAPBOND_KEYDIST_CLINK 0x80
437 
443 #define GAPBOND_SAME_IRK_UPDATE_BOND_REC 0x00
445 #define GAPBOND_SAME_IRK_TERMINATE_LINK 0x01
447 
483 #define GAP_BOND_REC_ID_OFFSET 0
484 #define GAP_BOND_LOCAL_LTK_OFFSET 1
485 #define GAP_BOND_DEV_LTK_OFFSET 2
486 #define GAP_BOND_DEV_IRK_OFFSET 3
487 #define GAP_BOND_DEV_CSRK_OFFSET 4
488 #define GAP_BOND_DEV_SIGN_COUNTER_OFFSET 5
489 #define GAP_BOND_REC_IDS 6
490 
491 // Bonded State Flags
492 #define GAP_BONDED_STATE_AUTHENTICATED 0x01
493 #define GAP_BONDED_STATE_SERVICE_CHANGED 0x02
494 #define GAP_BONDED_STATE_CAR 0x04
495 #define GAP_BONDED_STATE_SECURECONNECTION 0x08
496 #define GAP_BONDED_STATE_RPA_ONLY 0x10
497 
515 #define GAPBOND_PAIRING_STATE_STARTED 0x00
516 
536 #define GAPBOND_PAIRING_STATE_COMPLETE 0x01
537 
555 #define GAPBOND_PAIRING_STATE_ENCRYPTED 0x02
556 #define GAPBOND_PAIRING_STATE_BOND_SAVED 0x03
558 #define GAPBOND_PAIRING_STATE_CAR_READ 0x04
560 #define GAPBOND_PAIRING_STATE_RPAO_READ 0x05
562 #define GAPBOND_GENERATE_ECC_DONE 0x06
564 
579 #define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01
580 #define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02
582 
586 #define SMP_PAIRING_FAILED_AUTH_REQ 0x03
587 #define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04
589 #define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05
591 
595 #define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06
596 #define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07
598 #define SMP_PAIRING_FAILED_UNSPECIFIED 0x08
600 
604 #define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09
605 
609 #define SMP_PAIRING_FAILED_INVALID_PARAMETERS 0x0A
610 
614 #define SMP_PAIRING_FAILED_DHKEY_CHECK_FAILED 0x0B
615 
619 #define SMP_PAIRING_FAILED_NUM_COMPARISON_FAILED 0x0C
620 
626 #define GAPBOND_FAIL_NO_ACTION 0x00
628 #define GAPBOND_FAIL_INITIATE_PAIRING 0x01
630 #define GAPBOND_FAIL_TERMINATE_LINK 0x02
632 
636 #define GAPBOND_FAIL_TERMINATE_ERASE_BONDS 0x03
637 
641 #define GAPBOND_FAIL_TERMINATE_ERASE_SINGLE_BOND 0x04
642 
648 #define GAPBOND_SECURE_CONNECTION_NONE 0x00
650 #define GAPBOND_SECURE_CONNECTION_ALLOW 0x01
652 #define GAPBOND_SECURE_CONNECTION_ONLY 0x02
654 
664 #define GAPBOND_REGENERATE_ALWAYS 0x00
666 #define GAPBOND_REGENERATE_NEVER 0xFF
668 
670 #define ECC_KEYLEN 32
672 
675 /*-------------------------------------------------------------------
676  * TYPEDEFS
677  */
678 
702 typedef void (*pfnPasscodeCB_t)
703 (
704  uint8_t *deviceAddr,
705  uint16_t connectionHandle,
706  uint8_t uiInputs,
707  uint8_t uiOutputs,
708  uint32_t numComparison
709 );
710 
722 typedef void (*pfnPairStateCB_t)
723 (
724  uint16_t connectionHandle,
725  uint8_t state,
726  uint8_t status
727 );
728 
735 typedef struct
736 {
739 } gapBondCBs_t;
740 
748 typedef struct
750 {
751  uint8_t privateKey[ECC_KEYLEN];
752  uint8_t publicKeyX[ECC_KEYLEN];
753  uint8_t publicKeyY[ECC_KEYLEN];
755 
756 //structure of OOB data
757 typedef struct gapBondOOBData
758 {
759  uint8 confirm[KEYLEN]; //calculated/received confirm value
760  uint8 rand[KEYLEN]; //calculated/received random number
761 } gapBondOOBData_t;
762 
764 typedef struct
765 {
766  uint8_t LTK[KEYLEN]; // Long Term Key (LTK)
767  uint16_t div; //lint -e754 // LTK eDiv
768  uint8_t rand[B_RANDOM_NUM_SIZE]; // LTK random number
769  uint8_t keySize; // LTK key size
770 } gapBondLTK_t;
771 
773 typedef struct
774 {
781  uint8_t addr[B_ADDR_LEN];
791  uint8_t stateFlags;
792 } gapBondRec_t;
793 
795 typedef struct
796 {
797  uint16_t attrHandle; // attribute handle
798  uint8_t value; // attribute value for this device
800 
802 typedef struct
803 {
804  uint8_t pairMode;
805  uint8_t mitm;
806  uint8_t ioCap;
807  uint8_t bonding;
808  uint8_t secureConnection;
809  uint8_t authenPairingOnly;
810  uint8_t autoSyncAL;
811  uint8_t eccReGenPolicy;
812  uint8_t KeySize;
813  uint8_t removeLRUBond;
814  uint8_t KeyDistList;
815  uint8_t eccDebugKeys;
816  uint8_t eraseBondWhileInConn;
817  uint8_t bondFailAction;
818  uint8_t sameIrkAction;
820 
822 /*-------------------------------------------------------------------
823  * API's
824  */
825 
831 extern void GAPBondMgr_Register(gapBondCBs_t *pCB);
832 
849 extern bStatus_t GAPBondMgr_SetParameter(uint16_t param, uint8_t len,
850  void *pValue);
851 
866 extern bStatus_t GAPBondMgr_GetParameter(uint16_t param, void *pValue);
867 
886 extern bStatus_t GAPBondMgr_Pair(uint16_t connHandle);
887 
916 extern bStatus_t GAPBondMgr_FindAddr(uint8_t *pDevAddr,
917  GAP_Peer_Addr_Types_t addrType,
918  uint8_t *pIdx,
919  GAP_Peer_Addr_Types_t *pIdentityAddrType,
920  uint8_t *pIdentityAddr);
921 
934 extern bStatus_t GAPBondMgr_ServiceChangeInd(uint16_t connectionHandle,
935  uint8_t setParam);
936 
951 extern bStatus_t GAPBondMgr_PasscodeRsp(uint16_t connectionHandle,
952  uint8_t status, uint32_t passcode);
953 
964 extern bStatus_t GAPBondMgr_SCGetLocalOOBParameters(gapBondOOBData_t *localOobData);
965 
978 extern bStatus_t GAPBondMgr_SCSetRemoteOOBParameters(gapBondOOBData_t *remoteOobData,
979  uint8 OOBDataFlag);
980 
990 
1007 extern uint8_t gapBondMgrReadBondRec(GAP_Peer_Addr_Types_t addrType,
1008  uint8_t *pDevAddr,
1009  gapBondRec_t *pBondRec,
1010  gapBondLTK_t *pLocalLtk,
1011  gapBondLTK_t *pDevLtk,
1012  uint8_t *pIRK,
1013  uint8_t *pSRK,
1014  uint32_t *signCount,
1015  gapBondCharCfg_t *charCfg);
1016 
1031 extern uint8_t gapBondMgrImportBond(gapBondRec_t *pBondRec,
1032  gapBondLTK_t *pLocalLtk,
1033  gapBondLTK_t *pDevLtk,
1034  uint8_t *pIRK,
1035  uint8_t *pSRK,
1036  uint32_t signCount,
1037  gapBondCharCfg_t *charCfg);
1038 
1055 extern uint8_t GapBondMgr_GetPrevAuth(uint16_t connHandle, uint8_t *pMitmReq, uint8_t *pKeySize);
1056 
1071 extern uint8_t GapBondMgr_StartEnc(uint16_t connHandle);
1072 
1073 /*-------------------------------------------------------------------
1074 -------------------------------------------------------------------*/
1075 #ifdef __cplusplus
1076 }
1077 #endif
1078 
1079 #endif /* GAPBONDMGR_H */
1080 
GAP_Peer_Addr_Types_t
Address types used for specifying peer address type.
Definition: gap.h:727
Public and Private ECC Keys.
Definition: gapbondmgr.h:749
bStatus_t GAPBondMgr_Pair(uint16_t connHandle)
#define B_RANDOM_NUM_SIZE
BLE Random Number Size.
Definition: bcomdef.h:127
Structure of NV data for the connected device's encryption information.
Definition: gapbondmgr.h:764
bStatus_t GAPBondMgr_GenerateEccKeys(void)
Generates ECC keys.
bStatus_t GAPBondMgr_GetParameter(uint16_t param, void *pValue)
bStatus_t GAPBondMgr_PasscodeRsp(uint16_t connectionHandle, uint8_t status, uint32_t passcode)
void(* pfnPairStateCB_t)(uint16_t connectionHandle, uint8_t state, uint8_t status)
Definition: gapbondmgr.h:723
bStatus_t GAPBondMgr_SCGetLocalOOBParameters(gapBondOOBData_t *localOobData)
Get local Random number and confirm value for secure connection.
Structure of NV data for the connected device's address information.
Definition: gapbondmgr.h:773
pfnPasscodeCB_t passcodeCB
Passcode callback.
Definition: gapbondmgr.h:737
bStatus_t GAPBondMgr_FindAddr(uint8_t *pDevAddr, GAP_Peer_Addr_Types_t addrType, uint8_t *pIdx, GAP_Peer_Addr_Types_t *pIdentityAddrType, uint8_t *pIdentityAddr)
Search for an address in the bonding table. If the address is a random private resolvable address...
void GAPBondMgr_Register(gapBondCBs_t *pCB)
Definition: gapbondmgr.h:735
uint8_t gapBondMgrReadBondRec(GAP_Peer_Addr_Types_t addrType, uint8_t *pDevAddr, gapBondRec_t *pBondRec, gapBondLTK_t *pLocalLtk, gapBondLTK_t *pDevLtk, uint8_t *pIRK, uint8_t *pSRK, uint32_t *signCount, gapBondCharCfg_t *charCfg)
Read bond record from NV.
void(* pfnPasscodeCB_t)(uint8_t *deviceAddr, uint16_t connectionHandle, uint8_t uiInputs, uint8_t uiOutputs, uint32_t numComparison)
Definition: gapbondmgr.h:703
uint8_t gapBondMgrImportBond(gapBondRec_t *pBondRec, gapBondLTK_t *pLocalLtk, gapBondLTK_t *pDevLtk, uint8_t *pIRK, uint8_t *pSRK, uint32_t signCount, gapBondCharCfg_t *charCfg)
Import bond record to NV.
Contains part of the GAP Bond Manager Parameters values.
Definition: gapbondmgr.h:802
uint8_t stateFlags
Definition: gapbondmgr.h:791
GAP layer interface.
bStatus_t GAPBondMgr_ServiceChangeInd(uint16_t connectionHandle, uint8_t setParam)
GAP_Peer_Addr_Types_t addrType
Definition: gapbondmgr.h:785
#define B_ADDR_LEN
Default Public and Random Address Length.
Definition: bcomdef.h:102
bStatus_t GAPBondMgr_SetParameter(uint16_t param, uint8_t len, void *pValue)
Status_t bStatus_t
BLE Generic Status return.
Definition: bcomdef.h:246
#define ECC_KEYLEN
ECC Key Length: 256 bit keys.
Definition: gapbondmgr.h:671
bStatus_t GAPBondMgr_SCSetRemoteOOBParameters(gapBondOOBData_t *remoteOobData, uint8 OOBDataFlag)
Set remote's OOB parameters for secure connection.
#define KEYLEN
Default key length.
Definition: bcomdef.h:105
pfnPairStateCB_t pairStateCB
Pairing state callback.
Definition: gapbondmgr.h:738
Structure of NV data for the connected device's characteristic configuration.
Definition: gapbondmgr.h:795
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale