-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
2,873 additions
and
2,193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
/* | ||
* $Id: $ | ||
*/ | ||
#include "cookie.h" | ||
#include "str.h" | ||
#include "uint32.h" | ||
#include "surfpcs.h" | ||
|
||
void cookie(hash,key,keylen,date,addr,action) | ||
char *hash; | ||
char *key; | ||
unsigned int keylen; | ||
char *date; | ||
char *addr; | ||
char *action; | ||
void | ||
cookie(char *hash, char *key, size_t keylen, char *date, char *addr, char *action) | ||
{ | ||
surfpcs s; | ||
uint32 seed[32]; | ||
unsigned char out[32]; | ||
int i; | ||
int j; | ||
surfpcs s; | ||
uint32 seed[32]; | ||
unsigned char out[32]; | ||
int i; | ||
int j; | ||
|
||
/* | ||
step 1: create seed from key. note that this doesn't have to be | ||
cryptographic; it simply has to avoid destroying the user's entropy. | ||
if speed turns out to be a problem, switch to a CRC. | ||
*/ | ||
for (i = 0;i < 32;++i) seed[i] = 0; | ||
for (j = 0;j < 4;++j) { | ||
surfpcs_init(&s,seed); | ||
surfpcs_add(&s,key,keylen); | ||
surfpcs_out(&s,out); | ||
for (i = 0;i < 32;++i) seed[i] = (seed[i] << 8) + out[i]; | ||
} | ||
/* | ||
* step 1: create seed from key. note that this doesn't have to be | ||
* cryptographic; it simply has to avoid destroying the user's entropy. | ||
* if speed turns out to be a problem, switch to a CRC. | ||
*/ | ||
for (i = 0; i < 32; ++i) | ||
seed[i] = 0; | ||
for (j = 0; j < 4; ++j) { | ||
surfpcs_init(&s, seed); | ||
surfpcs_add(&s, key, keylen); | ||
surfpcs_out(&s, out); | ||
for (i = 0; i < 32; ++i) | ||
seed[i] = (seed[i] << 8) + out[i]; | ||
} | ||
|
||
/* | ||
step 2: apply SURF. | ||
*/ | ||
surfpcs_init(&s,seed); | ||
surfpcs_add(&s,date,str_len(date) + 1); | ||
surfpcs_add(&s,addr,str_len(addr) + 1); | ||
surfpcs_add(&s,action,1); | ||
surfpcs_out(&s,out); | ||
/*- step 2: apply SURF. */ | ||
surfpcs_init(&s, seed); | ||
surfpcs_add(&s, date, str_len(date) + 1); | ||
surfpcs_add(&s, addr, str_len(addr) + 1); | ||
surfpcs_add(&s, action, 1); | ||
surfpcs_out(&s, out); | ||
|
||
/* | ||
step 3: extract a readable cookie from the SURF output. | ||
*/ | ||
for (i = 0;i < 20;++i) | ||
hash[i] = 'a' + (out[i] & 15); | ||
/*- step 3: extract a readable cookie from the SURF output. */ | ||
for (i = 0; i < 20; ++i) | ||
hash[i] = 'a' + (out[i] & 15); | ||
} | ||
|
||
/* | ||
* $Log: $ | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#ifndef COOKIE_H | ||
#define COOKIE_H | ||
#include <sys/types.h> | ||
|
||
#define COOKIE 20 | ||
|
||
extern void cookie(); | ||
extern void cookie(char *, char *, size_t, char *, char *, char *); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.