mirror of https://github.com/ARMmbed/mbed-os.git
clear up type confusion, added key funcs to pal
parent
7325ca90fd
commit
c202076d1e
|
@ -25,6 +25,8 @@
|
||||||
class SecurityManagerEventHandler;
|
class SecurityManagerEventHandler;
|
||||||
class LegacySecurityManagerEventHandler;
|
class LegacySecurityManagerEventHandler;
|
||||||
|
|
||||||
|
using ble::connection_handle_t;
|
||||||
|
|
||||||
class SecurityManager {
|
class SecurityManager {
|
||||||
public:
|
public:
|
||||||
enum Keypress_t {
|
enum Keypress_t {
|
||||||
|
@ -497,53 +499,53 @@ public:
|
||||||
SecurityManagerEventHandler() {};
|
SecurityManagerEventHandler() {};
|
||||||
virtual ~SecurityManagerEventHandler() {};
|
virtual ~SecurityManagerEventHandler() {};
|
||||||
|
|
||||||
virtual void securitySetupInitiated(Gap::Handle_t handle, bool allowBonding, bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) {
|
virtual void securitySetupInitiated(connection_handle_t handle, bool allowBonding, bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)allowBonding;
|
(void)allowBonding;
|
||||||
(void)requireMITM;
|
(void)requireMITM;
|
||||||
(void)iocaps;
|
(void)iocaps;
|
||||||
};
|
};
|
||||||
virtual void securitySetupCompleted(Gap::Handle_t handle, SecurityManager::SecurityCompletionStatus_t status) {
|
virtual void securitySetupCompleted(connection_handle_t handle, SecurityManager::SecurityCompletionStatus_t status) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)status;
|
(void)status;
|
||||||
};
|
};
|
||||||
virtual void linkSecured(Gap::Handle_t handle, SecurityManager::SecurityMode_t securityMode) {
|
virtual void linkSecured(connection_handle_t handle, SecurityManager::SecurityMode_t securityMode) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)securityMode;
|
(void)securityMode;
|
||||||
};
|
};
|
||||||
virtual void securityContextStored(Gap::Handle_t handle) {
|
virtual void securityContextStored(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
}
|
}
|
||||||
virtual void passkeyDisplay(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey) {
|
virtual void passkeyDisplay(connection_handle_t handle, const SecurityManager::Passkey_t passkey) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)passkey;
|
(void)passkey;
|
||||||
};
|
};
|
||||||
virtual void validMicTimeout(Gap::Handle_t handle) {
|
virtual void validMicTimeout(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
};
|
};
|
||||||
virtual void linkKeyFailure(Gap::Handle_t handle) {
|
virtual void linkKeyFailure(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
};
|
};
|
||||||
virtual void keypressNotification(Gap::Handle_t handle, SecurityManager::Keypress_t keypress) {
|
virtual void keypressNotification(connection_handle_t handle, SecurityManager::Keypress_t keypress) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)keypress;
|
(void)keypress;
|
||||||
};
|
};
|
||||||
virtual void legacyPairingOobRequest(Gap::Handle_t handle) {
|
virtual void legacyPairingOobRequest(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
};
|
};
|
||||||
virtual void oobRequest(Gap::Handle_t handle) {
|
virtual void oobRequest(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
};
|
};
|
||||||
virtual void pinRequest(Gap::Handle_t handle) {
|
virtual void pinRequest(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
};
|
};
|
||||||
virtual void passkeyRequest(Gap::Handle_t handle) {
|
virtual void passkeyRequest(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
};
|
};
|
||||||
virtual void confirmationRequest(Gap::Handle_t handle) {
|
virtual void confirmationRequest(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
};
|
};
|
||||||
virtual void acceptPairingRequest(Gap::Handle_t handle) {
|
virtual void acceptPairingRequest(connection_handle_t handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -558,27 +560,27 @@ public:
|
||||||
securityContextStoredCallback(),
|
securityContextStoredCallback(),
|
||||||
passkeyDisplayCallback() { };
|
passkeyDisplayCallback() { };
|
||||||
|
|
||||||
void securitySetupInitiated(Gap::Handle_t handle, bool allowBonding, bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) {
|
void securitySetupInitiated(connection_handle_t handle, bool allowBonding, bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) {
|
||||||
if (securitySetupInitiatedCallback) {
|
if (securitySetupInitiatedCallback) {
|
||||||
securitySetupInitiatedCallback(handle, allowBonding, requireMITM, iocaps);
|
securitySetupInitiatedCallback(handle, allowBonding, requireMITM, iocaps);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
void securitySetupCompleted(Gap::Handle_t handle, SecurityManager::SecurityCompletionStatus_t status) {
|
void securitySetupCompleted(connection_handle_t handle, SecurityManager::SecurityCompletionStatus_t status) {
|
||||||
if (securitySetupCompletedCallback) {
|
if (securitySetupCompletedCallback) {
|
||||||
securitySetupCompletedCallback(handle, status);
|
securitySetupCompletedCallback(handle, status);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
void linkSecured(Gap::Handle_t handle, SecurityManager::SecurityMode_t securityMode) {
|
void linkSecured(connection_handle_t handle, SecurityManager::SecurityMode_t securityMode) {
|
||||||
if (linkSecuredCallback) {
|
if (linkSecuredCallback) {
|
||||||
linkSecuredCallback(handle, securityMode);
|
linkSecuredCallback(handle, securityMode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
void securityContextStored(Gap::Handle_t handle) {
|
void securityContextStored(connection_handle_t handle) {
|
||||||
if (securityContextStoredCallback) {
|
if (securityContextStoredCallback) {
|
||||||
securityContextStoredCallback(handle);
|
securityContextStoredCallback(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void passkeyDisplay(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey) {
|
void passkeyDisplay(connection_handle_t handle, const SecurityManager::Passkey_t passkey) {
|
||||||
if (passkeyDisplayCallback) {
|
if (passkeyDisplayCallback) {
|
||||||
passkeyDisplayCallback(handle, passkey);
|
passkeyDisplayCallback(handle, passkey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,7 @@ typedef SecurityManager::C192_t c192_t;
|
||||||
typedef SecurityManager::R192_t r192_t;
|
typedef SecurityManager::R192_t r192_t;
|
||||||
typedef SecurityManager::C256_t c256_t;
|
typedef SecurityManager::C256_t c256_t;
|
||||||
typedef SecurityManager::R256_t r256_t;
|
typedef SecurityManager::R256_t r256_t;
|
||||||
|
typedef BLEProtocol::AddressBytes_t address_t;
|
||||||
using BLEProtocol::Address_t;
|
|
||||||
|
|
||||||
typedef uint8_t irk_t[16];
|
typedef uint8_t irk_t[16];
|
||||||
typedef uint8_t csrk_t[16];
|
typedef uint8_t csrk_t[16];
|
||||||
|
@ -52,7 +51,7 @@ typedef uint8_t rand_t[2];
|
||||||
typedef uint32_t passkey_num_t;
|
typedef uint32_t passkey_num_t;
|
||||||
|
|
||||||
struct bonded_list_entry_t {
|
struct bonded_list_entry_t {
|
||||||
Address_t peer_address;
|
address_t peer_address;
|
||||||
ediv_t ediv;
|
ediv_t ediv;
|
||||||
rand_t rand;
|
rand_t rand;
|
||||||
ltk_t ltk;
|
ltk_t ltk;
|
||||||
|
@ -60,7 +59,7 @@ struct bonded_list_entry_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct resolving_list_entry_t {
|
struct resolving_list_entry_t {
|
||||||
Address_t peer_address;
|
address_t peer_address;
|
||||||
irk_t peer_irk;
|
irk_t peer_irk;
|
||||||
irk_t local_irk;
|
irk_t local_irk;
|
||||||
};
|
};
|
||||||
|
@ -81,89 +80,91 @@ struct bonded_list_t {
|
||||||
|
|
||||||
class SecurityManagerEventHandler {
|
class SecurityManagerEventHandler {
|
||||||
SecurityManagerEventHandler() : _app_event_handler(NULL) { };
|
SecurityManagerEventHandler() : _app_event_handler(NULL) { };
|
||||||
virtual void security_setup_initiated(Gap::Handle_t handle, bool allowBonding,
|
virtual void security_setup_initiated(connection_handle_t handle, bool allowBonding,
|
||||||
bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) {
|
bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->securitySetupInitiated(handle, allowBonding, requireMITM, iocaps);
|
_app_event_handler->securitySetupInitiated(handle, allowBonding, requireMITM, iocaps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void security_setup_completed(Gap::Handle_t handle,
|
virtual void security_setup_completed(connection_handle_t handle,
|
||||||
SecurityManager::SecurityCompletionStatus_t status) {
|
SecurityManager::SecurityCompletionStatus_t status) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->securitySetupCompleted(handle, status);
|
_app_event_handler->securitySetupCompleted(handle, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void link_secured(Gap::Handle_t handle, SecurityManager::SecurityMode_t securityMode) {
|
virtual void link_secured(connection_handle_t handle, SecurityManager::SecurityMode_t securityMode) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->linkSecured(handle, securityMode);
|
_app_event_handler->linkSecured(handle, securityMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void security_context_stored(Gap::Handle_t handle) {
|
virtual void security_context_stored(connection_handle_t handle) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->securityContextStored(handle);
|
_app_event_handler->securityContextStored(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void passkey_display(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey) {
|
virtual void passkey_display(connection_handle_t handle, const SecurityManager::Passkey_t passkey) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->passkeyDisplay(handle, passkey);
|
_app_event_handler->passkeyDisplay(handle, passkey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void valid_mic_timeout(Gap::Handle_t handle) {
|
virtual void valid_mic_timeout(connection_handle_t handle) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->validMicTimeout(handle);
|
_app_event_handler->validMicTimeout(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void link_key_failure(Gap::Handle_t handle) {
|
virtual void link_key_failure(connection_handle_t handle) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->linkKeyFailure(handle);
|
_app_event_handler->linkKeyFailure(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void keypress_notification(Gap::Handle_t handle, SecurityManager::Keypress_t keypress) {
|
virtual void keypress_notification(connection_handle_t handle, SecurityManager::Keypress_t keypress) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->keypressNotification(handle, keypress);
|
_app_event_handler->keypressNotification(handle, keypress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void legacy_pariring_oob_request(Gap::Handle_t handle) {
|
virtual void legacy_pariring_oob_request(connection_handle_t handle) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->legacyPairingOobRequest(handle);
|
_app_event_handler->legacyPairingOobRequest(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void oob_request(Gap::Handle_t handle) {
|
virtual void oob_request(connection_handle_t handle) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->oobRequest(handle);
|
_app_event_handler->oobRequest(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void pin_request(Gap::Handle_t handle) {
|
virtual void pin_request(connection_handle_t handle) {
|
||||||
|
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->pinRequest(handle);
|
_app_event_handler->pinRequest(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void passkey_request(Gap::Handle_t handle) {
|
virtual void passkey_request(connection_handle_t handle) {
|
||||||
|
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->passkeyRequest(handle);
|
_app_event_handler->passkeyRequest(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void confirmation_request(Gap::Handle_t handle) {
|
virtual void confirmation_request(connection_handle_t handle) {
|
||||||
|
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->confirmationRequest(handle);
|
_app_event_handler->confirmationRequest(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void accept_pairing_request(Gap::Handle_t handle) {
|
virtual void accept_pairing_request(connection_handle_t handle) {
|
||||||
if (_app_event_handler) {
|
if (_app_event_handler) {
|
||||||
_app_event_handler->acceptPairingRequest(handle);
|
_app_event_handler->acceptPairingRequest(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void keys_exchanged(Gap::Handle_t handle, Address_t &peer_address, ediv_t &ediv, rand_t &rand, ltk_t <k, csrk_t &csrk);
|
virtual void keys_exchanged(connection_handle_t handle, address_t &peer_address, ediv_t &ediv,
|
||||||
|
rand_t &rand, ltk_t <k, csrk_t &csrk);
|
||||||
|
virtual void ltk_request(connection_handle_t handle, ediv_t &ediv, rand_t &rand);
|
||||||
|
|
||||||
virtual void set_app_event_handler(::SecurityManagerEventHandler *app_event_handler) {
|
virtual void set_app_event_handler(::SecurityManagerEventHandler *app_event_handler) {
|
||||||
_app_event_handler = app_event_handler;
|
_app_event_handler = app_event_handler;
|
||||||
|
@ -293,12 +294,18 @@ public:
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ble_error_t generate_irk() {
|
/* keys */
|
||||||
|
|
||||||
|
virtual ble_error_t set_key_distribution() {
|
||||||
|
(void);
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
virtual ble_error_t generate_csrk() {
|
|
||||||
|
virtual ble_error_t set_ltk(connection_handle_t handle, ltk_t ltk) {
|
||||||
|
(void)ltk;
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ble_error_t set_irk(irk_t irk) {
|
virtual ble_error_t set_irk(irk_t irk) {
|
||||||
(void)irk;
|
(void)irk;
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
@ -307,6 +314,12 @@ public:
|
||||||
(void)csrk;
|
(void)csrk;
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
virtual ble_error_t generate_irk() {
|
||||||
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
virtual ble_error_t generate_csrk() {
|
||||||
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
/* authentication */
|
/* authentication */
|
||||||
|
|
||||||
|
@ -316,23 +329,22 @@ public:
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ble_error_t request_pairing(bool authentication_required = true) {
|
virtual ble_error_t request_pairing() {
|
||||||
(void)authentication_required;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
virtual ble_error_t set_pairing_request_authorisation(bool authorisation_required = true) {
|
||||||
|
(void)authorisation_required;
|
||||||
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
virtual ble_error_t accept_pairing() {
|
||||||
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
virtual ble_error_t reject_pairing() {
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
virtual ble_error_t cancel_pairing() {
|
virtual ble_error_t cancel_pairing() {
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
virtual ble_error_t set_pairing_request_authorisation(bool authorisation_required = true) {
|
|
||||||
(void)authentication_required;
|
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
virtual ble_error_t accept_pairing(bool accept = true) {
|
|
||||||
(void)accept;
|
|
||||||
(void)authentication_required;
|
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
reject_pairing
|
|
||||||
|
|
||||||
virtual ble_error_t request_authentication() {
|
virtual ble_error_t request_authentication() {
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
Loading…
Reference in New Issue