~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
progs/cc-kem.c (getkem): Parse the `kdf' spec after bulk crypto.
[catacomb]
/
symm
/
cfb-def.h
diff --git
a/symm/cfb-def.h
b/symm/cfb-def.h
index
767f4c4
..
78aa6d9
100644
(file)
--- a/
symm/cfb-def.h
+++ b/
symm/cfb-def.h
@@
-68,7
+68,9
@@
* Use: Creates an implementation for CFB mode.
*/
* Use: Creates an implementation for CFB mode.
*/
-#define CFB_DEF(PRE, pre) \
+#define CFB_DEF(PRE, pre) CFB_DEFX(PRE, pre, #pre, #pre)
+
+#define CFB_DEFX(PRE, pre, name, fname) \
\
/* --- @pre_cfbgetiv@ --- * \
* \
\
/* --- @pre_cfbgetiv@ --- * \
* \
@@
-389,14
+391,16
@@
static const gcipher_ops gops = { \
}; \
\
const gccipher pre##_cfb = { \
}; \
\
const gccipher pre##_cfb = { \
-
#pr
e "-cfb", pre##_keysz, PRE##_BLKSZ, \
+
nam
e "-cfb", pre##_keysz, PRE##_BLKSZ, \
ginit \
}; \
\
ginit \
}; \
\
-CFB_TEST
(PRE, pr
e)
+CFB_TEST
X(PRE, pre, name, fnam
e)
/*----- Test rig ----------------------------------------------------------*/
/*----- Test rig ----------------------------------------------------------*/
+#define CFB_TEST(PRE, pre) CFB_TESTX(PRE, pre, #pre, #pre)
+
#ifdef TEST_RIG
#include <stdio.h>
#ifdef TEST_RIG
#include <stdio.h>
@@
-410,7
+414,7
@@
CFB_TEST(PRE, pre)
* Use: Standard test rig for CFB functions.
*/
* Use: Standard test rig for CFB functions.
*/
-#define CFB_TEST
(PRE, pre)
\
+#define CFB_TEST
X(PRE, pre, name, fname)
\
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
@@
-426,12
+430,12
@@
static const octet iv[] = IV; \
static octet ct[sizeof(text)]; \
static octet pt[sizeof(text)]; \
\
static octet ct[sizeof(text)]; \
static octet pt[sizeof(text)]; \
\
-static void hexdump(const octet *p, size_t sz
)
\
+static void hexdump(const octet *p, size_t sz
, size_t off)
\
{ \
const octet *q = p + sz; \
for (sz = 0; p < q; p++, sz++) { \
printf("%02x", *p); \
{ \
const octet *q = p + sz; \
for (sz = 0; p < q; p++, sz++) { \
printf("%02x", *p); \
- if ((
sz + 1) % PRE##_BLKSZ == 0)
\
+ if ((
off + sz + 1) % PRE##_BLKSZ == 0)
\
putchar(':'); \
} \
} \
putchar(':'); \
} \
} \
@@
-447,7
+451,7
@@
int main(void) \
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
- fputs(
#pr
e "-cfb: ", stdout); \
+ fputs(
nam
e "-cfb: ", stdout); \
\
pre##_init(&k, key, keysz); \
pre##_cfbsetkey(&ctx, &k); \
\
pre##_init(&k, key, keysz); \
pre##_cfbsetkey(&ctx, &k); \
@@
-472,14
+476,14
@@
int main(void) \
} else { \
printf("\nError (sz = %lu)\n", (unsigned long)sz); \
status = 1; \
} else { \
printf("\nError (sz = %lu)\n", (unsigned long)sz); \
status = 1; \
- printf("\tplaintext = "); hexdump(text, sz
);
\
- printf(", "); hexdump(text + sz, rest
);
\
+ printf("\tplaintext = "); hexdump(text, sz
, 0);
\
+ printf(", "); hexdump(text + sz, rest
, sz);
\
fputc('\n', stdout); \
fputc('\n', stdout); \
- printf("\tciphertext = "); hexdump(ct, sz
);
\
- printf(", "); hexdump(ct + sz, rest
);
\
+ printf("\tciphertext = "); hexdump(ct, sz
, 0);
\
+ printf(", "); hexdump(ct + sz, rest
, sz);
\
fputc('\n', stdout); \
fputc('\n', stdout); \
- printf("\trecovered text = "); hexdump(pt, sz
);
\
- printf(", "); hexdump(pt + sz, rest
);
\
+ printf("\trecovered text = "); hexdump(pt, sz
, 0);
\
+ printf(", "); hexdump(pt + sz, rest
, sz);
\
fputc('\n', stdout); \
fputc('\n', stdout); \
} \
fputc('\n', stdout); \
fputc('\n', stdout); \
} \
@@
-494,7
+498,7
@@
int main(void) \
}
#else
}
#else
-# define CFB_TEST
(PRE, pr
e)
+# define CFB_TEST
X(PRE, pre, name, fnam
e)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/