gap: add gap_secure_connection to check if encryption key results from LE Secure Connection Pairing

This commit is contained in:
Matthias Ringwald 2019-03-06 15:09:48 +01:00
parent 3dc3a67de7
commit f1dfbe18c8
2 changed files with 14 additions and 0 deletions

View File

@ -428,6 +428,13 @@ int gap_encryption_key_size(hci_con_handle_t con_handle);
*/
int gap_authenticated(hci_con_handle_t con_handle);
/**
* @brief Get secure connection property
* @param con_handle
* @return 1 if bonded usiung LE Secure Connections
*/
int gap_secure_connection(hci_con_handle_t con_handle);
/**
* @brief Queries authorization state.
* @param con_handle

View File

@ -5001,6 +5001,13 @@ int gap_authenticated(hci_con_handle_t con_handle){
return sm_conn->sm_connection_authenticated;
}
int gap_secure_connection(hci_con_handle_t con_handle){
sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle);
if (!sm_conn) return 0; // wrong connection
if (!sm_conn->sm_connection_encrypted) return 0; // unencrypted connection cannot be authenticated
return sm_conn->sm_connection_sc;
}
authorization_state_t gap_authorization_state(hci_con_handle_t con_handle){
sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle);
if (!sm_conn) return AUTHORIZATION_UNKNOWN; // wrong connection