ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
crypto.h
Go to the documentation of this file.
1 /*
2  *
3  * BlueZ - Bluetooth protocol stack for Linux
4  *
5  * Copyright (C) 2012-2014 Intel Corporation. All rights reserved.
6  *
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 #include <stdbool.h>
25 #include <stdint.h>
26 
27 struct bt_crypto;
28 
29 struct bt_crypto *bt_crypto_new(void);
30 
31 struct bt_crypto *bt_crypto_ref(struct bt_crypto *crypto);
32 void bt_crypto_unref(struct bt_crypto *crypto);
33 
34 bool bt_crypto_random_bytes(struct bt_crypto *crypto,
35  uint8_t *buf, uint8_t num_bytes);
36 
37 bool bt_crypto_e(struct bt_crypto *crypto, const uint8_t key[16],
38  const uint8_t plaintext[16], uint8_t encrypted[16]);
39 bool bt_crypto_ah(struct bt_crypto *crypto, const uint8_t k[16],
40  const uint8_t r[3], uint8_t hash[3]);
41 bool bt_crypto_c1(struct bt_crypto *crypto, const uint8_t k[16],
42  const uint8_t r[16], const uint8_t pres[7],
43  const uint8_t preq[7], uint8_t iat,
44  const uint8_t ia[6], uint8_t rat,
45  const uint8_t ra[6], uint8_t res[16]);
46 bool bt_crypto_s1(struct bt_crypto *crypto, const uint8_t k[16],
47  const uint8_t r1[16], const uint8_t r2[16],
48  uint8_t res[16]);
49 bool bt_crypto_f4(struct bt_crypto *crypto, uint8_t u[32], uint8_t v[32],
50  uint8_t x[16], uint8_t z, uint8_t res[16]);
51 bool bt_crypto_f5(struct bt_crypto *crypto, uint8_t w[32], uint8_t n1[16],
52  uint8_t n2[16], uint8_t a1[7], uint8_t a2[7],
53  uint8_t mackey[16], uint8_t ltk[16]);
54 bool bt_crypto_f6(struct bt_crypto *crypto, uint8_t w[16], uint8_t n1[16],
55  uint8_t n2[16], uint8_t r[16], uint8_t io_cap[3],
56  uint8_t a1[7], uint8_t a2[7], uint8_t res[16]);
57 bool bt_crypto_g2(struct bt_crypto *crypto, uint8_t u[32], uint8_t v[32],
58  uint8_t x[16], uint8_t y[16], uint32_t *val);
59 bool bt_crypto_sign_att(struct bt_crypto *crypto, const uint8_t key[16],
60  const uint8_t *m, uint16_t m_len,
61  uint32_t sign_cnt, uint8_t signature[12]);
bool bt_crypto_ah(struct bt_crypto *crypto, const uint8_t k[16], const uint8_t r[3], uint8_t hash[3])
Definition: crypto.c:424
bool bt_crypto_c1(struct bt_crypto *crypto, const uint8_t k[16], const uint8_t r[16], const uint8_t pres[7], const uint8_t preq[7], uint8_t iat, const uint8_t ia[6], uint8_t rat, const uint8_t ra[6], uint8_t res[16])
Definition: crypto.c:517
struct bt_crypto * bt_crypto_new(void)
Definition: crypto.c:158
bool bt_crypto_e(struct bt_crypto *crypto, const uint8_t key[16], const uint8_t plaintext[16], uint8_t encrypted[16])
Definition: crypto.c:359
bool bt_crypto_f4(struct bt_crypto *crypto, uint8_t u[32], uint8_t v[32], uint8_t x[16], uint8_t z, uint8_t res[16])
Definition: crypto.c:626
bool bt_crypto_f6(struct bt_crypto *crypto, uint8_t w[16], uint8_t n1[16], uint8_t n2[16], uint8_t r[16], uint8_t io_cap[3], uint8_t a1[7], uint8_t a2[7], uint8_t res[16])
Definition: crypto.c:669
bool bt_crypto_s1(struct bt_crypto *crypto, const uint8_t k[16], const uint8_t r1[16], const uint8_t r2[16], uint8_t res[16])
Definition: crypto.c:581
bool bt_crypto_g2(struct bt_crypto *crypto, uint8_t u[32], uint8_t v[32], uint8_t x[16], uint8_t y[16], uint32_t *val)
Definition: crypto.c:685
void bt_crypto_unref(struct bt_crypto *crypto)
Definition: crypto.c:200
struct bt_crypto * bt_crypto_ref(struct bt_crypto *crypto)
Definition: crypto.c:190
bool bt_crypto_f5(struct bt_crypto *crypto, uint8_t w[32], uint8_t n1[16], uint8_t n2[16], uint8_t a1[7], uint8_t a2[7], uint8_t mackey[16], uint8_t ltk[16])
Definition: crypto.c:641
bool bt_crypto_random_bytes(struct bt_crypto *crypto, uint8_t *buf, uint8_t num_bytes)
Definition: crypto.c:215
bool bt_crypto_sign_att(struct bt_crypto *crypto, const uint8_t key[16], const uint8_t *m, uint16_t m_len, uint32_t sign_cnt, uint8_t signature[12])
Definition: crypto.c:286