Add an internal-representation no-op function.
[u/mdw/catacomb] / blowfish.h
CommitLineData
d03ab969 1/* -*-c-*-
2 *
89ae755d 3 * $Id: blowfish.h,v 1.3 2000/06/17 10:48:13 mdw Exp $
d03ab969 4 *
5 * The Blowfish block cipher
6 *
7 * (c) 1998 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * Catacomb 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 Library General Public License for more details.
23 *
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: blowfish.h,v $
89ae755d 33 * Revision 1.3 2000/06/17 10:48:13 mdw
34 * Support new key size interface.
35 *
b3f05084 36 * Revision 1.2 1999/12/10 23:29:48 mdw
37 * Change header file guard names.
38 *
d03ab969 39 * Revision 1.1 1999/09/03 08:41:11 mdw
40 * Initial import.
41 *
42 */
43
44/*----- Notes on the Blowfish block cipher --------------------------------*
45 *
46 * Blowfish was invented by Bruce Schneier. The algorithm is unpatented and
47 * free for anyone to use. It's fast, simple, offers a big key, and is
48 * looking relatively bulletproof. It's also this author's block cipher of
49 * choice, for what little that's worth. The disadvantage is that Blowfish
50 * has a particularly heavyweight key schedule.
51 */
52
b3f05084 53#ifndef CATACOMB_BLOWFISH_H
54#define CATACOMB_BLOWFISH_H
d03ab969 55
56#ifdef __cplusplus
57 extern "C" {
58#endif
59
60/*----- Header files ------------------------------------------------------*/
61
62#include <stddef.h>
63
64#include <mLib/bits.h>
65
66/*----- Magical numbers ---------------------------------------------------*/
67
68#define BLOWFISH_BLKSZ 8
89ae755d 69#define BLOWFISH_KEYSZ 32
d03ab969 70#define BLOWFISH_CLASS (N, B, 64)
71
89ae755d 72extern const octet blowfish_keysz[];
73
d03ab969 74/*----- Data structures ---------------------------------------------------*/
75
76typedef struct blowfish_ctx {
77 uint32 p[18];
78 uint32 s0[256], s1[256], s2[256], s3[256];
79} blowfish_ctx;
80
81/*----- Functions provided ------------------------------------------------*/
82
83/* --- @blowfish_init@ --- *
84 *
85 * Arguments: @blowfish_ctx *k@ = pointer to key block to fill in
86 * @const void *buf@ = pointer to buffer of key material
87 * @size_t sz@ = size of key material
88 *
89 * Returns: ---
90 *
91 * Use: Initializes a Blowfish key buffer. Blowfish accepts
92 * a more-or-less arbitrary size key.
93 */
94
95extern void blowfish_init(blowfish_ctx */*k*/,
96 const void */*buf*/, size_t /*sz*/);
97
98/* --- @blowfish_eblk@, @blowfish_dblk@ --- *
99 *
100 * Arguments: @const blowfish_ctx *k@ = pointer to key block
101 * @const uint32 s[2]@ = pointer to source block
102 * @uint32 d[2]@ = pointer to destination block
103 *
104 * Returns: ---
105 *
106 * Use: Low-level block encryption and decryption.
107 */
108
109extern void blowfish_eblk(const blowfish_ctx */*k*/,
110 const uint32 */*s*/, uint32 */*d*/);
111
112extern void blowfish_dblk(const blowfish_ctx */*k*/,
113 const uint32 */*s*/, uint32 */*d*/);
114
115/*----- That's all, folks -------------------------------------------------*/
116
117#ifdef __cplusplus
118 }
119#endif
120
121#endif