}
bool send_req_key(meshlink_handle_t *mesh, node_t *to) {
- if(!node_read_ecdsa_public_key(mesh, to)) {
+ if(!node_read_public_key(mesh, to)) {
logger(mesh, MESHLINK_DEBUG, "No ECDSA key known for %s", to->name);
send_request(mesh, to->nexthop->connection, NULL, "%d %s %s %d", REQ_KEY, mesh->self->name, to->name, REQ_PUBKEY);
return true;
to->status.waitingforkey = true;
to->last_req_key = mesh->loop.now.tv_sec;
to->incompression = mesh->self->incompression;
- return sptps_start(&to->sptps, to, true, true, mesh->self->connection->ecdsa, to->ecdsa, label, sizeof(label) - 1, send_initial_sptps_data, receive_sptps_record);
+ return sptps_start(&to->sptps, to, true, true, mesh->private_key, to->ecdsa, label, sizeof(label) - 1, send_initial_sptps_data, receive_sptps_record);
}
/* REQ_KEY is overloaded to allow arbitrary requests to be routed between two nodes. */
switch(reqno) {
case REQ_PUBKEY: {
- char *pubkey = ecdsa_get_base64_public_key(mesh->self->connection->ecdsa);
+ char *pubkey = ecdsa_get_base64_public_key(mesh->private_key);
if(!from->nexthop || !from->nexthop->connection) {
return false;
}
case ANS_PUBKEY: {
- if(node_read_ecdsa_public_key(mesh, from)) {
+ if(node_read_public_key(mesh, from)) {
logger(mesh, MESHLINK_WARNING, "Got ANS_PUBKEY from %s even though we already have his pubkey", from->name);
return true;
}
}
logger(mesh, MESHLINK_INFO, "Learned ECDSA public key from %s", from->name);
- append_config_file(mesh, from->name, "ECDSAPublicKey", pubkey);
+ from->status.dirty = true;
return true;
}
case REQ_KEY: {
- if(!node_read_ecdsa_public_key(mesh, from)) {
+ if(!node_read_public_key(mesh, from)) {
logger(mesh, MESHLINK_DEBUG, "No ECDSA key known for %s", from->name);
send_request(mesh, from->nexthop->connection, NULL, "%d %s %s %d", REQ_KEY, mesh->self->name, from->name, REQ_PUBKEY);
return true;
from->status.validkey = false;
from->status.waitingforkey = true;
from->last_req_key = mesh->loop.now.tv_sec;
- sptps_start(&from->sptps, from, false, true, mesh->self->connection->ecdsa, from->ecdsa, label, sizeof(label) - 1, send_sptps_data, receive_sptps_record);
+ sptps_start(&from->sptps, from, false, true, mesh->private_key, from->ecdsa, label, sizeof(label) - 1, send_sptps_data, receive_sptps_record);
sptps_receive_data(&from->sptps, buf, len);
return true;
}