~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Release 2.4.1.
[catacomb]
/
symm
/
ofb-def.h
diff --git
a/symm/ofb-def.h
b/symm/ofb-def.h
index
6b1357d
..
e9eb503
100644
(file)
--- a/
symm/ofb-def.h
+++ b/
symm/ofb-def.h
@@
-65,7
+65,9
@@
* Use: Creates definitions for output feedback mode.
*/
* Use: Creates definitions for output feedback mode.
*/
-#define OFB_DEF(PRE, pre) \
+#define OFB_DEF(PRE, pre) OFB_DEFX(PRE, pre, #pre, #pre)
+
+#define OFB_DEFX(PRE, pre, name, fname) \
\
/* --- @pre_ofbgetiv@ --- * \
* \
\
/* --- @pre_ofbgetiv@ --- * \
* \
@@
-306,7
+308,7
@@
static const gcipher_ops gops = { \
}; \
\
const gccipher pre##_ofb = { \
}; \
\
const gccipher pre##_ofb = { \
-
#pr
e "-ofb", pre##_keysz, PRE##_BLKSZ, \
+
nam
e "-ofb", pre##_keysz, PRE##_BLKSZ, \
ginit \
}; \
\
ginit \
}; \
\
@@
-407,10
+409,10
@@
static void grfill(grand *r, void *p, size_t sz) \
} \
\
static const grand_ops grops = { \
} \
\
static const grand_ops grops = { \
-
#pr
e "-ofb", \
+
nam
e "-ofb", \
GRAND_CRYPTO, 0, \
grmisc, grdestroy, \
GRAND_CRYPTO, 0, \
grmisc, grdestroy, \
- grword, grbyte, grword, grand_
range, grfill
\
+ grword, grbyte, grword, grand_
defaultrange, grfill
\
}; \
\
/* --- @pre_ofbrand@ --- * \
}; \
\
/* --- @pre_ofbrand@ --- * \
@@
-432,10
+434,12
@@
grand *pre##_ofbrand(const void *k, size_t sz) \
return (&g->r); \
} \
\
return (&g->r); \
} \
\
-OFB_TEST
(PRE, pr
e)
+OFB_TEST
X(PRE, pre, name, nam
e)
/*----- Test rig ----------------------------------------------------------*/
/*----- Test rig ----------------------------------------------------------*/
+#define OFB_TEST(PRE, pre) OFB_TESTX(PRE, pre, #pre, #pre)
+
#ifdef TEST_RIG
#include <stdio.h>
#ifdef TEST_RIG
#include <stdio.h>
@@
-449,7
+453,7
@@
OFB_TEST(PRE, pre)
* Use: Standard test rig for OFB functions.
*/
* Use: Standard test rig for OFB functions.
*/
-#define OFB_TEST
(PRE, pre)
\
+#define OFB_TEST
X(PRE, pre, name, fname)
\
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
@@
-465,12
+469,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(':'); \
} \
} \
@@
-486,7
+490,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 "-ofb: ", stdout); \
+ fputs(
nam
e "-ofb: ", stdout); \
\
pre##_init(&k, key, keysz); \
pre##_ofbsetkey(&ctx, &k); \
\
pre##_init(&k, key, keysz); \
pre##_ofbsetkey(&ctx, &k); \
@@
-511,14
+515,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); \
} \
@@
-533,7
+537,7
@@
int main(void) \
}
#else
}
#else
-# define OFB_TEST
(PRE, pr
e)
+# define OFB_TEST
X(PRE, pre, name, fnam
e)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/