|
|
@ -1,4 +1,4 @@ |
|
|
|
/* $OpenBSD: blowfish.c,v 1.3 1997/02/16 20:58:17 provos Exp $ */ |
|
|
|
/* $OpenBSD: blowfish.c,v 1.4 1997/04/30 05:57:05 tholo Exp $ */ |
|
|
|
/* |
|
|
|
* Blowfish block cipher for OpenBSD |
|
|
|
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> |
|
|
@ -441,11 +441,16 @@ Blowfish_initstate(c) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#if __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; |
|
|
@ -464,11 +469,16 @@ 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; |
|
|
@ -506,6 +516,11 @@ 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; |
|
|
@ -513,6 +528,7 @@ Blowfish_expandstate(c, data, databytes, key, keybytes) |
|
|
|
u_int16_t databytes; |
|
|
|
const u_int8_t *key; |
|
|
|
u_int16_t keybytes; |
|
|
|
#endif |
|
|
|
{ |
|
|
|
u_int16_t i; |
|
|
|
u_int16_t j; |
|
|
@ -553,11 +569,16 @@ 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 |
|
|
|
{ |
|
|
|
/* Initalize S-boxes and subkeys with Pi */ |
|
|
|
Blowfish_initstate(c); |
|
|
@ -566,11 +587,16 @@ 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; |
|
|
@ -581,11 +607,17 @@ blf_enc(c, data, blocks) |
|
|
|
d += 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#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; |
|
|
|