mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-19 05:07:56 +00:00
fixed bugs and completed implementation of storing SID:SAS mappings.
Now to finish implementing verification process.
This commit is contained in:
parent
2a67153613
commit
e639d3d255
23
keyring.c
23
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");
|
||||
|
||||
/* work out where to put it */
|
||||
int i;
|
||||
for(i=0;i<sid_sas_mapping_count;i++)
|
||||
if (!bcmp(req->out.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;
|
||||
}
|
||||
WHY("Not implemented");
|
||||
break;
|
||||
default:
|
||||
WHY("Key mapping response for unknown key type. Oh well.");
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user