Add an internal-representation no-op function.
[u/mdw/catacomb] / ecb.h
1 /* -*-c-*-
2 *
3 * $Id: ecb.h,v 1.2 1999/12/10 23:16:40 mdw Exp $
4 *
5 * Electronic code book for block ciphers
6 *
7 * (c) 1999 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: ecb.h,v $
33 * Revision 1.2 1999/12/10 23:16:40 mdw
34 * Split mode macros into interface and implementation.
35 *
36 * Revision 1.1 1999/09/03 08:41:12 mdw
37 * Initial import.
38 *
39 */
40
41 #ifndef CATACOMB_ECB_H
42 #define CATACOMB_ECB_H
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /*----- Header files ------------------------------------------------------*/
49
50 #include <stddef.h>
51
52 #ifndef CATACOMB_GCIPHER_H
53 # include "gcipher.h"
54 #endif
55
56 /*----- Macros ------------------------------------------------------------*/
57
58 /* --- @ECB_DECL@ --- *
59 *
60 * Arguments: @PRE@, @pre@ = prefixes for the underlying block cipher
61 *
62 * Use: Creates declarations for ECB stealing mode.
63 */
64
65 #define ECB_DECL(PRE, pre) \
66 \
67 /* --- Electronic codebook context --- */ \
68 \
69 typedef struct pre##_ecbctx { \
70 pre##_ctx ctx; /* Underlying cipher context */ \
71 } pre##_ecbctx; \
72 \
73 /* --- @pre_ecbsetkey@ --- * \
74 * \
75 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
76 * @const pre_ctx *k@ = pointer to cipher context \
77 * \
78 * Returns: --- \
79 * \
80 * Use: Sets the ECB context to use a different cipher key. \
81 */ \
82 \
83 extern void pre##_ecbsetkey(pre##_ecbctx */*ctx*/, \
84 const pre##_ctx */*k*/); \
85 \
86 /* --- @pre_ecbinit@ --- * \
87 * \
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 \
92 * \
93 * Returns: --- \
94 * \
95 * Use: Initializes an ECB context ready for use. This is \
96 * equivalent to calls to @pre_init@ and @pre_setkey@. \
97 */ \
98 \
99 extern void pre##_ecbinit(pre##_ecbctx */*ctx*/, \
100 const void */*key*/, size_t /*sz*/, \
101 const void */*iv*/); \
102 \
103 /* --- @pre_ecbencrypt@ --- * \
104 * \
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 \
109 * \
110 * Returns: --- \
111 * \
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. \
116 */ \
117 \
118 extern void pre##_ecbencrypt(pre##_ecbctx */*ctx*/, \
119 const void */*src*/, void */*dest*/, \
120 size_t /*sz*/); \
121 \
122 /* --- @pre_ecbdecrypt@ --- * \
123 * \
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 \
128 * \
129 * Returns: --- \
130 * \
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. \
135 */ \
136 \
137 extern void pre##_ecbdecrypt(pre##_ecbctx */*ctx*/, \
138 const void */*src*/, void */*dest*/, \
139 size_t /*sz*/); \
140 \
141 /* --- Generic cipher interface --- */ \
142 \
143 extern const gccipher pre##_ecb;
144
145 /*----- That's all, folks -------------------------------------------------*/
146
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif