reseting the security db

pull/6932/head
paul-szczepanek-arm 2018-05-16 11:23:17 +01:00
parent c2bbc94b44
commit bcca75973e
5 changed files with 28 additions and 0 deletions

View File

@ -126,6 +126,8 @@ public:
virtual void set_restore(bool reload);
virtual void reset();
private:
virtual uint8_t get_entry_count();

View File

@ -148,6 +148,16 @@ public:
}
}
/* saving and loading from nvm */
virtual void reset() {
SecurityDb::reset();
for (size_t i = 0; i < MAX_ENTRIES; ++i) {
_entries[i] = entry_t();
}
}
private:
virtual uint8_t get_entry_count() {
return MAX_ENTRIES;

View File

@ -656,6 +656,15 @@ public:
*/
virtual void set_restore(bool reload) { };
/**
* Reset the databse by removing all information
*/
virtual void reset() {
_local_identity = SecurityEntryIdentity_t();
_local_csrk = csrk_t();
_local_sign_counter = 0;
}
private:
/**
* Get an entry for a new connection not present in the db yet. This will find a free entry

View File

@ -304,6 +304,11 @@ void FileSecurityDb::set_restore(bool reload) {
db_write(&reload, DB_OFFSET_RESTORE);
}
void FileSecurityDb::reset() {
SecurityDb::reset();
erase_db_file(_db_file);
}
/* helper functions */
uint8_t FileSecurityDb::get_entry_count() {

View File

@ -116,7 +116,9 @@ ble_error_t GenericSecurityManager::init(
}
ble_error_t GenericSecurityManager::reset(void) {
MBED_ASSERT(_db);
_pal.reset();
_db->reset();
SecurityManager::reset();
return BLE_ERROR_NONE;