btstack_crypto: fix typo in ccm functions

This commit is contained in:
Matthias Ringwald 2019-01-12 23:15:46 +01:00
parent f88ad41f77
commit 03843d749b
3 changed files with 15 additions and 15 deletions

View File

@ -1142,7 +1142,7 @@ int btstack_crypto_ecc_p256_validate_public_key(const uint8_t * public_key){
}
#endif
void btstack_crypo_ccm_init(btstack_crypto_ccm_t * request, const uint8_t * key, const uint8_t * nonce, uint16_t message_len, uint16_t additional_authenticated_data_len, uint8_t auth_len){
void btstack_crypto_ccm_init(btstack_crypto_ccm_t * request, const uint8_t * key, const uint8_t * nonce, uint16_t message_len, uint16_t additional_authenticated_data_len, uint8_t auth_len){
request->key = key;
request->nonce = nonce;
request->message_len = message_len;
@ -1153,7 +1153,7 @@ void btstack_crypo_ccm_init(btstack_crypto_ccm_t * request, const uint8_t * key,
request->state = CCM_CALCULATE_X1;
}
void btstack_crypo_ccm_digest(btstack_crypto_ccm_t * request, uint8_t * additional_authenticated_data, uint16_t additional_authenticated_data_len, void (* callback)(void * arg), void * callback_arg){
void btstack_crypto_ccm_digest(btstack_crypto_ccm_t * request, uint8_t * additional_authenticated_data, uint16_t additional_authenticated_data_len, void (* callback)(void * arg), void * callback_arg){
// not implemented yet
request->btstack_crypto.context_callback.callback = callback;
request->btstack_crypto.context_callback.context = callback_arg;
@ -1164,7 +1164,7 @@ void btstack_crypo_ccm_digest(btstack_crypto_ccm_t * request, uint8_t * addition
btstack_crypto_run();
}
void btstack_crypo_ccm_get_authentication_value(btstack_crypto_ccm_t * request, uint8_t * authentication_value){
void btstack_crypto_ccm_get_authentication_value(btstack_crypto_ccm_t * request, uint8_t * authentication_value){
memcpy(authentication_value, request->x_i, request->auth_len);
}

View File

@ -229,24 +229,24 @@ int btstack_crypto_ecc_p256_validate_public_key(const uint8_t * public_key);
* @param additional_authenticated_data_len must be smaller than 0xff00
* @param auth_len
*/
void btstack_crypo_ccm_init(btstack_crypto_ccm_t * request, const uint8_t * key, const uint8_t * nonce, uint16_t message_len, uint16_t additional_authenticated_data_len, uint8_t auth_len);
void btstack_crypto_ccm_init(btstack_crypto_ccm_t * request, const uint8_t * key, const uint8_t * nonce, uint16_t message_len, uint16_t additional_authenticated_data_len, uint8_t auth_len);
/**
* Get authentication value after encrypt or decrypt operation
* @param request
* @param authentication_value
*/
void btstack_crypo_ccm_get_authentication_value(btstack_crypto_ccm_t * request, uint8_t * authentication_value);
void btstack_crypto_ccm_get_authentication_value(btstack_crypto_ccm_t * request, uint8_t * authentication_value);
/**
* Digest Additional Authentication Data - can be called multipled times up to total additional_authenticated_data_len specified in btstack_crypo_ccm_init
* Digest Additional Authentication Data - can be called multipled times up to total additional_authenticated_data_len specified in btstack_crypto_ccm_init
* @param request
* @param additional_authenticated_data
* @param additional_authenticated_data_len
* @param callback
* @param callback_arg
*/
void btstack_crypo_ccm_digest(btstack_crypto_ccm_t * request, uint8_t * additional_authenticated_data, uint16_t additional_authenticated_data_len, void (* callback)(void * arg), void * callback_arg);
void btstack_crypto_ccm_digest(btstack_crypto_ccm_t * request, uint8_t * additional_authenticated_data, uint16_t additional_authenticated_data_len, void (* callback)(void * arg), void * callback_arg);
/**
* Encrypt block - can be called multiple times. len must be a multiply of 16 for all but the last call

View File

@ -53,10 +53,10 @@ static void message_24_upper_transport_encrypt(void){
uint8_t trans_mic[8];
btstack_crypto_init();
btstack_crypto_ccm_t btstack_crypto_ccm;
btstack_crypo_ccm_init(&btstack_crypto_ccm, app_key, app_nonce, sizeof(plaintext), sizeof(label_uuid), sizeof(trans_mic));
btstack_crypo_ccm_digest(&btstack_crypto_ccm, label_uuid, 16, &ccm_done, NULL);
btstack_crypto_ccm_init(&btstack_crypto_ccm, app_key, app_nonce, sizeof(plaintext), sizeof(label_uuid), sizeof(trans_mic));
btstack_crypto_ccm_digest(&btstack_crypto_ccm, label_uuid, 16, &ccm_done, NULL);
btstack_crypto_ccm_encrypt_block(&btstack_crypto_ccm, sizeof(plaintext), plaintext, ciphertext, &ccm_done, NULL);
btstack_crypo_ccm_get_authentication_value(&btstack_crypto_ccm, trans_mic);
btstack_crypto_ccm_get_authentication_value(&btstack_crypto_ccm, trans_mic);
printf("%16s: ", "ciphertext"); printf_hexdump(ciphertext, 8);
printf("%16s: ", "TransMIC"); printf_hexdump(trans_mic, 8);
}
@ -86,10 +86,10 @@ static void message_24_upper_transport_decrypt(void){
uint8_t trans_mic[8];
btstack_crypto_init();
btstack_crypto_ccm_t btstack_crypto_ccm;
btstack_crypo_ccm_init(&btstack_crypto_ccm, app_key, app_nonce, sizeof(ciphertext), sizeof(label_uuid), sizeof(trans_mic));
btstack_crypo_ccm_digest(&btstack_crypto_ccm, label_uuid, 16, &ccm_done, NULL);
btstack_crypto_ccm_init(&btstack_crypto_ccm, app_key, app_nonce, sizeof(ciphertext), sizeof(label_uuid), sizeof(trans_mic));
btstack_crypto_ccm_digest(&btstack_crypto_ccm, label_uuid, 16, &ccm_done, NULL);
btstack_crypto_ccm_decrypt_block(&btstack_crypto_ccm, sizeof(ciphertext), ciphertext, plaintext, &ccm_done, NULL);
btstack_crypo_ccm_get_authentication_value(&btstack_crypto_ccm, trans_mic);
btstack_crypto_ccm_get_authentication_value(&btstack_crypto_ccm, trans_mic);
printf("%16s: ", "plaintext"); printf_hexdump(plaintext, 8);
printf("%16s: ", "TransMIC"); printf_hexdump(trans_mic, 8);
}
@ -117,9 +117,9 @@ static void message_24_lower_transport_segment_0(void){
uint8_t net_mic[4];
btstack_crypto_init();
btstack_crypto_ccm_t btstack_crypto_ccm;
btstack_crypo_ccm_init(&btstack_crypto_ccm, encryption_key, network_nonce, sizeof(plaintext), 0, 4);
btstack_crypto_ccm_init(&btstack_crypto_ccm, encryption_key, network_nonce, sizeof(plaintext), 0, 4);
btstack_crypto_ccm_encrypt_block(&btstack_crypto_ccm, sizeof(plaintext), plaintext, ciphertext, &ccm_done, NULL);
btstack_crypo_ccm_get_authentication_value(&btstack_crypto_ccm, net_mic);
btstack_crypto_ccm_get_authentication_value(&btstack_crypto_ccm, net_mic);
printf("%16s: ", "ciphertext"); printf_hexdump(ciphertext, 18);
printf("%16s: ", "NetMIC"); printf_hexdump(net_mic, 4);
}