conn_mgr: add missing sc_init_ctx before sc_set_peer_public_key
Without sc_init_ctx, crypto_ctx.initialized==0, sc_set_peer_public_key returns SC_ERR_NOT_INITIALIZED, and all subsequent sc_encrypt (INIT, etc) fail with 'encryption failed' error 2. Fixed in cm_start_phase_direct and reverse-connect path (both places that create ETCP_CONN for conn_mgr).
This commit is contained in:
1 parent
f3b27bbb26
commit
e2ee9b1c14
1 file changed
+3
-1
+3
-1
@@ -472,6 +472,7 @@ static void cm_start_phase_direct(struct CONN_MGR_ENTRY* entry) {
|
||||
struct ETCP_CONN* conn = etcp_connection_create(entry->mgr->instance, NULL);
|
||||
if (conn) {
|
||||
etcp_conn_set_ready_cbk(conn, cm_direct_ready_cb, entry);
|
||||
sc_init_ctx(&conn->crypto_ctx, &entry->mgr->instance->my_keys);
|
||||
sc_set_peer_public_key(&conn->crypto_ctx, target->node->public_key, 0);
|
||||
if (etcp_link_new(conn, s, &sa, 0)) {
|
||||
entry->main.timer = uasync_set_timeout(entry->mgr->instance->ua, CONN_MGR_CONNECT_DIRECT_TIMEOUT_MS * 10, entry, cm_direct_timeout_cb, "conn_mgr_direct");
|
||||
@@ -854,7 +855,8 @@ static void cm_handle_direct_req(struct ETCP_CONN* conn, const uint8_t* data, si
|
||||
struct ETCP_CONN* new_conn = etcp_connection_create(conn->instance, NULL);
|
||||
if (new_conn) {
|
||||
struct TOPO_NODEQ* nq = topo_node_find_by_id(topo_groups_get_default(conn->instance->topo_groups), src_node_id);
|
||||
if (nq) sc_set_peer_public_key(&new_conn->crypto_ctx, nq->node->public_key, 0);
|
||||
if (nq) { sc_init_ctx(&new_conn->crypto_ctx, &conn->instance->my_keys);
|
||||
sc_set_peer_public_key(&new_conn->crypto_ctx, nq->node->public_key, 0); }
|
||||
struct cm_reverse_pending* rp = u_calloc(1, sizeof(struct cm_reverse_pending));
|
||||
if (rp) { rp->request_id = req->request_id; rp->entry = NULL; rp->next = mgr->reverse_pending;
|
||||
etcp_conn_set_ready_cbk(new_conn, cm_reverse_ready_cb, rp); mgr->reverse_pending = rp; }
|
||||
|
||||
Reference in new issue
Block a user