hci.c (44f858f3f18601da9145a6368a9c25755ff660d9) hci.c (4a659b0ecf2ec86a4cee54c9a19c78ec778f51d2)
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

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

2112 case HCI_OPCODE_HCI_READ_ENCRYPTION_KEY_SIZE:
2113 status = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE];
2114 handle = little_endian_read_16(packet, OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1);
2115 conn = hci_connection_for_handle(handle);
2116 if (conn != NULL) {
2117 uint8_t key_size = 0;
2118 if (status == 0){
2119 key_size = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+3];
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

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

2112 case HCI_OPCODE_HCI_READ_ENCRYPTION_KEY_SIZE:
2113 status = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE];
2114 handle = little_endian_read_16(packet, OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1);
2115 conn = hci_connection_for_handle(handle);
2116 if (conn != NULL) {
2117 uint8_t key_size = 0;
2118 if (status == 0){
2119 key_size = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+3];
2120 log_info("Handle %x04x key Size: %u", handle, key_size);
2120 log_info("Handle %04x key Size: %u", handle, key_size);
2121 } else {
2122 log_info("Read Encryption Key Size failed 0x%02x-> assuming insecure connection with key size of 1", status);
2123 }
2124 hci_handle_read_encryption_key_size_complete(conn, key_size);
2125 }
2126 break;
2127#endif
2128 default:

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

2466 bool sc_used_during_pairing = gap_secure_connection_for_link_key_type(conn->link_key_type) != 0;
2467 bool connected_uses_aes_ccm = encryption_enabled == 2;
2468 if (sc_used_during_pairing && !connected_uses_aes_ccm){
2469 log_info("SC during pairing, but only E0 now -> abort");
2470 conn->bonding_flags |= BONDING_DISCONNECT_SECURITY_BLOCK;
2471 break;
2472 }
2473
2121 } else {
2122 log_info("Read Encryption Key Size failed 0x%02x-> assuming insecure connection with key size of 1", status);
2123 }
2124 hci_handle_read_encryption_key_size_complete(conn, key_size);
2125 }
2126 break;
2127#endif
2128 default:

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

2466 bool sc_used_during_pairing = gap_secure_connection_for_link_key_type(conn->link_key_type) != 0;
2467 bool connected_uses_aes_ccm = encryption_enabled == 2;
2468 if (sc_used_during_pairing && !connected_uses_aes_ccm){
2469 log_info("SC during pairing, but only E0 now -> abort");
2470 conn->bonding_flags |= BONDING_DISCONNECT_SECURITY_BLOCK;
2471 break;
2472 }
2473
2474 // if AES-CCM is used, authentication used SC -> authentication was mutual and we can skip explicit authentication
2475 if (connected_uses_aes_ccm){
2476 conn->authentication_flags |= CONNECTION_AUTHENTICATED;
2477 }
2478
2474 if ((hci_stack->local_supported_commands[0] & 0x80) != 0){
2475 // For Classic, we need to validate encryption key size first, if possible (== supported by Controller)
2476 conn->bonding_flags |= BONDING_SEND_READ_ENCRYPTION_KEY_SIZE;
2477 } else {
2478 // if not, pretend everything is perfect
2479 hci_handle_read_encryption_key_size_complete(conn, 16);
2480 }
2481 }

--- 3244 unchanged lines hidden ---
2479 if ((hci_stack->local_supported_commands[0] & 0x80) != 0){
2480 // For Classic, we need to validate encryption key size first, if possible (== supported by Controller)
2481 conn->bonding_flags |= BONDING_SEND_READ_ENCRYPTION_KEY_SIZE;
2482 } else {
2483 // if not, pretend everything is perfect
2484 hci_handle_read_encryption_key_size_complete(conn, 16);
2485 }
2486 }

--- 3244 unchanged lines hidden ---