Skip to content

Commit cc92a46

Browse files
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.
1 parent 2998495 commit cc92a46

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

features/FEATURE_BLE/ble/generic/FileSecurityDb.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef GENERIC_FILE_SECURITY_DB_H_
1818
#define GENERIC_FILE_SECURITY_DB_H_
1919

20+
#if BLE_SECURITY_DATABASE_FILESYSTEM
21+
2022
#include "SecurityDb.h"
2123

2224
#include <stdio.h>
@@ -167,4 +169,6 @@ class FileSecurityDb : public SecurityDb {
167169
} /* namespace pal */
168170
} /* namespace ble */
169171

172+
#endif // BLE_SECURITY_DATABASE_FILESYSTEM
173+
170174
#endif /*GENERIC_FILE_SECURITY_DB_H_*/

features/FEATURE_BLE/source/generic/FileSecurityDb.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
#if BLE_SECURITY_DATABASE_FILESYSTEM
18+
1719
#include "FileSecurityDb.h"
1820

1921
namespace ble {
@@ -408,4 +410,7 @@ SecurityEntrySigning_t* FileSecurityDb::read_in_entry_peer_signing(entry_handle_
408410
};
409411

410412
} /* namespace pal */
411-
} /* namespace ble */
413+
} /* namespace ble */
414+
415+
#endif // BLE_SECURITY_DATABASE_FILESYSTEM
416+

features/FEATURE_BLE/source/generic/GenericSecurityManager.tpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "ble/generic/GenericSecurityManager.h"
2222
#include "ble/generic/MemorySecurityDb.h"
2323
#include "ble/generic/FileSecurityDb.h"
24+
#include "ble/generic/KVStoreSecurityDb.h"
2425

2526
using ble::pal::advertising_peer_address_type_t;
2627
using ble::pal::AuthenticationMask;
@@ -884,11 +885,19 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::init_da
884885
) {
885886
delete _db;
886887

888+
#if BLE_SECURITY_DATABASE_FILESYSTEM
887889
FILE* db_file = FileSecurityDb::open_db_file(db_path);
888890

889891
if (db_file) {
890892
_db = new (std::nothrow) FileSecurityDb(db_file);
891-
} else {
893+
} else
894+
#endif
895+
#if BLE_SECURITY_DATABASE_KVSTORE
896+
if (KVStoreSecurityDb::open_db()) {
897+
_db = new (std::nothrow) KVStoreSecurityDb();
898+
} else
899+
#endif
900+
{
892901
_db = new (std::nothrow) MemorySecurityDb();
893902
}
894903

0 commit comments

Comments
 (0)