sm.c (f53ec64947e97afcda218638b155231e5ec57955) sm.c (1dca9d8a30ade4cf41e6e82a0331879c9ae3eaa4)
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

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

1010 // generate new ec key after each pairing (that used it)
1011 if (setup->sm_use_secure_connections){
1012 sm_ec_generate_new_key();
1013 }
1014#endif
1015 }
1016}
1017
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

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

1010 // generate new ec key after each pairing (that used it)
1011 if (setup->sm_use_secure_connections){
1012 sm_ec_generate_new_key();
1013 }
1014#endif
1015 }
1016}
1017
1018void sm_master_pairing_success(sm_connection_t *connection) {// master -> all done
1019 connection->sm_engine_state = SM_INITIATOR_CONNECTED;
1020 sm_notify_client_status_reason(connection, ERROR_CODE_SUCCESS, 0);
1021 sm_done_for_handle(connection->sm_handle);
1022}
1023
1018static int sm_key_distribution_flags_for_auth_req(void){
1019
1020 int flags = SM_KEYDIST_ID_KEY;
1021 if (sm_auth_req & SM_AUTHREQ_BONDING){
1022 // encryption and signing information only if bonding requested
1023 flags |= SM_KEYDIST_ENC_KEY;
1024#ifdef ENABLE_LE_SIGNED_WRITE
1025 flags |= SM_KEYDIST_SIGN;

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

2672 sm_key_distribution_handle_all_received(connection);
2673 connection->sm_engine_state = SM_RESPONDER_IDLE;
2674 sm_notify_client_status_reason(connection, ERROR_CODE_SUCCESS, 0);
2675 sm_done_for_handle(connection->sm_handle);
2676 } else {
2677 connection->sm_engine_state = SM_PH3_RECEIVE_KEYS;
2678 }
2679 } else {
1024static int sm_key_distribution_flags_for_auth_req(void){
1025
1026 int flags = SM_KEYDIST_ID_KEY;
1027 if (sm_auth_req & SM_AUTHREQ_BONDING){
1028 // encryption and signing information only if bonding requested
1029 flags |= SM_KEYDIST_ENC_KEY;
1030#ifdef ENABLE_LE_SIGNED_WRITE
1031 flags |= SM_KEYDIST_SIGN;

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

2678 sm_key_distribution_handle_all_received(connection);
2679 connection->sm_engine_state = SM_RESPONDER_IDLE;
2680 sm_notify_client_status_reason(connection, ERROR_CODE_SUCCESS, 0);
2681 sm_done_for_handle(connection->sm_handle);
2682 } else {
2683 connection->sm_engine_state = SM_PH3_RECEIVE_KEYS;
2684 }
2685 } else {
2680 // master -> all done
2681 connection->sm_engine_state = SM_INITIATOR_CONNECTED;
2682 sm_notify_client_status_reason(connection, ERROR_CODE_SUCCESS, 0);
2683 sm_done_for_handle(connection->sm_handle);
2686 sm_master_pairing_success(connection);
2684 }
2685 break;
2686
2687 default:
2688 break;
2689 }
2690
2691 // check again if active connection was released

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

2845 // no keys to send, just continue
2846 if (IS_RESPONDER(connection->sm_role)){
2847 // slave -> receive master keys
2848 connection->sm_engine_state = SM_PH3_RECEIVE_KEYS;
2849 } else {
2850 if (setup->sm_use_secure_connections && (setup->sm_key_distribution_received_set & SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION)){
2851 connection->sm_engine_state = SM_SC_W2_CALCULATE_H6_ILK;
2852 } else {
2687 }
2688 break;
2689
2690 default:
2691 break;
2692 }
2693
2694 // check again if active connection was released

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

2848 // no keys to send, just continue
2849 if (IS_RESPONDER(connection->sm_role)){
2850 // slave -> receive master keys
2851 connection->sm_engine_state = SM_PH3_RECEIVE_KEYS;
2852 } else {
2853 if (setup->sm_use_secure_connections && (setup->sm_key_distribution_received_set & SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION)){
2854 connection->sm_engine_state = SM_SC_W2_CALCULATE_H6_ILK;
2855 } else {
2853 // master -> all done
2854 connection->sm_engine_state = SM_INITIATOR_CONNECTED;
2855 sm_done_for_handle(connection->sm_handle);
2856 sm_master_pairing_success(connection);
2856 }
2857 }
2858 }
2859 sm_run();
2860}
2861
2862#ifdef ENABLE_LE_PERIPHERAL
2863static void sm_handle_encryption_result_enc_ph4_ltk(void *arg){

--- 1540 unchanged lines hidden ---
2857 }
2858 }
2859 }
2860 sm_run();
2861}
2862
2863#ifdef ENABLE_LE_PERIPHERAL
2864static void sm_handle_encryption_result_enc_ph4_ltk(void *arg){

--- 1540 unchanged lines hidden ---