sm.c (44263cccdec3144ada9cc3ea89ea892e10748030) | sm.c (f55bd52945f4ddd49af344f18580538ca5157f2b) |
---|---|
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 --- 2344 unchanged lines hidden (view full) --- 2353 sm_timeout_reset(connection); 2354 break; 2355 } 2356 2357#endif 2358 2359#ifdef ENABLE_LE_PERIPHERAL 2360 case SM_RESPONDER_PH1_SEND_PAIRING_RESPONSE: | 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 --- 2344 unchanged lines hidden (view full) --- 2353 sm_timeout_reset(connection); 2354 break; 2355 } 2356 2357#endif 2358 2359#ifdef ENABLE_LE_PERIPHERAL 2360 case SM_RESPONDER_PH1_SEND_PAIRING_RESPONSE: |
2361 // echo initiator for now | |
2362 sm_pairing_packet_set_code(setup->sm_s_pres,SM_CODE_PAIRING_RESPONSE); | 2361 sm_pairing_packet_set_code(setup->sm_s_pres,SM_CODE_PAIRING_RESPONSE); |
2362 2363 // start with initiator key dist flags |
|
2363 key_distribution_flags = sm_key_distribution_flags_for_auth_req(); 2364 | 2364 key_distribution_flags = sm_key_distribution_flags_for_auth_req(); 2365 |
2366#ifdef ENABLE_LE_SECURE_CONNECTIONS 2367 // LTK (= encyrption information & master identification) only exchanged for LE Legacy Connection |
|
2365 if (setup->sm_use_secure_connections){ | 2368 if (setup->sm_use_secure_connections){ |
2366 connection->sm_engine_state = SM_SC_W4_PUBLIC_KEY_COMMAND; 2367 } else { 2368 connection->sm_engine_state = SM_RESPONDER_PH1_W4_PAIRING_CONFIRM; | 2369 key_distribution_flags &= ~SM_KEYDIST_ENC_KEY; |
2369 } | 2370 } |
2370 | 2371#endif 2372 // setup in response |
2371 sm_pairing_packet_set_initiator_key_distribution(setup->sm_s_pres, sm_pairing_packet_get_initiator_key_distribution(setup->sm_m_preq) & key_distribution_flags); 2372 sm_pairing_packet_set_responder_key_distribution(setup->sm_s_pres, sm_pairing_packet_get_responder_key_distribution(setup->sm_m_preq) & key_distribution_flags); | 2373 sm_pairing_packet_set_initiator_key_distribution(setup->sm_s_pres, sm_pairing_packet_get_initiator_key_distribution(setup->sm_m_preq) & key_distribution_flags); 2374 sm_pairing_packet_set_responder_key_distribution(setup->sm_s_pres, sm_pairing_packet_get_responder_key_distribution(setup->sm_m_preq) & key_distribution_flags); |
2375 |
|
2373 // update key distribution after ENC was dropped 2374 sm_setup_key_distribution(sm_pairing_packet_get_responder_key_distribution(setup->sm_s_pres)); 2375 | 2376 // update key distribution after ENC was dropped 2377 sm_setup_key_distribution(sm_pairing_packet_get_responder_key_distribution(setup->sm_s_pres)); 2378 |
2379 if (setup->sm_use_secure_connections){ 2380 connection->sm_engine_state = SM_SC_W4_PUBLIC_KEY_COMMAND; 2381 } else { 2382 connection->sm_engine_state = SM_RESPONDER_PH1_W4_PAIRING_CONFIRM; 2383 } 2384 |
|
2376 l2cap_send_connectionless(connection->sm_handle, L2CAP_CID_SECURITY_MANAGER_PROTOCOL, (uint8_t*) &setup->sm_s_pres, sizeof(sm_pairing_packet_t)); 2377 sm_timeout_reset(connection); 2378 // SC Numeric Comparison will trigger user response after public keys & nonces have been exchanged 2379 if (!setup->sm_use_secure_connections || setup->sm_stk_generation_method == JUST_WORKS){ 2380 sm_trigger_user_response(connection); 2381 } 2382 return; 2383#endif --- 1724 unchanged lines hidden --- | 2385 l2cap_send_connectionless(connection->sm_handle, L2CAP_CID_SECURITY_MANAGER_PROTOCOL, (uint8_t*) &setup->sm_s_pres, sizeof(sm_pairing_packet_t)); 2386 sm_timeout_reset(connection); 2387 // SC Numeric Comparison will trigger user response after public keys & nonces have been exchanged 2388 if (!setup->sm_use_secure_connections || setup->sm_stk_generation_method == JUST_WORKS){ 2389 sm_trigger_user_response(connection); 2390 } 2391 return; 2392#endif --- 1724 unchanged lines hidden --- |