|
|
|
@ -1126,7 +1126,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { |
|
|
|
// Try INIT decryption (for incoming connection requests)
|
|
|
|
// Try INIT decryption (for incoming connection requests)
|
|
|
|
// This handles: no link found, or link without session, or normal decrypt failed
|
|
|
|
// This handles: no link found, or link without session, or normal decrypt failed
|
|
|
|
if (recv_len <= SC_PUBKEY_ENC_SIZE + UDP_SC_HDR_SIZE) { |
|
|
|
if (recv_len <= SC_PUBKEY_ENC_SIZE + UDP_SC_HDR_SIZE) { |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "packet too small for init, size=%zd", recv_len); |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "packet too small for init, size=%zd from %s", recv_len, sockaddr_storage_to_str(&addr).str); |
|
|
|
errorcode=1; |
|
|
|
errorcode=1; |
|
|
|
goto ec_fr; |
|
|
|
goto ec_fr; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1141,19 +1141,19 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { |
|
|
|
sc_obfuscate_pubkey(salt, e_sock->instance->my_keys.public_key, encrypted_pubkey, decrypted_pubkey); |
|
|
|
sc_obfuscate_pubkey(salt, e_sock->instance->my_keys.public_key, encrypted_pubkey, decrypted_pubkey); |
|
|
|
|
|
|
|
|
|
|
|
if (sc_set_peer_public_key(&sc, decrypted_pubkey, SC_PEER_PUBKEY_BIN)!=SC_OK) {
|
|
|
|
if (sc_set_peer_public_key(&sc, decrypted_pubkey, SC_PEER_PUBKEY_BIN)!=SC_OK) {
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "failed to set peer public key during init"); |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "failed to set peer public key during init, from %s", sockaddr_storage_to_str(&addr).str); |
|
|
|
errorcode=2;
|
|
|
|
errorcode=2;
|
|
|
|
goto ec_fr;
|
|
|
|
goto ec_fr;
|
|
|
|
} |
|
|
|
} |
|
|
|
if (sc_decrypt(&sc, data, recv_len - SC_PUBKEY_ENC_SIZE, (uint8_t*)&pkt->timestamp, &pkt_len)) { |
|
|
|
if (sc_decrypt(&sc, data, recv_len - SC_PUBKEY_ENC_SIZE, (uint8_t*)&pkt->timestamp, &pkt_len)) { |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "failed to decrypt init packet"); |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "failed to decrypt init packet, from %s", sockaddr_storage_to_str(&addr).str); |
|
|
|
errorcode=3;
|
|
|
|
errorcode=3;
|
|
|
|
goto ec_fr;
|
|
|
|
goto ec_fr;
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// INIT decryption succeeded - process as new incoming connection
|
|
|
|
// INIT decryption succeeded - process as new incoming connection
|
|
|
|
if (pkt_len<3) { |
|
|
|
if (pkt_len<3) { |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "too short packet"); |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "too short packet, from %s", sockaddr_storage_to_str(&addr).str); |
|
|
|
errorcode=7; |
|
|
|
errorcode=7; |
|
|
|
goto ec_fr;
|
|
|
|
goto ec_fr;
|
|
|
|
} |
|
|
|
} |
|
|
|
@ -1547,7 +1547,7 @@ process_decrypted: |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
ec_fr: |
|
|
|
ec_fr: |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "etcp_connections_read_callback: error %d", errorcode); |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "etcp_connections_read_callback: error %d, from %s", errorcode, sockaddr_storage_to_str(&addr).str); |
|
|
|
e_sock->pkt_format_errors++; |
|
|
|
e_sock->pkt_format_errors++; |
|
|
|
e_sock->errorcode=errorcode; |
|
|
|
e_sock->errorcode=errorcode; |
|
|
|
memory_pool_free(e_sock->instance->pkt_pool, pkt); |
|
|
|
memory_pool_free(e_sock->instance->pkt_pool, pkt); |
|
|
|
|