mirror of https://github.com/ARMmbed/mbed-os.git
init random number on local device for OOB data
parent
564749674f
commit
fe9b558a2a
|
@ -315,6 +315,13 @@ struct octet_type_t {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the pointer to the buffer holding data.
|
||||||
|
*/
|
||||||
|
uint8_t* buffer() const {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Size in byte of a data.
|
* Size in byte of a data.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -344,6 +344,7 @@ private:
|
||||||
const csrk_t *csrk
|
const csrk_t *csrk
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CMAC_C)
|
||||||
/**
|
/**
|
||||||
* Generate local OOB data to be sent to the application which sends it to the peer.
|
* Generate local OOB data to be sent to the application which sends it to the peer.
|
||||||
*
|
*
|
||||||
|
@ -352,6 +353,7 @@ private:
|
||||||
void generate_secure_connections_oob(
|
void generate_secure_connections_oob(
|
||||||
connection_handle_t connection
|
connection_handle_t connection
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the entry for the connection with OOB data presence.
|
* Updates the entry for the connection with OOB data presence.
|
||||||
|
|
|
@ -492,9 +492,11 @@ ble_error_t GenericSecurityManager::setOOBDataUsage(
|
||||||
entry->attempt_oob = useOOB;
|
entry->attempt_oob = useOOB;
|
||||||
entry->oob_mitm_protection = OOBProvidesMITM;
|
entry->oob_mitm_protection = OOBProvidesMITM;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CMAC_C)
|
||||||
if (_public_keys_generated) {
|
if (_public_keys_generated) {
|
||||||
generate_secure_connections_oob(connection);
|
generate_secure_connections_oob(connection);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return BLE_ERROR_NONE;
|
return BLE_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -640,28 +642,38 @@ void GenericSecurityManager::return_csrk_cb(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CMAC_C)
|
||||||
void GenericSecurityManager::generate_secure_connections_oob(
|
void GenericSecurityManager::generate_secure_connections_oob(
|
||||||
connection_handle_t connection
|
connection_handle_t connection
|
||||||
) {
|
) {
|
||||||
#if defined(MBEDTLS_CMAC_C)
|
|
||||||
address_t local_address;
|
address_t local_address;
|
||||||
/*TODO: get local address*/
|
|
||||||
oob_confirm_t confirm;
|
oob_confirm_t confirm;
|
||||||
|
oob_rand_t random;
|
||||||
|
random_data_t random_data;
|
||||||
|
|
||||||
|
/*TODO: get local address*/
|
||||||
|
|
||||||
|
_pal.get_random_data(random_data);
|
||||||
|
memcpy(random.buffer(), random_data.buffer(), random_data_t.size());
|
||||||
|
_pal.get_random_data(random_data);
|
||||||
|
memcpy(random.buffer() + random_data_t.size(), &random_data.buffer(), random_data_t.size());
|
||||||
|
|
||||||
crypto_toolbox_f4(
|
crypto_toolbox_f4(
|
||||||
_db.get_public_key_x(),
|
_db.get_public_key_x(),
|
||||||
_db.get_public_key_y(),
|
_db.get_public_key_y(),
|
||||||
_db.get_local_sc_oob_random(),
|
random,
|
||||||
confirm
|
confirm
|
||||||
);
|
);
|
||||||
|
|
||||||
_app_event_handler->oobGenerated(
|
_app_event_handler->oobGenerated(
|
||||||
&local_address,
|
&local_address,
|
||||||
&_db.get_local_sc_oob_random(),
|
&random,
|
||||||
&confirm
|
&confirm
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
|
_db.set_local_sc_oob_random(random);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void GenericSecurityManager::update_oob_presence(connection_handle_t connection) {
|
void GenericSecurityManager::update_oob_presence(connection_handle_t connection) {
|
||||||
SecurityEntry_t *entry = _db.get_entry(connection);
|
SecurityEntry_t *entry = _db.get_entry(connection);
|
||||||
|
|
Loading…
Reference in New Issue