fka mod

Fork of BLE_API by Bluetooth Low Energy

Committer:
FrancisDrake
Date:
Fri Nov 24 12:18:15 2017 +0000
Revision:
1209:26d85722b59f
Parent:
1192:718787de23b7
Caliper Mods

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 1126:08db6549adef 1 /* mbed Microcontroller Library
vcoubard 1126:08db6549adef 2 * Copyright (c) 2006-2015 ARM Limited
vcoubard 1126:08db6549adef 3 *
vcoubard 1126:08db6549adef 4 * Licensed under the Apache License, Version 2.0 (the "License");
vcoubard 1126:08db6549adef 5 * you may not use this file except in compliance with the License.
vcoubard 1126:08db6549adef 6 * You may obtain a copy of the License at
vcoubard 1126:08db6549adef 7 *
vcoubard 1126:08db6549adef 8 * http://www.apache.org/licenses/LICENSE-2.0
vcoubard 1126:08db6549adef 9 *
vcoubard 1126:08db6549adef 10 * Unless required by applicable law or agreed to in writing, software
vcoubard 1126:08db6549adef 11 * distributed under the License is distributed on an "AS IS" BASIS,
vcoubard 1126:08db6549adef 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vcoubard 1126:08db6549adef 13 * See the License for the specific language governing permissions and
vcoubard 1126:08db6549adef 14 * limitations under the License.
vcoubard 1126:08db6549adef 15 */
vcoubard 1126:08db6549adef 16
vcoubard 1126:08db6549adef 17 #ifndef __SECURITY_MANAGER_H__
vcoubard 1126:08db6549adef 18 #define __SECURITY_MANAGER_H__
vcoubard 1126:08db6549adef 19
vcoubard 1126:08db6549adef 20 #include <stdint.h>
vcoubard 1126:08db6549adef 21
vcoubard 1126:08db6549adef 22 #include "Gap.h"
vcoubard 1135:22aada733dbd 23 #include "CallChainOfFunctionPointersWithContext.h"
vcoubard 1126:08db6549adef 24
vcoubard 1126:08db6549adef 25 class SecurityManager {
vcoubard 1126:08db6549adef 26 public:
vcoubard 1126:08db6549adef 27 enum SecurityMode_t {
vcoubard 1126:08db6549adef 28 SECURITY_MODE_NO_ACCESS,
vcoubard 1126:08db6549adef 29 SECURITY_MODE_ENCRYPTION_OPEN_LINK, /**< Require no protection, open link. */
vcoubard 1126:08db6549adef 30 SECURITY_MODE_ENCRYPTION_NO_MITM, /**< Require encryption, but no MITM protection. */
vcoubard 1126:08db6549adef 31 SECURITY_MODE_ENCRYPTION_WITH_MITM, /**< Require encryption and MITM protection. */
vcoubard 1126:08db6549adef 32 SECURITY_MODE_SIGNED_NO_MITM, /**< Require signing or encryption, but no MITM protection. */
vcoubard 1126:08db6549adef 33 SECURITY_MODE_SIGNED_WITH_MITM, /**< Require signing or encryption, and MITM protection. */
vcoubard 1126:08db6549adef 34 };
vcoubard 1126:08db6549adef 35
vcoubard 1126:08db6549adef 36 /**
vcoubard 1126:08db6549adef 37 * @brief Defines possible security status or states.
vcoubard 1126:08db6549adef 38 *
vcoubard 1126:08db6549adef 39 * @details Defines possible security status or states of a link when requested by getLinkSecurity().
vcoubard 1126:08db6549adef 40 */
vcoubard 1126:08db6549adef 41 enum LinkSecurityStatus_t {
vcoubard 1126:08db6549adef 42 NOT_ENCRYPTED, /**< The link is not secured. */
vcoubard 1126:08db6549adef 43 ENCRYPTION_IN_PROGRESS, /**< Link security is being established.*/
vcoubard 1126:08db6549adef 44 ENCRYPTED /**< The link is secure.*/
vcoubard 1126:08db6549adef 45 };
vcoubard 1126:08db6549adef 46
vcoubard 1126:08db6549adef 47 enum SecurityIOCapabilities_t {
vcoubard 1126:08db6549adef 48 IO_CAPS_DISPLAY_ONLY = 0x00, /**< Display only. */
vcoubard 1126:08db6549adef 49 IO_CAPS_DISPLAY_YESNO = 0x01, /**< Display and yes/no entry. */
vcoubard 1126:08db6549adef 50 IO_CAPS_KEYBOARD_ONLY = 0x02, /**< Keyboard only. */
vcoubard 1126:08db6549adef 51 IO_CAPS_NONE = 0x03, /**< No I/O capabilities. */
vcoubard 1126:08db6549adef 52 IO_CAPS_KEYBOARD_DISPLAY = 0x04, /**< Keyboard and display. */
vcoubard 1126:08db6549adef 53 };
vcoubard 1126:08db6549adef 54
vcoubard 1126:08db6549adef 55 enum SecurityCompletionStatus_t {
vcoubard 1126:08db6549adef 56 SEC_STATUS_SUCCESS = 0x00, /**< Procedure completed with success. */
vcoubard 1126:08db6549adef 57 SEC_STATUS_TIMEOUT = 0x01, /**< Procedure timed out. */
vcoubard 1126:08db6549adef 58 SEC_STATUS_PDU_INVALID = 0x02, /**< Invalid PDU received. */
vcoubard 1126:08db6549adef 59 SEC_STATUS_PASSKEY_ENTRY_FAILED = 0x81, /**< Passkey entry failed (user canceled or other). */
vcoubard 1126:08db6549adef 60 SEC_STATUS_OOB_NOT_AVAILABLE = 0x82, /**< Out of Band Key not available. */
vcoubard 1126:08db6549adef 61 SEC_STATUS_AUTH_REQ = 0x83, /**< Authentication requirements not met. */
vcoubard 1126:08db6549adef 62 SEC_STATUS_CONFIRM_VALUE = 0x84, /**< Confirm value failed. */
vcoubard 1126:08db6549adef 63 SEC_STATUS_PAIRING_NOT_SUPP = 0x85, /**< Pairing not supported. */
vcoubard 1126:08db6549adef 64 SEC_STATUS_ENC_KEY_SIZE = 0x86, /**< Encryption key size. */
vcoubard 1126:08db6549adef 65 SEC_STATUS_SMP_CMD_UNSUPPORTED = 0x87, /**< Unsupported SMP command. */
vcoubard 1126:08db6549adef 66 SEC_STATUS_UNSPECIFIED = 0x88, /**< Unspecified reason. */
vcoubard 1126:08db6549adef 67 SEC_STATUS_REPEATED_ATTEMPTS = 0x89, /**< Too little time elapsed since last attempt. */
vcoubard 1126:08db6549adef 68 SEC_STATUS_INVALID_PARAMS = 0x8A, /**< Invalid parameters. */
vcoubard 1126:08db6549adef 69 };
vcoubard 1126:08db6549adef 70
vcoubard 1126:08db6549adef 71 /**
vcoubard 1126:08db6549adef 72 * Declaration of type containing a passkey to be used during pairing. This
vcoubard 1126:08db6549adef 73 * is passed into initializeSecurity() to specify a pre-programmed passkey
vcoubard 1126:08db6549adef 74 * for authentication instead of generating a random one.
vcoubard 1126:08db6549adef 75 */
vcoubard 1126:08db6549adef 76 static const unsigned PASSKEY_LEN = 6;
vcoubard 1126:08db6549adef 77 typedef uint8_t Passkey_t[PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
vcoubard 1126:08db6549adef 78
vcoubard 1126:08db6549adef 79 public:
vcoubard 1126:08db6549adef 80 typedef void (*HandleSpecificEvent_t)(Gap::Handle_t handle);
vcoubard 1126:08db6549adef 81 typedef void (*SecuritySetupInitiatedCallback_t)(Gap::Handle_t, bool allowBonding, bool requireMITM, SecurityIOCapabilities_t iocaps);
vcoubard 1126:08db6549adef 82 typedef void (*SecuritySetupCompletedCallback_t)(Gap::Handle_t, SecurityCompletionStatus_t status);
vcoubard 1126:08db6549adef 83 typedef void (*LinkSecuredCallback_t)(Gap::Handle_t handle, SecurityMode_t securityMode);
vcoubard 1126:08db6549adef 84 typedef void (*PasskeyDisplayCallback_t)(Gap::Handle_t handle, const Passkey_t passkey);
vcoubard 1126:08db6549adef 85
vcoubard 1135:22aada733dbd 86 typedef FunctionPointerWithContext<const SecurityManager *> SecurityManagerShutdownCallback_t;
vcoubard 1135:22aada733dbd 87 typedef CallChainOfFunctionPointersWithContext<const SecurityManager *> SecurityManagerShutdownCallbackChain_t;
vcoubard 1135:22aada733dbd 88
vcoubard 1126:08db6549adef 89 /*
vcoubard 1126:08db6549adef 90 * The following functions are meant to be overridden in the platform-specific sub-class.
vcoubard 1126:08db6549adef 91 */
vcoubard 1126:08db6549adef 92 public:
vcoubard 1126:08db6549adef 93 /**
vcoubard 1126:08db6549adef 94 * Enable the BLE stack's Security Manager. The Security Manager implements
vcoubard 1126:08db6549adef 95 * the actual cryptographic algorithms and protocol exchanges that allow two
vcoubard 1126:08db6549adef 96 * devices to securely exchange data and privately detect each other.
vcoubard 1126:08db6549adef 97 * Calling this API is a prerequisite for encryption and pairing (bonding).
vcoubard 1126:08db6549adef 98 *
vcoubard 1126:08db6549adef 99 * @param[in] enableBonding Allow for bonding.
vcoubard 1126:08db6549adef 100 * @param[in] requireMITM Require protection for man-in-the-middle attacks.
vcoubard 1126:08db6549adef 101 * @param[in] iocaps To specify the I/O capabilities of this peripheral,
vcoubard 1126:08db6549adef 102 * such as availability of a display or keyboard, to
vcoubard 1126:08db6549adef 103 * support out-of-band exchanges of security data.
vcoubard 1126:08db6549adef 104 * @param[in] passkey To specify a static passkey.
vcoubard 1126:08db6549adef 105 *
vcoubard 1126:08db6549adef 106 * @return BLE_ERROR_NONE on success.
vcoubard 1126:08db6549adef 107 */
vcoubard 1126:08db6549adef 108 virtual ble_error_t init(bool enableBonding = true,
vcoubard 1126:08db6549adef 109 bool requireMITM = true,
vcoubard 1126:08db6549adef 110 SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
vcoubard 1126:08db6549adef 111 const Passkey_t passkey = NULL) {
vcoubard 1126:08db6549adef 112 /* Avoid compiler warnings about unused variables. */
vcoubard 1126:08db6549adef 113 (void)enableBonding;
vcoubard 1126:08db6549adef 114 (void)requireMITM;
vcoubard 1126:08db6549adef 115 (void)iocaps;
vcoubard 1126:08db6549adef 116 (void)passkey;
vcoubard 1126:08db6549adef 117
vcoubard 1126:08db6549adef 118 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if security is supported. */
vcoubard 1126:08db6549adef 119 }
vcoubard 1126:08db6549adef 120
vcoubard 1126:08db6549adef 121 /**
vcoubard 1126:08db6549adef 122 * Get the security status of a connection.
vcoubard 1126:08db6549adef 123 *
vcoubard 1126:08db6549adef 124 * @param[in] connectionHandle Handle to identify the connection.
vcoubard 1126:08db6549adef 125 * @param[out] securityStatusP Security status.
vcoubard 1126:08db6549adef 126 *
vcoubard 1135:22aada733dbd 127 * @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
vcoubard 1126:08db6549adef 128 */
vcoubard 1126:08db6549adef 129 virtual ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, LinkSecurityStatus_t *securityStatusP) {
vcoubard 1126:08db6549adef 130 /* Avoid compiler warnings about unused variables. */
vcoubard 1126:08db6549adef 131 (void)connectionHandle;
vcoubard 1126:08db6549adef 132 (void)securityStatusP;
vcoubard 1126:08db6549adef 133
vcoubard 1126:08db6549adef 134 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if security is supported. */
vcoubard 1126:08db6549adef 135 }
vcoubard 1126:08db6549adef 136
vcoubard 1126:08db6549adef 137 /**
vcoubard 1135:22aada733dbd 138 * Set the security mode on a connection. Useful for elevating the security mode
vcoubard 1135:22aada733dbd 139 * once certain conditions are met, e.g., a particular service is found.
vcoubard 1135:22aada733dbd 140 *
vcoubard 1135:22aada733dbd 141 * @param[in] connectionHandle Handle to identify the connection.
vcoubard 1135:22aada733dbd 142 * @param[in] securityMode Requested security mode.
vcoubard 1135:22aada733dbd 143 *
vcoubard 1135:22aada733dbd 144 * @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
vcoubard 1135:22aada733dbd 145 */
vcoubard 1135:22aada733dbd 146 virtual ble_error_t setLinkSecurity(Gap::Handle_t connectionHandle, SecurityMode_t securityMode) {
vcoubard 1135:22aada733dbd 147 /* Avoid compiler warnings about unused variables. */
vcoubard 1135:22aada733dbd 148 (void)connectionHandle;
vcoubard 1135:22aada733dbd 149 (void)securityMode;
vcoubard 1135:22aada733dbd 150
vcoubard 1135:22aada733dbd 151 return BLE_ERROR_NOT_IMPLEMENTED;
vcoubard 1135:22aada733dbd 152 }
vcoubard 1135:22aada733dbd 153
vcoubard 1135:22aada733dbd 154 /**
vcoubard 1126:08db6549adef 155 * Delete all peer device context and all related bonding information from
vcoubard 1126:08db6549adef 156 * the database within the security manager.
vcoubard 1126:08db6549adef 157 *
vcoubard 1126:08db6549adef 158 * @retval BLE_ERROR_NONE On success, else an error code indicating reason for failure.
vcoubard 1126:08db6549adef 159 * @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or
vcoubard 1126:08db6549adef 160 * application registration.
vcoubard 1126:08db6549adef 161 */
vcoubard 1126:08db6549adef 162 virtual ble_error_t purgeAllBondingState(void) {
vcoubard 1126:08db6549adef 163 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if security is supported. */
vcoubard 1126:08db6549adef 164 }
vcoubard 1126:08db6549adef 165
vcoubard 1136:6b1e6b7282a6 166 /**
vcoubard 1136:6b1e6b7282a6 167 * Get a list of addresses from all peers in the bond table.
vcoubard 1136:6b1e6b7282a6 168 *
vcoubard 1183:1589830dbdb7 169 * @param[in,out] addresses
vcoubard 1136:6b1e6b7282a6 170 * (on input) addresses.capacity contains the maximum
vcoubard 1136:6b1e6b7282a6 171 * number of addresses to be returned.
vcoubard 1136:6b1e6b7282a6 172 * (on output) The populated table with copies of the
vcoubard 1136:6b1e6b7282a6 173 * addresses in the implementation's whitelist.
vcoubard 1136:6b1e6b7282a6 174 *
vcoubard 1136:6b1e6b7282a6 175 * @retval BLE_ERROR_NONE On success, else an error code indicating reason for failure.
vcoubard 1136:6b1e6b7282a6 176 * @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or
vcoubard 1136:6b1e6b7282a6 177 * application registration.
vcoubard 1136:6b1e6b7282a6 178 *
vcoubard 1136:6b1e6b7282a6 179 * @experimental
vcoubard 1136:6b1e6b7282a6 180 */
vcoubard 1136:6b1e6b7282a6 181 virtual ble_error_t getAddressesFromBondTable(Gap::Whitelist_t &addresses) const {
vcoubard 1136:6b1e6b7282a6 182 /* Avoid compiler warnings about unused variables */
vcoubard 1136:6b1e6b7282a6 183 (void) addresses;
vcoubard 1136:6b1e6b7282a6 184
vcoubard 1136:6b1e6b7282a6 185 return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if security is supported. */
vcoubard 1136:6b1e6b7282a6 186 }
vcoubard 1136:6b1e6b7282a6 187
vcoubard 1126:08db6549adef 188 /* Event callback handlers. */
vcoubard 1126:08db6549adef 189 public:
vcoubard 1126:08db6549adef 190 /**
vcoubard 1135:22aada733dbd 191 * Setup a callback to be invoked to notify the user application that the
vcoubard 1135:22aada733dbd 192 * SecurityManager instance is about to shutdown (possibly as a result of a call
vcoubard 1135:22aada733dbd 193 * to BLE::shutdown()).
vcoubard 1135:22aada733dbd 194 *
vcoubard 1183:1589830dbdb7 195 * @note It is possible to chain together multiple onShutdown callbacks
vcoubard 1135:22aada733dbd 196 * (potentially from different modules of an application) to be notified
vcoubard 1135:22aada733dbd 197 * before the SecurityManager is shutdown.
vcoubard 1135:22aada733dbd 198 *
vcoubard 1183:1589830dbdb7 199 * @note It is also possible to set up a callback into a member function of
vcoubard 1135:22aada733dbd 200 * some object.
vcoubard 1135:22aada733dbd 201 *
vcoubard 1183:1589830dbdb7 202 * @note It is possible to unregister a callback using onShutdown().detach(callback)
vcoubard 1135:22aada733dbd 203 */
vcoubard 1135:22aada733dbd 204 void onShutdown(const SecurityManagerShutdownCallback_t& callback) {
vcoubard 1135:22aada733dbd 205 shutdownCallChain.add(callback);
vcoubard 1135:22aada733dbd 206 }
vcoubard 1135:22aada733dbd 207 template <typename T>
vcoubard 1192:718787de23b7 208 void onShutdown(T *objPtr, void (T::*memberPtr)(const SecurityManager *)) {
vcoubard 1135:22aada733dbd 209 shutdownCallChain.add(objPtr, memberPtr);
vcoubard 1135:22aada733dbd 210 }
vcoubard 1135:22aada733dbd 211
vcoubard 1135:22aada733dbd 212 /**
vcoubard 1135:22aada733dbd 213 * @brief provide access to the callchain of shutdown event callbacks
vcoubard 1135:22aada733dbd 214 * It is possible to register callbacks using onShutdown().add(callback);
vcoubard 1135:22aada733dbd 215 * It is possible to unregister callbacks using onShutdown().detach(callback)
vcoubard 1135:22aada733dbd 216 * @return The shutdown event callbacks chain
vcoubard 1135:22aada733dbd 217 */
vcoubard 1135:22aada733dbd 218 SecurityManagerShutdownCallbackChain_t& onShutdown() {
vcoubard 1135:22aada733dbd 219 return shutdownCallChain;
vcoubard 1135:22aada733dbd 220 }
vcoubard 1135:22aada733dbd 221
vcoubard 1135:22aada733dbd 222 /**
vcoubard 1126:08db6549adef 223 * To indicate that a security procedure for the link has started.
vcoubard 1126:08db6549adef 224 */
vcoubard 1126:08db6549adef 225 virtual void onSecuritySetupInitiated(SecuritySetupInitiatedCallback_t callback) {securitySetupInitiatedCallback = callback;}
vcoubard 1126:08db6549adef 226
vcoubard 1126:08db6549adef 227 /**
vcoubard 1126:08db6549adef 228 * To indicate that the security procedure for the link has completed.
vcoubard 1126:08db6549adef 229 */
vcoubard 1126:08db6549adef 230 virtual void onSecuritySetupCompleted(SecuritySetupCompletedCallback_t callback) {securitySetupCompletedCallback = callback;}
vcoubard 1126:08db6549adef 231
vcoubard 1126:08db6549adef 232 /**
vcoubard 1126:08db6549adef 233 * To indicate that the link with the peer is secured. For bonded devices,
vcoubard 1126:08db6549adef 234 * subsequent reconnections with a bonded peer will result only in this callback
vcoubard 1126:08db6549adef 235 * when the link is secured; setup procedures will not occur (unless the
vcoubard 1126:08db6549adef 236 * bonding information is either lost or deleted on either or both sides).
vcoubard 1126:08db6549adef 237 */
vcoubard 1126:08db6549adef 238 virtual void onLinkSecured(LinkSecuredCallback_t callback) {linkSecuredCallback = callback;}
vcoubard 1126:08db6549adef 239
vcoubard 1126:08db6549adef 240 /**
vcoubard 1126:08db6549adef 241 * To indicate that device context is stored persistently.
vcoubard 1126:08db6549adef 242 */
vcoubard 1126:08db6549adef 243 virtual void onSecurityContextStored(HandleSpecificEvent_t callback) {securityContextStoredCallback = callback;}
vcoubard 1126:08db6549adef 244
vcoubard 1126:08db6549adef 245 /**
vcoubard 1126:08db6549adef 246 * To set the callback for when the passkey needs to be displayed on a peripheral with DISPLAY capability.
vcoubard 1126:08db6549adef 247 */
vcoubard 1126:08db6549adef 248 virtual void onPasskeyDisplay(PasskeyDisplayCallback_t callback) {passkeyDisplayCallback = callback;}
vcoubard 1126:08db6549adef 249
vcoubard 1126:08db6549adef 250 /* Entry points for the underlying stack to report events back to the user. */
vcoubard 1126:08db6549adef 251 public:
vcoubard 1126:08db6549adef 252 void processSecuritySetupInitiatedEvent(Gap::Handle_t handle, bool allowBonding, bool requireMITM, SecurityIOCapabilities_t iocaps) {
vcoubard 1126:08db6549adef 253 if (securitySetupInitiatedCallback) {
vcoubard 1126:08db6549adef 254 securitySetupInitiatedCallback(handle, allowBonding, requireMITM, iocaps);
vcoubard 1126:08db6549adef 255 }
vcoubard 1126:08db6549adef 256 }
vcoubard 1126:08db6549adef 257
vcoubard 1126:08db6549adef 258 void processSecuritySetupCompletedEvent(Gap::Handle_t handle, SecurityCompletionStatus_t status) {
vcoubard 1126:08db6549adef 259 if (securitySetupCompletedCallback) {
vcoubard 1126:08db6549adef 260 securitySetupCompletedCallback(handle, status);
vcoubard 1126:08db6549adef 261 }
vcoubard 1126:08db6549adef 262 }
vcoubard 1126:08db6549adef 263
vcoubard 1126:08db6549adef 264 void processLinkSecuredEvent(Gap::Handle_t handle, SecurityMode_t securityMode) {
vcoubard 1126:08db6549adef 265 if (linkSecuredCallback) {
vcoubard 1126:08db6549adef 266 linkSecuredCallback(handle, securityMode);
vcoubard 1126:08db6549adef 267 }
vcoubard 1126:08db6549adef 268 }
vcoubard 1126:08db6549adef 269
vcoubard 1126:08db6549adef 270 void processSecurityContextStoredEvent(Gap::Handle_t handle) {
vcoubard 1126:08db6549adef 271 if (securityContextStoredCallback) {
vcoubard 1126:08db6549adef 272 securityContextStoredCallback(handle);
vcoubard 1126:08db6549adef 273 }
vcoubard 1126:08db6549adef 274 }
vcoubard 1126:08db6549adef 275
vcoubard 1126:08db6549adef 276 void processPasskeyDisplayEvent(Gap::Handle_t handle, const Passkey_t passkey) {
vcoubard 1126:08db6549adef 277 if (passkeyDisplayCallback) {
vcoubard 1126:08db6549adef 278 passkeyDisplayCallback(handle, passkey);
vcoubard 1126:08db6549adef 279 }
vcoubard 1126:08db6549adef 280 }
vcoubard 1126:08db6549adef 281
vcoubard 1126:08db6549adef 282 protected:
vcoubard 1126:08db6549adef 283 SecurityManager() :
vcoubard 1126:08db6549adef 284 securitySetupInitiatedCallback(),
vcoubard 1126:08db6549adef 285 securitySetupCompletedCallback(),
vcoubard 1126:08db6549adef 286 linkSecuredCallback(),
vcoubard 1126:08db6549adef 287 securityContextStoredCallback(),
vcoubard 1126:08db6549adef 288 passkeyDisplayCallback() {
vcoubard 1126:08db6549adef 289 /* empty */
vcoubard 1126:08db6549adef 290 }
vcoubard 1126:08db6549adef 291
vcoubard 1135:22aada733dbd 292 public:
vcoubard 1135:22aada733dbd 293 /**
vcoubard 1135:22aada733dbd 294 * Notify all registered onShutdown callbacks that the SecurityManager is
vcoubard 1135:22aada733dbd 295 * about to be shutdown and clear all SecurityManager state of the
vcoubard 1135:22aada733dbd 296 * associated object.
vcoubard 1135:22aada733dbd 297 *
vcoubard 1135:22aada733dbd 298 * This function is meant to be overridden in the platform-specific
vcoubard 1135:22aada733dbd 299 * sub-class. Nevertheless, the sub-class is only expected to reset its
vcoubard 1135:22aada733dbd 300 * state and not the data held in SecurityManager members. This shall be
vcoubard 1135:22aada733dbd 301 * achieved by a call to SecurityManager::reset() from the sub-class'
vcoubard 1135:22aada733dbd 302 * reset() implementation.
vcoubard 1135:22aada733dbd 303 *
vcoubard 1135:22aada733dbd 304 * @return BLE_ERROR_NONE on success.
vcoubard 1135:22aada733dbd 305 */
vcoubard 1135:22aada733dbd 306 virtual ble_error_t reset(void) {
vcoubard 1135:22aada733dbd 307 /* Notify that the instance is about to shutdown */
vcoubard 1135:22aada733dbd 308 shutdownCallChain.call(this);
vcoubard 1135:22aada733dbd 309 shutdownCallChain.clear();
vcoubard 1135:22aada733dbd 310
vcoubard 1135:22aada733dbd 311 securitySetupInitiatedCallback = NULL;
vcoubard 1135:22aada733dbd 312 securitySetupCompletedCallback = NULL;
vcoubard 1135:22aada733dbd 313 linkSecuredCallback = NULL;
vcoubard 1135:22aada733dbd 314 securityContextStoredCallback = NULL;
vcoubard 1135:22aada733dbd 315 passkeyDisplayCallback = NULL;
vcoubard 1135:22aada733dbd 316
vcoubard 1135:22aada733dbd 317 return BLE_ERROR_NONE;
vcoubard 1135:22aada733dbd 318 }
vcoubard 1135:22aada733dbd 319
vcoubard 1126:08db6549adef 320 protected:
vcoubard 1126:08db6549adef 321 SecuritySetupInitiatedCallback_t securitySetupInitiatedCallback;
vcoubard 1126:08db6549adef 322 SecuritySetupCompletedCallback_t securitySetupCompletedCallback;
vcoubard 1126:08db6549adef 323 LinkSecuredCallback_t linkSecuredCallback;
vcoubard 1126:08db6549adef 324 HandleSpecificEvent_t securityContextStoredCallback;
vcoubard 1126:08db6549adef 325 PasskeyDisplayCallback_t passkeyDisplayCallback;
vcoubard 1135:22aada733dbd 326
vcoubard 1135:22aada733dbd 327 private:
vcoubard 1135:22aada733dbd 328 SecurityManagerShutdownCallbackChain_t shutdownCallChain;
vcoubard 1126:08db6549adef 329 };
vcoubard 1126:08db6549adef 330
rgrover1 716:11b41f651697 331 #endif /*__SECURITY_MANAGER_H__*/