Mistake on this page?
Report an issue in GitHub or email us
dm_priv.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief DM privacy module.
6  *
7  * Copyright (c) 2011-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 DM_PRIV_H
25 #define DM_PRIV_H
26 
27 #include "util/bda.h"
28 #include "wsf_os.h"
29 #include "wsf_timer.h"
30 #include "sec_api.h"
31 #include "dm_main.h"
32 #include "smp_defs.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /**************************************************************************************************
39  Macros
40 **************************************************************************************************/
41 
42 /* DM privacy event handler messages */
43 enum
44 {
45  DM_PRIV_MSG_API_RESOLVE_ADDR = DM_MSG_START(DM_ID_PRIV),
46  DM_PRIV_MSG_API_ADD_DEV_TO_RES_LIST,
47  DM_PRIV_MSG_API_REM_DEV_FROM_RES_LIST,
48  DM_PRIV_MSG_API_CLEAR_RES_LIST,
49  DM_PRIV_MSG_API_SET_ADDR_RES_ENABLE,
50  DM_PRIV_MSG_API_SET_PRIVACY_MODE,
51  DM_PRIV_MSG_API_GEN_ADDR
52 };
53 
54 /* DM privacy AES event handler messages */
55 enum
56 {
57  DM_PRIV_MSG_RESOLVE_AES_CMPL = DM_MSG_START(DM_ID_PRIV_AES),
58  DM_PRIV_MSG_GEN_ADDR_AES_CMPL
59 };
60 
61 /**************************************************************************************************
62  Data Types
63 **************************************************************************************************/
64 
65 /* Data structure for DM_PRIV_MSG_API_RESOLVE_ADDR */
66 typedef struct
67 {
68  wsfMsgHdr_t hdr;
69  uint8_t irk[SMP_KEY_LEN];
70  bdAddr_t addr;
72 
73 /* Data structure for DM_PRIV_MSG_API_GEN_ADDR */
74 typedef struct
75 {
76  wsfMsgHdr_t hdr;
77  uint8_t irk[SMP_KEY_LEN];
79 
80 /* Data structure for DM_PRIV_MSG_API_ADD_DEV_TO_RES_LIST */
81 typedef struct
82 {
83  wsfMsgHdr_t hdr;
84  uint8_t addrType;
85  bdAddr_t peerAddr;
86  uint8_t peerIrk[SMP_KEY_LEN];
87  uint8_t localIrk[SMP_KEY_LEN];
88  bool_t enableLlPriv;
90 
91 /* Data structure for DM_PRIV_MSG_API_REM_DEV_FROM_RES_LIST */
92 typedef struct
93 {
94  wsfMsgHdr_t hdr;
95  uint8_t addrType;
96  bdAddr_t peerAddr;
98 
99 /* Data structure for DM_PRIV_MSG_API_SET_ADDR_RES_ENABLE */
100 typedef struct
101 {
102  wsfMsgHdr_t hdr;
103  bool_t enable;
105 
106 /* Data structure for DM_PRIV_MSG_API_SET_PRIVACY_MODE */
107 typedef struct
108 {
109  wsfMsgHdr_t hdr;
110  uint8_t addrType;
111  bdAddr_t peerAddr;
112  uint8_t mode;
114 
115 /* Union of all privacy messages */
116 typedef union
117 {
118  wsfMsgHdr_t hdr;
119  dmPrivApiResolveAddr_t apiResolveAddr;
120  dmPrivApiAddDevToResList_t apiAddDevToResList;
121  dmPrivApiRemDevFromResList_t apiRemDevFromResList;
122  dmPrivApiSetAddrResEnable_t apiSetAddrResEnable;
123  dmPrivApiSetPrivacyMode_t apiSetPrivacyMode;
124  dmPrivApiGenAddr_t apiGenerateAddr;
125  dmPrivGenAddrIndEvt_t genAddrInd;
126  secAes_t aes;
127 } dmPrivMsg_t;
128 
129 /* Action function */
130 typedef void (*dmPrivAct_t)(dmPrivMsg_t *pMsg);
131 
132 /* Control block for privacy module */
133 typedef struct
134 {
135  uint8_t hash[DM_PRIV_HASH_LEN]; /* Hash part of resolvable address */
136  bool_t inProgress; /* Address resolution in progress */
137  uint16_t addDevToResListParam; /* 'Add device to resolving list' callback param */
138  uint16_t remDevFromResListParam; /* 'Remove device from resolving list' callback param */
139  bool_t enableLlPriv; /* 'Add device to resolving list' input param */
140  bool_t addrResEnable; /* 'Set address resolution enable' input param */
141  uint8_t genAddrBuf[HCI_ENCRYPT_DATA_LEN]; /* Random value buffer for generating an RPA */
142 } dmPrivCb_t;
143 
144 /**************************************************************************************************
145  Function declarations
146 **************************************************************************************************/
147 
148 /* Privacy component inteface */
149 void dmPrivMsgHandler(wsfMsgHdr_t *pMsg);
150 void dmPrivHciHandler(hciEvt_t *pEvent);
151 void dmPrivReset(void);
152 
153 /* Privacy action functions */
154 void dmPrivActResolveAddr(dmPrivMsg_t *pMsg);
155 void dmPrivActAddDevToResList(dmPrivMsg_t *pMsg);
156 void dmPrivActRemDevFromResList(dmPrivMsg_t *pMsg);
157 void dmPrivActSetAddrResEnable(dmPrivMsg_t *pMsg);
158 void dmPrivActClearResList(dmPrivMsg_t *pMsg);
159 void dmPrivActSetPrivacyMode(dmPrivMsg_t *pMsg);
160 void dmPrivActGenAddr(dmPrivMsg_t *pMsg);
161 
162 /* Privacy ASE component inteface */
163 void dmPrivAesMsgHandler(wsfMsgHdr_t *pMsg);
164 
165 /* Privacy ASE action functions */
166 void dmPrivAesActResAddrAesCmpl(dmPrivMsg_t *pMsg);
167 void dmPrivAesActGenAddrAesCmpl(dmPrivMsg_t *pMsg);
168 
169 #ifdef __cplusplus
170 };
171 #endif
172 
173 #endif /* DM_PRIV_H */
#define HCI_ENCRYPT_DATA_LEN
Definition: hci_defs.h:1446
Data type for DM_PRIV_GENERATE_ADDR_IND.
Definition: dm_api.h:693
AES Security callback parameters structure.
Definition: sec_api.h:70
#define SMP_KEY_LEN
Key length.
Definition: smp_defs.h:183
uint8_t bdAddr_t[6]
BD address data type.
Definition: bda.h:67
Security manager constants and definitions from the Bluetooth specification.
Bluetooth device address utilities.
Union of all event types.
Definition: hci_api.h:931
DM main module.
Timer service.
Software foundation OS API.
Common message structure passed to event handler.
Definition: wsf_os.h:106
AES and random number security service 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.