| 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" |
| 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; |
| 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; |
| 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; |
| 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 |
|
|
| 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 |
|
|