/* -*-c-*-
*
- * $Id: blkc.h,v 1.1 1999/09/03 08:41:11 mdw Exp $
+ * $Id: blkc.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Common definitions for block ciphers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: blkc.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:11 mdw
* Initial import.
*
*/
-#ifndef BLKC_H
-#define BLKC_H
+#ifndef CATACOMB_BLKC_H
+#define CATACOMB_BLKC_H
#ifdef __cplusplus
extern "C" {
#define BLKC_FIRST(x, y, z) x
#define BLKC_SECOND(x, y, z) y
#define BLKC_THIRD(x, y, z) z
-#define BLKC_TYPE(PRE) BLKC_APPLY(BLKC_FIRST, PRE ## _CLASS)
-#define BLKC_ENDIAN(PRE) BLKC_APPLY(BLKC_SECOND, PRE ## _CLASS)
-#define BLKC_BITS(PRE) BLKC_APPLY(BLKC_THIRD, PRE ## _CLASS)
+#define BLKC_TYPE(PRE) BLKC_APPLY(BLKC_FIRST, PRE##_CLASS)
+#define BLKC_ENDIAN(PRE) BLKC_APPLY(BLKC_SECOND, PRE##_CLASS)
+#define BLKC_BITS(PRE) BLKC_APPLY(BLKC_THIRD, PRE##_CLASS)
#define BLKC_STORE_E(PRE) BLKC_GLUE(STORE32_, BLKC_ENDIAN(PRE))
#define BLKC_LOAD_E(PRE) BLKC_GLUE(LOAD32_, BLKC_ENDIAN(PRE))
#define BLKC_SKEL_X(PRE, decl, guts) \
BLKC_SKEL(PRE, int _i; decl, \
- for (_i = 0; _i < PRE ## _BLKSZ / 4; _i++) { \
+ for (_i = 0; _i < PRE##_BLKSZ / 4; _i++) { \
guts \
})
\
static int verify(dstr *v) \
{ \
- pre ## _ctx k; \
- uint32 p[PRE ## _BLKSZ / 4]; \
- uint32 c[PRE ## _BLKSZ / 4]; \
- uint32 d[PRE ## _BLKSZ / 4]; \
+ pre##_ctx k; \
+ uint32 p[PRE##_BLKSZ / 4]; \
+ uint32 c[PRE##_BLKSZ / 4]; \
+ uint32 d[PRE##_BLKSZ / 4]; \
dstr b = DSTR_INIT; \
int ok = 1; \
\
/* --- Initialize the key buffer --- */ \
\
- dstr_ensure(&b, PRE ## _BLKSZ); \
- b.len = PRE ## _BLKSZ; \
- pre ## _init(&k, v[0].buf, v[0].len); \
+ dstr_ensure(&b, PRE##_BLKSZ); \
+ b.len = PRE##_BLKSZ; \
+ pre##_init(&k, v[0].buf, v[0].len); \
BLKC_LOAD(PRE, p, v[1].buf); \
BLKC_LOAD(PRE, c, v[2].buf); \
\
/* --- Test encryption --- */ \
\
BLKC_MOVE(PRE, d, p); \
- pre ## _eblk(&k, d, d); \
+ pre##_eblk(&k, d, d); \
BLKC_STORE(PRE, b.buf, d); \
- if (memcmp(b.buf, v[2].buf, PRE ## _BLKSZ)) { \
+ if (memcmp(b.buf, v[2].buf, PRE##_BLKSZ)) { \
ok = 0; \
printf("\nfail encryption:" \
"\n\tkey = "); \
/* --- Test decryption --- */ \
\
BLKC_MOVE(PRE, d, c); \
- pre ## _dblk(&k, d, d); \
+ pre##_dblk(&k, d, d); \
BLKC_STORE(PRE, b.buf, d); \
- if (memcmp(b.buf, v[1].buf, PRE ## _BLKSZ)) { \
+ if (memcmp(b.buf, v[1].buf, PRE##_BLKSZ)) { \
ok = 0; \
printf("\nfail decryption:" \
"\n\tkey = "); \