10#include "nimble/porting/nimble/include/os/queue.h"
12#include "nimble/porting/nimble/include/syscfg/syscfg.h"
13#include "nimble/nimble/host/include/host/ble_gap.h"
18#if MYNEWT_VAL(ENC_ADV_DATA)
21#define BLE_EAD_RANDOMIZER_SIZE 5
24#define BLE_EAD_KEY_SIZE 16
27#define BLE_EAD_IV_SIZE 8
30#define BLE_EAD_MIC_SIZE 4
33#define BLE_EAD_NONCE_SIZE 13
38#define BLE_EAD_RANDOMIZER_DIRECTION_BIT 7
41#define BLE_EAD_AAD_SIZE 1
47#define BLE_EAD_ENCRYPTED_PAYLOAD_SIZE(payload_size) \
48 ((payload_size) + BLE_EAD_RANDOMIZER_SIZE + BLE_EAD_MIC_SIZE)
53#define BLE_EAD_DECRYPTED_PAYLOAD_SIZE(encrypted_payload_size) \
54 ((encrypted_payload_size) - (BLE_EAD_RANDOMIZER_SIZE + BLE_EAD_MIC_SIZE))
57 uint8_t session_key[BLE_EAD_KEY_SIZE];
58 uint8_t iv[BLE_EAD_IV_SIZE];
94int ble_ead_encrypt(
const uint8_t session_key[BLE_EAD_KEY_SIZE],
95 const uint8_t iv[BLE_EAD_IV_SIZE],
const uint8_t *payload,
96 size_t payload_size, uint8_t *encrypted_payload);
119int ble_ead_decrypt(
const uint8_t session_key[BLE_EAD_KEY_SIZE],
120 const uint8_t iv[BLE_EAD_IV_SIZE],
const uint8_t *encrypted_payload,
121 size_t encrypted_payload_size, uint8_t *payload);
123int ble_ead_serialize_data(
const struct enc_adv_data *input, uint8_t *output);