diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2010-07-09 12:32:17 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2010-07-09 12:32:17 +0200 |
commit | 6c027b4de25a529908be895e7ff19236f4002a57 (patch) | |
tree | f70d3a400bbb9ba8a83e9d4ffcaa4b6e367fc8bb /blowfish.h | |
download | crypto-6c027b4de25a529908be895e7ff19236f4002a57.zip crypto-6c027b4de25a529908be895e7ff19236f4002a57.tar.gz |
initial commit, resurrect one of my realy old projects
Diffstat (limited to 'blowfish.h')
-rw-r--r-- | blowfish.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/blowfish.h b/blowfish.h new file mode 100644 index 0000000..d0f2bce --- /dev/null +++ b/blowfish.h @@ -0,0 +1,52 @@ +/* + * Cryptographic API. + * + * Blowfish Cipher Algorithm, by Bruce Schneier. + * http://www.counterpane.com/blowfish.html + * + * Adapated from Kerneli implementation. + * + * Copyright (c) Herbert Valerio Riedel <hvr@hvrlab.org> + * Copyright (c) Kyle McMartin <kyle@debian.org> + * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#ifndef _BLOWFISH_ +#define _BLOWFISH_ + +#include "uint.h" + +#define BF_BLOCK_SIZE 8 + +/* key length from 32 to 448 bits, but no checks are made */ +#define BF_MIN_KEY_SIZE 4 +#define BF_MAX_KEY_SIZE 56 + +struct blowfish_ctx { + u32 p[18]; + u32 s[1024]; +}; + +/* + * Calculates the blowfish S and P boxes for encryption and decryption. + */ +int blowfish_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags); + +void blowfish_encrypt(void *cx, u8 *dst, const u8 *src); + +void blowfish_decrypt(void *cx, u8 *dst, const u8 *src); + + +/* memcpy */ +/* +void blowfish_encrypt_fake(void *cx, u8 *dst, const u8 *src); +void blowfish_decrypt_fake(void *cx, u8 *dst, const u8 *src); +*/ + +#endif |