blowfish.h revision 302408
1169691Skan/* $FreeBSD: stable/11/sys/crypto/blowfish/blowfish.h 121072 2003-10-13 19:26:08Z ume $ */ 2169691Skan/* $KAME: blowfish.h,v 1.12 2002/02/27 01:33:59 itojun Exp $ */ 3169691Skan 4169691Skan/* crypto/bf/blowfish.h */ 5169691Skan/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) 6169691Skan * All rights reserved. 7169691Skan * 8169691Skan * This package is an SSL implementation written 9169691Skan * by Eric Young (eay@mincom.oz.au). 10169691Skan * The implementation was written so as to conform with Netscapes SSL. 11169691Skan * 12169691Skan * This library is free for commercial and non-commercial use as long as 13169691Skan * the following conditions are aheared to. The following conditions 14169691Skan * apply to all code found in this distribution, be it the RC4, RSA, 15169691Skan * lhash, DES, etc., code; not just the SSL code. The SSL documentation 16169691Skan * included with this distribution is covered by the same copyright terms 17169691Skan * except that the holder is Tim Hudson (tjh@mincom.oz.au). 18169691Skan * 19169691Skan * Copyright remains Eric Young's, and as such any Copyright notices in 20169691Skan * the code are not to be removed. 21169691Skan * If this package is used in a product, Eric Young should be given attribution 22169691Skan * as the author of the parts of the library used. 23169691Skan * This can be in the form of a textual message at program startup or 24169691Skan * in documentation (online or textual) provided with the package. 25169691Skan * 26169691Skan * Redistribution and use in source and binary forms, with or without 27169691Skan * modification, are permitted provided that the following conditions 28169691Skan * are met: 29169691Skan * 1. Redistributions of source code must retain the copyright 30169691Skan * notice, this list of conditions and the following disclaimer. 31169691Skan * 2. Redistributions in binary form must reproduce the above copyright 32169691Skan * notice, this list of conditions and the following disclaimer in the 33169691Skan * documentation and/or other materials provided with the distribution. 34169691Skan * 3. All advertising materials mentioning features or use of this software 35169691Skan * must display the following acknowledgement: 36169691Skan * "This product includes cryptographic software written by 37169691Skan * Eric Young (eay@mincom.oz.au)" 38169691Skan * The word 'cryptographic' can be left out if the rouines from the library 39169691Skan * being used are not cryptographic related :-). 40169691Skan * 4. If you include any Windows specific code (or a derivative thereof) from 41169691Skan * the apps directory (application code) you must include an acknowledgement: 42169691Skan * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" 43169691Skan * 44169691Skan * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 45169691Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 46169691Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 47169691Skan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 48169691Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 49169691Skan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 50169691Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51169691Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52169691Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 53169691Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 54169691Skan * SUCH DAMAGE. 55169691Skan * 56169691Skan * The licence and distribution terms for any publically available version or 57169691Skan * derivative of this code cannot be changed. i.e. this code cannot simply be 58169691Skan * copied and put under another distribution licence 59169691Skan * [including the GNU Public Licence.] 60169691Skan */ 61169691Skan 62169691Skan#ifndef HEADER_BLOWFISH_H 63169691Skan#define HEADER_BLOWFISH_H 64169691Skan 65169691Skan#ifdef __cplusplus 66extern "C" { 67#endif 68 69#define BF_ENCRYPT 1 70#define BF_DECRYPT 0 71 72/* must be 32bit quantity */ 73#define BF_LONG u_int32_t 74 75#define BF_ROUNDS 16 76#define BF_BLOCK 8 77 78typedef struct bf_key_st { 79 BF_LONG P[BF_ROUNDS+2]; 80 BF_LONG S[4*256]; 81} BF_KEY; 82 83void BF_set_key(BF_KEY *, int, unsigned char *); 84void BF_encrypt(BF_LONG *, BF_KEY *); 85void BF_decrypt(BF_LONG *, BF_KEY *); 86void BF_ecb_encrypt(const unsigned char *, unsigned char *, 87 BF_KEY *, int); 88 89#ifdef __cplusplus 90} 91#endif 92 93#endif 94