Mistake on this page?
Report an issue in GitHub or email us
smp_sc_main.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief SMP main module header file.
6  *
7  * Copyright (c) 2010-2018 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef SMP_SC_MAIN_H
25 #define SMP_SC_MAIN_H
26 
27 #include "smp_main.h"
28 #include "smp_defs.h"
29 #include "smp_api.h"
30 #include "wsf_trace.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /**************************************************************************************************
37  Macros
38 **************************************************************************************************/
39 
40 #if WSF_TOKEN_ENABLED == TRUE || WSF_TRACE_ENABLED == TRUE
41 #define SMP_TRACE_128(msg, ptr) smpLogByteArray(msg, ptr, 16)
42 #define SMP_TRACE_256(msg, ptr) smpLogByteArray(msg, ptr, 32)
43 #else
44 #define SMP_TRACE_128(msg, ptr)
45 #define SMP_TRACE_256(msg, ptr)
46 #endif
47 
48 /**************************************************************************************************
49  Constants
50 **************************************************************************************************/
51 
52 /* Number of bits in the Passkey */
53 #define SMP_PK_BIT_COUNT 20
54 
55 /**************************************************************************************************
56  Function Declarations
57 **************************************************************************************************/
58 
59 /* common state machine action functions */
60 void smpScActCleanup(smpCcb_t *pCcb, smpMsg_t *pMsg);
61 void smpScActPairingFailed(smpCcb_t *pCcb, smpMsg_t *pMsg);
62 void smpScActPairingCancel(smpCcb_t *pCcb, smpMsg_t *pMsg);
63 void smpScActAuthSelect(smpCcb_t *pCcb, smpMsg_t *pMsg);
64 void smpScActPkSetup(smpCcb_t *pCcb, smpMsg_t *pMsg);
65 void smpScActJwncCalcF4(smpCcb_t *pCcb, smpMsg_t *pMsg);
66 void smpScActJwncCalcG2(smpCcb_t *pCcb, smpMsg_t *pMsg);
67 void smpScActJwncDisplay(smpCcb_t *pCcb, smpMsg_t *pMsg);
68 void smpScActPkKeypress(smpCcb_t *pCcb, smpMsg_t *pMsg);
69 void smpScActPkSendKeypress(smpCcb_t *pCcb, smpMsg_t *pMsg);
70 void smpScActCalcSharedSecret(smpCcb_t *pCcb, smpMsg_t *pMsg);
71 void smpScActCalcF5TKey(smpCcb_t *pCcb, smpMsg_t *pMsg);
72 void smpScActCalcF5MacKey(smpCcb_t *pCcb, smpMsg_t *pMsg);
73 void smpScActCalcF5Ltk(smpCcb_t *pCcb, smpMsg_t *pMsg);
74 void smpScActDHKeyCalcF6Ea(smpCcb_t *pCcb, smpMsg_t *pMsg);
75 void smpScActDHKeyCalcF6Eb(smpCcb_t *pCcb, smpMsg_t *pMsg);
76 
77 /* initiator state machine action functions */
78 void smpiScActSendPubKey(smpCcb_t *pCcb, smpMsg_t *pMsg);
79 void smpiScActAuthSelect(smpCcb_t *pCcb, smpMsg_t *pMsg);
80 void smpiScActJwncSetup(smpCcb_t *pCcb, smpMsg_t *pMsg);
81 void smpiScActJwncSendRand(smpCcb_t *pCcb, smpMsg_t *pMsg);
82 void smpiScActJwncCalcF4(smpCcb_t *pCcb, smpMsg_t *pMsg);
83 void smpiScActJwncCalcG2(smpCcb_t *pCcb, smpMsg_t *pMsg);
84 void smpiScActPkCalcCa(smpCcb_t *pCcb, smpMsg_t *pMsg);
85 void smpiScActPkCalcCb(smpCcb_t *pCcb, smpMsg_t *pMsg);
86 void smpiScActPkSendCnf(smpCcb_t *pCcb, smpMsg_t *pMsg);
87 void smpiScActPkSendRand(smpCcb_t *pCcb, smpMsg_t *pMsg);
88 void smpiScActPkCheck(smpCcb_t *pCcb, smpMsg_t *pMsg);
89 void smpiScActOobCalcCb(smpCcb_t *pCcb, smpMsg_t *pMsg);
90 void smpiScActOobSendRand(smpCcb_t *pCcb, smpMsg_t *pMsg);
91 void smpiScActOobProcRand(smpCcb_t *pCcb, smpMsg_t *pMsg);
92 void smpiScActDHKeyCheckSend(smpCcb_t *pCcb, smpMsg_t *pMsg);
93 void smpiScActDHKeyCheckVerify(smpCcb_t *pCcb, smpMsg_t *pMsg);
94 
95 /* responder state machine action functions */
96 void smprScActStoreLescPin(smpCcb_t *pCcb, smpMsg_t *pMsg);
97 void smprScActSendPubKey(smpCcb_t *pCcb, smpMsg_t *pMsg);
98 void smprScActJwncSetup(smpCcb_t *pCcb, smpMsg_t *pMsg);
99 void smprScActJwncCalcG2(smpCcb_t *pCcb, smpMsg_t *pMsg);
100 void smprScActJwncDisplay(smpCcb_t *pCcb, smpMsg_t *pMsg);
101 void smprScActJwncSendCnf(smpCcb_t *pCcb, smpMsg_t *pMsg);
102 void smprScActPkStoreCnf(smpCcb_t *pCcb, smpMsg_t *pMsg);
103 void smprScActPkStoreCnfAndCalcCb(smpCcb_t *pCcb, smpMsg_t *pMsg);
104 void smprScActPkStorePinAndCalcCb(smpCcb_t *pCcb, smpMsg_t *pMsg);
105 void smprScActPkCalcCb(smpCcb_t *pCcb, smpMsg_t *pMsg);
106 void smprScActPkSendCnf(smpCcb_t *pCcb, smpMsg_t *pMsg);
107 void smprScActPkCalcCa(smpCcb_t *pCcb, smpMsg_t *pMsg);
108 void smprScActPkSendRand(smpCcb_t *pCcb, smpMsg_t *pMsg);
109 void smprScActOobSetup(smpCcb_t *pCcb, smpMsg_t *pMsg);
110 void smprScActOobCalcCa(smpCcb_t *pCcb, smpMsg_t *pMsg);
111 void smprScActOobSendRand(smpCcb_t *pCcb, smpMsg_t *pMsg);
112 void smprScActStoreDhCheck(smpCcb_t *pCcb, smpMsg_t *pMsg);
113 void smprScActWaitDhCheck(smpCcb_t *pCcb, smpMsg_t *pMsg);
114 void smprScActDHKeyCheckSend(smpCcb_t *pCcb, smpMsg_t *pMsg);
115 void smprScActCalcDHKey(smpCcb_t *pCcb, smpMsg_t *pMsg);
116 
117 /* common functions */
118 bool_t SmpScAllocScratchBuffers(smpCcb_t *pCcb);
119 void SmpScFreeScratchBuffers(smpCcb_t *pCcb);
120 bool_t smpScProcPairing(smpCcb_t *pCcb, uint8_t *pOob, uint8_t *pDisplay);
121 void SmpReverseCpy(uint8_t *pBuf1, uint8_t *pBuf2, uint8_t len);
122 void SmpScCmac(const uint8_t *pKey, uint8_t *pText, uint8_t textLen, smpCcb_t *pCcb, smpMsg_t *pMsg);
123 uint8_t *SmpScAlloc(uint8_t size, smpCcb_t *pCcb, smpMsg_t *pMsg);
124 void SmpScFree(uint8_t *pBuf);
125 void SmpScCalcF4(smpCcb_t *pCcb, smpMsg_t *pMsg, uint8_t *pU, uint8_t *pV, uint8_t z, uint8_t *pX);
126 uint8_t *SmpScCat(uint8_t *pDst, const uint8_t *pSrc, uint8_t len);
127 uint8_t *SmpScCat128(uint8_t *pDst, uint8_t *pSrc);
128 uint8_t smpGetPkBit(smpCcb_t *pCcb);
129 smpScPubKey_t *smpGetPeerPublicKey(dmConnId_t connId);
130 void smpSetPeerPublicKey(dmConnId_t connId, smpScPubKey_t *pKey);
131 void SmpScSetOobCfg(dmConnId_t connId, dmSecLescOobCfg_t *pConfig);
132 void smpScAuthReq(smpCcb_t *pCcb, uint8_t oob, uint8_t display);
133 void smpScFailWithReattempt(smpCcb_t *pCcb);
134 void SmpScInit(void);
135 
136 /* common command send functoins */
137 void smpScSendPubKey(smpCcb_t *pCcb, smpMsg_t *pMsg);
138 void smpScSendDHKeyCheck(smpCcb_t *pCcb, smpMsg_t *pMsg, uint8_t *pCheck);
139 void smpScSendRand(smpCcb_t *pCcb, smpMsg_t *pMsg, uint8_t *pRand);
140 void smpScSendPairCnf(smpCcb_t *pCcb, smpMsg_t *pMsg, uint8_t *pCnf);
141 
142 /* diagnostics utility functions */
143 void smpLogByteArray(char *str, uint8_t *pArray, uint8_t len);
144 uint8_t *smpiStateStr(uint8_t state);
145 uint8_t *smprStateStr(uint8_t state);
146 
147 #ifdef __cplusplus
148 };
149 #endif
150 
151 #endif /* SMP_SC_MAIN_H */
uint8_t dmConnId_t
Connection identifier.
Definition: dm_api.h:588
SMP main module.
Data type for DmSecSetOob().
Definition: dm_api.h:859
Trace message interface.
Security manager constants and definitions from the Bluetooth specification.
SMP subsystem API.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.