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;
   328             (void)connectionHandle;
   332 #if BLE_FEATURE_SECURE_CONNECTIONS   343             (void)connectionHandle;
   345 #endif // BLE_FEATURE_SECURE_CONNECTIONS   354             (void)connectionHandle;
   357 #if BLE_FEATURE_SECURE_CONNECTIONS   365             (void)connectionHandle;
   368 #endif // BLE_FEATURE_SECURE_CONNECTIONS   376             (void)connectionHandle;
   411 #if BLE_FEATURE_SIGNING   420             (void)connectionHandle;
   424 #endif // BLE_FEATURE_SIGNING   461         bool                     enableBonding = 
true,
   462         bool                     requireMITM   = 
true,
   464         const Passkey_t          passkey       = 
nullptr,
   466         const char              *dbFilepath    = 
nullptr   480     ble_error_t setDatabaseFilepath(
const char *dbFilepath = 
nullptr);
   504     ble_error_t preserveBondingStateOnReset(
bool enable);
   547 #endif // BLE_ROLE_CENTRAL   549 #if BLE_ROLE_PERIPHERAL   558 #endif // BLE_ROLE_PERIPHERAL   579     ble_error_t setPairingRequestAuthorisation(
bool required = 
true);
   593 #if BLE_FEATURE_SECURE_CONNECTIONS   610     ble_error_t getSecureConnectionsSupport(
bool *enabled);
   611 #endif // BLE_FEATURE_SECURE_CONNECTIONS   632     ble_error_t setDisplayPasskey(
const Passkey_t passkey);
   654     ble_error_t setKeypressNotification(
bool enabled = 
true);
   656 #if BLE_FEATURE_SIGNING   668 #endif // BLE_FEATURE_SIGNING   677     ble_error_t setHintFutureRoleReversal(
bool enable = 
true);
   710     ble_error_t setEncryptionKeyRequirements(uint8_t minimumByteSize, uint8_t maximumByteSize);
   784 #if BLE_FEATURE_SECURE_CONNECTIONS   793 #endif // BLE_FEATURE_SECURE_CONNECTIONS   804 #if BLE_FEATURE_SECURE_CONNECTIONS   814 #endif // BLE_FEATURE_SECURE_CONNECTIONS   825 #if BLE_FEATURE_SECURE_CONNECTIONS   836 #endif // BLE_FEATURE_SECURE_CONNECTIONS   842 #if BLE_FEATURE_SIGNING   855 #endif // BLE_FEATURE_SIGNING   861 #if BLE_FEATURE_PRIVACY   870         uint16_t timeout_in_seconds
   872 #endif // BLE_FEATURE_PRIVACY   890     void onShutdown(
const SecurityManagerShutdownCallback_t& 
callback);
   892     template <
typename T>
   893     void onShutdown(T *objPtr, 
void (T::*memberPtr)(
const SecurityManager *))
   895         onShutdown({objPtr, memberPtr});
   905     SecurityManagerShutdownCallbackChain_t& onShutdown();
   913     void setSecurityManagerEventHandler(
EventHandler* handler);
   916 #if !defined(DOXYGEN_ONLY)   924 #endif // !defined(DOXYGEN_ONLY)   927     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.