3 * $Id: ecb.h,v 1.2 1999/12/10 23:16:40 mdw Exp $
5 * Electronic code book for block ciphers
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
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.
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.
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,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.2 1999/12/10 23:16:40 mdw
34 * Split mode macros into interface and implementation.
36 * Revision 1.1 1999/09/03 08:41:12 mdw
41 #ifndef CATACOMB_ECB_H
42 #define CATACOMB_ECB_H
48 /*----- Header files ------------------------------------------------------*/
52 #ifndef CATACOMB_GCIPHER_H
56 /*----- Macros ------------------------------------------------------------*/
58 /* --- @ECB_DECL@ --- *
60 * Arguments: @PRE@, @pre@ = prefixes for the underlying block cipher
62 * Use: Creates declarations for ECB stealing mode.
65 #define ECB_DECL(PRE, pre) \
67 /* --- Electronic codebook context --- */ \
69 typedef struct pre##_ecbctx { \
70 pre##_ctx ctx; /* Underlying cipher context */ \
73 /* --- @pre_ecbsetkey@ --- * \
75 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
76 * @const pre_ctx *k@ = pointer to cipher context \
80 * Use: Sets the ECB context to use a different cipher key. \
83 extern void pre##_ecbsetkey(pre##_ecbctx */*ctx*/, \
84 const pre##_ctx */*k*/); \
86 /* --- @pre_ecbinit@ --- * \
88 * Arguments: @pre_ecbctx *ctx@ = pointer to cipher context \
89 * @const void *key@ = pointer to the key buffer \
90 * @size_t sz@ = size of the key \
91 * @const void *iv@ = pointer to initialization vector \
95 * Use: Initializes an ECB context ready for use. This is \
96 * equivalent to calls to @pre_init@ and @pre_setkey@. \
99 extern void pre##_ecbinit(pre##_ecbctx */*ctx*/, \
100 const void */*key*/, size_t /*sz*/, \
101 const void */*iv*/); \
103 /* --- @pre_ecbencrypt@ --- * \
105 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
106 * @const void *src@ = pointer to source data \
107 * @void *dest@ = pointer to destination data \
108 * @size_t sz@ = size of block to be encrypted \
112 * Use: Encrypts a block with a block cipher in ECB mode, with \
113 * ciphertext stealing and other clever tricks. \
114 * Essentially, data can be encrypted in arbitrary sized \
115 * chunks, although decryption must use the same chunks. \
118 extern void pre##_ecbencrypt(pre##_ecbctx */*ctx*/, \
119 const void */*src*/, void */*dest*/, \
122 /* --- @pre_ecbdecrypt@ --- * \
124 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
125 * @const void *src@ = pointer to source data \
126 * @void *dest@ = pointer to destination data \
127 * @size_t sz@ = size of block to be encrypted \
131 * Use: Decrypts a block with a block cipher in ECB mode, with \
132 * ciphertext stealing and other clever tricks. \
133 * Essentially, data can be encrypted in arbitrary sized \
134 * chunks, although decryption must use the same chunks. \
137 extern void pre##_ecbdecrypt(pre##_ecbctx */*ctx*/, \
138 const void */*src*/, void */*dest*/, \
141 /* --- Generic cipher interface --- */ \
143 extern const gccipher pre##_ecb;
145 /*----- That's all, folks -------------------------------------------------*/