mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 01:42:18 +00:00
Use the correct public key when a new keyring is created
This commit is contained in:
parent
7c73ca7a78
commit
6d31aa52e7
@ -439,11 +439,7 @@ void handle_reply_line(const char *bufp, size_t len)
|
||||
else {
|
||||
if (debug & DEBUG_DNAHELPER)
|
||||
DEBUGF("DNAHELPER reply %s", alloca_toprint(-1, bufp, len));
|
||||
int cn=0, in=0, kp=0;
|
||||
if (!keyring_next_identity(keyring, &cn, &in, &kp))
|
||||
WHYF("No local identity, cannot send DNA LOOKUP reply");
|
||||
else
|
||||
overlay_mdp_dnalookup_reply(&request_mdp_data.src, keyring->contexts[cn]->identities[in]->keypairs[kp]->public_key, uri, did, name);
|
||||
overlay_mdp_dnalookup_reply(&request_mdp_data.src, my_subscriber->sid, uri, did, name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
16
keyring.c
16
keyring.c
@ -840,6 +840,14 @@ keyring_identity *keyring_create_identity(keyring_file *k,keyring_context *c, co
|
||||
crypto_box_curve25519xsalsa20poly1305_keypair(id->keypairs[0]->public_key,
|
||||
id->keypairs[0]->private_key);
|
||||
|
||||
// add new identity to in memory table
|
||||
struct subscriber *subscriber = find_subscriber(id->keypairs[0]->public_key, SID_SIZE, 1);
|
||||
if (subscriber){
|
||||
set_reachable(subscriber, REACHABLE_SELF);
|
||||
if (!my_subscriber)
|
||||
my_subscriber=subscriber;
|
||||
}
|
||||
|
||||
/* crypto_sign key pair */
|
||||
id->keypairs[1]=calloc(sizeof(keypair),1);
|
||||
if (!id->keypairs[1]) {
|
||||
@ -906,14 +914,6 @@ keyring_identity *keyring_create_identity(keyring_file *k,keyring_context *c, co
|
||||
else
|
||||
#endif
|
||||
|
||||
// add new identity to in memory table
|
||||
struct subscriber *subscriber = find_subscriber(id->keypairs[1]->public_key, SID_SIZE, 1);
|
||||
if (subscriber){
|
||||
set_reachable(subscriber, REACHABLE_SELF);
|
||||
if (!my_subscriber)
|
||||
my_subscriber=subscriber;
|
||||
}
|
||||
|
||||
/* Everything went fine */
|
||||
return id;
|
||||
|
||||
|
@ -684,6 +684,7 @@ int overlay_mdp_dispatch(overlay_mdp_frame *mdp,int userGeneratedFrameP,
|
||||
op_free(frame);
|
||||
RETURN(WHY("Packet had broadcast address as source address"));
|
||||
}else{
|
||||
// assume all local identities have already been unlocked and marked as SELF.
|
||||
frame->source = find_subscriber(mdp->out.src.sid, SID_SIZE, 0);
|
||||
if (!frame->source){
|
||||
op_free(frame);
|
||||
|
Loading…
x
Reference in New Issue
Block a user