mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-06 07:00:59 +00:00
btstack_crypto: provide auth_len for ccm init
This commit is contained in:
parent
81132a3911
commit
6015e1edc2
@ -364,7 +364,8 @@ static void btstack_crypto_ccm_setup_a_i(btstack_crypto_ccm_t * btstack_crypto_c
|
||||
*/
|
||||
|
||||
static void btstack_crypto_ccm_setup_b_0(btstack_crypto_ccm_t * btstack_crypto_ccm, uint8_t * b0){
|
||||
b0[0] = (3 << 3) | 1 ; // Adata = 0, M' = (M-2)/2, L' = L - 1
|
||||
uint8_t m_prime = (btstack_crypto_ccm->auth_len - 2) / 2;
|
||||
b0[0] = (m_prime << 3) | 1 ; // Adata = 0, M', L' = L - 1
|
||||
memcpy(&b0[1], btstack_crypto_ccm->nonce, 13);
|
||||
big_endian_store_16(b0, 14, btstack_crypto_ccm->message_len);
|
||||
}
|
||||
@ -997,10 +998,11 @@ 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){
|
||||
void btstack_crypo_ccm_init(btstack_crypto_ccm_t * request, const uint8_t * key, const uint8_t * nonce, uint16_t message_len, uint8_t auth_len){
|
||||
request->key = key;
|
||||
request->nonce = nonce;
|
||||
request->message_len = message_len;
|
||||
request->auth_len = auth_len;
|
||||
request->counter = 1;
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,7 @@ typedef struct {
|
||||
uint16_t message_len;
|
||||
uint16_t block_len;
|
||||
uint16_t counter;
|
||||
uint8_t auth_len;
|
||||
} btstack_crypto_ccm_t;
|
||||
|
||||
/**
|
||||
@ -219,8 +220,9 @@ int btstack_crypto_ecc_p256_validate_public_key(const uint8_t * public_key);
|
||||
* @param nonce
|
||||
* @param key
|
||||
* @param message_len
|
||||
* @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);
|
||||
void btstack_crypo_ccm_init(btstack_crypto_ccm_t * request, const uint8_t * key, const uint8_t * nonce, uint16_t message_len, uint8_t auth_len);
|
||||
|
||||
/**
|
||||
* Get authentication value (M=8) after encrypt or decrypt operation
|
||||
|
Loading…
Reference in New Issue
Block a user