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 265 (void)connectionHandle;
267 #endif // BLE_ROLE_PERIPHERAL 279 (void)connectionHandle;
295 bool address_is_public) {
296 (void)connectionHandle;
298 (void)address_is_public;
331 (void)connectionHandle;
349 #if BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION 350 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.")
351 #endif // BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION 353 (void)connectionHandle;
357 #if BLE_FEATURE_SECURE_CONNECTIONS 372 (void)connectionHandle;
374 #endif // BLE_FEATURE_SECURE_CONNECTIONS 387 (void)connectionHandle;
390 #if BLE_FEATURE_SECURE_CONNECTIONS 402 (void)connectionHandle;
405 #endif // BLE_FEATURE_SECURE_CONNECTIONS 416 (void)connectionHandle;
454 #if BLE_FEATURE_SIGNING 465 (void)connectionHandle;
469 #endif // BLE_FEATURE_SIGNING 506 bool enableBonding =
true,
507 bool requireMITM =
true,
509 const Passkey_t passkey =
nullptr,
511 const char *dbFilepath =
nullptr 525 ble_error_t setDatabaseFilepath(
const char *dbFilepath =
nullptr);
553 ble_error_t preserveBondingStateOnReset(
bool enable);
566 ble_error_t writeBondingStateToPersistentStorage();
611 #endif // BLE_ROLE_CENTRAL 613 #if BLE_ROLE_PERIPHERAL 624 #endif // BLE_ROLE_PERIPHERAL 651 ble_error_t setPairingRequestAuthorisation(
bool required =
true);
667 #if BLE_FEATURE_SECURE_CONNECTIONS 684 ble_error_t getSecureConnectionsSupport(
bool *enabled);
685 #endif // BLE_FEATURE_SECURE_CONNECTIONS 709 ble_error_t setDisplayPasskey(
const Passkey_t passkey);
736 ble_error_t setKeypressNotification(
bool enabled =
true);
738 #if BLE_FEATURE_SIGNING 750 #endif // BLE_FEATURE_SIGNING 759 ble_error_t setHintFutureRoleReversal(
bool enable =
true);
794 ble_error_t setEncryptionKeyRequirements(uint8_t minimumByteSize, uint8_t maximumByteSize);
873 #if BLE_FEATURE_SECURE_CONNECTIONS 884 #endif // BLE_FEATURE_SECURE_CONNECTIONS 897 #if BLE_FEATURE_SECURE_CONNECTIONS 909 #endif // BLE_FEATURE_SECURE_CONNECTIONS 922 #if BLE_FEATURE_SECURE_CONNECTIONS 934 #endif // BLE_FEATURE_SECURE_CONNECTIONS 940 #if BLE_FEATURE_SIGNING 955 #endif // BLE_FEATURE_SIGNING 961 #if BLE_FEATURE_PRIVACY 970 uint16_t timeout_in_seconds
972 #endif // BLE_FEATURE_PRIVACY 990 void onShutdown(
const SecurityManagerShutdownCallback_t&
callback);
992 template <
typename T>
993 void onShutdown(T *objPtr,
void (T::*memberPtr)(
const SecurityManager *))
995 onShutdown({objPtr, memberPtr});
1005 SecurityManagerShutdownCallbackChain_t& onShutdown();
1013 void setSecurityManagerEventHandler(
EventHandler* handler);
1016 #if !defined(DOXYGEN_ONLY) 1024 #endif // !defined(DOXYGEN_ONLY) 1027 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 using legacyPairingOob...
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)
Called when a pairing request is received.
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)
Triggered by change of encryption state on a 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 through another commu...
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)
Triggered during pairing based on IO capabilities of devices.
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.