3 * $Id: ecb.h,v 1.3 2004/04/08 01:36:15 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 #ifndef CATACOMB_ECB_H
31 #define CATACOMB_ECB_H
37 /*----- Header files ------------------------------------------------------*/
41 #ifndef CATACOMB_GCIPHER_H
45 /*----- Macros ------------------------------------------------------------*/
47 /* --- @ECB_DECL@ --- *
49 * Arguments: @PRE@, @pre@ = prefixes for the underlying block cipher
51 * Use: Creates declarations for ECB stealing mode.
54 #define ECB_DECL(PRE, pre) \
56 /* --- Electronic codebook context --- */ \
58 typedef struct pre##_ecbctx { \
59 pre##_ctx ctx; /* Underlying cipher context */ \
62 /* --- @pre_ecbsetkey@ --- * \
64 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
65 * @const pre_ctx *k@ = pointer to cipher context \
69 * Use: Sets the ECB context to use a different cipher key. \
72 extern void pre##_ecbsetkey(pre##_ecbctx */*ctx*/, \
73 const pre##_ctx */*k*/); \
75 /* --- @pre_ecbinit@ --- * \
77 * Arguments: @pre_ecbctx *ctx@ = pointer to cipher context \
78 * @const void *key@ = pointer to the key buffer \
79 * @size_t sz@ = size of the key \
80 * @const void *iv@ = pointer to initialization vector \
84 * Use: Initializes an ECB context ready for use. This is \
85 * equivalent to calls to @pre_init@ and @pre_setkey@. \
88 extern void pre##_ecbinit(pre##_ecbctx */*ctx*/, \
89 const void */*key*/, size_t /*sz*/, \
90 const void */*iv*/); \
92 /* --- @pre_ecbencrypt@ --- * \
94 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
95 * @const void *src@ = pointer to source data \
96 * @void *dest@ = pointer to destination data \
97 * @size_t sz@ = size of block to be encrypted \
101 * Use: Encrypts a block with a block cipher in ECB mode, with \
102 * ciphertext stealing and other clever tricks. \
103 * Essentially, data can be encrypted in arbitrary sized \
104 * chunks, although decryption must use the same chunks. \
107 extern void pre##_ecbencrypt(pre##_ecbctx */*ctx*/, \
108 const void */*src*/, void */*dest*/, \
111 /* --- @pre_ecbdecrypt@ --- * \
113 * Arguments: @pre_ecbctx *ctx@ = pointer to ECB context block \
114 * @const void *src@ = pointer to source data \
115 * @void *dest@ = pointer to destination data \
116 * @size_t sz@ = size of block to be encrypted \
120 * Use: Decrypts a block with a block cipher in ECB mode, with \
121 * ciphertext stealing and other clever tricks. \
122 * Essentially, data can be encrypted in arbitrary sized \
123 * chunks, although decryption must use the same chunks. \
126 extern void pre##_ecbdecrypt(pre##_ecbctx */*ctx*/, \
127 const void */*src*/, void */*dest*/, \
130 /* --- Generic cipher interface --- */ \
132 extern const gccipher pre##_ecb;
134 /*----- That's all, folks -------------------------------------------------*/