X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/98421fc1a6832ad5de4b3f6171852437aa3e0fb2..6a024d24d97cb5d42c0091571735475b849f59f4:/symm/counter-def.h diff --git a/symm/counter-def.h b/symm/counter-def.h index 45536795..ad955dba 100644 --- a/symm/counter-def.h +++ b/symm/counter-def.h @@ -65,7 +65,9 @@ * 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@ --- * \ * \ @@ -299,7 +301,7 @@ static const gcipher_ops gops = { \ }; \ \ const gccipher pre##_counter = { \ - #pre "-counter", pre##_keysz, PRE##_BLKSZ, \ + name "-counter", pre##_keysz, PRE##_BLKSZ, \ ginit \ }; \ \ @@ -395,7 +397,7 @@ static void grfill(grand *r, void *p, size_t sz) \ } \ \ static const grand_ops grops = { \ - #pre "-counter", \ + name "-counter", \ GRAND_CRYPTO, 0, \ grmisc, grdestroy, \ grword, grbyte, grword, grand_defaultrange, grfill \ @@ -420,10 +422,12 @@ grand *pre##_counterrand(const void *k, size_t sz) \ return (&g->r); \ } \ \ -COUNTER_TEST(PRE, pre) +COUNTER_TESTX(PRE, pre, name, fname) /*----- Test rig ----------------------------------------------------------*/ +#define COUNTER_TEST(PRE, pre) COUNTER_TESTX(PRE, pre, #pre, #pre) + #ifdef TEST_RIG #include @@ -437,7 +441,7 @@ COUNTER_TEST(PRE, pre) * Use: Standard test rig for counter functions. */ -#define COUNTER_TEST(PRE, pre) \ +#define COUNTER_TESTX(PRE, pre, name, fname) \ \ /* --- Initial plaintext for the test --- */ \ \ @@ -474,7 +478,7 @@ int main(void) \ 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); \ @@ -521,7 +525,7 @@ int main(void) \ } #else -# define COUNTER_TEST(PRE, pre) +# define COUNTER_TESTX(PRE, pre, name, fname) #endif /*----- That's all, folks -------------------------------------------------*/