sm.c (b41539d54f136ae0d2f578ab20bd45925ee2fff3) | sm.c (a3aba2f99a32576094d5fce80d77eaa0fe0a823d) |
---|---|
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 --- 3184 unchanged lines hidden (view full) --- 3193 break; 3194 } 3195 3196 // received random value 3197 reverse_128(&packet[1], setup->sm_peer_nonce); 3198 3199 // validate confirm value if Cb = f4(Pkb, Pka, Nb, z) 3200 // only check for JUST WORK/NC in initiator role AND passkey entry | 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 --- 3184 unchanged lines hidden (view full) --- 3193 break; 3194 } 3195 3196 // received random value 3197 reverse_128(&packet[1], setup->sm_peer_nonce); 3198 3199 // validate confirm value if Cb = f4(Pkb, Pka, Nb, z) 3200 // only check for JUST WORK/NC in initiator role AND passkey entry |
3201 int passkey_entry = sm_passkey_used(setup->sm_stk_generation_method); 3202 if (sm_conn->sm_role || passkey_entry) { | 3201 if (sm_conn->sm_role || sm_passkey_used(setup->sm_stk_generation_method)) { |
3203 sm_conn->sm_engine_state = SM_SC_W2_CMAC_FOR_CHECK_CONFIRMATION; 3204 } 3205 3206 sm_sc_state_after_receiving_random(sm_conn); 3207 break; 3208 3209 case SM_SC_W2_CALCULATE_G2: 3210 case SM_SC_W4_CALCULATE_G2: --- 232 unchanged lines hidden (view full) --- 3443 memcpy(setup->sm_peer_qy, ec_qy, 32); 3444 sm_sc_calculate_dhkey(dhkey); 3445 } 3446#endif 3447#endif 3448} 3449 3450void sm_use_fixed_ec_keypair(uint8_t * qx, uint8_t * qy, uint8_t * d){ | 3202 sm_conn->sm_engine_state = SM_SC_W2_CMAC_FOR_CHECK_CONFIRMATION; 3203 } 3204 3205 sm_sc_state_after_receiving_random(sm_conn); 3206 break; 3207 3208 case SM_SC_W2_CALCULATE_G2: 3209 case SM_SC_W4_CALCULATE_G2: --- 232 unchanged lines hidden (view full) --- 3442 memcpy(setup->sm_peer_qy, ec_qy, 32); 3443 sm_sc_calculate_dhkey(dhkey); 3444 } 3445#endif 3446#endif 3447} 3448 3449void sm_use_fixed_ec_keypair(uint8_t * qx, uint8_t * qy, uint8_t * d){ |
3450#ifdef ENABLE_LE_SECURE_CONNECTIONS |
|
3451 memcpy(ec_qx, qx, 32); 3452 memcpy(ec_qy, qy, 32); 3453 memcpy(ec_d, d, 32); 3454 sm_have_ec_keypair = 1; 3455 ec_key_generation_state = EC_KEY_GENERATION_DONE; | 3451 memcpy(ec_qx, qx, 32); 3452 memcpy(ec_qy, qy, 32); 3453 memcpy(ec_d, d, 32); 3454 sm_have_ec_keypair = 1; 3455 ec_key_generation_state = EC_KEY_GENERATION_DONE; |
3456#endif |
|
3456} 3457 3458void sm_test_use_fixed_ec_keypair(void){ | 3457} 3458 3459void sm_test_use_fixed_ec_keypair(void){ |
3460#ifdef ENABLE_LE_SECURE_CONNECTIONS |
|
3459#ifdef USE_MBEDTLS_FOR_ECDH 3460 // use test keypair from spec 3461 mbedtls_mpi x; 3462 mbedtls_mpi_init(&x); 3463 mbedtls_mpi_read_string( &x, 16, "3f49f6d4a3c55f3874c9b3e3d2103f504aff607beb40b7995899b8a6cd3c1abd"); 3464 mbedtls_mpi_write_binary(&x, ec_d, 32); 3465 mbedtls_mpi_read_string( &x, 16, "20b003d2f297be2c5e2c83a7e9f9a5b9eff49111acf4fddbcc0301480e359de6"); 3466 mbedtls_mpi_write_binary(&x, ec_qx, 32); 3467 mbedtls_mpi_read_string( &x, 16, "dc809c49652aeb6d63329abf5a52155c766345c28fed3024741c8ed01589d28b"); 3468 mbedtls_mpi_write_binary(&x, ec_qy, 32); 3469 mbedtls_mpi_free(&x); 3470#endif 3471 sm_have_ec_keypair = 1; 3472 ec_key_generation_state = EC_KEY_GENERATION_DONE; | 3461#ifdef USE_MBEDTLS_FOR_ECDH 3462 // use test keypair from spec 3463 mbedtls_mpi x; 3464 mbedtls_mpi_init(&x); 3465 mbedtls_mpi_read_string( &x, 16, "3f49f6d4a3c55f3874c9b3e3d2103f504aff607beb40b7995899b8a6cd3c1abd"); 3466 mbedtls_mpi_write_binary(&x, ec_d, 32); 3467 mbedtls_mpi_read_string( &x, 16, "20b003d2f297be2c5e2c83a7e9f9a5b9eff49111acf4fddbcc0301480e359de6"); 3468 mbedtls_mpi_write_binary(&x, ec_qx, 32); 3469 mbedtls_mpi_read_string( &x, 16, "dc809c49652aeb6d63329abf5a52155c766345c28fed3024741c8ed01589d28b"); 3470 mbedtls_mpi_write_binary(&x, ec_qy, 32); 3471 mbedtls_mpi_free(&x); 3472#endif 3473 sm_have_ec_keypair = 1; 3474 ec_key_generation_state = EC_KEY_GENERATION_DONE; |
3475#endif |
|
3473} 3474 3475static sm_connection_t * sm_get_connection_for_handle(hci_con_handle_t con_handle){ 3476 hci_connection_t * hci_con = hci_connection_for_handle(con_handle); 3477 if (!hci_con) return NULL; 3478 return &hci_con->sm_connection; 3479} 3480 --- 223 unchanged lines hidden --- | 3476} 3477 3478static sm_connection_t * sm_get_connection_for_handle(hci_con_handle_t con_handle){ 3479 hci_connection_t * hci_con = hci_connection_for_handle(con_handle); 3480 if (!hci_con) return NULL; 3481 return &hci_con->sm_connection; 3482} 3483 --- 223 unchanged lines hidden --- |