comparison src/proto.nacltai.c @ 11:5be1ecb80cc9

Fixed build script for debian systems without packaging tools, removed packet logging from nacltai
author root <root@Really.UFO-Net.nl>
date Sat, 04 Dec 2010 02:10:00 +0000
parents 1e4ba8d8ffc2
children 3400045a57b8
comparison
equal deleted inserted replaced
10:1e4ba8d8ffc2 11:5be1ecb80cc9
117 } 117 }
118 118
119 extern crypto_scalarmult_curve25519_base(unsigned char *pk, unsigned char *sk); 119 extern crypto_scalarmult_curve25519_base(unsigned char *pk, unsigned char *sk);
120 120
121 static int encode(struct qtsession* sess, char* raw, char* enc, int len) { 121 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); 122 // 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; 123 struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data;
124 memset(raw, 0, crypto_box_ZEROBYTES); 124 memset(raw, 0, crypto_box_ZEROBYTES);
125 taia_now(&d->cdtaic); 125 taia_now(&d->cdtaic);
126 taia_pack(d->cenonce + nonceoffset, &(d->cdtaic)); 126 taia_pack(d->cenonce + nonceoffset, &(d->cdtaic));
127 if (crypto_box_afternm(enc, raw, len + crypto_box_ZEROBYTES, d->cenonce, d->cbefore)) return errorexit("Crypto failed"); 127 if (crypto_box_afternm(enc, raw, len + crypto_box_ZEROBYTES, d->cenonce, d->cbefore)) return errorexit("Crypto failed");
128 memcpy((void*)(enc + crypto_box_BOXZEROBYTES - noncelength), d->cenonce + nonceoffset, noncelength); 128 memcpy((void*)(enc + crypto_box_BOXZEROBYTES - noncelength), d->cenonce + nonceoffset, noncelength);
129 len += overhead; 129 len += overhead;
130 fprintf(stderr, "Encoded packet of %d bytes from %d to %d\n", len, raw, enc); 130 // fprintf(stderr, "Encoded packet of %d bytes from %d to %d\n", len, raw, enc);
131 return len; 131 return len;
132 } 132 }
133 133
134 static int decode(struct qtsession* sess, char* enc, char* raw, int len) { 134 static int decode(struct qtsession* sess, char* enc, char* raw, int len) {
135 fprintf(stderr, "Decoding packet of %d bytes from %d to %d\n", len, enc, raw); 135 // fprintf(stderr, "Decoding packet of %d bytes from %d to %d\n", len, enc, raw);
136 struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data; 136 struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data;
137 int i; 137 int i;
138 if (len < overhead) { 138 if (len < overhead) {
139 fprintf(stderr, "Short packet received: %d\n", len); 139 fprintf(stderr, "Short packet received: %d\n", len);
140 return 0; 140 return 0;
150 if (i = crypto_box_open_afternm(raw, enc, len + crypto_box_ZEROBYTES, d->cdnonce, d->cbefore)) { 150 if (i = crypto_box_open_afternm(raw, enc, len + crypto_box_ZEROBYTES, d->cdnonce, d->cbefore)) {
151 fprintf(stderr, "Decryption failed len=%d result=%d\n", len, i); 151 fprintf(stderr, "Decryption failed len=%d result=%d\n", len, i);
152 return 0; 152 return 0;
153 } 153 }
154 d->cdtaip = d->cdtaic; 154 d->cdtaip = d->cdtaic;
155 fprintf(stderr, "Decoded packet of %d bytes from %d to %d\n", len, enc, raw); 155 // fprintf(stderr, "Decoded packet of %d bytes from %d to %d\n", len, enc, raw);
156 return len; 156 return len;
157 } 157 }
158 158
159 static int init(struct qtsession* sess) { 159 static int init(struct qtsession* sess) {
160 struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data; 160 struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data;