comparison src/proto.salty.c @ 62:5b9e742bb704

Fixed compiler warnings, removed redundant version dependencies in debian package
author Ivo Smits <Ivo@UFO-Net.nl>
date Sat, 07 Jan 2017 15:47:19 +0100
parents 66d9d80215f0
children
comparison
equal deleted inserted replaced
61:66d9d80215f0 62:5b9e742bb704
207 memcpy(d->remotekey, rkey, PUBLICKEYBYTES); 207 memcpy(d->remotekey, rkey, PUBLICKEYBYTES);
208 memcpy(d->nonce, nonce, NONCEBYTES); 208 memcpy(d->nonce, nonce, NONCEBYTES);
209 memset(d->timestamps, 0, 5 * sizeof(uint32)); 209 memset(d->timestamps, 0, 5 * sizeof(uint32));
210 if (debug) dumphex("INIT DECODER SK", lkey, 32); 210 if (debug) dumphex("INIT DECODER SK", lkey, 32);
211 if (debug) dumphex("INIT DECODER RK", rkey, 32); 211 if (debug) dumphex("INIT DECODER RK", rkey, 32);
212 crypto_box_curve25519xsalsa20poly1305_beforenm(d->sharedkey, rkey, lkey); 212 if (crypto_box_curve25519xsalsa20poly1305_beforenm(d->sharedkey, rkey, lkey)) {
213 errorexit("Encryption key calculation failed");
214 abort();
215 }
213 } 216 }
214 217
215 static void sendkeyupdate(struct qtsession* sess, bool ack) { 218 static void sendkeyupdate(struct qtsession* sess, bool ack) {
216 struct qt_proto_data_salty* d = (struct qt_proto_data_salty*)sess->protocol_data; 219 struct qt_proto_data_salty* d = (struct qt_proto_data_salty*)sess->protocol_data;
217 unsigned char buffer[32 + (1 + 32 + 24 + 32 + 24 + 8)]; 220 unsigned char buffer[32 + (1 + 32 + 24 + 32 + 24 + 8)];
289 } 292 }
290 fclose(pkfile); 293 fclose(pkfile);
291 } else { 294 } else {
292 return errorexit("Missing PRIVATE_KEY"); 295 return errorexit("Missing PRIVATE_KEY");
293 } 296 }
294 crypto_box_curve25519xsalsa20poly1305_beforenm(d->controlkey, cpublickey, csecretkey); 297 if (crypto_box_curve25519xsalsa20poly1305_beforenm(d->controlkey, cpublickey, csecretkey))
298 return errorexit("Encryption key calculation failed");
295 unsigned char cownpublickey[PUBLICKEYBYTES]; 299 unsigned char cownpublickey[PUBLICKEYBYTES];
296 crypto_scalarmult_curve25519_base(cownpublickey, csecretkey); 300 crypto_scalarmult_curve25519_base(cownpublickey, csecretkey);
297 int role = memcmp(cownpublickey, cpublickey, PUBLICKEYBYTES); 301 int role = memcmp(cownpublickey, cpublickey, PUBLICKEYBYTES);
298 d->controlroles = (role == 0) ? 0 : ((role > 0) ? 1 : 2); 302 d->controlroles = (role == 0) ? 0 : ((role > 0) ? 1 : 2);
299 d->controldecodetime = 0; 303 d->controldecodetime = 0;
432 if (lkeyid != -1 && lkeyid == d->datalocalkeynextid) { 436 if (lkeyid != -1 && lkeyid == d->datalocalkeynextid) {
433 d->datalocalkeyid = lkeyid; 437 d->datalocalkeyid = lkeyid;
434 d->datalocalkeynextid = -1; 438 d->datalocalkeynextid = -1;
435 } 439 }
436 if (lkeyid == d->datalocalkeyid) { 440 if (lkeyid == d->datalocalkeyid) {
437 crypto_box_curve25519xsalsa20poly1305_beforenm(enckey->sharedkey, d->dataremotekey, enckey->privatekey); 441 if (crypto_box_curve25519xsalsa20poly1305_beforenm(enckey->sharedkey, d->dataremotekey, enckey->privatekey)) {
442 errorexit("Encryption key calculation failed");
443 abort();
444 }
438 d->dataencoder = enckey; 445 d->dataencoder = enckey;
439 } 446 }
440 if (debug) fprintf(stderr, "Decoded control packet: rkid=%d, lkid=%d, ack=%d, lkvalid=%d, uptodate=%d\n", d->dataremotekeyid, (cflags >> 5) & 0x01, (cflags >> 4) & 0x01, lkeyid != -1, d->datalocalkeynextid == -1); 447 if (debug) fprintf(stderr, "Decoded control packet: rkid=%d, lkid=%d, ack=%d, lkvalid=%d, uptodate=%d\n", d->dataremotekeyid, (cflags >> 5) & 0x01, (cflags >> 4) & 0x01, lkeyid != -1, d->datalocalkeynextid == -1);
441 if (d->datalocalkeynextid != -1) dosendkeyupdate |= 2; 448 if (d->datalocalkeynextid != -1) dosendkeyupdate |= 2;
442 if (dosendkeyupdate) sendkeyupdate(sess, (dosendkeyupdate & 2) == 0); 449 if (dosendkeyupdate) sendkeyupdate(sess, (dosendkeyupdate & 2) == 0);