/* mbed Microcontroller Library * Copyright (c) 2019 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. */ #include "ble/SecurityManager.h" namespace ble { namespace interface { template ble_error_t SecurityManager::init( bool enableBonding, bool requireMITM, SecurityIOCapabilities_t iocaps, const Passkey_t passkey, bool signing, const char *dbFilepath ) { return impl()->init_( enableBonding, requireMITM, iocaps, passkey, signing, dbFilepath ); } template ble_error_t SecurityManager::setDatabaseFilepath(const char *dbFilepath) { return impl()->setDatabaseFilepath_(dbFilepath); } template ble_error_t SecurityManager::reset(void) { return impl()->reset_(); } template ble_error_t SecurityManager::reset_() { /* Notify that the instance is about to shutdown */ shutdownCallChain.call(this); shutdownCallChain.clear(); eventHandler = &defaultEventHandler; return BLE_ERROR_NONE; } template ble_error_t SecurityManager::preserveBondingStateOnReset(bool enable) { return impl()->preserveBondingStateOnReset_(enable); } template ble_error_t SecurityManager::purgeAllBondingState(void) { return impl()->purgeAllBondingState_(); } template ble_error_t SecurityManager::generateWhitelistFromBondTable( ::Gap::Whitelist_t *whitelist ) const { return impl()->generateWhitelistFromBondTable_(whitelist); } template ble_error_t SecurityManager::requestPairing( ble::connection_handle_t connectionHandle ) { return impl()->requestPairing_(connectionHandle); } template ble_error_t SecurityManager::acceptPairingRequest( ble::connection_handle_t connectionHandle ) { return impl()->acceptPairingRequest_(connectionHandle); } template ble_error_t SecurityManager::cancelPairingRequest( ble::connection_handle_t connectionHandle ) { return impl()->cancelPairingRequest_(connectionHandle); } template ble_error_t SecurityManager::setPairingRequestAuthorisation( bool required ) { return impl()->setPairingRequestAuthorisation_(required); } template ble_error_t SecurityManager::allowLegacyPairing(bool allow) { return impl()->allowLegacyPairing_(allow); } template ble_error_t SecurityManager::getSecureConnectionsSupport(bool *enabled) { return impl()->getSecureConnectionsSupport_(enabled); } template ble_error_t SecurityManager::setIoCapability(SecurityIOCapabilities_t iocaps) { return impl()->setIoCapability_(iocaps); } template ble_error_t SecurityManager::setDisplayPasskey(const Passkey_t passkey) { return impl()->setDisplayPasskey_(passkey); } template ble_error_t SecurityManager::setLinkSecurity( ble::connection_handle_t connectionHandle, SecurityMode_t securityMode ) { return impl()->setLinkSecurity_(connectionHandle, securityMode); } template ble_error_t SecurityManager::setKeypressNotification(bool enabled) { return impl()->setKeypressNotification_(enabled); } #if BLE_FEATURE_SIGNING template ble_error_t SecurityManager::enableSigning( ble::connection_handle_t connectionHandle, bool enabled ) { return impl()->enableSigning_(connectionHandle, enabled); } #endif // BLE_FEATURE_SIGNING template ble_error_t SecurityManager::setHintFutureRoleReversal(bool enable) { return impl()->setHintFutureRoleReversal_(enable); } template ble_error_t SecurityManager::getLinkEncryption( ble::connection_handle_t connectionHandle, ble::link_encryption_t *encryption ) { return impl()->getLinkEncryption_(connectionHandle, encryption); } template ble_error_t SecurityManager::setLinkEncryption( ble::connection_handle_t connectionHandle, ble::link_encryption_t encryption ) { return impl()->setLinkEncryption_(connectionHandle, encryption); } template ble_error_t SecurityManager::setEncryptionKeyRequirements( uint8_t minimumByteSize, uint8_t maximumByteSize ) { return impl()->setEncryptionKeyRequirements_(minimumByteSize, maximumByteSize); } template ble_error_t SecurityManager::requestAuthentication( ble::connection_handle_t connectionHandle ) { return impl()->requestAuthentication_(connectionHandle); } template ble_error_t SecurityManager::generateOOB(const ble::address_t *address) { return impl()->generateOOB_(address); } template ble_error_t SecurityManager::setOOBDataUsage( ble::connection_handle_t connectionHandle, bool useOOB, bool OOBProvidesMITM ) { return impl()->setOOBDataUsage_(connectionHandle, useOOB, OOBProvidesMITM); } template ble_error_t SecurityManager::confirmationEntered( ble::connection_handle_t connectionHandle, bool confirmation ) { return impl()->confirmationEntered_(connectionHandle, confirmation); } template ble_error_t SecurityManager::passkeyEntered( ble::connection_handle_t connectionHandle, Passkey_t passkey ) { return impl()->passkeyEntered_(connectionHandle, passkey); } template ble_error_t SecurityManager::sendKeypressNotification( ble::connection_handle_t connectionHandle, Keypress_t keypress ) { return impl()->sendKeypressNotification_(connectionHandle, keypress); } template ble_error_t SecurityManager::legacyPairingOobReceived( const ble::address_t *address, const ble::oob_tk_t *tk ) { return impl()->legacyPairingOobReceived_(address, tk); } template ble_error_t SecurityManager::oobReceived( const ble::address_t *address, const ble::oob_lesc_value_t *random, const ble::oob_confirm_t *confirm ) { return impl()->oobReceived_(address, random, confirm); } template ble_error_t SecurityManager::getSigningKey( ble::connection_handle_t connectionHandle, bool authenticated ) { return impl()->getSigningKey_(connectionHandle, authenticated); } template ble_error_t SecurityManager::getAddressesFromBondTable( ::Gap::Whitelist_t &addresses ) const { return impl()->getAddressesFromBondTable_(addresses); } template ble_error_t SecurityManager::getAddressesFromBondTable_( ::Gap::Whitelist_t &addresses ) const { return BLE_ERROR_NOT_IMPLEMENTED; } /* ------------------------ Dummy implementations --------------------------- */ template ble_error_t SecurityManager::init_( bool enableBonding, bool requireMITM, SecurityIOCapabilities_t iocaps, const Passkey_t passkey, bool signing, const char *dbFilepath ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setDatabaseFilepath_(const char *dbFilepath) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::preserveBondingStateOnReset_(bool enable) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::purgeAllBondingState_(void) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::generateWhitelistFromBondTable_( ::Gap::Whitelist_t *whitelist ) const { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::requestPairing_( ble::connection_handle_t connectionHandle ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::acceptPairingRequest_( ble::connection_handle_t connectionHandle ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::cancelPairingRequest_( ble::connection_handle_t connectionHandle ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setPairingRequestAuthorisation_( bool required ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::allowLegacyPairing_(bool allow) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::getSecureConnectionsSupport_(bool *enabled) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setIoCapability_(SecurityIOCapabilities_t iocaps) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setDisplayPasskey_(const Passkey_t passkey) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setLinkSecurity_( ble::connection_handle_t connectionHandle, SecurityMode_t securityMode ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setKeypressNotification_(bool enabled) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::enableSigning_( ble::connection_handle_t connectionHandle, bool enabled ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setHintFutureRoleReversal_(bool enable) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::getLinkEncryption_( ble::connection_handle_t connectionHandle, ble::link_encryption_t *encryption ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setLinkEncryption_( ble::connection_handle_t connectionHandle, ble::link_encryption_t encryption ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setEncryptionKeyRequirements_( uint8_t minimumByteSize, uint8_t maximumByteSize ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::requestAuthentication_( ble::connection_handle_t connectionHandle ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::generateOOB_(const ble::address_t *address) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::setOOBDataUsage_( ble::connection_handle_t connectionHandle, bool useOOB, bool OOBProvidesMITM ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::confirmationEntered_( ble::connection_handle_t connectionHandle, bool confirmation ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::passkeyEntered_( ble::connection_handle_t connectionHandle, Passkey_t passkey ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::sendKeypressNotification_( ble::connection_handle_t connectionHandle, Keypress_t keypress ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::legacyPairingOobReceived_( const ble::address_t *address, const ble::oob_tk_t *tk ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::oobReceived_( const ble::address_t *address, const ble::oob_lesc_value_t *random, const ble::oob_confirm_t *confirm ) { return BLE_ERROR_NOT_IMPLEMENTED; } template ble_error_t SecurityManager::getSigningKey_( ble::connection_handle_t connectionHandle, bool authenticated ) { return BLE_ERROR_NOT_IMPLEMENTED; } } // interface } // ble