mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			store local csrk and identity in the security db
							parent
							
								
									94a6cac838
								
							
						
					
					
						commit
						05f7685a79
					
				| 
						 | 
				
			
			@ -116,6 +116,21 @@ public:
 | 
			
		|||
        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 */
 | 
			
		||||
 | 
			
		||||
    virtual void restore();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -425,6 +425,22 @@ public:
 | 
			
		|||
        _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 */
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 */
 | 
			
		||||
 | 
			
		||||
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->flags, entry->file_offset + DB_STORE_OFFSET_FLAGS);
 | 
			
		||||
    db_write(&_local_sign_counter, DB_OFFSET_LOCAL_SIGN_COUNT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FileSecurityDb::set_restore(bool reload) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue