2018-01-29 17:57:00 +00:00
|
|
|
/* mbed Microcontroller Library
|
|
|
|
* Copyright (c) 2018 ARM Limited
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GENERIC_SECURITY_MANAGER_H__
|
|
|
|
#define __GENERIC_SECURITY_MANAGER_H__
|
|
|
|
|
|
|
|
#include "ble/pal/GapTypes.h"
|
|
|
|
#include "ble/BLETypes.h"
|
|
|
|
#include "ble/generic/GenericSecurityDb.h"
|
|
|
|
#include "Callback.h"
|
|
|
|
|
|
|
|
namespace ble {
|
|
|
|
namespace generic {
|
|
|
|
|
|
|
|
using ble::pal::advertising_peer_address_type_t;
|
2018-01-31 18:06:01 +00:00
|
|
|
using ble::pal::AuthenticationMask;
|
|
|
|
using ble::pal::KeyDistribution;
|
2018-02-06 10:17:31 +00:00
|
|
|
using ble::pal::connection_peer_address_type_t;
|
2018-01-31 18:06:01 +00:00
|
|
|
|
2018-02-06 22:59:21 +00:00
|
|
|
using ble::address_t;
|
2018-01-29 17:57:00 +00:00
|
|
|
using ble::irk_t;
|
|
|
|
using ble::csrk_t;
|
|
|
|
using ble::ltk_t;
|
|
|
|
using ble::ediv_t;
|
|
|
|
using ble::rand_t;
|
|
|
|
using ble::pairing_failure_t;
|
2018-02-06 15:39:31 +00:00
|
|
|
using ble::PasskeyAscii;
|
2018-01-31 18:06:01 +00:00
|
|
|
using ble::passkey_num_t;
|
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
typedef SecurityManager::SecurityIOCapabilities_t SecurityIOCapabilities_t;
|
|
|
|
|
|
|
|
class GenericSecurityManagerEventHandler;
|
|
|
|
|
|
|
|
class GenericSecurityManager : public SecurityManager,
|
|
|
|
public ble::pal::SecurityManagerEventHandler {
|
|
|
|
public:
|
2018-02-08 16:03:52 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// GAP integration
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inform the security manager that a device has been disconnected and its
|
|
|
|
* entry can be put in NVM storage. Called by GAP.
|
|
|
|
*
|
|
|
|
* @param[in] connectionHandle Handle to identify the connection.
|
|
|
|
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
|
|
|
*/
|
|
|
|
virtual void disconnected(
|
|
|
|
connection_handle_t connection
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inform the Security manager of a new connection. This will create
|
|
|
|
* or retrieve an existing security manager entry for the connected device.
|
|
|
|
* Called by GAP.
|
|
|
|
*
|
|
|
|
* @param[in] connectionHandle Handle to identify the connection.
|
|
|
|
* @param[in] is_master True if device is the master.
|
|
|
|
* @param[in] peer_address_type type of address
|
|
|
|
* @param[in] peer_address Address of the connected device.
|
|
|
|
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
|
|
|
*/
|
|
|
|
virtual void connected(
|
|
|
|
connection_handle_t connection,
|
|
|
|
bool is_master,
|
|
|
|
connection_peer_address_type_t::type peer_address_type,
|
|
|
|
const address_t &peer_address
|
|
|
|
);
|
|
|
|
|
|
|
|
/* implements SecurityManager */
|
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SM lifecycle management
|
|
|
|
//
|
2018-02-08 16:03:52 +00:00
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual ble_error_t init(
|
|
|
|
bool bondable = true,
|
|
|
|
bool mitm = true,
|
|
|
|
SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
|
|
|
|
const Passkey_t passkey = NULL,
|
|
|
|
bool signing = true
|
|
|
|
);
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t reset();
|
2018-01-29 17:57:00 +00:00
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t preserveBondingStateOnReset(
|
|
|
|
bool enabled
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// List management
|
|
|
|
//
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t purgeAllBondingState();
|
2018-01-29 17:57:00 +00:00
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t generateWhitelistFromBondTable(
|
|
|
|
Gap::Whitelist_t *whitelist
|
|
|
|
) const;
|
2018-01-30 22:49:35 +00:00
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Pairing
|
|
|
|
//
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t requestPairing(
|
|
|
|
connection_handle_t connection
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t acceptPairingRequest(
|
|
|
|
connection_handle_t connection
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t canceltPairingRequest(
|
|
|
|
connection_handle_t connection
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t setPairingRequestAuthorisation(
|
|
|
|
bool required = true
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Feature support
|
|
|
|
//
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t allowLegacyPairing(
|
|
|
|
bool allow = true
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t getSecureConnectionsSupport(
|
|
|
|
bool *enabled
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Security settings
|
|
|
|
//
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t setIoCapability(
|
|
|
|
SecurityIOCapabilities_t iocaps
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t setDisplayPasskey(
|
|
|
|
const Passkey_t passkey
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
virtual ble_error_t setAuthenticationTimeout(
|
|
|
|
connection_handle_t connection,
|
|
|
|
uint32_t timeout_in_ms
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ble_error_t getAuthenticationTimeout(
|
|
|
|
connection_handle_t connection,
|
|
|
|
uint32_t *timeout_in_ms
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ble_error_t setLinkSecurity(
|
|
|
|
connection_handle_t connection,
|
|
|
|
SecurityMode_t securityMode
|
|
|
|
);
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t setKeypressNotification(
|
|
|
|
bool enabled = true
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
virtual ble_error_t enableSigning(
|
|
|
|
connection_handle_t connection,
|
|
|
|
bool enabled = true
|
|
|
|
);
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t setHintFutureRoleReversal(
|
|
|
|
bool enable = true
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Encryption
|
|
|
|
//
|
|
|
|
|
|
|
|
virtual ble_error_t getLinkEncryption(
|
|
|
|
connection_handle_t connection,
|
|
|
|
link_encryption_t *encryption
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ble_error_t setLinkEncryption(
|
|
|
|
connection_handle_t connection,
|
|
|
|
link_encryption_t encryption
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ble_error_t getEncryptionKeySize(
|
|
|
|
connection_handle_t connection,
|
|
|
|
uint8_t *size
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ble_error_t setEncryptionKeyRequirements(
|
|
|
|
uint8_t minimumByteSize,
|
|
|
|
uint8_t maximumByteSize
|
|
|
|
);
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Privacy
|
|
|
|
//
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t setPrivateAddressTimeout(
|
|
|
|
uint16_t timeout_in_seconds
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Keys
|
|
|
|
//
|
|
|
|
|
2018-01-29 21:10:08 +00:00
|
|
|
virtual ble_error_t getSigningKey(
|
|
|
|
connection_handle_t connection,
|
|
|
|
bool authenticated
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Authentication
|
|
|
|
//
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
virtual ble_error_t requestAuthentication(
|
|
|
|
connection_handle_t connection
|
|
|
|
);
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// MITM
|
|
|
|
//
|
|
|
|
|
|
|
|
virtual ble_error_t setOOBDataUsage(
|
|
|
|
connection_handle_t connection,
|
|
|
|
bool useOOB,
|
|
|
|
bool OOBProvidesMITM = true
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ble_error_t confirmationEntered(
|
|
|
|
connection_handle_t connection,
|
|
|
|
bool confirmation
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ble_error_t passkeyEntered(
|
|
|
|
connection_handle_t connection,
|
|
|
|
Passkey_t passkey
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual ble_error_t sendKeypressNotification(
|
|
|
|
connection_handle_t connection,
|
|
|
|
Keypress_t keypress
|
|
|
|
);
|
2018-01-29 23:16:47 +00:00
|
|
|
|
2018-02-06 22:59:21 +00:00
|
|
|
virtual ble_error_t legacyPairingOobReceived(
|
2018-02-07 10:16:44 +00:00
|
|
|
const address_t *address,
|
2018-02-06 22:59:21 +00:00
|
|
|
const oob_tk_t *tk
|
2018-02-06 10:17:31 +00:00
|
|
|
);
|
|
|
|
|
2018-02-06 22:59:21 +00:00
|
|
|
virtual ble_error_t oobReceived(
|
2018-02-07 10:16:44 +00:00
|
|
|
const address_t *address,
|
2018-02-06 22:59:21 +00:00
|
|
|
const oob_rand_t *random,
|
|
|
|
const oob_confirm_t *confirm
|
|
|
|
);
|
2018-02-06 10:17:31 +00:00
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
/* ends implements SecurityManager */
|
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
protected:
|
|
|
|
GenericSecurityManager(ble::pal::SecurityManager& palImpl, GenericSecurityDb& dbImpl)
|
|
|
|
: _pal(palImpl),
|
|
|
|
_db(dbImpl),
|
2018-02-08 18:23:23 +00:00
|
|
|
_default_authentication(0),
|
|
|
|
_default_key_distribution(KeyDistribution::KEY_DISTRIBUTION_ALL),
|
2018-01-29 17:57:00 +00:00
|
|
|
_pairing_authorisation_required(false),
|
|
|
|
_legacy_pairing_allowed(true),
|
|
|
|
_master_sends_keys(false),
|
2018-02-08 18:23:23 +00:00
|
|
|
_public_keys_generated(false) {
|
2018-01-29 17:57:00 +00:00
|
|
|
_app_event_handler = &defaultEventHandler;
|
|
|
|
_pal.set_event_handler(this);
|
|
|
|
}
|
|
|
|
|
2018-01-29 23:16:47 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helper functions
|
|
|
|
//
|
|
|
|
|
|
|
|
private:
|
2018-01-31 20:16:56 +00:00
|
|
|
/**
|
|
|
|
* Generate the CSRK if needed.
|
|
|
|
*
|
|
|
|
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
|
|
|
*/
|
2018-01-29 23:16:47 +00:00
|
|
|
ble_error_t init_signing();
|
|
|
|
|
2018-01-31 20:16:56 +00:00
|
|
|
/**
|
|
|
|
* Send slave security request based on current link settings.
|
|
|
|
*
|
|
|
|
* @param[in] connectionHandle Handle to identify the connection.
|
|
|
|
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
|
|
|
*/
|
2018-01-29 23:16:47 +00:00
|
|
|
ble_error_t slave_security_request(connection_handle_t connection);
|
|
|
|
|
2018-01-31 20:16:56 +00:00
|
|
|
/**
|
|
|
|
* Enable encryption on the link, depending on whether device is master or slave.
|
|
|
|
*
|
|
|
|
* @param[in] connectionHandle Handle to identify the connection.
|
|
|
|
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
|
|
|
*/
|
2018-01-29 23:16:47 +00:00
|
|
|
ble_error_t enable_encryption(connection_handle_t connection);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the requested LTK to the PAL. Called by the security db.
|
|
|
|
*
|
2018-01-31 20:16:56 +00:00
|
|
|
* @param[in] entry security entry returned by the database.
|
|
|
|
* @param[in] entryKeys security entry containing keys.
|
2018-01-29 23:16:47 +00:00
|
|
|
*/
|
2018-01-31 20:16:56 +00:00
|
|
|
void enable_encryption_cb(
|
|
|
|
const SecurityEntry_t* entry,
|
|
|
|
const SecurityEntryKeys_t* entryKeys
|
2018-01-29 23:16:47 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the requested LTK to the PAL. Called by the security db.
|
|
|
|
*
|
2018-01-31 20:16:56 +00:00
|
|
|
* @param[in] entry security entry returned by the database.
|
|
|
|
* @param[in] entryKeys security entry containing keys.
|
2018-01-29 23:16:47 +00:00
|
|
|
*/
|
2018-01-31 20:16:56 +00:00
|
|
|
void set_ltk_cb(
|
|
|
|
const SecurityEntry_t* entry,
|
|
|
|
const SecurityEntryKeys_t* entryKeys
|
2018-01-29 23:16:47 +00:00
|
|
|
);
|
|
|
|
|
2018-01-31 20:16:56 +00:00
|
|
|
/**
|
|
|
|
* Returns the CSRK for the connection. Called by the security db.
|
|
|
|
*
|
2018-02-08 18:23:23 +00:00
|
|
|
* @param[in] connectionHandle Handle to identify the connection.
|
2018-01-31 20:16:56 +00:00
|
|
|
* @param[in] entryKeys security entry containing keys.
|
|
|
|
*/
|
2018-01-29 23:16:47 +00:00
|
|
|
void return_csrk_cb(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const csrk_t *csrk
|
|
|
|
);
|
|
|
|
|
2018-02-08 18:23:23 +00:00
|
|
|
/**
|
|
|
|
* Generate local OOB data to be sent to the application which sends it to the peer.
|
|
|
|
*
|
|
|
|
* @param[in] connectionHandle Handle to identify the connection.
|
|
|
|
*/
|
|
|
|
void generate_secure_connections_oob(
|
|
|
|
connection_handle_t connection
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the entry for the connection with OOB data presence.
|
|
|
|
*
|
|
|
|
* @param[in] connectionHandle Handle to identify the connection.
|
|
|
|
*/
|
|
|
|
void update_oob_presence(
|
|
|
|
connection_handle_t connection
|
|
|
|
);
|
2018-02-08 21:48:43 +00:00
|
|
|
/**
|
|
|
|
* Calculate the confirmation value for secure connections OOB data based
|
|
|
|
* on local public key and a random number.
|
|
|
|
* @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part H - 2.2.6
|
|
|
|
|
|
|
|
* @param[in] U public key x component
|
|
|
|
* @param[in] V public key y component
|
|
|
|
* @param[in] X random number
|
|
|
|
* @param[out] confirm confirmation value
|
|
|
|
*/
|
|
|
|
static void crypto_toolbox_f4(
|
|
|
|
const public_key_t& U,
|
|
|
|
const public_key_t& V,
|
|
|
|
const oob_rand_t& X,
|
|
|
|
oob_confirm_t& confirm
|
|
|
|
);
|
2018-02-08 18:23:23 +00:00
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
private:
|
|
|
|
ble::pal::SecurityManager& _pal;
|
|
|
|
GenericSecurityDb& _db;
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
AuthenticationMask _default_authentication;
|
|
|
|
KeyDistribution _default_key_distribution;
|
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
bool _pairing_authorisation_required;
|
|
|
|
bool _legacy_pairing_allowed;
|
|
|
|
bool _master_sends_keys;
|
2018-02-08 16:03:52 +00:00
|
|
|
bool _public_keys_generated;
|
2018-01-29 17:57:00 +00:00
|
|
|
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
/* implements ble::pal::SecurityManagerEventHandler */
|
2018-01-29 17:57:00 +00:00
|
|
|
public:
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Pairing
|
|
|
|
//
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_pairing_request
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_pairing_request(
|
|
|
|
connection_handle_t connection,
|
|
|
|
bool use_oob,
|
|
|
|
AuthenticationMask authentication,
|
|
|
|
KeyDistribution initiator_dist,
|
|
|
|
KeyDistribution responder_dist
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_pairing_error
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_pairing_error(
|
|
|
|
connection_handle_t connection,
|
|
|
|
pairing_failure_t error
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_pairing_timed_out
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_pairing_timed_out(connection_handle_t connection);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_pairing_completed
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_pairing_completed(connection_handle_t connection);
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Security
|
|
|
|
//
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_valid_mic_timeout
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_valid_mic_timeout(connection_handle_t connection);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_slave_security_request
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_slave_security_request(
|
|
|
|
connection_handle_t connection,
|
|
|
|
AuthenticationMask authentication
|
|
|
|
);
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Encryption
|
|
|
|
//
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_link_encryption_result
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_link_encryption_result(
|
|
|
|
connection_handle_t connection,
|
|
|
|
link_encryption_t result
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_link_encryption_request_timed_out
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_link_encryption_request_timed_out(
|
|
|
|
connection_handle_t connection
|
|
|
|
);
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// MITM
|
|
|
|
//
|
2018-01-31 20:16:56 +00:00
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::set_mitm_performed
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void set_mitm_performed(connection_handle_t connection, bool enable = true);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_passkey_display
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_passkey_display(
|
|
|
|
connection_handle_t connection,
|
2018-01-29 22:00:53 +00:00
|
|
|
passkey_num_t passkey
|
2018-01-29 17:57:00 +00:00
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keypress_notification
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keypress_notification(
|
|
|
|
connection_handle_t connection,
|
|
|
|
SecurityManager::Keypress_t keypress
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_passkey_request
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_passkey_request(connection_handle_t connection);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_confirmation_request
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_confirmation_request(connection_handle_t connection);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_legacy_pairing_oob_request
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_legacy_pairing_oob_request(connection_handle_t connection);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_oob_request
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_oob_request(connection_handle_t connection);
|
|
|
|
|
2018-02-08 15:17:12 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_oob_data_verification_request
|
|
|
|
*/
|
|
|
|
virtual void on_oob_data_verification_request(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const public_key_t &peer_public_key_x,
|
|
|
|
const public_key_t &peer_public_key_y
|
|
|
|
);
|
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Keys
|
|
|
|
//
|
|
|
|
|
2018-02-08 16:03:52 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_public_key_generated
|
|
|
|
*/
|
|
|
|
virtual void on_public_key_generated(
|
|
|
|
const public_key_t &public_key_x,
|
|
|
|
const public_key_t &public_key_y
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_secure_connections_ltk_generated
|
|
|
|
*/
|
2018-02-06 21:50:57 +00:00
|
|
|
virtual void on_secure_connections_ltk_generated(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const ltk_t *ltk
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keys_distributed
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keys_distributed(
|
|
|
|
connection_handle_t connection,
|
|
|
|
advertising_peer_address_type_t peer_address_type,
|
|
|
|
const address_t &peer_identity_address,
|
|
|
|
const ediv_t *ediv,
|
|
|
|
const rand_t *rand,
|
|
|
|
const ltk_t *ltk,
|
|
|
|
const irk_t *irk,
|
|
|
|
const csrk_t *csrk
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keys_distributed_ltk
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keys_distributed_ltk(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const ltk_t *ltk
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keys_distributed_ediv_rand
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keys_distributed_ediv_rand(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const ediv_t *ediv,
|
|
|
|
const rand_t *rand
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keys_distributed_local_ltk
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keys_distributed_local_ltk(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const ltk_t *ltk
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keys_distributed_local_ediv_rand
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keys_distributed_local_ediv_rand(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const ediv_t *ediv,
|
|
|
|
const rand_t *rand
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keys_distributed_irk
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keys_distributed_irk(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const irk_t *irk
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keys_distributed_bdaddr
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keys_distributed_bdaddr(
|
|
|
|
connection_handle_t connection,
|
|
|
|
advertising_peer_address_type_t peer_address_type,
|
|
|
|
const address_t &peer_identity_address
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_keys_distributed_csrk
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_keys_distributed_csrk(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const csrk_t *csrk
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/** @copydoc SecurityManagerEventHandler::on_ltk_requeston_ltk_request
|
|
|
|
*/
|
2018-01-29 17:57:00 +00:00
|
|
|
virtual void on_ltk_request(
|
|
|
|
connection_handle_t connection,
|
|
|
|
const ediv_t *ediv,
|
|
|
|
const rand_t *rand
|
|
|
|
);
|
|
|
|
|
2018-02-06 22:01:54 +00:00
|
|
|
/* end implements ble::pal::SecurityManagerEventHandler */
|
|
|
|
|
2018-01-29 17:57:00 +00:00
|
|
|
private:
|
|
|
|
/* handler is always a valid pointer */
|
|
|
|
::SecurityManager::SecurityManagerEventHandler *_app_event_handler;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} /* namespace generic */
|
|
|
|
} /* namespace ble */
|
|
|
|
|
|
|
|
|
|
|
|
#endif /*__GENERIC_SECURITY_MANAGER_H__*/
|