/*1* Blowfish - a fast block cipher designed by Bruce Schneier2*3* Copyright 1997 Niels Provos <[email protected]>4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. All advertising materials mentioning features or use of this software15* must display the following acknowledgement:16* This product includes software developed by Niels Provos.17* 4. The name of the author may not be used to endorse or promote products18* derived from this software without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR21* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES22* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.23* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,24* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT25* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,26* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY27* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT28* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF29* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.30*/3132/*33* FreeBSD implementation by Paul Herman <[email protected]>34*/3536#ifndef _BLF_H_37#define _BLF_H_3839/* Schneier states the maximum key length to be 56 bytes.40* The way how the subkeys are initalized by the key up41* to (N+2)*4 i.e. 72 bytes are utilized.42* Warning: For normal blowfish encryption only 56 bytes43* of the key affect all cipherbits.44*/4546#define BLF_N 16 /* Number of Subkeys */4748/* Blowfish context */49typedef struct BlowfishContext {50u_int32_t S[4][256]; /* S-Boxes */51u_int32_t P[BLF_N + 2]; /* Subkeys */52} blf_ctx;5354/* Raw access to customized Blowfish55* blf_key is just:56* Blowfish_initstate( state )57* Blowfish_expand0state( state, key, keylen )58*/5960void Blowfish_initstate(blf_ctx *);61void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t);62void Blowfish_expandstate63(blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t);64u_int32_t Blowfish_stream2word(const u_int8_t *, u_int16_t, u_int16_t *);6566void blf_enc(blf_ctx *, u_int32_t *, u_int16_t);6768#endif /* _BLF_H_ */697071