Add an internal-representation no-op function.
[u/mdw/catacomb] / ecb.h
CommitLineData
d03ab969 1/* -*-c-*-
2 *
79ba130c 3 * $Id: ecb.h,v 1.2 1999/12/10 23:16:40 mdw Exp $
d03ab969 4 *
79ba130c 5 * Electronic code book for block ciphers
d03ab969 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 $
79ba130c 33 * Revision 1.2 1999/12/10 23:16:40 mdw
34 * Split mode macros into interface and implementation.
35 *
d03ab969 36 * Revision 1.1 1999/09/03 08:41:12 mdw
37 * Initial import.
38 *
39 */
40
79ba130c 41#ifndef CATACOMB_ECB_H
42#define CATACOMB_ECB_H
d03ab969 43
44#ifdef __cplusplus
45 extern "C" {
46#endif
47
48/*----- Header files ------------------------------------------------------*/
49
79ba130c 50#include <stddef.h>
d03ab969 51
79ba130c 52#ifndef CATACOMB_GCIPHER_H
53# include "gcipher.h"
d03ab969 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 \
79ba130c 67/* --- Electronic codebook context --- */ \
d03ab969 68 \
79ba130c 69typedef struct pre##_ecbctx { \
70 pre##_ctx ctx; /* Underlying cipher context */ \
71} pre##_ecbctx; \
d03ab969 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 \
79ba130c 83extern void pre##_ecbsetkey(pre##_ecbctx */*ctx*/, \
84 const pre##_ctx */*k*/); \
d03ab969 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 \
79ba130c 99extern void pre##_ecbinit(pre##_ecbctx */*ctx*/, \
100 const void */*key*/, size_t /*sz*/, \
101 const void */*iv*/); \
d03ab969 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 \
79ba130c 118extern void pre##_ecbencrypt(pre##_ecbctx */*ctx*/, \
119 const void */*src*/, void */*dest*/, \
120 size_t /*sz*/); \
d03ab969 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 * \
79ba130c 131 * Use: Decrypts a block with a block cipher in ECB mode, with \
d03ab969 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 \
79ba130c 137extern void pre##_ecbdecrypt(pre##_ecbctx */*ctx*/, \
138 const void */*src*/, void */*dest*/, \
139 size_t /*sz*/); \
d03ab969 140 \
79ba130c 141/* --- Generic cipher interface --- */ \
d03ab969 142 \
79ba130c 143extern const gccipher pre##_ecb;
d03ab969 144
145/*----- That's all, folks -------------------------------------------------*/
146
147#ifdef __cplusplus
148 }
149#endif
150
151#endif