hci.c (cf01e8888ddd40b7860e88b8069a674e2ff2ee0e) | hci.c (11b03efaa1f10ccd376a2bc59480f38a358b0cb8) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2561 unchanged lines hidden (view full) --- 2570 // PIN CODE REQUEST means the link key request didn't succee -> delete stored link key 2571 if (!hci_stack->link_key_db) break; 2572 hci_event_pin_code_request_get_bd_addr(packet, addr); 2573 hci_stack->link_key_db->delete_link_key(addr); 2574 break; 2575 2576 case HCI_EVENT_IO_CAPABILITY_REQUEST: 2577 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], RECV_IO_CAPABILITIES_REQUEST); | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2561 unchanged lines hidden (view full) --- 2570 // PIN CODE REQUEST means the link key request didn't succee -> delete stored link key 2571 if (!hci_stack->link_key_db) break; 2572 hci_event_pin_code_request_get_bd_addr(packet, addr); 2573 hci_stack->link_key_db->delete_link_key(addr); 2574 break; 2575 2576 case HCI_EVENT_IO_CAPABILITY_REQUEST: 2577 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], RECV_IO_CAPABILITIES_REQUEST); |
2578 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_IO_CAPABILITIES_REPLY); | 2578 log_info("IO Capability Request received, stack bondable %u, io cap %u", hci_stack->bondable, hci_stack->ssp_io_capability); 2579 if (hci_stack->bondable && (hci_stack->ssp_io_capability != SSP_IO_CAPABILITY_UNKNOWN)){ 2580 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_IO_CAPABILITIES_REPLY); 2581 } else { 2582 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_IO_CAPABILITIES_NEGATIVE_REPLY); 2583 } |
2579 break; 2580 2581#ifdef ENABLE_CLASSIC_PAIRING_OOB 2582 case HCI_EVENT_REMOTE_OOB_DATA_REQUEST: 2583 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SSP_PAIRING_ACTIVE); 2584 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_REMOTE_OOB_DATA_REPLY); 2585 break; 2586#endif --- 1622 unchanged lines hidden (view full) --- 4209 log_info("denying to pin request"); 4210 connectionClearAuthenticationFlags(connection, DENY_PIN_CODE_REQUEST); 4211 hci_send_cmd(&hci_pin_code_request_negative_reply, connection->address); 4212 return true; 4213 } 4214 4215 if (connection->authentication_flags & SEND_IO_CAPABILITIES_REPLY){ 4216 connectionClearAuthenticationFlags(connection, SEND_IO_CAPABILITIES_REPLY); | 2584 break; 2585 2586#ifdef ENABLE_CLASSIC_PAIRING_OOB 2587 case HCI_EVENT_REMOTE_OOB_DATA_REQUEST: 2588 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SSP_PAIRING_ACTIVE); 2589 hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_REMOTE_OOB_DATA_REPLY); 2590 break; 2591#endif --- 1622 unchanged lines hidden (view full) --- 4214 log_info("denying to pin request"); 4215 connectionClearAuthenticationFlags(connection, DENY_PIN_CODE_REQUEST); 4216 hci_send_cmd(&hci_pin_code_request_negative_reply, connection->address); 4217 return true; 4218 } 4219 4220 if (connection->authentication_flags & SEND_IO_CAPABILITIES_REPLY){ 4221 connectionClearAuthenticationFlags(connection, SEND_IO_CAPABILITIES_REPLY); |
4217 log_info("IO Capability Request received, stack bondable %u, io cap %u", hci_stack->bondable, hci_stack->ssp_io_capability); 4218 if (hci_stack->bondable && (hci_stack->ssp_io_capability != SSP_IO_CAPABILITY_UNKNOWN)){ 4219 // tweak authentication requirements 4220 uint8_t authreq = hci_stack->ssp_authentication_requirement; 4221 if (connection->bonding_flags & BONDING_DEDICATED){ 4222 authreq = SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING; 4223 } 4224 if (gap_mitm_protection_required_for_security_level(connection->requested_security_level)){ 4225 authreq |= 1; 4226 } 4227 uint8_t have_oob_data = 0; | 4222 // tweak authentication requirements 4223 uint8_t authreq = hci_stack->ssp_authentication_requirement; 4224 if (connection->bonding_flags & BONDING_DEDICATED){ 4225 authreq = SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING; 4226 } 4227 if (gap_mitm_protection_required_for_security_level(connection->requested_security_level)){ 4228 authreq |= 1; 4229 } 4230 uint8_t have_oob_data = 0; |
4228#ifdef ENABLE_CLASSIC_PAIRING_OOB | 4231#ifdef ENABLE_CLASSIC_PAIRING_OOB |
4229 if (connection->classic_oob_c_192 != NULL){ | 4232 if (connection->classic_oob_c_192 != NULL){ |
4230 have_oob_data |= 1; | 4233 have_oob_data |= 1; |
4231 } 4232 if (connection->classic_oob_c_256 != NULL){ 4233 have_oob_data |= 2; 4234 } 4235#endif 4236 hci_send_cmd(&hci_io_capability_request_reply, &connection->address, hci_stack->ssp_io_capability, have_oob_data, authreq); 4237 } else { 4238 hci_send_cmd(&hci_io_capability_request_negative_reply, &connection->address, ERROR_CODE_PAIRING_NOT_ALLOWED); | |
4239 } | 4234 } |
4235 if (connection->classic_oob_c_256 != NULL){ 4236 have_oob_data |= 2; 4237 } 4238#endif 4239 hci_send_cmd(&hci_io_capability_request_reply, &connection->address, hci_stack->ssp_io_capability, have_oob_data, authreq); |
|
4240 return true; 4241 } 4242 | 4240 return true; 4241 } 4242 |
4243 if (connection->authentication_flags & SEND_IO_CAPABILITIES_NEGATIVE_REPLY) { 4244 connectionClearAuthenticationFlags(connection, SEND_IO_CAPABILITIES_NEGATIVE_REPLY); 4245 hci_send_cmd(&hci_io_capability_request_negative_reply, &connection->address, ERROR_CODE_PAIRING_NOT_ALLOWED); 4246 return true; 4247 } 4248 |
|
4243#ifdef ENABLE_CLASSIC_PAIRING_OOB 4244 if (connection->authentication_flags & SEND_REMOTE_OOB_DATA_REPLY){ 4245 connectionClearAuthenticationFlags(connection, SEND_REMOTE_OOB_DATA_REPLY); 4246 const uint8_t zero[16] = { 0 }; 4247 const uint8_t * r_192 = zero; 4248 const uint8_t * c_192 = zero; 4249 const uint8_t * r_256 = zero; 4250 const uint8_t * c_256 = zero; --- 2063 unchanged lines hidden --- | 4249#ifdef ENABLE_CLASSIC_PAIRING_OOB 4250 if (connection->authentication_flags & SEND_REMOTE_OOB_DATA_REPLY){ 4251 connectionClearAuthenticationFlags(connection, SEND_REMOTE_OOB_DATA_REPLY); 4252 const uint8_t zero[16] = { 0 }; 4253 const uint8_t * r_192 = zero; 4254 const uint8_t * c_192 = zero; 4255 const uint8_t * r_256 = zero; 4256 const uint8_t * c_256 = zero; --- 2063 unchanged lines hidden --- |