Use the Blowfish encryption algorithm instead of IDEA. This is partly
[become] / src / blowfish.h
CommitLineData
c4f2d992 1/* -*-c-*-
2 *
cda05cf9 3 * $Id: blowfish.h,v 1.3.2.1 1997/09/26 09:07:59 mdw Exp $
c4f2d992 4 *
5 * Blowfish encryption routines
6 *
7 * (c) 1997 Mark Wooding
8 */
9
a37d956f 10/*----- Licensing notice --------------------------------------------------*
c4f2d992 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
a37d956f 25 * along with `become'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
c4f2d992 27 */
28
29/*----- Revision history --------------------------------------------------*
30 *
31 * $Log: blowfish.h,v $
cda05cf9 32 * Revision 1.3.2.1 1997/09/26 09:07:59 mdw
33 * Use the Blowfish encryption algorithm instead of IDEA. This is partly
34 * because I prefer Blowfish (without any particularly strong evidence) but
35 * mainly because IDEA is patented and Blowfish isn't.
36 *
a37d956f 37 * Revision 1.3 1997/08/07 09:43:20 mdw
38 * Fix address of the FSF.
39 *
03f996bd 40 * Revision 1.2 1997/08/04 10:24:20 mdw
41 * Sources placed under CVS control.
42 *
43 * Revision 1.1 1997/07/21 13:47:53 mdw
c4f2d992 44 * Initial revision
45 *
46 */
47
48#ifndef BLOWFISH_H
49#define BLOWFISH_H
50
51#ifdef __cplusplus
52 extern "C" {
53#endif
54
cda05cf9 55/*----- Required headers --------------------------------------------------*/
56
57#ifndef CONFIG_H
58# include "config.h"
59#endif
60
c4f2d992 61/*----- Type definitions --------------------------------------------------*/
62
63/* --- A blowfish expanded key --- */
64
65typedef struct blowfish_key {
66 uint_32 p[18];
67 uint_32 s0[256];
68 uint_32 s1[256];
69 uint_32 s2[256];
70 uint_32 s3[256];
71} blowfish_key;
72
cda05cf9 73/* --- Size of a blowfish block --- */
74
75#define BLOWFISH_BLKSIZE (8u)
76
c4f2d992 77/*----- Functions provided ------------------------------------------------*/
78
79/* --- @blowfish_encrypt@ --- *
80 *
81 * Arguments: @const blowfish_key *k@ = pointer to key block
82 * @const voic *from@ = block to encrypt from
83 * @void *to@ = block to encrypt to
84 *
85 * Returns: ---
86 *
87 * Use: Encrypts a block using the Blowfish algorithm.
88 */
89
90extern void blowfish_encrypt(const blowfish_key */*k*/,
91 const void */*from*/, void */*to*/);
92
93
94/* --- @blowfish_decrypt@ --- *
95 *
96 * Arguments: @const blowfish_key *k@ = pointer to key block
97 * @const void *from@ = block to decrypt from
98 * @void *to@ = block to decrypt to
99 *
100 * Returns: ---
101 *
102 * Use: Decrypts a block using the Blowfish algorithm.
103 */
104
105extern void blowfish_decrypt(const blowfish_key */*k*/,
106 const void */*from*/, void */*to*/);
107
108/* --- @blowfish_setKey@ --- *
109 *
110 * Arguments: @blowfish_key *kb@ = pointer to key block to fill
111 * @void *k@ = pointer to key data
112 * @size_t sz@ = length of data in bytes
113 *
114 * Returns: ---
115 *
116 * Use: Expands a key which isn't represented as a number of whole
117 * words. This is a nonstandard extension, although it can be
118 * used to support 40-bit keys, which some governments might
119 * find more palatable than 160-bit (or 448-bit!) keys.
120 */
121
122extern void blowfish_setKey(blowfish_key */*kb*/,
123 const void */*k*/, size_t /*sz*/);
124
125/*----- That's all, folks -------------------------------------------------*/
126
127#ifdef __cplusplus
128 }
129#endif
130
131#endif