bt_app_sec.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. ****************************************************************************************
  3. *
  4. * @file bt_app_sec.h
  5. *
  6. * @brief Application entry point
  7. *
  8. * Copyright (C) Espressif 2016
  9. * Created by Yulong at 2016/10/13
  10. *
  11. *
  12. ****************************************************************************************
  13. */
  14. #include "bt_types.h"
  15. #define APP_SEC_IRK_FLAG (0)
  16. #define RAND_NB_LEN 0x08
  17. #define SEC_KEY_LEN 0x10
  18. /*
  19. * STRUCTURES DEFINITIONS
  20. ****************************************************************************************
  21. */
  22. /// Generic Security key structure
  23. typedef struct
  24. {
  25. /// Key value MSB -> LSB
  26. UINT8 key[SEC_KEY_LEN];
  27. }smp_sec_key;
  28. ///Random number structure
  29. typedef struct
  30. {
  31. ///8-byte array for random number
  32. UINT8 nb[RAND_NB_LEN];
  33. }rand_nb;
  34. typedef struct
  35. {
  36. // LTK
  37. smp_sec_key ltk;
  38. // Random Number
  39. rand_nb rand_nb;
  40. // EDIV
  41. UINT16 ediv;
  42. // LTK key size
  43. UINT8 key_size;
  44. // Last paired peer address type
  45. UINT8 peer_addr_type;
  46. // Last paired peer address
  47. BD_ADDR peer_addr;
  48. // authentication level
  49. UINT8 auth;
  50. }tAPP_SEC_ENV;
  51. extern tAPP_SEC_ENV app_sec_env;
  52. /*
  53. * GLOBAL FUNCTIONS DECLARATIONS
  54. ****************************************************************************************
  55. */
  56. void app_ble_sec_init(void);
  57. void app_ble_sec_pairing_cmp_evt_send(UINT8);
  58. UINT32 app_ble_sec_gen_tk(void);
  59. void app_ble_sec_gen_ltk(UINT8 key_size);
  60. void app_ble_security_start(void);