This is quite a performance, actually.
* The `multigen' tool now has a modifier `:f' which makes a filename-
safe version of a value.
* The `multigen' input files and `Makefile.am' have been changed to
use `:f' appropriately.
* All of the `MUMBLE-def.h' header files have been changed to
introduce a new macro `MUMBLE_DEFX' with two extra arguments: the
thing's presentable name (for use in class structures), and a
filename-safe version of it. The old `MUMBLE_DEF' macro still
exists for compatibility (has anyone else written a mode?).
* Similar changes have been made to the testing machinery in `blkc.h'
and `hash.h', but this still needs cleaning up somewhat.
16 files changed:
modes/gen-stamp: Makefile.am
$(AM_V_at)$(MKDIR_P) $(srcdir)/modes
$(AM_V_GEN)$(multigen) -g $(srcdir)/mode.c.in \
modes/gen-stamp: Makefile.am
$(AM_V_at)$(MKDIR_P) $(srcdir)/modes
$(AM_V_GEN)$(multigen) -g $(srcdir)/mode.c.in \
- $(srcdir)/modes/@base-@mode.c \
+ $(srcdir)/modes/@{base:f}-@mode.c \
base="$(BLKCS)" mode="$(BLKCMODES)"
$(AM_V_at)$(multigen) -g $(srcdir)/mode.h.in \
base="$(BLKCS)" mode="$(BLKCMODES)"
$(AM_V_at)$(multigen) -g $(srcdir)/mode.h.in \
- $(srcdir)/modes/@base-@mode.h \
+ $(srcdir)/modes/@{base:f}-@mode.h \
base="$(BLKCS)" mode="$(BLKCMODES)"
$(AM_V_at)$(multigen) -g $(srcdir)/mode.c.in \
base="$(BLKCS)" mode="$(BLKCMODES)"
$(AM_V_at)$(multigen) -g $(srcdir)/mode.c.in \
- $(srcdir)/modes/@base-@mode.c \
+ $(srcdir)/modes/@{base:f}-@mode.c \
base="$(HASHES)" mode="$(HASHMODES)"
$(AM_V_at)$(multigen) -g $(srcdir)/mode.h.in \
base="$(HASHES)" mode="$(HASHMODES)"
$(AM_V_at)$(multigen) -g $(srcdir)/mode.h.in \
- $(srcdir)/modes/@base-@mode.h \
+ $(srcdir)/modes/@{base:f}-@mode.h \
base="$(HASHES)" mode="$(HASHMODES)"
$(AM_V_at)touch $(srcdir)/modes/gen-stamp
base="$(HASHES)" mode="$(HASHMODES)"
$(AM_V_at)touch $(srcdir)/modes/gen-stamp
#include <mLib/quis.h>
#include <mLib/testrig.h>
#include <mLib/quis.h>
#include <mLib/testrig.h>
-#define BLKC_VERIFY(PRE, pre) \
+#define BLKC_VERIFY(PRE, pre) BLKC_VERIFYX(PRE, pre, #pre)
+
+#define BLKC_VERIFYX(PRE, pre, name) \
\
static int pre##_verify(dstr *v) \
{ \
\
static int pre##_verify(dstr *v) \
{ \
-#define BLKC_TEST(PRE, pre) \
+#define BLKC_TESTX(PRE, pre, name, fname) \
+BLKC_VERIFYX(PRE, pre, name) \
\
static const test_chunk defs[] = { \
\
static const test_chunk defs[] = { \
- { #pre, pre##_verify, { &type_hex, &type_hex, &type_hex, 0 } }, \
+ { name, pre##_verify, { &type_hex, &type_hex, &type_hex, 0 } }, \
{ 0, 0, { 0 } } \
}; \
\
int main(int argc, char *argv[]) \
{ \
{ 0, 0, { 0 } } \
}; \
\
int main(int argc, char *argv[]) \
{ \
- test_run(argc, argv, defs, SRCDIR"/t/" #pre); \
+ test_run(argc, argv, defs, SRCDIR"/t/" fname); \
-# define BLKC_VERIFY(PRE, pre)
-# define BLKC_TEST(PRE, pre)
+# define BLKC_TESTX(PRE, pre, name, fname)
+#define BLKC_TEST(PRE, pre) BLKC_TESTX(PRE, pre, #pre, #pre)
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
* 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@ --- * \
* \
}; \
\
const gccipher pre##_cbc = { \
}; \
\
const gccipher pre##_cbc = { \
- #pre "-cbc", pre##_keysz, PRE##_BLKSZ, \
+ name "-cbc", pre##_keysz, PRE##_BLKSZ, \
+CBC_TESTX(PRE, pre, name, fname)
/*----- 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>
* Use: Standard test rig for CBC functions.
*/
* Use: Standard test rig for CBC functions.
*/
-#define CBC_TEST(PRE, pre) \
+#define CBC_TESTX(PRE, pre, name, fname) \
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
- fputs(#pre "-cbc: ", stdout); \
+ fputs(name "-cbc: ", stdout); \
\
pre##_init(&k, key, keysz); \
pre##_cbcsetkey(&ctx, &k); \
\
pre##_init(&k, key, keysz); \
pre##_cbcsetkey(&ctx, &k); \
-# define CBC_TEST(PRE, pre)
+# define CBC_TESTX(PRE, pre, name, fname)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/
* 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@ --- * \
* \
}; \
\
const gccipher pre##_cfb = { \
}; \
\
const gccipher pre##_cfb = { \
- #pre "-cfb", pre##_keysz, PRE##_BLKSZ, \
+ name "-cfb", pre##_keysz, PRE##_BLKSZ, \
+CFB_TESTX(PRE, pre, name, fname)
/*----- 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>
* Use: Standard test rig for CFB functions.
*/
* Use: Standard test rig for CFB functions.
*/
-#define CFB_TEST(PRE, pre) \
+#define CFB_TESTX(PRE, pre, name, fname) \
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
- fputs(#pre "-cfb: ", stdout); \
+ fputs(name "-cfb: ", stdout); \
\
pre##_init(&k, key, keysz); \
pre##_cfbsetkey(&ctx, &k); \
\
pre##_init(&k, key, keysz); \
pre##_cfbsetkey(&ctx, &k); \
-# define CFB_TEST(PRE, pre)
+# define CFB_TESTX(PRE, pre, name, fname)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/
* Use: Creates definitions for counter mode.
*/
* Use: Creates definitions for counter mode.
*/
-#define COUNTER_DEF(PRE, pre) \
+#define COUNTER_DEF(PRE, pre) COUNTER_DEFX(PRE, pre, #pre, #pre)
+
+#define COUNTER_DEFX(PRE, pre, name, fname) \
\
/* --- @pre_countergetiv@ --- * \
* \
\
/* --- @pre_countergetiv@ --- * \
* \
}; \
\
const gccipher pre##_counter = { \
}; \
\
const gccipher pre##_counter = { \
- #pre "-counter", pre##_keysz, PRE##_BLKSZ, \
+ name "-counter", pre##_keysz, PRE##_BLKSZ, \
} \
\
static const grand_ops grops = { \
} \
\
static const grand_ops grops = { \
GRAND_CRYPTO, 0, \
grmisc, grdestroy, \
grword, grbyte, grword, grand_defaultrange, grfill \
GRAND_CRYPTO, 0, \
grmisc, grdestroy, \
grword, grbyte, grword, grand_defaultrange, grfill \
+COUNTER_TESTX(PRE, pre, name, fname)
/*----- Test rig ----------------------------------------------------------*/
/*----- Test rig ----------------------------------------------------------*/
+#define COUNTER_TEST(PRE, pre) COUNTER_TESTX(PRE, pre, #pre, #pre)
+
#ifdef TEST_RIG
#include <stdio.h>
#ifdef TEST_RIG
#include <stdio.h>
* Use: Standard test rig for counter functions.
*/
* Use: Standard test rig for counter functions.
*/
-#define COUNTER_TEST(PRE, pre) \
+#define COUNTER_TESTX(PRE, pre, name, fname) \
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
- fputs(#pre "-counter: ", stdout); \
+ fputs(name "-counter: ", stdout); \
\
pre##_init(&k, key, keysz); \
pre##_countersetkey(&ctx, &k); \
\
pre##_init(&k, key, keysz); \
pre##_countersetkey(&ctx, &k); \
-# define COUNTER_TEST(PRE, pre)
+# define COUNTER_TESTX(PRE, pre, name, fname)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/
* Use: Creates an implementation for ECB stealing mode.
*/
* Use: Creates an implementation for ECB stealing mode.
*/
-#define ECB_DEF(PRE, pre) \
+#define ECB_DEF(PRE, pre) ECB_DEFX(PRE, pre, #pre, #pre)
+
+#define ECB_DEFX(PRE, pre, name, fname) \
\
/* --- @pre_ecbsetkey@ --- * \
* \
\
/* --- @pre_ecbsetkey@ --- * \
* \
}; \
\
const gccipher pre##_ecb = { \
}; \
\
const gccipher pre##_ecb = { \
- #pre "-ecb", pre##_keysz, PRE##_BLKSZ, \
+ name "-ecb", pre##_keysz, PRE##_BLKSZ, \
+ECB_TESTX(PRE, pre, name, fname)
/*----- Test rig ----------------------------------------------------------*/
/*----- Test rig ----------------------------------------------------------*/
+#define ECB_TEST(PRE, pre) ECB_TESTX(PRE, pre, #pre, #pre)
+
#ifdef TEST_RIG
#include <stdio.h>
#ifdef TEST_RIG
#include <stdio.h>
* Use: Standard test rig for ECB functions.
*/
* Use: Standard test rig for ECB functions.
*/
-#define ECB_TEST(PRE, pre) \
+#define ECB_TESTX(PRE, pre, name, fname) \
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
- fputs(#pre "-ecb: ", stdout); \
+ fputs(name "-ecb: ", stdout); \
\
pre##_ecbinit(&ctx, key, keysz, iv); \
\
\
pre##_ecbinit(&ctx, key, keysz, iv); \
\
-# define ECB_TEST(PRE, pre)
+# define ECB_TESTX(PRE, pre, name, fname)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/
* Use: Defines the generic hash instance.
*/
* Use: Defines the generic hash instance.
*/
-#define GHASH_DEF(PRE, pre) \
+#define GHASH_DEF(PRE, pre) GHASH_DEFX(PRE, pre, #pre)
+#define GHASH_DEFX(PRE, pre, name) \
-static const ghash_ops gops; \
+static const ghash_ops gops_##pre; \
+typedef struct gctx_##pre { \
ghash h; \
pre##_ctx c; \
octet buf[PRE##_HASHSZ]; \
ghash h; \
pre##_ctx c; \
octet buf[PRE##_HASHSZ]; \
-static ghash *ghinit(void) \
+static ghash *ghinit_##pre(void) \
- gctx *g = S_CREATE(gctx); \
- g->h.ops = &gops; \
+ gctx_##pre *g = S_CREATE(gctx_##pre); \
+ g->h.ops = &gops_##pre; \
pre##_init(&g->c); \
return (&g->h); \
} \
\
pre##_init(&g->c); \
return (&g->h); \
} \
\
-static void ghhash(ghash *h, const void *p, size_t sz) \
+static void ghhash_##pre(ghash *h, const void *p, size_t sz) \
+ gctx_##pre *g = (gctx_##pre *)h; \
pre##_hash(&g->c, p, sz); \
} \
\
pre##_hash(&g->c, p, sz); \
} \
\
-static octet *ghdone(ghash *h, void *buf) \
+static octet *ghdone_##pre(ghash *h, void *buf) \
+ gctx_##pre *g = (gctx_##pre *)h; \
if (!buf) \
buf = g->buf; \
pre##_done(&g->c, buf); \
return (buf); \
} \
\
if (!buf) \
buf = g->buf; \
pre##_done(&g->c, buf); \
return (buf); \
} \
\
-static void ghdestroy(ghash *h) \
+static void ghdestroy_##pre(ghash *h) \
+ gctx_##pre *g = (gctx_##pre *)h; \
BURN(*g); \
S_DESTROY(g); \
} \
\
BURN(*g); \
S_DESTROY(g); \
} \
\
-static ghash *ghcopy(ghash *h) \
+static ghash *ghcopy_##pre(ghash *h) \
- gctx *g = (gctx *)h; \
- gctx *gg = S_CREATE(gctx); \
- memcpy(gg, g, sizeof(gctx)); \
+ gctx_##pre *g = (gctx_##pre *)h; \
+ gctx_##pre *gg = S_CREATE(gctx_##pre); \
+ memcpy(gg, g, sizeof(gctx_##pre)); \
-static const ghash_ops gops = \
- { &pre, ghhash, ghdone, ghdestroy, ghcopy }; \
-const gchash pre = { #pre, PRE##_HASHSZ, ghinit, PRE##_BUFSZ };
+static const ghash_ops gops_##pre = \
+ { &pre, ghhash_##pre, ghdone_##pre, ghdestroy_##pre, ghcopy_##pre }; \
+const gchash pre = { name, PRE##_HASHSZ, ghinit_##pre, PRE##_BUFSZ };
/*----- That's all, folks -------------------------------------------------*/
/*----- That's all, folks -------------------------------------------------*/
#include "@what.h"
%repeat
#include "@what.h"
%repeat
-#include "@{thing:left}.h"
+#include "@{thing:left:f}.h"
%end
const @cls *const @{what}tab[] = {
%end
const @cls *const @{what}tab[] = {
#define HASH_BUFLEN 100000
#define HASH_BUFLEN 100000
-#define HASH_TEST(PRE, pre) \
+#define HASH_TESTX(PRE, pre, name, fname) \
\
static int verify(dstr *v) \
{ \
\
static int verify(dstr *v) \
{ \
} \
\
static test_chunk defs[] = { \
} \
\
static test_chunk defs[] = { \
- { #pre, verify, { &type_string, &type_hex, 0 } }, \
- { #pre "-rep", verifyrep, \
+ { name, verify, { &type_string, &type_hex, 0 } }, \
+ { name "-rep", verifyrep, \
{ &type_string, &type_int, &type_hex, 0 } }, \
{ 0, 0, { 0 } } \
}; \
{ &type_string, &type_int, &type_hex, 0 } }, \
{ 0, 0, { 0 } } \
}; \
int main(int argc, char *argv[]) \
{ \
ego(argv[0]); \
int main(int argc, char *argv[]) \
{ \
ego(argv[0]); \
- test_run(argc, argv, defs, SRCDIR"/t/" #pre); \
+ test_run(argc, argv, defs, SRCDIR"/t/" fname); \
-# define HASH_TEST(PRE, pre)
+# define HASH_TESTX(PRE, pre, name, fname)
+#define HASH_TEST(PRE, pre) HASH_TESTX(PRE, pre, #pre, #pre)
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
* Use: Creates implementations for the HMAC and NMAC functions.
*/
* Use: Creates implementations for the HMAC and NMAC functions.
*/
-#define HMAC_DEF(PRE, pre) \
+#define HMAC_DEF(PRE, pre) HMAC_DEFX(PRE, pre, #pre, #pre)
+#define HMAC_DEFX(PRE, pre, name, fname) \
\
/* --- Useful constants --- */ \
\
\
/* --- Useful constants --- */ \
\
} \
\
const gcmac pre##_nmac = \
} \
\
const gcmac pre##_nmac = \
- { #pre "-nmac", PRE##_HASHSZ, pre##_nmackeysz, gnkey }; \
+ { name "-nmac", PRE##_HASHSZ, pre##_nmackeysz, gnkey }; \
const gcmac pre##_hmac = \
const gcmac pre##_hmac = \
- { #pre "-hmac", PRE##_HASHSZ, pre##_hmackeysz, gkey }; \
+ { name "-hmac", PRE##_HASHSZ, pre##_hmackeysz, gkey }; \
const gcmac pre##_sslmac = \
const gcmac pre##_sslmac = \
- { #pre "-sslmac", PRE##_HASHSZ, pre##_sslmackeysz, gsslkey }; \
+ { name "-sslmac", PRE##_HASHSZ, pre##_sslmackeysz, gsslkey }; \
static const gmac_ops gkops = { &pre##_hmac, gkinit, gkdestroy }; \
static const gmac_ops gnkops = { &pre##_nmac, gkinit, gkdestroy }; \
static const gmac_ops gsslkops = { &pre##_sslmac, gkinit, gkdestroy }; \
static const gmac_ops gkops = { &pre##_hmac, gkinit, gkdestroy }; \
static const gmac_ops gnkops = { &pre##_nmac, gkinit, gkdestroy }; \
static const gmac_ops gsslkops = { &pre##_sslmac, gkinit, gkdestroy }; \
-static const gchash gch = { #pre "-hmac", PRE##_HASHSZ, ghinit }; \
+static const gchash gch = { name "-hmac", PRE##_HASHSZ, ghinit }; \
static const ghash_ops gops = \
{ &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
static const ghash_ops gops = \
{ &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
-static const gchash gnch = { #pre "-nmac", PRE##_HASHSZ, ghinit }; \
+static const gchash gnch = { name "-nmac", PRE##_HASHSZ, ghinit }; \
static const ghash_ops gnops = \
{ &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
static const ghash_ops gnops = \
{ &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
-static const gchash gsslch = { #pre "-sslmac", PRE##_HASHSZ, ghinit }; \
+static const gchash gsslch = { name "-sslmac", PRE##_HASHSZ, ghinit }; \
static const ghash_ops gsslops = \
{ &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
\
static const ghash_ops gsslops = \
{ &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
\
+HMAC_TESTX(PRE, pre, name, fname)
+
+#define HMAC_TEST(PRE, pre) HMAC_TESTX(PRE, pre, #pre, #pre)
/* --- @HMAC_TEST@ --- *
*
/* --- @HMAC_TEST@ --- *
*
#include <mLib/quis.h>
#include <mLib/testrig.h>
#include <mLib/quis.h>
#include <mLib/testrig.h>
-#define HMAC_TEST(PRE, pre) \
+#define HMAC_TESTX(PRE, pre, name, fname) \
\
static int macverify(dstr *v) \
{ \
\
static int macverify(dstr *v) \
{ \
} \
\
static test_chunk macdefs[] = { \
} \
\
static test_chunk macdefs[] = { \
- { #pre "-hmac", macverify, \
+ { name "-hmac", macverify, \
{ &type_string, &type_hex, &type_hex, 0 } }, \
{ 0, 0, { 0 } } \
}; \
{ &type_string, &type_hex, &type_hex, 0 } }, \
{ 0, 0, { 0 } } \
}; \
int main(int argc, char *argv[]) \
{ \
ego(argv[0]); \
int main(int argc, char *argv[]) \
{ \
ego(argv[0]); \
- test_run(argc, argv, macdefs, SRCDIR"/t/" #pre); \
+ test_run(argc, argv, macdefs, SRCDIR"/t/" fname); \
-# define HMAC_TEST(PRE, pre)
+# define HMAC_TESTX(PRE, pre, name, fname)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/
/*----- Macros ------------------------------------------------------------*/
/*----- Macros ------------------------------------------------------------*/
-#define MGF_DEF(PRE, pre) \
+#define MGF_DEF(PRE, pre) MGF_DEFX(PRE, pre, #pre, #pre)
+
+#define MGF_DEFX(PRE, pre, name, fname) \
\
/* --- Useful constants --- */ \
\
\
/* --- Useful constants --- */ \
\
}; \
\
const gccipher pre##_mgf = { \
}; \
\
const gccipher pre##_mgf = { \
- #pre "-mgf", pre##_mgfkeysz, 0, \
+ name "-mgf", pre##_mgfkeysz, 0, \
} \
\
static const grand_ops grops = { \
} \
\
static const grand_ops grops = { \
GRAND_CRYPTO, 0, \
grmisc, grdestroy, \
grword, grbyte, grword, grand_defaultrange, grfill \
GRAND_CRYPTO, 0, \
grmisc, grdestroy, \
grword, grbyte, grword, grand_defaultrange, grfill \
+MGF_TESTX(PRE, pre, name, fname)
/*----- Test rig ----------------------------------------------------------*/
/*----- Test rig ----------------------------------------------------------*/
+#define MGF_TEST(PRE, pre) MGF_TESTX(PRE, pre, #pre, #pre)
+
#ifdef TEST_RIG
#include <stdio.h>
#ifdef TEST_RIG
#include <stdio.h>
* Use: Standard test rig for MGF functions.
*/
* Use: Standard test rig for MGF functions.
*/
-#define MGF_TEST(PRE, pre) \
+#define MGF_TESTX(PRE, pre, name, fname) \
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
\
size_t keysz = strlen((const char *)key); \
\
\
size_t keysz = strlen((const char *)key); \
\
- fputs(#pre "-mgf: ", stdout); \
+ fputs(name "-mgf: ", stdout); \
\
pre##_mgfinit(&ctx, key, keysz); \
\
\
pre##_mgfinit(&ctx, key, keysz); \
\
-# define MGF_TEST(PRE, pre)
+# define MGF_TESTX(PRE, pre, name, fname)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/
%#
/* -*-c-*- GENERATED from mode.c.in
*
%#
/* -*-c-*- GENERATED from mode.c.in
*
-#include "@base-@mode.h"
+#include "@{base:f}-@mode.h"
-@{mode:u}_DEF(@{base:u}, @base)
+@{mode:u}_DEFX(@{base:u:c}, @{base:c}, "@base", "@{base:f}")
%#
/* -*-c-*- GENERATED from mode.h.in
*
%#
/* -*-c-*- GENERATED from mode.h.in
*
-#ifndef CATACOMB_@{base:u}_@{mode:u}_H
-#define CATACOMB_@{base:u}_@{mode:u}_H
+#ifndef CATACOMB_@{base:u:c}_@{mode:u}_H
+#define CATACOMB_@{base:u:c}_@{mode:u}_H
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
extern "C" {
# include "@mode.h"
#endif
# include "@mode.h"
#endif
-#ifndef CATACOMB_@{base:u}_H
-# include "@base.h"
+#ifndef CATACOMB_@{base:u:c}_H
+# include "@{base:f}.h"
-@{mode:u}_DECL(@{base:u}, @base)
+@{mode:u}_DECL(@{base:u:c}, @{base:c})
## Block cipher modes.
%repeat
## Block cipher modes.
%repeat
-GENMODES_C += modes/@blkc-@blkcmode.c
-GENMODES_H += modes/@blkc-@blkcmode.h
-SYMM_TESTS += modes/@blkc-@blkcmode.t$(EXEEXT)
+GENMODES_C += modes/@{blkc:f}-@blkcmode.c
+GENMODES_H += modes/@{blkc:f}-@blkcmode.h
+SYMM_TESTS += modes/@{blkc:f}-@blkcmode.t$(EXEEXT)
%end
## Hash function modes.
%repeat
%end
## Hash function modes.
%repeat
-GENMODES_C += modes/@hash-@hashmode.c
-GENMODES_H += modes/@hash-@hashmode.h
-SYMM_TESTS += modes/@hash-@hashmode.t$(EXEEXT)
+GENMODES_C += modes/@{hash:f}-@hashmode.c
+GENMODES_H += modes/@{hash:f}-@hashmode.h
+SYMM_TESTS += modes/@{hash:f}-@hashmode.t$(EXEEXT)
%end
## Interface and implementation headers for the various modes.
%end
## Interface and implementation headers for the various modes.
BLKC_C =
BLKC_H =
%repeat
BLKC_C =
BLKC_H =
%repeat
-BLKC_C += @blkc.c
-BLKC_H += @blkc.h
-SYMM_TESTS += @blkc.t$(EXEEXT)
+BLKC_C += @{blkc:f}.c
+BLKC_H += @{blkc:f}.h
+SYMM_TESTS += @{blkc:f}.t$(EXEEXT)
%end
## Hash function interfaces and implementations.
HASH_C =
HASH_H =
%repeat
%end
## Hash function interfaces and implementations.
HASH_C =
HASH_H =
%repeat
-HASH_C += @hash.c
-HASH_H += @hash.h
-SYMM_TESTS += @hash.t$(EXEEXT)
+HASH_C += @{hash:f}.c
+HASH_H += @{hash:f}.h
+SYMM_TESTS += @{hash:f}.t$(EXEEXT)
%end
## Modes for symmetric encryption.
CIPHER_MODES =
%repeat
%end
## Modes for symmetric encryption.
CIPHER_MODES =
%repeat
-CIPHER_MODES += @blkc-@blkcciphermode
+CIPHER_MODES += @{blkc:f}-@blkcciphermode
-CIPHER_MODES += @hash-@hashciphermode
+CIPHER_MODES += @{hash:f}-@hashciphermode
%end
## Modes for message authentication.
MAC_MODES =
%repeat
%end
## Modes for message authentication.
MAC_MODES =
%repeat
-MAC_MODES += @hash-@hashmacmode
+MAC_MODES += @{hash:f}-@hashmacmode
%end
## Test input files.
SYMM_TEST_FILES =
%repeat
%end
## Test input files.
SYMM_TEST_FILES =
%repeat
-SYMM_TEST_FILES += t/@blkc
+SYMM_TEST_FILES += t/@{blkc:f}
-SYMM_TEST_FILES += t/@hash
+SYMM_TEST_FILES += t/@{hash:f}
"""@{COLUMN:l} -- the item in upper case."""
return val.lower()
"""@{COLUMN:l} -- the item in upper case."""
return val.lower()
+@defop
+def op_f(val):
+ """@{COLUMN:f} -- the item, with `/' characters replaced by `-'."""
+ return val.replace('/', '-')
+
R_NOTIDENT = RX.compile(r'[^a-zA-Z0-9_]+')
@defop
def op_c(val):
R_NOTIDENT = RX.compile(r'[^a-zA-Z0-9_]+')
@defop
def op_c(val):
* 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@ --- * \
* \
}; \
\
const gccipher pre##_ofb = { \
}; \
\
const gccipher pre##_ofb = { \
- #pre "-ofb", pre##_keysz, PRE##_BLKSZ, \
+ name "-ofb", pre##_keysz, PRE##_BLKSZ, \
} \
\
static const grand_ops grops = { \
} \
\
static const grand_ops grops = { \
GRAND_CRYPTO, 0, \
grmisc, grdestroy, \
grword, grbyte, grword, grand_defaultrange, grfill \
GRAND_CRYPTO, 0, \
grmisc, grdestroy, \
grword, grbyte, grword, grand_defaultrange, grfill \
+OFB_TESTX(PRE, pre, name, name)
/*----- 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>
* Use: Standard test rig for OFB functions.
*/
* Use: Standard test rig for OFB functions.
*/
-#define OFB_TEST(PRE, pre) \
+#define OFB_TESTX(PRE, pre, name, fname) \
\
/* --- Initial plaintext for the test --- */ \
\
\
/* --- Initial plaintext for the test --- */ \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
size_t keysz = PRE##_KEYSZ ? \
PRE##_KEYSZ : strlen((const char *)key); \
\
- fputs(#pre "-ofb: ", stdout); \
+ fputs(name "-ofb: ", stdout); \
\
pre##_init(&k, key, keysz); \
pre##_ofbsetkey(&ctx, &k); \
\
pre##_init(&k, key, keysz); \
pre##_ofbsetkey(&ctx, &k); \
-# define OFB_TEST(PRE, pre)
+# define OFB_TESTX(PRE, pre, name, fname)
#endif
/*----- That's all, folks -------------------------------------------------*/
#endif
/*----- That's all, folks -------------------------------------------------*/