mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-30 15:32:41 +00:00
btstack_crypto: fix typo in ccm functions
This commit is contained in:
parent
a6376dac39
commit
56d016f692
@ -292,7 +292,7 @@ static void mesh_network_send_b(void *arg){
|
||||
|
||||
// store NetMIC
|
||||
uint8_t net_mic[8];
|
||||
btstack_crypo_ccm_get_authentication_value(&mesh_network_crypto_request.ccm, net_mic);
|
||||
btstack_crypto_ccm_get_authentication_value(&mesh_network_crypto_request.ccm, net_mic);
|
||||
|
||||
// store MIC
|
||||
uint8_t net_mic_len = network_pdu->data[1] & 0x80 ? 8 : 4;
|
||||
@ -341,7 +341,7 @@ static void mesh_network_send_a(mesh_network_pdu_t * network_pdu){
|
||||
// start ccm
|
||||
uint8_t cypher_len = network_pdu->len - 7;
|
||||
uint8_t net_mic_len = network_pdu->data[1] & 0x80 ? 8 : 4;
|
||||
btstack_crypo_ccm_init(&mesh_network_crypto_request.ccm, current_network_key->encryption_key, network_nonce, cypher_len, 0, net_mic_len);
|
||||
btstack_crypto_ccm_init(&mesh_network_crypto_request.ccm, current_network_key->encryption_key, network_nonce, cypher_len, 0, net_mic_len);
|
||||
btstack_crypto_ccm_encrypt_block(&mesh_network_crypto_request.ccm, cypher_len, &network_pdu->data[7], &network_pdu->data[7], &mesh_network_send_b, network_pdu);
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ static void process_network_pdu_validate_d(void * arg){
|
||||
|
||||
// store NetMIC
|
||||
uint8_t net_mic[8];
|
||||
btstack_crypo_ccm_get_authentication_value(&mesh_network_crypto_request.ccm, net_mic);
|
||||
btstack_crypto_ccm_get_authentication_value(&mesh_network_crypto_request.ccm, net_mic);
|
||||
printf("NetMIC: ");
|
||||
printf_hexdump(net_mic, net_mic_len);
|
||||
// store in pdu
|
||||
@ -498,7 +498,7 @@ static void process_network_pdu_validate_b(void * arg){
|
||||
|
||||
// 034b50057e400000010000
|
||||
|
||||
btstack_crypo_ccm_init(&mesh_network_crypto_request.ccm, current_network_key->encryption_key, network_nonce, cypher_len, 0, net_mic_len);
|
||||
btstack_crypto_ccm_init(&mesh_network_crypto_request.ccm, current_network_key->encryption_key, network_nonce, cypher_len, 0, net_mic_len);
|
||||
btstack_crypto_ccm_decrypt_block(&mesh_network_crypto_request.ccm, cypher_len, &network_pdu_in_validation->data[7], &network_pdu->data[7], &process_network_pdu_validate_d, network_pdu);
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ static void mesh_upper_transport_validate_unsegmented_message_ccm(void * arg){
|
||||
|
||||
// store TransMIC
|
||||
uint8_t trans_mic[8];
|
||||
btstack_crypo_ccm_get_authentication_value(&ccm, trans_mic);
|
||||
btstack_crypto_ccm_get_authentication_value(&ccm, trans_mic);
|
||||
mesh_print_hex("TransMIC", trans_mic, trans_mic_len);
|
||||
|
||||
uint8_t * upper_transport_pdu = mesh_network_pdu_data(network_pdu) + 1;
|
||||
@ -378,7 +378,7 @@ static void mesh_upper_transport_validate_segmented_message_ccm(void * arg){
|
||||
|
||||
// store TransMIC
|
||||
uint8_t trans_mic[8];
|
||||
btstack_crypo_ccm_get_authentication_value(&ccm, trans_mic);
|
||||
btstack_crypto_ccm_get_authentication_value(&ccm, trans_mic);
|
||||
mesh_print_hex("TransMIC", trans_mic, transport_pdu->transmic_len);
|
||||
|
||||
if (memcmp(trans_mic, &upper_transport_pdu[upper_transport_pdu_len], transport_pdu->transmic_len) == 0){
|
||||
@ -447,7 +447,7 @@ static void mesh_upper_transport_validate_unsegmented_message(mesh_network_pdu_t
|
||||
|
||||
// decrypt ccm
|
||||
mesh_transport_crypto_active = 1;
|
||||
btstack_crypo_ccm_init(&ccm, message_key->key, application_nonce, upper_transport_pdu_len, 0, trans_mic_len);
|
||||
btstack_crypto_ccm_init(&ccm, message_key->key, application_nonce, upper_transport_pdu_len, 0, trans_mic_len);
|
||||
btstack_crypto_ccm_decrypt_block(&ccm, upper_transport_pdu_len, upper_transport_pdu_data, upper_transport_pdu_data, &mesh_upper_transport_validate_unsegmented_message_ccm, network_pdu_in_validation);
|
||||
}
|
||||
|
||||
@ -482,7 +482,7 @@ static void mesh_upper_transport_validate_segmented_message(mesh_transport_pdu_t
|
||||
|
||||
// decrypt ccm
|
||||
mesh_transport_crypto_active = 1;
|
||||
btstack_crypo_ccm_init(&ccm, message_key->key, application_nonce, upper_transport_pdu_len, 0, transport_pdu->transmic_len);
|
||||
btstack_crypto_ccm_init(&ccm, message_key->key, application_nonce, upper_transport_pdu_len, 0, transport_pdu->transmic_len);
|
||||
btstack_crypto_ccm_decrypt_block(&ccm, upper_transport_pdu_len, upper_transport_pdu_data, upper_transport_pdu_data, &mesh_upper_transport_validate_segmented_message_ccm, transport_pdu);
|
||||
}
|
||||
|
||||
@ -920,7 +920,7 @@ static void mesh_upper_transport_send_unsegmented_access_pdu_ccm(void * arg){
|
||||
uint8_t upper_transport_pdu_len = mesh_network_pdu_len(network_pdu) - 1;
|
||||
mesh_print_hex("EncAccessPayload", upper_transport_pdu, upper_transport_pdu_len);
|
||||
// store TransMIC
|
||||
btstack_crypo_ccm_get_authentication_value(&ccm, &upper_transport_pdu[upper_transport_pdu_len]);
|
||||
btstack_crypto_ccm_get_authentication_value(&ccm, &upper_transport_pdu[upper_transport_pdu_len]);
|
||||
mesh_print_hex("TransMIC", &upper_transport_pdu[upper_transport_pdu_len], 4);
|
||||
network_pdu->len += 4;
|
||||
// send network pdu
|
||||
@ -933,7 +933,7 @@ static void mesh_upper_transport_send_segmented_access_pdu_ccm(void * arg){
|
||||
mesh_transport_pdu_t * transport_pdu = (mesh_transport_pdu_t *) arg;
|
||||
mesh_print_hex("EncAccessPayload", transport_pdu->data, transport_pdu->len);
|
||||
// store TransMIC
|
||||
btstack_crypo_ccm_get_authentication_value(&ccm, &transport_pdu->data[transport_pdu->len]);
|
||||
btstack_crypto_ccm_get_authentication_value(&ccm, &transport_pdu->data[transport_pdu->len]);
|
||||
mesh_print_hex("TransMIC", &transport_pdu->data[transport_pdu->len], transport_pdu->transmic_len);
|
||||
transport_pdu->len += transport_pdu->transmic_len;
|
||||
mesh_upper_transport_send_segmented_pdu(transport_pdu);
|
||||
@ -1113,7 +1113,7 @@ void mesh_upper_transport_send_unsegmented_access_pdu(mesh_network_pdu_t * netwo
|
||||
// encrypt ccm
|
||||
mesh_transport_crypto_active = 1;
|
||||
|
||||
btstack_crypo_ccm_init(&ccm, appkey->key, application_nonce, access_pdu_len, 0, trans_mic_len);
|
||||
btstack_crypto_ccm_init(&ccm, appkey->key, application_nonce, access_pdu_len, 0, trans_mic_len);
|
||||
btstack_crypto_ccm_encrypt_block(&ccm, access_pdu_len, access_pdu_data, access_pdu_data, &mesh_upper_transport_send_unsegmented_access_pdu_ccm, network_pdu);
|
||||
}
|
||||
|
||||
@ -1145,7 +1145,7 @@ void mesh_upper_transport_send_segmented_access_pdu(mesh_transport_pdu_t * trans
|
||||
mesh_transport_crypto_active = 1;
|
||||
|
||||
// encrypt ccm
|
||||
btstack_crypo_ccm_init(&ccm, appkey->key, application_nonce, access_pdu_len, 0, transmic_len);
|
||||
btstack_crypto_ccm_init(&ccm, appkey->key, application_nonce, access_pdu_len, 0, transmic_len);
|
||||
btstack_crypto_ccm_encrypt_block(&ccm, access_pdu_len,access_pdu_data, access_pdu_data, &mesh_upper_transport_send_segmented_access_pdu_ccm, transport_pdu);
|
||||
}
|
||||
|
||||
|
@ -756,7 +756,7 @@ static void provisioning_handle_data_ccm(void * arg){
|
||||
|
||||
// validate MIC?
|
||||
uint8_t mic[8];
|
||||
btstack_crypo_ccm_get_authentication_value(&prov_ccm_request, mic);
|
||||
btstack_crypto_ccm_get_authentication_value(&prov_ccm_request, mic);
|
||||
printf("MIC: ");
|
||||
printf_hexdump(mic, 8);
|
||||
|
||||
@ -786,7 +786,7 @@ static void provisioning_handle_data(uint8_t *packet, uint16_t size){
|
||||
memcpy(enc_provisioning_data, packet, 25);
|
||||
|
||||
// decode response
|
||||
btstack_crypo_ccm_init(&prov_ccm_request, session_key, session_nonce, 25, 0, 8);
|
||||
btstack_crypto_ccm_init(&prov_ccm_request, session_key, session_nonce, 25, 0, 8);
|
||||
btstack_crypto_ccm_decrypt_block(&prov_ccm_request, 25, enc_provisioning_data, provisioning_data, &provisioning_handle_data_ccm, NULL);
|
||||
}
|
||||
|
||||
|
@ -553,7 +553,7 @@ static void provisioning_handle_data_encrypted(void * arg){
|
||||
printf("EncProvisioningData: ");
|
||||
printf_hexdump(enc_provisioning_data, sizeof(enc_provisioning_data));
|
||||
|
||||
btstack_crypo_ccm_get_authentication_value(&prov_ccm_request, provisioning_data_mic);
|
||||
btstack_crypto_ccm_get_authentication_value(&prov_ccm_request, provisioning_data_mic);
|
||||
printf("MIC: ");
|
||||
printf_hexdump(provisioning_data_mic, sizeof(provisioning_data_mic));
|
||||
|
||||
@ -581,7 +581,7 @@ static void provisioning_handle_session_nonce_calculated(void * arg){
|
||||
big_endian_store_32(provisioning_data, 19, iv_index);
|
||||
big_endian_store_16(provisioning_data, 23, unicast_address);
|
||||
|
||||
btstack_crypo_ccm_init(&prov_ccm_request, session_key, session_nonce, 25, 0, 8);
|
||||
btstack_crypto_ccm_init(&prov_ccm_request, session_key, session_nonce, 25, 0, 8);
|
||||
btstack_crypto_ccm_encrypt_block(&prov_ccm_request, 25, provisioning_data, enc_provisioning_data, &provisioning_handle_data_encrypted, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user