mirror of https://github.com/ARMmbed/mbed-os.git
Allow for security db type selection
The selection is now based on the lib json (which allows you to disable filesystem db or kvstore db) and the call to SecurityManager::init. It will always fall back on memory db if no other db is available.pull/13038/head
parent
beb56320eb
commit
559d6afc43
|
@ -17,6 +17,8 @@
|
||||||
#ifndef GENERIC_FILE_SECURITY_DB_H_
|
#ifndef GENERIC_FILE_SECURITY_DB_H_
|
||||||
#define GENERIC_FILE_SECURITY_DB_H_
|
#define GENERIC_FILE_SECURITY_DB_H_
|
||||||
|
|
||||||
|
#if BLE_SECURITY_DATABASE_FILESYSTEM
|
||||||
|
|
||||||
#include "SecurityDb.h"
|
#include "SecurityDb.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -167,4 +169,6 @@ private:
|
||||||
} /* namespace pal */
|
} /* namespace pal */
|
||||||
} /* namespace ble */
|
} /* namespace ble */
|
||||||
|
|
||||||
|
#endif // BLE_SECURITY_DATABASE_FILESYSTEM
|
||||||
|
|
||||||
#endif /*GENERIC_FILE_SECURITY_DB_H_*/
|
#endif /*GENERIC_FILE_SECURITY_DB_H_*/
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if BLE_SECURITY_DATABASE_FILESYSTEM
|
||||||
|
|
||||||
#include "FileSecurityDb.h"
|
#include "FileSecurityDb.h"
|
||||||
|
|
||||||
namespace ble {
|
namespace ble {
|
||||||
|
@ -408,4 +410,7 @@ SecurityEntrySigning_t* FileSecurityDb::read_in_entry_peer_signing(entry_handle_
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace pal */
|
} /* namespace pal */
|
||||||
} /* namespace ble */
|
} /* namespace ble */
|
||||||
|
|
||||||
|
#endif // BLE_SECURITY_DATABASE_FILESYSTEM
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "ble/generic/GenericSecurityManager.h"
|
#include "ble/generic/GenericSecurityManager.h"
|
||||||
#include "ble/generic/MemorySecurityDb.h"
|
#include "ble/generic/MemorySecurityDb.h"
|
||||||
#include "ble/generic/FileSecurityDb.h"
|
#include "ble/generic/FileSecurityDb.h"
|
||||||
|
#include "ble/generic/KVStoreSecurityDb.h"
|
||||||
|
|
||||||
using ble::pal::advertising_peer_address_type_t;
|
using ble::pal::advertising_peer_address_type_t;
|
||||||
using ble::pal::AuthenticationMask;
|
using ble::pal::AuthenticationMask;
|
||||||
|
@ -884,11 +885,19 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::init_da
|
||||||
) {
|
) {
|
||||||
delete _db;
|
delete _db;
|
||||||
|
|
||||||
|
#if BLE_SECURITY_DATABASE_FILESYSTEM
|
||||||
FILE* db_file = FileSecurityDb::open_db_file(db_path);
|
FILE* db_file = FileSecurityDb::open_db_file(db_path);
|
||||||
|
|
||||||
if (db_file) {
|
if (db_file) {
|
||||||
_db = new (std::nothrow) FileSecurityDb(db_file);
|
_db = new (std::nothrow) FileSecurityDb(db_file);
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
#if BLE_SECURITY_DATABASE_KVSTORE
|
||||||
|
if (KVStoreSecurityDb::open_db()) {
|
||||||
|
_db = new (std::nothrow) KVStoreSecurityDb();
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
_db = new (std::nothrow) MemorySecurityDb();
|
_db = new (std::nothrow) MemorySecurityDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue