|
|
@ -1,4 +1,4 @@ |
|
|
|
/* $OpenBSD: blowfish.c,v 1.15 2001/01/04 21:45:30 todd Exp $ */ |
|
|
|
/* $OpenBSD: blowfish.c,v 1.16 2002/02/19 19:39:36 millert Exp $ */ |
|
|
|
/* |
|
|
|
* Blowfish block cipher for OpenBSD |
|
|
|
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> |
|
|
@ -402,16 +402,8 @@ Blowfish_initstate(c) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef __STDC__ |
|
|
|
u_int32_t |
|
|
|
Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, u_int16_t *current) |
|
|
|
#else |
|
|
|
u_int32_t |
|
|
|
Blowfish_stream2word(data, databytes, current) |
|
|
|
const u_int8_t *data; |
|
|
|
u_int16_t databytes; |
|
|
|
u_int16_t *current; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int8_t i; |
|
|
|
u_int16_t j; |
|
|
@ -430,16 +422,8 @@ Blowfish_stream2word(data, databytes, current) |
|
|
|
return temp; |
|
|
|
} |
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes) |
|
|
|
#else |
|
|
|
void |
|
|
|
Blowfish_expand0state(c, key, keybytes) |
|
|
|
blf_ctx *c; |
|
|
|
const u_int8_t *key; |
|
|
|
u_int16_t keybytes; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int16_t i; |
|
|
|
u_int16_t j; |
|
|
@ -476,19 +460,9 @@ Blowfish_expand0state(c, key, keybytes) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes, |
|
|
|
const u_int8_t *key, u_int16_t keybytes) |
|
|
|
#else |
|
|
|
void |
|
|
|
Blowfish_expandstate(c, data, databytes, key, keybytes) |
|
|
|
blf_ctx *c; |
|
|
|
const u_int8_t *data; |
|
|
|
u_int16_t databytes; |
|
|
|
const u_int8_t *key; |
|
|
|
u_int16_t keybytes; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int16_t i; |
|
|
|
u_int16_t j; |
|
|
@ -529,16 +503,8 @@ Blowfish_expandstate(c, data, databytes, key, keybytes) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len) |
|
|
|
#else |
|
|
|
void |
|
|
|
blf_key(c, k, len) |
|
|
|
blf_ctx *c; |
|
|
|
const u_int8_t *k; |
|
|
|
u_int16_t len; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
/* Initialize S-boxes and subkeys with Pi */ |
|
|
|
Blowfish_initstate(c); |
|
|
@ -547,16 +513,8 @@ blf_key(c, k, len) |
|
|
|
Blowfish_expand0state(c, k, len); |
|
|
|
} |
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks) |
|
|
|
#else |
|
|
|
void |
|
|
|
blf_enc(c, data, blocks) |
|
|
|
blf_ctx *c; |
|
|
|
u_int32_t *data; |
|
|
|
u_int16_t blocks; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int32_t *d; |
|
|
|
u_int16_t i; |
|
|
@ -568,16 +526,8 @@ blf_enc(c, data, blocks) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks) |
|
|
|
#else |
|
|
|
void |
|
|
|
blf_dec(c, data, blocks) |
|
|
|
blf_ctx *c; |
|
|
|
u_int32_t *data; |
|
|
|
u_int16_t blocks; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int32_t *d; |
|
|
|
u_int16_t i; |
|
|
@ -589,16 +539,8 @@ blf_dec(c, data, blocks) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len) |
|
|
|
#else |
|
|
|
void |
|
|
|
blf_ecb_encrypt(c, data, len) |
|
|
|
blf_ctx *c; |
|
|
|
u_int8_t *data; |
|
|
|
u_int32_t len; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int32_t l, r; |
|
|
|
u_int32_t i; |
|
|
@ -619,16 +561,8 @@ blf_ecb_encrypt(c, data, len) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len) |
|
|
|
#else |
|
|
|
void |
|
|
|
blf_ecb_decrypt(c, data, len) |
|
|
|
blf_ctx *c; |
|
|
|
u_int8_t *data; |
|
|
|
u_int32_t len; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int32_t l, r; |
|
|
|
u_int32_t i; |
|
|
@ -649,17 +583,8 @@ blf_ecb_decrypt(c, data, len) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len) |
|
|
|
#else |
|
|
|
void |
|
|
|
blf_cbc_encrypt(c, iv, data, len) |
|
|
|
blf_ctx *c; |
|
|
|
u_int8_t *iv; |
|
|
|
u_int8_t *data; |
|
|
|
u_int32_t len; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int32_t l, r; |
|
|
|
u_int32_t i, j; |
|
|
@ -683,17 +608,8 @@ blf_cbc_encrypt(c, iv, data, len) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if __STDC__ |
|
|
|
void |
|
|
|
blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len) |
|
|
|
#else |
|
|
|
void |
|
|
|
blf_cbc_decrypt(c, iva, data, len) |
|
|
|
blf_ctx *c; |
|
|
|
u_int8_t *iva; |
|
|
|
u_int8_t *data; |
|
|
|
u_int32_t len; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int32_t l, r; |
|
|
|
u_int8_t *iv; |
|
|
|