diff --git a/keyring.c b/keyring.c index 7ef7816a..a94e6338 100644 --- a/keyring.c +++ b/keyring.c @@ -1132,7 +1132,6 @@ int keyring_mapping_request(keyring_file *k,overlay_mdp_frame *req) +crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES +slen; overlay_mdp_swap_src_dst(req); - #warning disabled crypt and sign for debugging. req->packetTypeAndFlags=MDP_TX; /* crypt and sign */ WHY("Sent SID:SAS mapping mutual-signature"); printf("%d byte reply is from %s:%u\n to %s:%u\n", @@ -1173,8 +1172,28 @@ int keyring_mapping_request(keyring_file *k,overlay_mdp_frame *req) if (bcmp(plain,req->out.src.sid,SID_SIZE)) return WHY("key mapping signed block is for wrong SID"); WHY("Key mapping looks valid"); - } - WHY("Not implemented"); + + /* work out where to put it */ + int i; + for(i=0;iout.src.sid,sid_sas_mappings[i].sid,SID_SIZE)) break; + + if (i>=MAX_SID_SAS_MAPPINGS) i=random()%MAX_SID_SAS_MAPPINGS; + if (i>=sid_sas_mapping_count) sid_sas_mapping_count=i+1; + + /* now put it */ + bcopy(&req->out.src.sid,&sid_sas_mappings[i].sid[0],SID_SIZE); + bcopy(sas_public,&sid_sas_mappings[i].sas_public[0], + crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES); + fprintf(stderr,"Mapping #%d (count=%d) SID=%s to SAS=%s*\n",i, + sid_sas_mapping_count, + overlay_render_sid(sid_sas_mappings[i].sid), + overlay_render_sid(sid_sas_mappings[i].sas_public)); + sid_sas_mappings[i].validP=1; + sid_sas_mappings[i].last_request_time_in_ms=0; + WHY("Stored mapping"); + return 0; + } break; default: WHY("Key mapping response for unknown key type. Oh well."); diff --git a/overlay_abbreviations.c b/overlay_abbreviations.c index 23105064..0d9756aa 100644 --- a/overlay_abbreviations.c +++ b/overlay_abbreviations.c @@ -228,7 +228,7 @@ int overlay_abbreviate_append_address(overlay_buffer *b,unsigned char *a) int count=0; ob_makespace(b,SID_SIZE+3); int r=overlay_abbreviate_address(a,&b->bytes[b->length],&count); - if (DEBUG_PACKETCONSTRUCTION) { + if (debug&DEBUG_PACKETCONSTRUCTION) { fprintf(stderr,"address %s abbreviates as shown in this ", overlay_render_sid(a)); dump(NULL,&b->bytes[b->length],count); diff --git a/overlay_mdp.c b/overlay_mdp.c index a31f2d46..c9c37e91 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -320,8 +320,10 @@ int overlay_saw_mdp_containing_frame(int interface,overlay_frame *f,long long no mdp.packetTypeAndFlags|=MDP_NOCRYPT; break; case OF_CRYPTO_CIPHERED|OF_CRYPTO_SIGNED: { + fflush(stderr); printf("crypted MDP frame for %s\n", overlay_render_sid(mdp.out.dst.sid)); + fflush(stdout); unsigned char *k=keyring_get_nm_bytes(&mdp.out.dst,&mdp.out.src); unsigned char *nonce=&f->payload->bytes[0];