sm: add sm_numeric_comparison_confirm(..) and use in le_counter

This commit is contained in:
Matthias Ringwald 2016-05-13 14:06:29 +02:00
parent 8362d86ace
commit c8c46d5108
3 changed files with 28 additions and 14 deletions

View File

@ -102,9 +102,9 @@ static void le_counter_setup(void){
sm_event_callback_registration.callback = &packet_handler;
sm_add_event_handler(&sm_event_callback_registration);
// Numeric Comparison
// sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_YES_NO);
sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_YES_NO);
// Passkey entry initiator enter, responder displays
sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY);
// sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY);
#ifdef ENABLE_LE_SECURE_CONNECTIONS
sm_set_authentication_requirements(SM_AUTHREQ_SECURE_CONNECTION|SM_AUTHREQ_MITM_PROTECTION);
#endif
@ -180,9 +180,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
case ATT_EVENT_CAN_SEND_NOW:
att_server_notify(con_handle, ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE, (uint8_t*) counter_string, counter_string_len);
break;
case SM_EVENT_NUMERIC_COMPARISON_REQUEST:
printf("Confirming numeric comparison: %u\n", sm_event_numeric_comparison_request_get_passkey(packet));
sm_numeric_comparison_confirm(sm_event_passkey_display_number_get_handle(packet));
break;
case SM_EVENT_PASSKEY_DISPLAY_NUMBER:
printf("LE Secure Connection - Numeric Comparison: %u\n", sm_event_passkey_display_number_get_passkey(packet));
// sm_just_works_confirm(sm_event_passkey_display_number_get_handle(packet));
printf("Display Passkey: %u\n", sm_event_passkey_display_number_get_passkey(packet));
break;
}
break;

View File

@ -1089,7 +1089,7 @@ static void sm_trigger_user_response(sm_connection_t * sm_conn){
break;
case NK_BOTH_INPUT:
setup->sm_user_response = SM_USER_RESPONSE_PENDING;
sm_notify_client_passkey(SM_EVENT_PASSKEY_DISPLAY_NUMBER, sm_conn->sm_handle, sm_conn->sm_peer_addr_type, sm_conn->sm_peer_address, big_endian_read_32(setup->sm_tk, 12));
sm_notify_client_passkey(SM_EVENT_NUMERIC_COMPARISON_REQUEST, sm_conn->sm_handle, sm_conn->sm_peer_addr_type, sm_conn->sm_peer_address, big_endian_read_32(setup->sm_tk, 12));
break;
case JUST_WORKS:
setup->sm_user_response = SM_USER_RESPONSE_PENDING;
@ -3067,6 +3067,11 @@ void sm_just_works_confirm(hci_con_handle_t con_handle){
sm_run();
}
void sm_numeric_comparison_confirm(hci_con_handle_t con_handle){
// for now, it's the same
sm_just_works_confirm(con_handle);
}
void sm_passkey_input(hci_con_handle_t con_handle, uint32_t passkey){
sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle);
if (!sm_conn) return; // wrong connection

View File

@ -166,19 +166,25 @@ void sm_send_security_request(hci_con_handle_t con_handle);
/**
* @brief Decline bonding triggered by event before
* @param addr_type and address
* @param con_handle
*/
void sm_bonding_decline(hci_con_handle_t con_handle);
/**
* @brief Confirm Just Works bonding
* @param addr_type and address
* @param con_handle
*/
void sm_just_works_confirm(hci_con_handle_t con_handle);
/**
* @brief Confirm value from SM_EVENT_NUMERIC_COMPARISON_REQUEST for Numeric Comparison bonding
* @param con_handle
*/
void sm_numeric_comparison_confirm(hci_con_handle_t con_handle);
/**
* @brief Reports passkey input by user
* @param addr_type and address
* @param con_handle
* @param passkey in [0..999999]
*/
void sm_passkey_input(hci_con_handle_t con_handle, uint32_t passkey);
@ -186,40 +192,40 @@ void sm_passkey_input(hci_con_handle_t con_handle, uint32_t passkey);
/**
*
* @brief Get encryption key size.
* @param addr_type and address
* @param con_handle
* @return 0 if not encrypted, 7-16 otherwise
*/
int sm_encryption_key_size(hci_con_handle_t con_handle);
/**
* @brief Get authentication property.
* @param addr_type and address
* @param con_handle
* @return 1 if bonded with OOB/Passkey (AND MITM protection)
*/
int sm_authenticated(hci_con_handle_t con_handle);
/**
* @brief Queries authorization state.
* @param addr_type and address
* @param con_handle
* @return authorization_state for the current session
*/
authorization_state_t sm_authorization_state(hci_con_handle_t con_handle);
/**
* @brief Used by att_server.c to request user authorization.
* @param addr_type and address
* @param con_handle
*/
void sm_request_pairing(hci_con_handle_t con_handle);
/**
* @brief Report user authorization decline.
* @param addr_type and address
* @param con_handle
*/
void sm_authorization_decline(hci_con_handle_t con_handle);
/**
* @brief Report user authorization grant.
* @param addr_type and address
* @param con_handle
*/
void sm_authorization_grant(hci_con_handle_t con_handle);