3 * Electronic code book for block ciphers
5 * (c) 1999 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef CATACOMB_ECB_H
29 #define CATACOMB_ECB_H
35 /*----- Header files ------------------------------------------------------*/
39 #ifndef CATACOMB_GCIPHER_H
43 /*----- Macros ------------------------------------------------------------*/
45 /* --- @ECB_DECL@ --- *
47 * Arguments: @PRE@, @pre@ = prefixes for the underlying block cipher
49 * Use: Creates declarations for ECB stealing mode.
52 #define ECB_DECL(PRE, pre) \
54 /* --- Electronic codebook context --- */ \
56 typedef struct pre##_ecbctx { \
57 pre##_ctx ctx; /* Underlying cipher context */ \
60 /* --- @pre_ecbsetkey@ --- * \
62 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
63 * @const pre_ctx *k@ = pointer to cipher context \
67 * Use: Sets the ECB context to use a different cipher key. \
70 extern void pre##_ecbsetkey(pre##_ecbctx */*ctx*/, \
71 const pre##_ctx */*k*/); \
73 /* --- @pre_ecbinit@ --- * \
75 * Arguments: @pre_ecbctx *ctx@ = pointer to cipher context \
76 * @const void *key@ = pointer to the key buffer \
77 * @size_t sz@ = size of the key \
78 * @const void *iv@ = pointer to initialization vector \
82 * Use: Initializes an ECB context ready for use. This is \
83 * equivalent to calls to @pre_init@ and @pre_setkey@. \
86 extern void pre##_ecbinit(pre##_ecbctx */*ctx*/, \
87 const void */*key*/, size_t /*sz*/, \
88 const void */*iv*/); \
90 /* --- @pre_ecbencrypt@ --- * \
92 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
93 * @const void *src@ = pointer to source data \
94 * @void *dest@ = pointer to destination data \
95 * @size_t sz@ = size of block to be encrypted \
99 * Use: Encrypts a block with a block cipher in ECB mode, with \
100 * ciphertext stealing and other clever tricks. \
101 * Essentially, data can be encrypted in arbitrary sized \
102 * chunks, although decryption must use the same chunks. \
105 extern void pre##_ecbencrypt(pre##_ecbctx */*ctx*/, \
106 const void */*src*/, void */*dest*/, \
109 /* --- @pre_ecbdecrypt@ --- * \
111 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
112 * @const void *src@ = pointer to source data \
113 * @void *dest@ = pointer to destination data \
114 * @size_t sz@ = size of block to be encrypted \
118 * Use: Decrypts a block with a block cipher in ECB mode, with \
119 * ciphertext stealing and other clever tricks. \
120 * Essentially, data can be encrypted in arbitrary sized \
121 * chunks, although decryption must use the same chunks. \
124 extern void pre##_ecbdecrypt(pre##_ecbctx */*ctx*/, \
125 const void */*src*/, void */*dest*/, \
128 /* --- Generic cipher interface --- */ \
130 extern const gccipher pre##_ecb;
132 /*----- That's all, folks -------------------------------------------------*/