Zephyr Project API 3.7.0
A Scalable Open Source RTOS
|
Encrypted Advertising Data (EAD) More...
Macros | |
#define | BT_EAD_RANDOMIZER_SIZE 5 |
Randomizer size in bytes. | |
#define | BT_EAD_KEY_SIZE 16 |
Key size in bytes. | |
#define | BT_EAD_IV_SIZE 8 |
Initialisation Vector size in bytes. | |
#define | BT_EAD_MIC_SIZE 4 |
MIC size in bytes. | |
#define | BT_EAD_ENCRYPTED_PAYLOAD_SIZE(payload_size) ((payload_size) + BT_EAD_RANDOMIZER_SIZE + BT_EAD_MIC_SIZE) |
Get the size (in bytes) of the encrypted advertising data for a given payload size in bytes. | |
#define | BT_EAD_DECRYPTED_PAYLOAD_SIZE(encrypted_payload_size) ((encrypted_payload_size) - (BT_EAD_RANDOMIZER_SIZE + BT_EAD_MIC_SIZE)) |
Get the size (in bytes) of the decrypted payload for a given payload size in bytes. | |
Functions | |
int | bt_ead_encrypt (const uint8_t session_key[16], const uint8_t iv[8], const uint8_t *payload, size_t payload_size, uint8_t *encrypted_payload) |
Encrypt and authenticate the given advertising data. | |
int | bt_ead_decrypt (const uint8_t session_key[16], const uint8_t iv[8], const uint8_t *encrypted_payload, size_t encrypted_payload_size, uint8_t *payload) |
Decrypt and authenticate the given encrypted advertising data. | |
Encrypted Advertising Data (EAD)
#define BT_EAD_DECRYPTED_PAYLOAD_SIZE | ( | encrypted_payload_size | ) | ((encrypted_payload_size) - (BT_EAD_RANDOMIZER_SIZE + BT_EAD_MIC_SIZE)) |
#include <include/zephyr/bluetooth/ead.h>
Get the size (in bytes) of the decrypted payload for a given payload size in bytes.
#define BT_EAD_ENCRYPTED_PAYLOAD_SIZE | ( | payload_size | ) | ((payload_size) + BT_EAD_RANDOMIZER_SIZE + BT_EAD_MIC_SIZE) |
#include <include/zephyr/bluetooth/ead.h>
Get the size (in bytes) of the encrypted advertising data for a given payload size in bytes.
#define BT_EAD_IV_SIZE 8 |
#include <include/zephyr/bluetooth/ead.h>
Initialisation Vector size in bytes.
#define BT_EAD_KEY_SIZE 16 |
#include <include/zephyr/bluetooth/ead.h>
Key size in bytes.
#define BT_EAD_MIC_SIZE 4 |
#include <include/zephyr/bluetooth/ead.h>
MIC size in bytes.
#define BT_EAD_RANDOMIZER_SIZE 5 |
#include <include/zephyr/bluetooth/ead.h>
Randomizer size in bytes.
int bt_ead_decrypt | ( | const uint8_t | session_key[16], |
const uint8_t | iv[8], | ||
const uint8_t * | encrypted_payload, | ||
size_t | encrypted_payload_size, | ||
uint8_t * | payload | ||
) |
#include <include/zephyr/bluetooth/ead.h>
Decrypt and authenticate the given encrypted advertising data.
advertising structure
is used to describe the advertising data with the advertising type and the length of those two.[in] | session_key | Key of 16 bytes used for the encryption. |
[in] | iv | Initialisation Vector used to generate the nonce . |
[in] | encrypted_payload | Encrypted Advertising Data received. This should only contain the advertising data from the received advertising structure, not the length nor the type. |
[in] | encrypted_payload_size | Size of the received advertising data in bytes. Should be equal to the length field of the received advertising structure, minus the size of the type (1 byte). |
[out] | payload | Decrypted advertising payload. Use BT_EAD_DECRYPTED_PAYLOAD_SIZE to get the right size. |
0 | Data have been correctly decrypted and authenticated. |
-EIO | Error occurred during the decryption or the authentication. |
-EINVAL | One of the argument is a NULL pointer or encrypted_payload_size is less than BT_EAD_RANDOMIZER_SIZE + BT_EAD_MIC_SIZE. |
int bt_ead_encrypt | ( | const uint8_t | session_key[16], |
const uint8_t | iv[8], | ||
const uint8_t * | payload, | ||
size_t | payload_size, | ||
uint8_t * | encrypted_payload | ||
) |
#include <include/zephyr/bluetooth/ead.h>
Encrypt and authenticate the given advertising data.
The resulting data in encrypted_payload
will look like that:
payload_size
bytes);advertising structure
is used to describe the advertising data with the advertising type and the length of those two.[in] | session_key | Key of BT_EAD_KEY_SIZE bytes used for the encryption. |
[in] | iv | Initialisation Vector used to generate the nonce. It must be changed each time the Session Key changes. |
[in] | payload | Advertising Data to encrypt. Can be multiple advertising structures that are concatenated. |
[in] | payload_size | Size of the Advertising Data to encrypt. |
[out] | encrypted_payload | Encrypted Ad Data including the Randomizer and the MIC. Size must be at least BT_EAD_RANDOMIZER_SIZE + payload_size + BT_EAD_MIC_SIZE. Use BT_EAD_ENCRYPTED_PAYLOAD_SIZE to get the right size. |
0 | Data have been correctly encrypted and authenticated. |
-EIO | Error occurred during the encryption or the authentication. |
-EINVAL | One of the argument is a NULL pointer. |
-ECANCELED | Error occurred during the random number generation. |