| Airoha M0 BLE API 1.0.5.4

sm_cryptotool.h
1 /******************************************************************************
2 Copyright (c) Airoha 2016 - All rights reserved
3
4 FILE NAME
5 sm_cryptotool.h
6 DESCRIPTION
7 NOTES
8 ********************************************************************************/
9 #ifndef __SM_CRYPTOTOOL_H__
10 #define __SM_CRYPTOTOOL_H__
11
12 #if (SM_HAL_AB1600_ENABLED)
13 #include <stdbool.h>
14 #include "bt_constants.h"
15 #endif
16
17 // SM_KEY_ID (h6 use)
18 #define SM_KEY_ID_LEBR 0
19 #define SM_KEY_ID_TMP1 1
20 #define SM_KEY_ID_BRLE 2
21 #define SM_KEY_ID_TMP2 3
22 #define SM_KEY_ID_MAX 4
23
24 typedef bool (*SM_Toolbox_cb)(uint8_t *dataPtr, uint8_t idx);
25
26 void SM_CryptoTool_SendLTKReply(uint16_t connHandle, uint8_t *ltk);
27 void SM_CryptoTool_SendLTKNegativeReply(uint16_t connHandle);
28
29 #if (SM_MASTER_SUPPORTED)
30 void SM_CryptoTool_StartEncryption(uint16_t connHandle, uint8_t *rand, uint8_t *ediv, uint8_t *ltk);
31 #endif
32
33 bool ah(uint8_t linkidx, uint8_t *k, uint8_t *r, EncryptionCB cb);
34 bool c1_1(uint8_t linkidx, uint8_t *k, uint8_t *r, uint8_t *p1, EncryptionCB cb);
35 bool c1_2(uint8_t linkidx, uint8_t *k, uint8_t *encData, uint8_t *p2, EncryptionCB cb);
36 bool s1(uint8_t linkidx, uint8_t *k, uint8_t *r1, uint8_t *r2, EncryptionCB cb);
37
38 #if (SM_SECURE_CONNECTION_SUPPORTED)
39 void SM_CryptoTool_ReadLocalP256PublicKeyComplete(uint8_t *evtPtr);
40 bool SM_CryptoTool_ReadLocalP256PublicKey(uint8_t linkidx, EncryptionCB cb);
41 void SM_CryptoTool_GenerateDHKeyComplete(uint8_t *evtPtr);
42 bool SM_CryptoTool_GenerateDHKey(uint8_t linkidx, uint8_t *pk, EncryptionCB cb);
43
44 bool f4(uint8_t linkidx,
45 uint8_t *u, //256 bits, PKax
46 uint8_t *v, //256 bits, PKbx
47 uint8_t *x, //128 bits
48 uint8_t z, //8 bits
49 EncryptionCB cb);
50
51 bool f5(uint8_t linkidx,
52 uint8_t *w, //256 bits
53 uint8_t *n1, //128 bits
54 uint8_t *n2, //128 bits
55 uint8_t *a1, //56 bits
56 uint8_t *a2, //56 bits
57 EncryptionCB macKeyCB,
58 EncryptionCB ltkKeyCB);
59
60 bool f6(uint8_t linkidx,
61 uint8_t *w, //128 bits
62 uint8_t *n1, //128 bits
63 uint8_t *n2, //128 bits
64 uint8_t *r, //128 bits
65 uint8_t *iocap, //24 bits
66 uint8_t *a1, //56 bits
67 uint8_t *a2, //56 bits
68 EncryptionCB cb);
69
70 bool g2(uint8_t linkidx,
71 uint8_t *u, //256 bits
72 uint8_t *v, //256 bits
73 uint8_t *x, //128 bits
74 uint8_t *y, //128 bits
75 EncryptionCB cb);
76
77 bool h6(uint8_t linkidx,
78 uint8_t *w, //128 bits
79 uint8_t keyID, //SM_KEY_ID
80 EncryptionCB cb);
81
82 #endif /*SM_SECURE_CONNECTION_SUPPORTED*/
83
84 #endif /*__SM_CRYPTOTOOL_H__*/