~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pub/t/x*: Rearrange the Monte-Carlo tests.
[catacomb]
/
symm
/
cbc-def.h
diff --git
a/symm/cbc-def.h
b/symm/cbc-def.h
index
f48ee46
..
907a5db
100644
(file)
--- a/
symm/cbc-def.h
+++ b/
symm/cbc-def.h
@@
-64,7
+64,9
@@
* Use: Creates an implementation for CBC stealing mode.
*/
* Use: Creates an implementation for CBC stealing mode.
*/
-#define CBC_DEF(PRE, pre) \
+#define CBC_DEF(PRE, pre) CBC_DEFX(PRE, pre, #pre, #pre)
+
+#define CBC_DEFX(PRE, pre, name, fname) \
\
/* --- @pre_cbcgetiv@ --- * \
* \
\
/* --- @pre_cbcgetiv@ --- * \
* \
@@
-430,14
+432,16
@@
static const gcipher_ops gops = { \
}; \
\
const gccipher pre##_cbc = { \
}; \
\
const gccipher pre##_cbc = { \
-
#pr
e "-cbc", pre##_keysz, PRE##_BLKSZ, \
+
nam
e "-cbc", pre##_keysz, PRE##_BLKSZ, \
ginit \
}; \
\
ginit \
}; \
\
-CBC_TEST
(PRE, pr
e)
+CBC_TEST
X(PRE, pre, name, fnam
e)
/*----- Test rig ----------------------------------------------------------*/
/*----- Test rig ----------------------------------------------------------*/
+#define CBC_TEST(PRE, pre) CBC_TESTX(PRE, pre, #pre, #pre)
+
#ifdef TEST_RIG
#include <stdio.h>
#ifdef TEST_RIG
#include <stdio.h>
@@
-451,7
+455,7
@@
CBC_TEST(PRE, pre)
* Use: Standard test rig for CBC functions.
*/
* Use: Standard test rig for CBC functions.
*/
-#define CBC_TEST
(PRE, pre)
\
+#define CBC_TEST
X(PRE, pre, name, fname)
\
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
@@
-467,12
+471,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(':'); \
} \
} \
@@
-488,7
+492,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 "-cbc: ", stdout); \
+ fputs(
nam
e "-cbc: ", stdout); \
\
pre##_init(&k, key, keysz); \
pre##_cbcsetkey(&ctx, &k); \
\
pre##_init(&k, key, keysz); \
pre##_cbcsetkey(&ctx, &k); \
@@
-513,14
+517,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); \
} \
@@
-535,7
+539,7
@@
int main(void) \
}
#else
}
#else
-# define CBC_TEST
(PRE, pr
e)
+# define CBC_TEST
X(PRE, pre, name, fnam
e)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/