comparison src/proto.nacltai.c @ 19:3400045a57b8 V2.1.6

Version 2.1.6, changed sourcecode archive generation, use NaCl version 20110221, do not duplicate NaCl sourcecode, support iproute2 for persistent tunnel creation on Debian, support running as root on Debian, removed autogenerated header files
author Ivo Smits <Ivo@UCIS.nl>
date Sun, 27 Feb 2011 22:42:27 +0100
parents 5be1ecb80cc9
children 38d495566d1c
comparison
equal deleted inserted replaced
18:c9fba5007577 19:3400045a57b8
23 authors and should not be interpreted as representing official policies, either expressed 23 authors and should not be interpreted as representing official policies, either expressed
24 or implied, of Ivo Smits.*/ 24 or implied, of Ivo Smits.*/
25 25
26 #include "common.c" 26 #include "common.c"
27 #include "crypto_box.h" 27 #include "crypto_box.h"
28 #include "crypto_scalarmult_curve25519.h"
28 #include <sys/types.h> 29 #include <sys/types.h>
29 #include <sys/time.h> 30 #include <sys/time.h>
30 31
31 #define uint64 unsigned long long //typedef unsigned long long uint64; 32 #define uint64 unsigned long long //typedef unsigned long long uint64;
32 33
114 t->sec.x = 4611686018427387914ULL + (uint64) now.tv_sec; 115 t->sec.x = 4611686018427387914ULL + (uint64) now.tv_sec;
115 t->nano = 1000 * now.tv_usec + 500; 116 t->nano = 1000 * now.tv_usec + 500;
116 t->atto = 0; 117 t->atto = 0;
117 } 118 }
118 119
119 extern crypto_scalarmult_curve25519_base(unsigned char *pk, unsigned char *sk);
120
121 static int encode(struct qtsession* sess, char* raw, char* enc, int len) { 120 static int encode(struct qtsession* sess, char* raw, char* enc, int len) {
122 // fprintf(stderr, "Encoding packet of %d bytes from %d to %d\n", len, raw, enc); 121 // fprintf(stderr, "Encoding packet of %d bytes from %d to %d\n", len, raw, enc);
123 struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data; 122 struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data;
124 memset(raw, 0, crypto_box_ZEROBYTES); 123 memset(raw, 0, crypto_box_ZEROBYTES);
125 taia_now(&d->cdtaic); 124 taia_now(&d->cdtaic);
170 crypto_box_beforenm(d->cbefore, cpublickey, csecretkey); 169 crypto_box_beforenm(d->cbefore, cpublickey, csecretkey);
171 170
172 memset(d->cenonce, 0, crypto_box_NONCEBYTES); 171 memset(d->cenonce, 0, crypto_box_NONCEBYTES);
173 memset(d->cdnonce, 0, crypto_box_NONCEBYTES); 172 memset(d->cdnonce, 0, crypto_box_NONCEBYTES);
174 173
175 const unsigned char base[32] = {9}; 174 crypto_scalarmult_curve25519_base(cownpublickey, csecretkey);
176 crypto_scalarmult(cownpublickey, csecretkey, base);
177 175
178 if (envval = getenv("TIME_WINDOW")) { 176 if (envval = getenv("TIME_WINDOW")) {
179 taia_now(&d->cdtaip); 177 taia_now(&d->cdtaip);
180 d->cdtaip.sec.x -= atol(envval); 178 d->cdtaip.sec.x -= atol(envval);
181 } else { 179 } else {