| 1 | /* -*-c-*- |
| 2 | * |
| 3 | * $Id: blowfish.h,v 1.3 1997/08/07 09:43:20 mdw Exp $ |
| 4 | * |
| 5 | * Blowfish encryption routines |
| 6 | * |
| 7 | * (c) 1997 Mark Wooding |
| 8 | */ |
| 9 | |
| 10 | /*----- Licensing notice --------------------------------------------------* |
| 11 | * |
| 12 | * This file is part of `become' |
| 13 | * |
| 14 | * `Become' is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * `Become' is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with `become'; if not, write to the Free Software Foundation, |
| 26 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 27 | */ |
| 28 | |
| 29 | /*----- Revision history --------------------------------------------------* |
| 30 | * |
| 31 | * $Log: blowfish.h,v $ |
| 32 | * Revision 1.3 1997/08/07 09:43:20 mdw |
| 33 | * Fix address of the FSF. |
| 34 | * |
| 35 | * Revision 1.2 1997/08/04 10:24:20 mdw |
| 36 | * Sources placed under CVS control. |
| 37 | * |
| 38 | * Revision 1.1 1997/07/21 13:47:53 mdw |
| 39 | * Initial revision |
| 40 | * |
| 41 | */ |
| 42 | |
| 43 | #ifndef BLOWFISH_H |
| 44 | #define BLOWFISH_H |
| 45 | |
| 46 | #ifdef __cplusplus |
| 47 | extern "C" { |
| 48 | #endif |
| 49 | |
| 50 | /*----- Type definitions --------------------------------------------------*/ |
| 51 | |
| 52 | /* --- A blowfish expanded key --- */ |
| 53 | |
| 54 | typedef struct blowfish_key { |
| 55 | uint_32 p[18]; |
| 56 | uint_32 s0[256]; |
| 57 | uint_32 s1[256]; |
| 58 | uint_32 s2[256]; |
| 59 | uint_32 s3[256]; |
| 60 | } blowfish_key; |
| 61 | |
| 62 | /*----- Functions provided ------------------------------------------------*/ |
| 63 | |
| 64 | /* --- @blowfish_encrypt@ --- * |
| 65 | * |
| 66 | * Arguments: @const blowfish_key *k@ = pointer to key block |
| 67 | * @const voic *from@ = block to encrypt from |
| 68 | * @void *to@ = block to encrypt to |
| 69 | * |
| 70 | * Returns: --- |
| 71 | * |
| 72 | * Use: Encrypts a block using the Blowfish algorithm. |
| 73 | */ |
| 74 | |
| 75 | extern void blowfish_encrypt(const blowfish_key */*k*/, |
| 76 | const void */*from*/, void */*to*/); |
| 77 | |
| 78 | |
| 79 | /* --- @blowfish_decrypt@ --- * |
| 80 | * |
| 81 | * Arguments: @const blowfish_key *k@ = pointer to key block |
| 82 | * @const void *from@ = block to decrypt from |
| 83 | * @void *to@ = block to decrypt to |
| 84 | * |
| 85 | * Returns: --- |
| 86 | * |
| 87 | * Use: Decrypts a block using the Blowfish algorithm. |
| 88 | */ |
| 89 | |
| 90 | extern void blowfish_decrypt(const blowfish_key */*k*/, |
| 91 | const void */*from*/, void */*to*/); |
| 92 | |
| 93 | /* --- @blowfish_setKey@ --- * |
| 94 | * |
| 95 | * Arguments: @blowfish_key *kb@ = pointer to key block to fill |
| 96 | * @void *k@ = pointer to key data |
| 97 | * @size_t sz@ = length of data in bytes |
| 98 | * |
| 99 | * Returns: --- |
| 100 | * |
| 101 | * Use: Expands a key which isn't represented as a number of whole |
| 102 | * words. This is a nonstandard extension, although it can be |
| 103 | * used to support 40-bit keys, which some governments might |
| 104 | * find more palatable than 160-bit (or 448-bit!) keys. |
| 105 | */ |
| 106 | |
| 107 | extern void blowfish_setKey(blowfish_key */*kb*/, |
| 108 | const void */*k*/, size_t /*sz*/); |
| 109 | |
| 110 | /*----- That's all, folks -------------------------------------------------*/ |
| 111 | |
| 112 | #ifdef __cplusplus |
| 113 | } |
| 114 | #endif |
| 115 | |
| 116 | #endif |