1 /*
2  * Copyright (C) 2015-2018 Alibaba Group Holding Limited
3  */
4 
5 #include <bt_errno.h>
6 #include <stddef.h>
7 #include <bluetooth/bluetooth.h>
8 #include <port/mesh_hal_sec.h>
9 
10 #ifndef CONFIG_MESH_STACK_ALONE
11 #include <crypto.h>
12 #include <tinycrypt/constants.h>
13 #include <tinycrypt/utils.h>
14 #include <tinycrypt/aes.h>
15 #include <tinycrypt/cmac_mode.h>
16 #include <tinycrypt/ccm_mode.h>
17 
bt_mesh_rand(void * buf,size_t len)18 int bt_mesh_rand(void *buf, size_t len)
19 {
20     return bt_rand(buf, len);
21 }
22 
bt_mesh_aes_encrypt(const uint8_t key[16],const uint8_t plaintext[16],uint8_t enc_data[16])23 int bt_mesh_aes_encrypt(const uint8_t key[16], const uint8_t plaintext[16], uint8_t enc_data[16])
24 {
25     return bt_encrypt_be(key, plaintext, enc_data);
26 }
27 
bt_mesh_aes_decrypt(const uint8_t key[16],const uint8_t enc_data[16],uint8_t dec_data[16])28 int bt_mesh_aes_decrypt(const uint8_t key[16], const uint8_t enc_data[16], uint8_t dec_data[16])
29 {
30     return bt_decrypt_be(key, enc_data, dec_data);
31 }
32 
33 #endif
34