hci.c (2ff4272d8d87327ca3949b094319eaa598d18698) hci.c (532454f96dc583da553adc4f3e6b006a1f85ec34)
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

--- 2668 unchanged lines hidden (view full) ---

2677
2678 // only store link key:
2679 // - if bondable enabled
2680 if (hci_stack->bondable == false) break;
2681 // - if security level sufficient
2682 if (gap_security_level_for_link_key_type(link_key_type) < conn->requested_security_level) break;
2683 // - for SSP, also check if remote side requested bonding as well
2684 if (conn->link_key_type != COMBINATION_KEY){
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

--- 2668 unchanged lines hidden (view full) ---

2677
2678 // only store link key:
2679 // - if bondable enabled
2680 if (hci_stack->bondable == false) break;
2681 // - if security level sufficient
2682 if (gap_security_level_for_link_key_type(link_key_type) < conn->requested_security_level) break;
2683 // - for SSP, also check if remote side requested bonding as well
2684 if (conn->link_key_type != COMBINATION_KEY){
2685 uint8_t auth_req_ignoring_mitm = conn->io_cap_response_auth_req & 0xfe;
2686 if (auth_req_ignoring_mitm == SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_NO_BONDING){
2685 bool remote_bonding = conn->io_cap_response_auth_req >= SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING;
2686 if (!remote_bonding){
2687 break;
2688 }
2689 }
2690 gap_store_link_key_for_bd_addr(addr, &packet[8], conn->link_key_type);
2691 break;
2692 }
2693
2694 case HCI_EVENT_PIN_CODE_REQUEST:

--- 1748 unchanged lines hidden (view full) ---

4443 hci_send_cmd(&hci_pin_code_request_negative_reply, connection->address);
4444 return true;
4445 }
4446
4447 if (connection->authentication_flags & SEND_IO_CAPABILITIES_REPLY){
4448 connectionClearAuthenticationFlags(connection, SEND_IO_CAPABILITIES_REPLY);
4449 // set authentication requirements:
4450 // - MITM = ssp_authentication_requirement (USER) | requested_security_level (dynamic)
2687 break;
2688 }
2689 }
2690 gap_store_link_key_for_bd_addr(addr, &packet[8], conn->link_key_type);
2691 break;
2692 }
2693
2694 case HCI_EVENT_PIN_CODE_REQUEST:

--- 1748 unchanged lines hidden (view full) ---

4443 hci_send_cmd(&hci_pin_code_request_negative_reply, connection->address);
4444 return true;
4445 }
4446
4447 if (connection->authentication_flags & SEND_IO_CAPABILITIES_REPLY){
4448 connectionClearAuthenticationFlags(connection, SEND_IO_CAPABILITIES_REPLY);
4449 // set authentication requirements:
4450 // - MITM = ssp_authentication_requirement (USER) | requested_security_level (dynamic)
4451 // - BONDING MODE:
4452 // - initiator: dedicated if requested, bondable otherwise
4453 // - responder: local & remote bondable
4451 // - BONDING MODE: dedicated if requested, bondable otherwise. Drop bondable if not set for remote
4454 uint8_t authreq = hci_stack->ssp_authentication_requirement & 1;
4455 if (gap_mitm_protection_required_for_security_level(connection->requested_security_level)){
4456 authreq |= 1;
4457 }
4452 uint8_t authreq = hci_stack->ssp_authentication_requirement & 1;
4453 if (gap_mitm_protection_required_for_security_level(connection->requested_security_level)){
4454 authreq |= 1;
4455 }
4458 if (connection->bonding_flags & BONDING_DEDICATED){
4459 authreq |= SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING;
4460 } else if (hci_stack->bondable){
4461 authreq |= SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING;
4456 bool bonding = hci_stack->bondable;
4457 if (connection->authentication_flags & RECV_IO_CAPABILITIES_RESPONSE){
4458 // if we have received IO Cap Response, we're in responder role
4459 bool remote_bonding = connection->io_cap_response_auth_req >= SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING;
4460 if (bonding && !remote_bonding){
4461 log_info("Remote not bonding, dropping local flag");
4462 bonding = false;
4463 }
4462 }
4464 }
4465 if (bonding){
4466 if (connection->bonding_flags & BONDING_DEDICATED){
4467 authreq |= SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING;
4468 } else {
4469 authreq |= SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING;
4470 }
4471 }
4463 uint8_t have_oob_data = 0;
4464#ifdef ENABLE_CLASSIC_PAIRING_OOB
4465 if (connection->classic_oob_c_192 != NULL){
4466 have_oob_data |= 1;
4467 }
4468 if (connection->classic_oob_c_256 != NULL){
4469 have_oob_data |= 2;
4470 }

--- 2171 unchanged lines hidden ---
4472 uint8_t have_oob_data = 0;
4473#ifdef ENABLE_CLASSIC_PAIRING_OOB
4474 if (connection->classic_oob_c_192 != NULL){
4475 have_oob_data |= 1;
4476 }
4477 if (connection->classic_oob_c_256 != NULL){
4478 have_oob_data |= 2;
4479 }

--- 2171 unchanged lines hidden ---