ezmlmx
0.68
ezmlmx
Loading...
Searching...
No Matches
ezmlmx-0.68
src
cookie.c
Go to the documentation of this file.
1
#include "
cookie.h
"
2
#include "str.h"
3
#include "uint_t.h"
4
#include "
surfpcs.h
"
5
6
#define WHO cookie
7
13
14
void
cookie
(
char
*hash,
15
const
char
*key,
16
unsigned
int
keylen,
17
const
char
*date,
18
const
char
*
addr
,
19
const
char
*
action
)
20
{
21
surfpcs
s;
22
uint32
seed
[32];
23
unsigned
char
out[32];
24
int
i;
25
int
j;
26
27
/* addr may be passed in as a NULL pointer.
28
* Make sure it points to a non-NULL empty string. */
29
if
(
addr
== 0)
addr
=
""
;
30
31
/*
32
step 1: create seed from key. note that this doesn't have to be
33
cryptographic; it simply has to avoid destroying the user's entropy.
34
if speed turns out to be a problem, switch to a CRC.
35
*/
36
for
(i = 0; i < 32; ++i)
seed
[i] = 0;
37
for
(j = 0; j < 4; ++j) {
38
surfpcs_init
(&s,
seed
);
39
surfpcs_add
(&s,key,keylen);
40
surfpcs_out
(&s,out);
41
for
(i = 0;i < 32;++i)
seed
[i] = (
seed
[i] << 8) + out[i];
42
}
43
44
/*
45
step 2: apply SURF.
46
*/
47
surfpcs_init
(&s,
seed
);
48
surfpcs_add
(&s,date,str_len(date) + 1);
49
surfpcs_add
(&s,
addr
,str_len(
addr
) + 1);
50
surfpcs_add
(&s,
action
,1);
51
surfpcs_out
(&s,out);
52
53
/*
54
step 3: extract a readable cookie from the SURF output.
55
*/
56
for
(i = 0; i < 20; ++i)
57
hash[i] =
'a'
+ (out[i] & 15);
58
}
cookie.h
surfpcs.h
surfpcs_add
void surfpcs_add(surfpcs *s, const unsigned char *x, unsigned int n)
Definition
surfpcs.c:26
surfpcs_init
void surfpcs_init(surfpcs *s, const uint32 k[32])
Definition
surfpcs.c:8
surfpcs_out
void surfpcs_out(surfpcs *s, unsigned char h[32])
Definition
surfpcs.c:44
seed
stralloc seed
Definition
ezmlm-get.c:74
cookie
void cookie(char *hash, const char *key, unsigned int keylen, const char *date, const char *addr, const char *action)
Definition
cookie.c:14
addr
stralloc addr
Definition
ezmlm-cron.c:45
action
stralloc action
Definition
ezmlm-store.c:84
surfpcs
Definition
surfpcs.h:6
Generated on
for ezmlmx by
1.14.0