diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index a03baf92..92205e52 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c @@ -32,7 +32,7 @@ START_TEST(test_basic) uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; crypto_box_keypair(self_public_key, self_secret_key); - TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_public_key, self_secret_key, NULL); + TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL); ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports"); @@ -214,7 +214,7 @@ START_TEST(test_some) uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; crypto_box_keypair(self_public_key, self_secret_key); - TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_public_key, self_secret_key, NULL); + TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL); ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports"); @@ -380,7 +380,7 @@ START_TEST(test_client) uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; crypto_box_keypair(self_public_key, self_secret_key); - TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_public_key, self_secret_key, NULL); + TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL); ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports"); diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 29aa5bcf..52e84315 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) #ifdef TCP_RELAY_ENABLED #define NUM_PORTS 3 uint16_t ports[NUM_PORTS] = {443, 3389, PORT}; - TCP_Server *tcp_s = new_TCP_server(ipv6enabled, NUM_PORTS, ports, dht->self_public_key, dht->self_secret_key, onion); + TCP_Server *tcp_s = new_TCP_server(ipv6enabled, NUM_PORTS, ports, dht->self_secret_key, onion); if (tcp_s == NULL) { printf("TCP server failed to initialize.\n"); diff --git a/other/bootstrap_daemon/tox-bootstrapd.c b/other/bootstrap_daemon/tox-bootstrapd.c index 8b5e6a4b..267e7238 100644 --- a/other/bootstrap_daemon/tox-bootstrapd.c +++ b/other/bootstrap_daemon/tox-bootstrapd.c @@ -624,8 +624,7 @@ int main(int argc, char *argv[]) return 1; } - tcp_server = new_TCP_server(enable_ipv6, tcp_relay_port_count, tcp_relay_ports, dht->self_public_key, - dht->self_secret_key, onion); + tcp_server = new_TCP_server(enable_ipv6, tcp_relay_port_count, tcp_relay_ports, dht->self_secret_key, onion); // tcp_relay_port_count != 0 at this point free(tcp_relay_ports); diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 381ee737..dccd6495 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -1813,8 +1813,7 @@ Messenger *new_messenger(Messenger_Options *options, unsigned int *error) } if (options->tcp_server_port) { - m->tcp_server = new_TCP_server(options->ipv6enabled, 1, &options->tcp_server_port, m->dht->self_public_key, - m->dht->self_secret_key, m->onion); + m->tcp_server = new_TCP_server(options->ipv6enabled, 1, &options->tcp_server_port, m->dht->self_secret_key, m->onion); if (m->tcp_server == NULL) { kill_friend_connections(m->fr_c); diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index f07df2c6..cf997d34 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c @@ -939,8 +939,8 @@ static sock_t new_listening_TCP_socket(int family, uint16_t port) return sock; } -TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uint16_t *ports, const uint8_t *public_key, - const uint8_t *secret_key, Onion *onion) +TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uint16_t *ports, const uint8_t *secret_key, + Onion *onion) { if (num_sockets == 0 || ports == NULL) return NULL; @@ -1015,8 +1015,8 @@ TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uin set_callback_handle_recv_1(onion, &handle_onion_recv_1, temp); } - memcpy(temp->public_key, public_key, crypto_box_PUBLICKEYBYTES); memcpy(temp->secret_key, secret_key, crypto_box_SECRETKEYBYTES); + crypto_scalarmult_curve25519_base(temp->public_key, temp->secret_key); bs_list_init(&temp->accepted_key_list, crypto_box_PUBLICKEYBYTES, 8); diff --git a/toxcore/TCP_server.h b/toxcore/TCP_server.h index ba3e7308..3f6b18ae 100644 --- a/toxcore/TCP_server.h +++ b/toxcore/TCP_server.h @@ -143,8 +143,8 @@ typedef struct { /* Create new TCP server instance. */ -TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uint16_t *ports, const uint8_t *public_key, - const uint8_t *secret_key, Onion *onion); +TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uint16_t *ports, const uint8_t *secret_key, + Onion *onion); /* Run the TCP_server */