Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Cryptography. More...

Functions

int bt_rand (void *buf, size_t len)
 Generate random data.
 
int bt_encrypt_le (const uint8_t key[16], const uint8_t plaintext[16], uint8_t enc_data[16])
 AES encrypt little-endian data.
 
int bt_encrypt_be (const uint8_t key[16], const uint8_t plaintext[16], uint8_t enc_data[16])
 AES encrypt big-endian data.
 
int bt_ccm_decrypt (const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_data, size_t len, const uint8_t *aad, size_t aad_len, uint8_t *plaintext, size_t mic_size)
 Decrypt big-endian data with AES-CCM.
 
int bt_ccm_encrypt (const uint8_t key[16], uint8_t nonce[13], const uint8_t *plaintext, size_t len, const uint8_t *aad, size_t aad_len, uint8_t *enc_data, size_t mic_size)
 Encrypt big-endian data with AES-CCM.
 

Detailed Description

Cryptography.

Function Documentation

◆ bt_ccm_decrypt()

int bt_ccm_decrypt ( const uint8_t  key[16],
uint8_t  nonce[13],
const uint8_t enc_data,
size_t  len,
const uint8_t aad,
size_t  aad_len,
uint8_t plaintext,
size_t  mic_size 
)

#include <zephyr/bluetooth/crypto.h>

Decrypt big-endian data with AES-CCM.

Decrypts and authorizes enc_data with AES-CCM, as described in https://tools.ietf.org/html/rfc3610.

Assumes that the MIC follows directly after the encrypted data.

Parameters
key128 bit MS byte first key
nonce13 byte MS byte first nonce
enc_dataEncrypted data
lenLength of the encrypted data
aadAdditional authenticated data
aad_lenAdditional authenticated data length
plaintextPlaintext buffer to place result in
mic_sizeSize of the trailing MIC (in bytes)
Return values
0Successfully decrypted the data.
-EINVALInvalid parameters.
-EBADMSGAuthentication failed.

◆ bt_ccm_encrypt()

int bt_ccm_encrypt ( const uint8_t  key[16],
uint8_t  nonce[13],
const uint8_t plaintext,
size_t  len,
const uint8_t aad,
size_t  aad_len,
uint8_t enc_data,
size_t  mic_size 
)

#include <zephyr/bluetooth/crypto.h>

Encrypt big-endian data with AES-CCM.

Encrypts and generates a MIC from plaintext with AES-CCM, as described in https://tools.ietf.org/html/rfc3610.

Places the MIC directly after the encrypted data.

Parameters
key128 bit MS byte first key
nonce13 byte MS byte first nonce
plaintextPlaintext buffer to encrypt
lenLength of the encrypted data
aadAdditional authenticated data
aad_lenAdditional authenticated data length
enc_dataBuffer to place encrypted data in
mic_sizeSize of the trailing MIC (in bytes)
Return values
0Successfully encrypted the data.
-EINVALInvalid parameters.

◆ bt_encrypt_be()

int bt_encrypt_be ( const uint8_t  key[16],
const uint8_t  plaintext[16],
uint8_t  enc_data[16] 
)

#include <zephyr/bluetooth/crypto.h>

AES encrypt big-endian data.

An AES encrypt helper is used to request the Bluetooth controller's own hardware to encrypt the plaintext using the key and returns the encrypted data.

Parameters
key128 bit MS byte first key for the encryption of the plaintext
plaintext128 bit MS byte first plaintext data block to be encrypted
enc_data128 bit MS byte first encrypted data block
Returns
Zero on success or error code otherwise.

◆ bt_encrypt_le()

int bt_encrypt_le ( const uint8_t  key[16],
const uint8_t  plaintext[16],
uint8_t  enc_data[16] 
)

#include <zephyr/bluetooth/crypto.h>

AES encrypt little-endian data.

An AES encrypt helper is used to request the Bluetooth controller's own hardware to encrypt the plaintext using the key and returns the encrypted data.

Parameters
key128 bit LS byte first key for the encryption of the plaintext
plaintext128 bit LS byte first plaintext data block to be encrypted
enc_data128 bit LS byte first encrypted data block
Returns
Zero on success or error code otherwise.

◆ bt_rand()

int bt_rand ( void *  buf,
size_t  len 
)

#include <zephyr/bluetooth/crypto.h>

Generate random data.

A random number generation helper which utilizes the Bluetooth controller's own RNG.

Parameters
bufBuffer to insert the random data
lenLength of random data to generate
Returns
Zero on success or error code otherwise, positive in case of protocol error or negative (POSIX) in case of stack internal error