projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use clever recursive algorithm for writing numbers out.
[u/mdw/catacomb]
/
blkc.h
diff --git
a/blkc.h
b/blkc.h
index
e7f5518
..
fcd31dd
100644
(file)
--- a/
blkc.h
+++ b/
blkc.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-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
*
*
* Common definitions for block ciphers
*
@@
-30,13
+30,16
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: blkc.h,v $
/*----- 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.
*
*/
* 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" {
#ifdef __cplusplus
extern "C" {
@@
-70,9
+73,9
@@
#define BLKC_FIRST(x, y, z) x
#define BLKC_SECOND(x, y, z) y
#define BLKC_THIRD(x, y, z) z
#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_STORE_E(PRE) BLKC_GLUE(STORE32_, BLKC_ENDIAN(PRE))
#define BLKC_LOAD_E(PRE) BLKC_GLUE(LOAD32_, BLKC_ENDIAN(PRE))
@@
-118,7
+121,7
@@
#define BLKC_SKEL_X(PRE, decl, guts) \
BLKC_SKEL(PRE, int _i; decl, \
#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 \
})
guts \
})
@@
-204,27
+207,27
@@
\
static int verify(dstr *v) \
{ \
\
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 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); \
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); \
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 = "); \
ok = 0; \
printf("\nfail encryption:" \
"\n\tkey = "); \
@@
-238,9
+241,9
@@
static int verify(dstr *v) \
/* --- Test decryption --- */ \
\
BLKC_MOVE(PRE, d, c); \
/* --- Test decryption --- */ \
\
BLKC_MOVE(PRE, d, c); \
- pre
## _dblk(&k, d, d);
\
+ pre
##_dblk(&k, d, d);
\
BLKC_STORE(PRE, b.buf, 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 = "); \
ok = 0; \
printf("\nfail decryption:" \
"\n\tkey = "); \