store local csrk and identity in the security db

pull/13037/head
Paul Szczeanek 2020-06-03 17:27:26 +01:00
parent 94a6cac838
commit 05f7685a79
3 changed files with 48 additions and 0 deletions

View File

@ -116,6 +116,21 @@ public:
sign_count_t sign_counter sign_count_t sign_counter
); );
/* local csrk and identity */
virtual void set_local_csrk(
const csrk_t &csrk
);
virtual void set_local_identity(
const irk_t &irk,
const address_t &identity_address,
bool public_address
);
/* I am not overriding set_local_sign_counter to avoid constant filesystem writes,
* instead this is synced by sync (which is called on disconnection) */
/* saving and loading from nvm */ /* saving and loading from nvm */
virtual void restore(); virtual void restore();

View File

@ -425,6 +425,22 @@ public:
_local_sign_counter = sign_counter; _local_sign_counter = sign_counter;
} }
/* local identity */
/**
* Update the local identity.
*
* @param[in] csrk new CSRK value
*/
virtual void set_local_identity(
const irk_t &irk,
const address_t &identity_address,
bool public_address
) {
_local_identity.irk = irk;
_local_identity.identity_address = identity_address;
_local_identity.identity_address_is_public = public_address;
}
/* list management */ /* list management */
/** /**

View File

@ -265,6 +265,22 @@ void FileSecurityDb::set_entry_peer_sign_counter(
} }
} }
void FileSecurityDb::set_local_csrk(
const csrk_t &csrk
) {
this->SecurityDb::set_local_csrk(csrk);
db_write(&_local_csrk, DB_OFFSET_LOCAL_CSRK);
}
void FileSecurityDb::set_local_identity(
const irk_t &irk,
const address_t &identity_address,
bool public_address
) {
this->SecurityDb::set_local_identity(irk, identity_address, public_address);
db_write(&_local_identity, DB_OFFSET_LOCAL_IDENTITY);
}
/* saving and loading from nvm */ /* saving and loading from nvm */
void FileSecurityDb::restore() { void FileSecurityDb::restore() {
@ -299,6 +315,7 @@ void FileSecurityDb::sync(entry_handle_t db_handle) {
db_write(&entry->peer_sign_counter, entry->file_offset + DB_STORE_OFFSET_PEER_SIGNING_COUNT); db_write(&entry->peer_sign_counter, entry->file_offset + DB_STORE_OFFSET_PEER_SIGNING_COUNT);
db_write(&entry->flags, entry->file_offset + DB_STORE_OFFSET_FLAGS); db_write(&entry->flags, entry->file_offset + DB_STORE_OFFSET_FLAGS);
db_write(&_local_sign_counter, DB_OFFSET_LOCAL_SIGN_COUNT);
} }
void FileSecurityDb::set_restore(bool reload) { void FileSecurityDb::set_restore(bool reload) {