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

Diff of /trunk/Mix/Src/rem2.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 595 by weaselp, Thu Sep 25 22:53:43 2003 UTC revision 596 by weaselp, Mon Oct 13 11:29:48 2003 UTC
# Line 6  Line 6 
6     details.     details.
7    
8     Process Mixmaster remailer messages     Process Mixmaster remailer messages
9     $Id: rem2.c,v 1.7 2003/09/25 22:53:43 weaselp Exp $ */     $Id: rem2.c,v 1.8 2003/10/13 11:29:48 weaselp Exp $ */
10    
11    
12  #include "mix3.h"  #include "mix3.h"
# Line 79  end: Line 79  end:
79  }  }
80    
81  static int isnewid(BUFFER *id, long timestamp)  static int isnewid(BUFFER *id, long timestamp)
82    /* return values:
83     *   0: ignore message, no error
84     *   1: ok, process message
85     *  -1: bad message, send reply
86     */
87  {  {
88    FILE *f;    FILE *f;
89    int ret = 1;    int ret = 1;
# Line 135  static int isnewid(BUFFER *id, long time Line 140  static int isnewid(BUFFER *id, long time
140        goto end;        goto end;
141      }      }
142    }    }
143      if (timestamp > now) {
144        errlog(LOG, "Ingoring message with future timestamp.\n");
145        ret = -1;
146        goto end;
147      }
148    if (ftell(f)%sizeof(idlog_t)) fseek(f,0-(ftell(f)%sizeof(idlog_t)),SEEK_CUR); /* make sure that we're on sizeof(idlog_t) byte boundary */    if (ftell(f)%sizeof(idlog_t)) fseek(f,0-(ftell(f)%sizeof(idlog_t)),SEEK_CUR); /* make sure that we're on sizeof(idlog_t) byte boundary */
149    memcpy(idbuf.id,id->data,sizeof(idbuf.id));    memcpy(idbuf.id,id->data,sizeof(idbuf.id));
150    idbuf.time = now;    idbuf.time = now;
# Line 147  end: Line 157  end:
157  }  }
158    
159  int mix2_decrypt(BUFFER *m)  int mix2_decrypt(BUFFER *m)
160       /* 0: ok  -1: error  -2: old message */       /*  0: ok
161          * -1: error
162          * -2: old message */
163  {  {
164    int err = 0;    int err = 0;
165    int i;    int i;
# Line 216  int mix2_decrypt(BUFFER *m) Line 228  int mix2_decrypt(BUFFER *m)
228        dec->data[dec->ptr + 4] == '\0') {        dec->data[dec->ptr + 4] == '\0') {
229      dec->ptr += 5;      dec->ptr += 5;
230      timestamp = buf_geti_lo(dec);      timestamp = buf_geti_lo(dec);
231      } else {
232        errlog(LOG, "Ignoring message without timestamp.\n");
233        err = -1;
234        goto end;
235    }    }
236    buf_get(dec, digest, 16);    buf_get(dec, digest, 16);
237    
# Line 227  int mix2_decrypt(BUFFER *m) Line 243  int mix2_decrypt(BUFFER *m)
243      err = -1;      err = -1;
244      goto end;      goto end;
245    }    }
246    if (!isnewid(packetid, timestamp * SECONDSPERDAY)) {    switch (isnewid(packetid, timestamp * SECONDSPERDAY)) {
247      err = -2;      case  0: err = -2; /* redundant message */
248      goto end;               goto end;
249        case -1: err = -1; /* future timestamp */
250                 goto end;
251    }    }
252    buf_append(body, m->data + 20 * 512, 10240);    buf_append(body, m->data + 20 * 512, 10240);
253    

Legend:
Removed from v.595  
changed lines
  Added in v.596

  ViewVC Help
Powered by ViewVC 1.1.5