mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-04 15:39:59 +00:00
btstack_crypto: collect (de)init functions at the end
This commit is contained in:
parent
d152b6c6cd
commit
6bc33c8be3
@ -1168,25 +1168,6 @@ static void btstack_crypto_event_handler(uint8_t packet_type, uint16_t cid, uint
|
||||
btstack_crypto_run();
|
||||
}
|
||||
|
||||
void btstack_crypto_init(void){
|
||||
if (btstack_crypto_initialized) return;
|
||||
btstack_crypto_initialized = true;
|
||||
|
||||
// register with HCI
|
||||
hci_event_callback_registration.callback = &btstack_crypto_event_handler;
|
||||
hci_add_event_handler(&hci_event_callback_registration);
|
||||
#ifndef USE_BTSTACK_AES128
|
||||
btstack_crypto_cmac_state = CMAC_IDLE;
|
||||
#endif
|
||||
#ifdef ENABLE_ECC_P256
|
||||
btstack_crypto_ecc_p256_key_generation_state = ECC_P256_KEY_GENERATION_IDLE;
|
||||
#endif
|
||||
#ifdef USE_MBEDTLS_ECC_P256
|
||||
mbedtls_ecp_group_init(&mbedtls_ec_group);
|
||||
mbedtls_ecp_group_load(&mbedtls_ec_group, MBEDTLS_ECP_DP_SECP256R1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void btstack_crypto_random_generate(btstack_crypto_random_t * request, uint8_t * buffer, uint16_t size, void (* callback)(void * arg), void * callback_arg){
|
||||
request->btstack_crypto.context_callback.callback = callback;
|
||||
request->btstack_crypto.context_callback.context = callback_arg;
|
||||
@ -1358,6 +1339,26 @@ void btstack_crypto_ccm_decrypt_block(btstack_crypto_ccm_t * request, uint16_t l
|
||||
btstack_crypto_run();
|
||||
}
|
||||
|
||||
|
||||
void btstack_crypto_init(void){
|
||||
if (btstack_crypto_initialized) return;
|
||||
btstack_crypto_initialized = true;
|
||||
|
||||
// register with HCI
|
||||
hci_event_callback_registration.callback = &btstack_crypto_event_handler;
|
||||
hci_add_event_handler(&hci_event_callback_registration);
|
||||
#ifndef USE_BTSTACK_AES128
|
||||
btstack_crypto_cmac_state = CMAC_IDLE;
|
||||
#endif
|
||||
#ifdef ENABLE_ECC_P256
|
||||
btstack_crypto_ecc_p256_key_generation_state = ECC_P256_KEY_GENERATION_IDLE;
|
||||
#endif
|
||||
#ifdef USE_MBEDTLS_ECC_P256
|
||||
mbedtls_ecp_group_init(&mbedtls_ec_group);
|
||||
mbedtls_ecp_group_load(&mbedtls_ec_group, MBEDTLS_ECP_DP_SECP256R1);
|
||||
#endif
|
||||
}
|
||||
|
||||
// De-Init
|
||||
void btstack_crypto_deinit(void) {
|
||||
btstack_crypto_initialized = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user