Zephyr Project
A Scalable Open Source RTOS for IoT Embedded Devices
crypto.h
Go to the documentation of this file.
1 
5 /*
6  * Copyright (c) 2017-2020 Nordic Semiconductor ASA
7  * Copyright (c) 2015-2017 Intel Corporation
8  *
9  * SPDX-License-Identifier: Apache-2.0
10  */
11 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_CRYPTO_H_
12 #define ZEPHYR_INCLUDE_BLUETOOTH_CRYPTO_H_
13 
21 #include <stdbool.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
38 int bt_rand(void *buf, size_t len);
39 
52 int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16],
53  uint8_t enc_data[16]);
54 
67 int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16],
68  uint8_t enc_data[16]);
69 
70 
91 int bt_ccm_decrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_data,
92  size_t len, const uint8_t *aad, size_t aad_len,
93  uint8_t *plaintext, size_t mic_size);
94 
95 
115 int bt_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13],
116  const uint8_t *plaintext, size_t len, const uint8_t *aad,
117  size_t aad_len, uint8_t *enc_data, size_t mic_size);
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
126 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_CRYPTO_H_ */
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)
Encrypt big-endian data with AES-CCM.
stdbool.h
bt_encrypt_le
int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], uint8_t enc_data[16])
AES encrypt little-endian data.
uint8_t
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
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)
Decrypt big-endian data with AES-CCM.
bt_rand
int bt_rand(void *buf, size_t len)
Generate random data.
bt_encrypt_be
int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], uint8_t enc_data[16])
AES encrypt big-endian data.
key
static k_spinlock_key_t key
Definition: spinlock_error_case.c:14