#include <stddef.h>
#include <stdint.h>
#include <zephyr/kernel.h>
#include <zephyr/bluetooth/bluetooth.h>
 
Go to the source code of this file.
◆ BT_EAD_DECRYPTED_PAYLOAD_SIZE
Get the size (in bytes) of the decrypted payload for a given payload size in bytes. 
 
 
◆ BT_EAD_ENCRYPTED_PAYLOAD_SIZE
Get the size (in bytes) of the encrypted advertising data for a given payload size in bytes. 
 
 
◆ BT_EAD_IV_SIZE
Initialisation Vector size in bytes 
 
 
◆ BT_EAD_KEY_SIZE
      
        
          | #define BT_EAD_KEY_SIZE   16 | 
        
      
 
 
◆ BT_EAD_MIC_SIZE
      
        
          | #define BT_EAD_MIC_SIZE   4 | 
        
      
 
 
◆ BT_EAD_RANDOMIZER_SIZE
      
        
          | #define BT_EAD_RANDOMIZER_SIZE   5 | 
        
      
 
 
◆ bt_ead_decrypt()
Decrypt and authenticate the given encrypted advertising data. 
- Note
 - The term 
advertising structure is used to describe the advertising data with the advertising type and the length of those two. 
- Parameters
 - 
  
    | [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. | 
  
   
- Return values
 - 
  
    | 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.  | 
  
   
 
 
◆ bt_ead_encrypt()
Encrypt and authenticate the given advertising data. 
The resulting data in encrypted_payload will look like that:
- Attention
 - The function must be called each time the RPA is updated or the data are modified.
 
- Note
 - The term 
advertising structure is used to describe the advertising data with the advertising type and the length of those two. 
- Parameters
 - 
  
    | [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. | 
  
   
- Return values
 - 
  
    | 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.  |