19 #ifndef BLE_SECURITY_MANAGER_H_ 20 #define BLE_SECURITY_MANAGER_H_ 24 #include "ble/common/BLETypes.h" 25 #include "ble/common/blecommon.h" 26 #include "ble/common/CallChainOfFunctionPointersWithContext.h" 30 #if !defined(DOXYGEN_ONLY) 34 #endif // !defined(DOXYGEN_ONLY) 194 SECURITY_MODE_NO_ACCESS,
204 IO_CAPS_DISPLAY_ONLY = 0x00,
205 IO_CAPS_DISPLAY_YESNO = 0x01,
206 IO_CAPS_KEYBOARD_ONLY = 0x02,
208 IO_CAPS_KEYBOARD_DISPLAY = 0x04,
213 SEC_STATUS_SUCCESS = 0x00,
214 SEC_STATUS_TIMEOUT = 0x01,
215 SEC_STATUS_PDU_INVALID = 0x02,
216 SEC_STATUS_PASSKEY_ENTRY_FAILED = 0x81,
217 SEC_STATUS_OOB_NOT_AVAILABLE = 0x82,
218 SEC_STATUS_AUTH_REQ = 0x83,
219 SEC_STATUS_CONFIRM_VALUE = 0x84,
220 SEC_STATUS_PAIRING_NOT_SUPP = 0x85,
221 SEC_STATUS_ENC_KEY_SIZE = 0x86,
222 SEC_STATUS_SMP_CMD_UNSUPPORTED = 0x87,
223 SEC_STATUS_UNSPECIFIED = 0x88,
224 SEC_STATUS_REPEATED_ATTEMPTS = 0x89,
225 SEC_STATUS_INVALID_PARAMS = 0x8A,
226 SEC_STATUS_DHKEY_CHECK_FAILED = 0x8B,
227 SEC_STATUS_COMPARISON_FAILED = 0x8C,
235 static const unsigned PASSKEY_LEN = 6;
236 typedef uint8_t Passkey_t[PASSKEY_LEN];
250 #if BLE_ROLE_PERIPHERAL 258 (void)connectionHandle;
260 #endif // BLE_ROLE_PERIPHERAL 269 (void)connectionHandle;
283 bool address_is_public) {
284 (void)connectionHandle;
286 (void)address_is_public;
313 (void)connectionHandle;
327 #if BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION 328 MBED_DEPRECATED_SINCE(
"mbed-os-6.8.0",
"This returns the passkey in reverse order. Please set the config option ble.ble-passkey-display-reversed-digits-deprecation in your mbed_app.json override section to false. This will then return the passkey in the correct order.")
329 #endif // BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION 331 (void)connectionHandle;
335 #if BLE_FEATURE_SECURE_CONNECTIONS 346 (void)connectionHandle;
348 #endif // BLE_FEATURE_SECURE_CONNECTIONS 357 (void)connectionHandle;
360 #if BLE_FEATURE_SECURE_CONNECTIONS 368 (void)connectionHandle;
371 #endif // BLE_FEATURE_SECURE_CONNECTIONS 379 (void)connectionHandle;
414 #if BLE_FEATURE_SIGNING 423 (void)connectionHandle;
427 #endif // BLE_FEATURE_SIGNING 464 bool enableBonding =
true,
465 bool requireMITM =
true,
467 const Passkey_t passkey =
nullptr,
469 const char *dbFilepath =
nullptr 483 ble_error_t setDatabaseFilepath(
const char *dbFilepath =
nullptr);
507 ble_error_t preserveBondingStateOnReset(
bool enable);
550 #endif // BLE_ROLE_CENTRAL 552 #if BLE_ROLE_PERIPHERAL 561 #endif // BLE_ROLE_PERIPHERAL 582 ble_error_t setPairingRequestAuthorisation(
bool required =
true);
596 #if BLE_FEATURE_SECURE_CONNECTIONS 613 ble_error_t getSecureConnectionsSupport(
bool *enabled);
614 #endif // BLE_FEATURE_SECURE_CONNECTIONS 635 ble_error_t setDisplayPasskey(
const Passkey_t passkey);
657 ble_error_t setKeypressNotification(
bool enabled =
true);
659 #if BLE_FEATURE_SIGNING 671 #endif // BLE_FEATURE_SIGNING 680 ble_error_t setHintFutureRoleReversal(
bool enable =
true);
713 ble_error_t setEncryptionKeyRequirements(uint8_t minimumByteSize, uint8_t maximumByteSize);
787 #if BLE_FEATURE_SECURE_CONNECTIONS 796 #endif // BLE_FEATURE_SECURE_CONNECTIONS 807 #if BLE_FEATURE_SECURE_CONNECTIONS 817 #endif // BLE_FEATURE_SECURE_CONNECTIONS 828 #if BLE_FEATURE_SECURE_CONNECTIONS 839 #endif // BLE_FEATURE_SECURE_CONNECTIONS 845 #if BLE_FEATURE_SIGNING 858 #endif // BLE_FEATURE_SIGNING 864 #if BLE_FEATURE_PRIVACY 873 uint16_t timeout_in_seconds
875 #endif // BLE_FEATURE_PRIVACY 893 void onShutdown(
const SecurityManagerShutdownCallback_t&
callback);
895 template <
typename T>
896 void onShutdown(T *objPtr,
void (T::*memberPtr)(
const SecurityManager *))
898 onShutdown({objPtr, memberPtr});
908 SecurityManagerShutdownCallbackChain_t& onShutdown();
916 void setSecurityManagerEventHandler(
EventHandler* handler);
919 #if !defined(DOXYGEN_ONLY) 927 #endif // !defined(DOXYGEN_ONLY) 930 impl::SecurityManager *impl;
Function like object adapter over freestanding and member functions.
uintptr_t connection_handle_t
Opaque reference to a connection.
Model fixed size array values.
virtual void passkeyRequest(ble::connection_handle_t connectionHandle)
Indicate to the application that a passkey is required.
virtual void legacyPairingOobRequest(ble::connection_handle_t connectionHandle)
Indicate to the application it needs to return legacy pairing OOB to the stack.
Keypress_t
events sent and received when passkey is being entered
Require encryption, but no MITM protection.
Representation of a whitelist of addresses.
virtual void pairingRequest(ble::connection_handle_t connectionHandle)
Request application to accept or reject pairing.
Require no protection, open link.
virtual void whitelistFromBondTable(::ble::whitelist_t *whitelist)
Deliver the requested whitelist to the application.
Type that describes link's encryption state.
SecurityMode_t
level of security required from the link by the application
Require signing or encryption, but no MITM protection.
SecurityIOCapabilities_t
Input/output capability of the device and application.
virtual void keypressNotification(ble::connection_handle_t connectionHandle, ble::Keypress_t keypress)
Notify the application that a key was pressed by the peer during passkey entry.
Require signing or encryption, and MITM protection.
virtual void oobGenerated(const ble::address_t *address, const ble::oob_lesc_value_t *random, const ble::oob_confirm_t *confirm)
Indicate that the application needs to send secure connections OOB data to the peer.
Require encryption and MITM protection.
virtual void linkEncryptionResult(ble::connection_handle_t connectionHandle, ble::link_encryption_t result)
Inform the device of the encryption state of a given link.
SecurityCompletionStatus_t
Result of security requests.
Function like object hosting a list of FunctionPointerWithContext.
virtual void legacyPairingOobGenerated(const ble::address_t *address, const ble::oob_tk_t *temporaryKey)
Indicate that the application needs to send legacy pairing OOB data to the peer.
virtual void signingKey(ble::connection_handle_t connectionHandle, const ble::csrk_t *csrk, bool authenticated)
Deliver the signing key to the application.
virtual void pairingResult(ble::connection_handle_t connectionHandle, SecurityCompletionStatus_t result)
Indicate to the application that pairing has completed.
The stack will use these functions to signal events to the application, subclass to override handlers...
Entry namespace for all BLE API definitions.
virtual void peerIdentity(ble::connection_handle_t connectionHandle, const address_t *peer_address, bool address_is_public)
Indicate that a peer address has been saved by the security manager or if we are bonded to the peer t...
virtual void passkeyDisplay(ble::connection_handle_t connectionHandle, const Passkey_t passkey)
Display the given passkey on the local device.
virtual void confirmationRequest(ble::connection_handle_t connectionHandle)
Indicate to the application that a confirmation is required.
ble_error_t
Error codes for the BLE API.