changeset 46:3f04a72ce035

Salty protocol: move local sending timestamp forward if remote has a newer timestamp
author Ivo Smits <Ivo@UCIS.nl>
date Fri, 24 May 2013 17:06:42 +0200
parents 671d640390f2
children e896392f7e03
files src/proto.salty.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/proto.salty.c	Fri May 17 16:10:58 2013 +0200
+++ b/src/proto.salty.c	Fri May 24 17:06:42 2013 +0200
@@ -415,6 +415,10 @@
 		memcpy(d->dataremotekey, raw + 32 + 1, 32);
 		memcpy(d->dataremotenonce, raw + 32 + 1 + 32, 24);
 		uint64 lexpectts = decodeuint64(raw + 32 + 1 + 32 + 24 + 32 + 24);
+		if (lexpectts > d->controlencodetime) {
+			fprintf(stderr, "Remote expects newer control timestamp (%llu > %llu), moving forward.\n", lexpectts, d->controlencodetime);
+			d->controlencodetime = lexpectts;
+		}
 		struct qt_proto_data_salty_keyset* enckey = &d->datalocalkeys[lkeyid];
 		if (memcmp(enckey->publickey, raw + 32 + 1 + 32 + 24, 32) || memcmp(enckey->nonce, raw + 32 + 1 + 32 + 24 + 32, 20)) {
 			dosendkeyupdate |= 2;