Mercurial > hg > quicktun
comparison src/proto.nacltai.c @ 43:4adbd9b67fe2
Fix nonce calculation when both sides use the same key in nacltai and salty protocols
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Thu, 16 May 2013 01:35:26 +0200 |
parents | 54d28a81ca99 |
children | 55f379f0a650 |
comparison
equal
deleted
inserted
replaced
42:c8d176154d7c | 43:4adbd9b67fe2 |
---|---|
194 taia_now(&d->cdtaip); | 194 taia_now(&d->cdtaip); |
195 d->cdtaip.sec.x -= atol(envval); | 195 d->cdtaip.sec.x -= atol(envval); |
196 } else { | 196 } else { |
197 fprintf(stderr, "Warning: TIME_WINDOW not set, risking an initial replay attack\n"); | 197 fprintf(stderr, "Warning: TIME_WINDOW not set, risking an initial replay attack\n"); |
198 } | 198 } |
199 if (envval = getconf("ROLE")) { | 199 int role = memcmp(cownpublickey, cpublickey, crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES); |
200 d->cenonce[nonceoffset-1] = atoi(envval) ? 1 : 0; | 200 if (envval = getconf("ROLE")) role = atoi(envval) ? 1 : -1; |
201 } else { | 201 role = (role == 0) ? 0 : ((role > 0) ? 1 : 2); |
202 d->cenonce[nonceoffset-1] = memcmp(cownpublickey, cpublickey, crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) > 0 ? 1 : 0; | 202 d->cenonce[nonceoffset-1] = role & 1; |
203 } | 203 d->cdnonce[nonceoffset-1] = (role >> 1) & 1; |
204 d->cdnonce[nonceoffset-1] = d->cenonce[nonceoffset-1] ? 0 : 1; | |
205 return 0; | 204 return 0; |
206 } | 205 } |
207 | 206 |
208 struct qtproto qtproto_nacltai = { | 207 struct qtproto qtproto_nacltai = { |
209 1, | 208 1, |