/[pkg-mixmaster]/trunk/Mix/Src/chain2.c
ViewVC logotype

Contents of /trunk/Mix/Src/chain2.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 512 - (hide annotations) (download)
Thu May 8 18:07:08 2003 UTC (10 years, 1 month ago) by weaselp
File MIME type: text/plain
File size: 19852 byte(s)
Experimental feature:  --redirect -l <chain>.  If you have a mixmaster message
with a chain starting with hop1 (you cannot know any more because it already is
encrypted) then mix --redirect -l=foo,bar < file redirect the message so the
chain is actually foo,bar,hop1,... and places it in your pool.  If the total
number of hops (which cannot be known) exceeds 20 the message is damanged and
will fail at the 20th node.
1 rabbi 1 /* Mixmaster version 3 -- (C) 1999 Anonymizer Inc.
2    
3     Mixmaster may be redistributed and modified under certain conditions.
4     This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
5     ANY KIND, either express or implied. See the file COPYRIGHT for
6     details.
7    
8     Encrypt message for Mixmaster chain
9 weaselp 512 $Id: chain2.c,v 1.12 2003/05/08 18:07:08 weaselp Exp $ */
10 rabbi 1
11    
12     #include "mix3.h"
13     #include <string.h>
14     #include <stdlib.h>
15     #include <time.h>
16     #include <ctype.h>
17     #include <assert.h>
18    
19     #ifdef USE_RSA
20    
21     #define N(X) (isdigit(X) ? (X)-'0' : 0)
22    
23 weaselp 168 int prepare_type2list(BUFFER *out)
24 rabbi 101 {
25     FILE *list;
26     char line[LINELEN], name[LINELEN], addr[LINELEN], keyid[LINELEN],
27 weaselp 214 version[LINELEN], flags[LINELEN], createdstr[LINELEN], expiresstr[LINELEN];
28     int assigned;
29     time_t created, expires;
30 rabbi 101
31     list = mix_openfile(TYPE2LIST, "r");
32     if (list == NULL) {
33     list = mix_openfile(PUBRING, "r");
34     if (list == NULL)
35     return (-1);
36     }
37     while (fgets(line, sizeof(line), list) != NULL) {
38     if (strleft(line, begin_key)) {
39     while (fgets(line, sizeof(line), list) != NULL &&
40     !strleft(line, end_key)) ;
41     } else if (strlen(line) > 36 && line[0] != '#') {
42 weaselp 214 assigned = sscanf(line, "%127s %127s %127s %127s %127s %127s %127s",
43     name, addr, keyid, version, flags, createdstr, expiresstr);
44     if (assigned < 4)
45 rabbi 101 continue;
46 weaselp 214 if (assigned >= 6) {
47     created = parse_yearmonthday(createdstr);
48     if (created == 0 || created == -1) {
49     errlog(WARNING, "Cannot parse creation date of key %s.\n", keyid);
50     continue;
51 weaselp 332 };
52 weaselp 214 if (created > time(NULL)) {
53     errlog(WARNING, "Key %s created in the future.\n", keyid);
54     continue;
55 weaselp 332 };
56 weaselp 214 }
57     if (assigned >= 7) {
58     expires = parse_yearmonthday(expiresstr);
59     if (expires == 0 || expires == -1) {
60     errlog(WARNING, "Cannot parse expiration date of key %s.\n", keyid);
61     continue;
62 weaselp 332 };
63 weaselp 214 if (expires < time(NULL)) {
64     errlog(WARNING, "Key %s has expired.\n", keyid);
65     continue;
66 weaselp 332 };
67 weaselp 214 }
68 weaselp 168 buf_appends(out, line);
69 rabbi 101 }
70     }
71     fclose(list);
72     return (0);
73     }
74    
75 weaselp 500 int mix2_rlist(REMAILER remailer[], int badchains[MAXREM][MAXREM])
76 rabbi 1 {
77 weaselp 387 FILE *list, *excl;
78 rabbi 1 int n, i, listed = 0;
79    
80     char line[LINELEN], name[LINELEN], addr[LINELEN], keyid[LINELEN],
81 weaselp 214 version[LINELEN], flags[LINELEN], createdstr[LINELEN], expiresstr[LINELEN];
82     int assigned;
83     time_t created, expires;
84 weaselp 387 BUFFER *starex;
85 rabbi 1
86 weaselp 387 starex = buf_new();
87     excl = mix_openfile(STAREX, "r");
88     if (excl != NULL) {
89     buf_read(starex, excl);
90     fclose(excl);
91     }
92    
93 rabbi 1 list = mix_openfile(TYPE2LIST, "r");
94     if (list == NULL) {
95     list = mix_openfile(PUBRING, "r");
96 weaselp 387 if (list == NULL) {
97     buf_free(starex);
98 rabbi 1 return (-1);
99 weaselp 387 }
100 rabbi 1 }
101     for (n = 1; fgets(line, sizeof(line), list) != NULL && n < MAXREM;)
102     if (strleft(line, begin_key)) {
103     while (fgets(line, sizeof(line), list) != NULL &&
104     !strleft(line, end_key)) ;
105     } else if (strlen(line) > 36 && line[0] != '#') {
106     flags[0] = '\0';
107 weaselp 214 assigned = sscanf(line, "%127s %127s %127s %127s %127s %127s %127s",
108     name, addr, keyid, version, flags, createdstr, expiresstr);
109     if (assigned < 4)
110 rabbi 1 continue;
111 weaselp 214 if (assigned >= 6) {
112     created = parse_yearmonthday(createdstr);
113     if (created == 0 || created == -1) {
114     errlog(WARNING, "Cannot parse creation date of key %s.\n", keyid);
115     continue;
116 weaselp 332 };
117 weaselp 214 if (created > time(NULL)) {
118     errlog(WARNING, "Key %s created in the future.\n", keyid);
119     continue;
120 weaselp 332 };
121 weaselp 214 }
122     if (assigned >= 7) {
123     expires = parse_yearmonthday(expiresstr);
124     if (expires == 0 || expires == -1) {
125     errlog(WARNING, "Cannot parse expiration date of key %s.\n", keyid);
126     continue;
127 weaselp 332 };
128 weaselp 214 if (expires < time(NULL)) {
129     errlog(WARNING, "Key %s has expired.\n", keyid);
130     continue;
131 weaselp 332 };
132 weaselp 214 }
133 rabbi 1 strncpy(remailer[n].name, name, sizeof(remailer[n].name));
134     remailer[n].name[sizeof(remailer[n].name) - 1] = '\0';
135     strncpy(remailer[n].addr, addr, sizeof(remailer[n].addr));
136     remailer[n].addr[sizeof(remailer[n].addr) - 1] = '\0';
137     remailer[n].flags.mix = 1;
138     remailer[n].flags.cpunk = 0;
139     remailer[n].flags.nym = 0;
140     remailer[n].flags.newnym = 0;
141     id_decode(keyid, remailer[n].keyid);
142     remailer[n].version = N(version[0]);
143     remailer[n].flags.compress = strfind(flags, "C");
144     remailer[n].flags.post = strfind(flags, "N");
145     remailer[n].flags.middle = strfind(flags, "M");
146     remailer[n].info[0].reliability = 0;
147     remailer[n].info[0].latency = 0;
148     remailer[n].info[0].history[0] = '\0';
149 weaselp 387 remailer[n].flags.star_ex = bufifind(starex, name);
150 rabbi 1 n++;
151     }
152     fclose(list);
153     list = mix_openfile(TYPE2REL, "r");
154     if (list != NULL) {
155     while (fgets(line, sizeof(line), list) != NULL &&
156 weaselp 503 !strleft(line, "--------------------------------------------")) {
157     if (strleft(line, "Last update:")) {
158 weaselp 511 int generated;
159     int now = time(NULL);
160 weaselp 503 char *tmp = line + strlen("Last update:") + 1;
161     /* For some weird reason, this isn't rfc822 */
162     if (strleft(tmp, "Mon") ||
163     strleft(tmp, "Tue") ||
164     strleft(tmp, "Wed") ||
165     strleft(tmp, "Thu") ||
166     strleft(tmp, "Fri") ||
167     strleft(tmp, "Sat") ||
168     strleft(tmp, "Sun"))
169     tmp += 3;
170 weaselp 511 generated = parsedate(tmp);
171     now = time(NULL);
172 weaselp 503 if (generated != -1 && generated < now - SECONDSPERDAY)
173     errlog(WARNING, "Remailer Reliability Statistics are older than one day.\n");
174     }
175     };
176 rabbi 1 while (fgets(line, sizeof(line), list) != NULL &&
177     !strleft(line, "</PRE>"))
178     if (strlen(line) >= 44 && strlen(line) <= 46)
179     for (i = 1; i < n; i++)
180     if (strleft(line, remailer[i].name) &&
181     line[strlen(remailer[i].name)] == ' ') {
182     strncpy(remailer[i].info[0].history, line + 15, 12);
183     remailer[i].info[0].history[12] = '\0';
184     remailer[i].info[0].reliability = 10000 * N(line[37])
185     + 1000 * N(line[38]) + 100 * N(line[39])
186     + 10 * N(line[41]) + N(line[42]);
187     remailer[i].info[0].latency = 36000 * N(line[28])
188     + 3600 * N(line[29]) + 600 * N(line[31])
189     + 60 * N(line[32]) + 10 * N(line[34])
190     + N(line[35]);
191     listed++;
192     }
193     fclose(list);
194     }
195 weaselp 500
196     parse_badchains(badchains, TYPE2REL, "Broken type-II remailer chains", remailer, n);
197 rabbi 1 if (listed < 4) /* we have no valid reliability info */
198     for (i = 1; i < n; i++)
199     remailer[i].info[0].reliability = 10000;
200 weaselp 387 buf_free(starex);
201 rabbi 1 return (n);
202     }
203    
204     static int send_packet(int numcopies, BUFFER *packet, int chain[],
205     int chainlen, int packetnum, int numpackets,
206 weaselp 500 BUFFER *mid, REMAILER remailer[], int badchains[MAXREM][MAXREM],
207 weaselp 512 int maxrem, char *redirect_to, BUFFER *feedback)
208     /*
209     * Puts a mix packet in the pool.
210     *
211     * numcopies ... how often to put this packet into the pool
212     * i.e. send it. required that random remailers are in the chain.
213     * packet ... the payload, 10240 bytes in size.
214     * chain ... the chain to send this message along
215     * chainlen ... length of the chain
216     * packetnum ... in multi-packet messages (fragmented) the serial of this packet
217     * numpackets ... the total number of packets
218     * mid ... the message ID (required for fragmented packets
219     * remailer ... information about remailers, their reliabilities, capabilities, etc.
220     * badchains ... broken chain information
221     * maxrem ... the number of remailers in remailer[] and badchains[]
222     * redirect_to ... if this is not-null it needs to be an email address.
223     * in this case packet needs to be not only the body, but a
224     * complete mixmaster packet of 20480 bytes in size (20 headers + body).
225     * the chain given is prepended to the one already encrypted in
226     * the existing message. If this exceeds the allowed 20 hops in total
227     * the message is corrupted, the last node will realize this.
228     * This is useful if you want to reroute an existing mixmaster message
229     * that has foo as the next hop via a chain so that the packet will
230     * actually flow hop1,hop2,hop3,foo,....
231     * feedback ... a buffer to write feedback to
232     */
233 rabbi 1 {
234     BUFFER *pid, *out, *header, *other, *encrypted, *key, *body;
235     BUFFER *iv, *ivarray, *temp;
236     BUFFER *pubkey;
237     char addr[LINELEN];
238     int thischain[20];
239     int hop;
240     int c, i;
241     int timestamp = 0;
242     int israndom = 0;
243     int err = 1;
244    
245     body = buf_new();
246     pid = buf_new();
247     out = buf_new();
248     header = buf_new();
249     other = buf_new();
250     key = buf_new();
251     encrypted = buf_new();
252     iv = buf_new();
253     ivarray = buf_new();
254     temp = buf_new();
255    
256 weaselp 512 if (redirect_to != NULL) {
257     assert(packet->length == 20480);
258     buf_append(header, packet->data, 10240);
259     buf_append(temp, packet->data + 10240, 10240);
260     buf_clear(packet);
261     buf_cat(packet, temp);
262     } else
263     assert(packet->length == 10240);
264    
265 rabbi 1 buf_setrnd(pid, 16);
266    
267     for (c = 0; c < numcopies; c++) {
268     buf_set(body, packet);
269    
270     for (hop = 0; hop < chainlen; hop++)
271     thischain[hop] = chain[hop];
272    
273 weaselp 500 israndom = chain_rand(remailer, badchains, maxrem, thischain, chainlen, 0);
274 rabbi 1 if (israndom == -1) {
275     err = -1;
276     clienterr(feedback, "No reliable remailers!");
277     }
278     if ((numcopies > 1 || numpackets > 1) && !israndom && (chainlen != 1)) {
279     clienterr(feedback,
280     "Multi-packet message without random remailers!");
281     err = -1;
282     goto end;
283     }
284     for (hop = 0; hop < chainlen; hop++) {
285     switch (remailer[thischain[hop]].version) {
286     case 2:
287     case 3: /* not implemented yet; fall back to version 2 */
288     /* create header chart to be encrypted with the session key */
289 weaselp 512 if (numcopies > 1 && hop == 0 && redirect_to == NULL)
290 rabbi 1 buf_set(encrypted, pid); /* same ID only at final hop */
291     else
292     buf_setrnd(encrypted, 16);
293     buf_setrnd(key, 24); /* key for encrypting the body */
294     buf_cat(encrypted, key);
295     buf_setrnd(iv, 8); /* IV for encrypting the body */
296    
297 weaselp 512 if (hop > 0 || redirect_to != NULL) {
298 rabbi 1 /* IVs for header chart encryption */
299     buf_setrnd(ivarray, 18 * 8);
300     buf_cat(ivarray, iv); /* 19th IV equals the body IV */
301    
302     buf_appendc(encrypted, 0);
303     buf_cat(encrypted, ivarray);
304     memset(addr, 0, 80);
305 weaselp 512 if (hop == 0) {
306     assert(redirect_to != NULL);
307     strncpy(addr, redirect_to, 80);
308     } else {
309     assert(hop > 0);
310     strcpy(addr, remailer[thischain[hop - 1]].addr);
311     };
312 rabbi 1 buf_append(encrypted, addr, 80);
313     } else {
314     if (numpackets == 1)
315     buf_appendc(encrypted, 1);
316     else {
317     buf_appendc(encrypted, 2);
318     buf_appendc(encrypted, (byte) packetnum);
319     buf_appendc(encrypted, (byte) numpackets);
320     }
321     buf_cat(encrypted, mid);
322     buf_cat(encrypted, iv); /* body encryption IV */
323     }
324    
325     /* timestamp */
326     buf_appends(encrypted, "0000");
327     buf_appendc(encrypted, '\0'); /* timestamp magic */
328     timestamp = time(NULL) / SECONDSPERDAY - rnd_number(4);
329     buf_appendi_lo(encrypted, timestamp);
330    
331     /* message digest for this header */
332     digest_md5(encrypted, temp);
333     buf_cat(encrypted, temp);
334     buf_pad(encrypted, 328);
335    
336     /* encrypt message body */
337     buf_crypt(body, key, iv, ENCRYPT);
338    
339 weaselp 512 if (hop > 0 || redirect_to != NULL) {
340 rabbi 1 /* encrypt the other header charts */
341     buf_clear(other);
342     for (i = 0; i < 19; i++) {
343     buf_clear(iv);
344     buf_clear(temp);
345     buf_append(iv, ivarray->data + 8 * i, 8);
346     buf_append(temp, header->data + 512 * i, 512);
347     buf_crypt(temp, key, iv, ENCRYPT);
348     buf_cat(other, temp);
349     }
350     } else
351     buf_setrnd(other, 19 * 512); /* fill with random data */
352    
353     /* create session key and IV to encrypt the header ... */
354     buf_setrnd(key, 24);
355     buf_setrnd(iv, 8);
356     buf_crypt(encrypted, key, iv, ENCRYPT);
357     pubkey = buf_new();
358     err = db_getpubkey(remailer[thischain[hop]].keyid, pubkey);
359     if (err == -1)
360     goto end;
361     err = pk_encrypt(key, pubkey); /* ... and encrypt the
362     session key */
363     buf_free(pubkey);
364     if (err == -1 || key->length != 128) {
365     clienterr(feedback, "Encryption failed!");
366     err = -1;
367     goto end;
368     }
369     /* now build the new header */
370     buf_clear(header);
371     buf_append(header, remailer[thischain[hop]].keyid, 16);
372     buf_appendc(header, 128);
373     buf_cat(header, key);
374     buf_cat(header, iv);
375     buf_cat(header, encrypted);
376     buf_pad(header, 512);
377     buf_cat(header, other);
378     break;
379     default:
380     err = -1;
381     goto end;
382     }
383     }
384    
385     /* build the message */
386     buf_sets(out, remailer[thischain[chainlen - 1]].addr);
387     buf_nl(out);
388     buf_cat(out, header);
389     buf_cat(out, body);
390     assert(header->length == 10240 && body->length == 10240);
391     mix_pool(out, INTERMEDIATE, -1);
392    
393     if (feedback) {
394     for (hop = chainlen - 1; hop >= 0; hop--) {
395     buf_appends(feedback, remailer[thischain[hop]].name);
396     if (hop > 0)
397     buf_appendc(feedback, ',');
398     }
399     buf_nl(feedback);
400     }
401     }
402     end:
403     buf_free(pid);
404     buf_free(body);
405     buf_free(out);
406     buf_free(header);
407     buf_free(temp);
408     buf_free(other);
409     buf_free(key);
410     buf_free(encrypted);
411     buf_free(iv);
412     buf_free(ivarray);
413     return (err);
414     }
415    
416 weaselp 512 int redirect_message(BUFFER *sendmsg, char *chainstr, int numcopies, BUFFER *feedback)
417     {
418     BUFFER *field;
419     BUFFER *content;
420     BUFFER *line;
421     char recipient[80] = "";
422     int num = 0;
423     int err = 0;
424     int c;
425     int hop;
426    
427     REMAILER remailer[MAXREM];
428     int chain[20];
429     int thischain[20];
430     int chainlen;
431     int badchains[MAXREM][MAXREM];
432     int maxrem;
433     int tempchain[20];
434     int tempchainlen;
435     int israndom;
436    
437     field = buf_new();
438     content = buf_new();
439     line = buf_new();
440    
441     if (numcopies == 0)
442     numcopies = NUMCOPIES;
443     if (numcopies > 10)
444     numcopies = 10;
445    
446     /* Find the recipient */
447     while (buf_getheader(sendmsg, field, content) == 0)
448     if (bufieq(field, "to")) {
449     strncpy(recipient, content->data, sizeof(recipient));
450     num++;
451     };
452     if (num != 1) {
453     clienterr(feedback, "Did not find exactly one To: address!");
454     err = -1;
455     goto end;
456     };
457    
458     /* Dearmor the message */
459     err = mix_dearmor(sendmsg, sendmsg);
460     if (err == -1)
461     goto end;
462     assert (sendmsg->length == 20480);
463    
464     /* Check the chain */
465     maxrem = mix2_rlist(remailer, badchains);
466     if (maxrem < 1) {
467     clienterr(feedback, "No remailer list!");
468     err = -1;
469     goto end;
470     }
471     chainlen = chain_select(chain, chainstr, maxrem, remailer, 0, line);
472     if (chainlen < 1) {
473     if (line->length)
474     clienterr(feedback, line->data);
475     else
476     clienterr(feedback, "Invalid remailer chain!");
477     err = -1;
478     goto end;
479     } else if (chainlen >= 20) {
480     clienterr(feedback, "A chainlength of 20 will certainly destroy the message!");
481     err = -1;
482     goto end;
483     };
484    
485    
486     for (c = 0; c < numcopies; c++) {
487     /* if our recipient is a remailer we want to make sure we're not using a known broken chain.
488     * therefore we need to pick the final remailer with care */
489     for (hop = 0; hop < chainlen; hop++)
490     thischain[hop] = chain[hop];
491     if (thischain[0] == 0) {
492     /* Find out, if recipient is a remailer */
493     tempchainlen = chain_select(tempchain, recipient, maxrem, remailer, 0, line);
494     if (tempchainlen < 1 && line->length == 0) {
495     /* recipient is apparently not a remailer we know about */
496     ;
497     } else {
498     /* Build a new chain, based on the one we already selected but
499     * with the recipient as the final hop.
500     * This is so that chain_rand properly selects nodes based on
501     * broken chains and DISTANCE */
502     assert(chainlen < 20);
503     for (hop = 0; hop < chainlen; hop++)
504     thischain[hop+1] = thischain[hop];
505     thischain[0] = tempchain[0];
506    
507     israndom = chain_rand(remailer, badchains, maxrem, thischain, chainlen + 1, 0);
508     if (israndom == -1) {
509     err = -1;
510     clienterr(feedback, "No reliable remailers!");
511     goto end;
512     }
513    
514     /* Remove the added recipient hop */
515     for (hop = 0; hop < chainlen; hop++)
516     thischain[hop] = thischain[hop + 1];
517     };
518     };
519    
520     /* queue the packet */
521     if (send_packet(1, sendmsg, thischain, chainlen,
522     -1, -1, NULL,
523     remailer, badchains, maxrem, recipient, feedback) == -1)
524     err = -1;
525     };
526    
527     end:
528     buf_free(field);
529     buf_free(content);
530     buf_free(line);
531     return (err);
532     }
533    
534 rabbi 1 int mix2_encrypt(int type, BUFFER *message, char *chainstr, int numcopies,
535     BUFFER *feedback)
536     {
537     /* returns 0 on success, -1 on error. feedback contains the selected
538     remailer chain or an error message */
539    
540     REMAILER remailer[MAXREM];
541 weaselp 500 int badchains[MAXREM][MAXREM];
542 rabbi 1 int maxrem;
543     BUFFER *line, *field, *content, *header, *msgdest, *msgheader, *body,
544     *temp, *mid;
545     byte numdest = 0, numhdr = 0;
546     char hdrline[LINELEN];
547     BUFFER *packet;
548     int chain[20];
549     int chainlen;
550     int i;
551     int err = 0;
552    
553     mix_init(NULL);
554     packet = buf_new();
555     line = buf_new();
556     field = buf_new();
557     content = buf_new();
558     msgheader = buf_new();
559     msgdest = buf_new();
560     body = buf_new();
561     temp = buf_new();
562     mid = buf_new();
563     header = buf_new();
564     if (feedback)
565     buf_reset(feedback);
566    
567     if (numcopies == 0)
568     numcopies = NUMCOPIES;
569     if (numcopies > 10)
570     numcopies = 10;
571    
572 weaselp 500 maxrem = mix2_rlist(remailer, badchains);
573 rabbi 1 if (maxrem < 1) {
574     clienterr(feedback, "No remailer list!");
575     err = -1;
576     goto end;
577     }
578     chainlen = chain_select(chain, chainstr, maxrem, remailer, 0, line);
579     if (chainlen < 1) {
580     if (line->length)
581     clienterr(feedback, line->data);
582     else
583     clienterr(feedback, "Invalid remailer chain!");
584     err = -1;
585     goto end;
586     }
587 weaselp 512 if (chain[0] == 0)
588 weaselp 510 chain[0] = chain_randfinal(type, remailer, badchains, maxrem, 0, chain, chainlen);
589 rabbi 1
590     if (chain[0] == -1) {
591     clienterr(feedback, "No reliable remailers!");
592     err = -1;
593     goto end;
594     }
595     switch (remailer[chain[0]].version) {
596     case 2:
597     if (type == MSG_NULL) {
598     memset(hdrline, 0, 80);
599     strcpy(hdrline, "null:");
600     buf_append(msgdest, hdrline, 80);
601     numdest++;
602     } else
603     while (buf_getheader(message, field, content) == 0) {
604     if (bufieq(field, "to")) {
605     memset(hdrline, 0, 80);
606     strncpy(hdrline, content->data, 80);
607     buf_append(msgdest, hdrline, 80);
608     numdest++;
609     } else if (type == MSG_POST && bufieq(field, "newsgroups")) {
610     memset(hdrline, 0, 80);
611     strcpy(hdrline, "post: ");
612     strcatn(hdrline, content->data, 80);
613     buf_append(msgdest, hdrline, 80);
614     numdest++;
615     } else {
616     buf_clear(header);
617     buf_appendheader(header, field, content);
618     hdr_encode(header, 80);
619     while (buf_getline(header, line) == 0) {
620     /* paste in encoded header entry */
621     memset(hdrline, 0, 80);
622     strncpy(hdrline, line->data, 80);
623     buf_append(msgheader, hdrline, 80);
624     numhdr++;
625     }
626     }
627     }
628     buf_appendc(body, numdest);
629     buf_cat(body, msgdest);
630     buf_appendc(body, numhdr);
631     buf_cat(body, msgheader);
632    
633     if (type != MSG_NULL) {
634     buf_rest(temp, message);
635     if (temp->length > 10236 && remailer[chain[0]].flags.compress)
636     buf_compress(temp);
637     buf_cat(body, temp);
638     buf_reset(temp);
639     }
640     buf_setrnd(mid, 16); /* message ID */
641     for (i = 0; i <= body->length / 10236; i++) {
642     long length;
643    
644     length = body->length - i * 10236;
645     if (length > 10236)
646     length = 10236;
647     buf_clear(packet);
648     buf_appendl_lo(packet, length);
649     buf_append(packet, body->data + i * 10236, length);
650     buf_pad(packet, 10240);
651     if (send_packet(numcopies, packet, chain, chainlen,
652     i + 1, body->length / 10236 + 1,
653 weaselp 512 mid, remailer, badchains, maxrem, NULL, feedback) == -1)
654 rabbi 1 err = -1;
655     }
656     break;
657     case 3:
658     NOT_IMPLEMENTED;
659     break;
660     default:
661 weaselp 500 fprintf(stderr, "%d\n", chain[0]);
662 rabbi 1 clienterr(feedback, "Unknown remailer version!");
663     err = -1;
664     }
665    
666     end:
667     buf_free(packet);
668     buf_free(line);
669     buf_free(field);
670     buf_free(content);
671     buf_free(header);
672     buf_free(msgheader);
673     buf_free(msgdest);
674     buf_free(body);
675     buf_free(temp);
676     buf_free(mid);
677     return (err);
678     }
679    
680 rabbi 262 #else /* end of USE_RSA */
681 rabbi 1
682     int mix2_rlist(REMAILER remailer[])
683     {
684     return (0);
685     }
686    
687     int mix2_encrypt(int type, BUFFER *message, char *chainstr, int numcopies,
688     BUFFER *feedback)
689     {
690     return (-1);
691     }
692 rabbi 262 #endif /* else not USE_RSA */

  ViewVC Help
Powered by ViewVC 1.1.5