esp_sec_api.h 1.2 KB

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