symm/: Allow block cipher and hash functions with strange names.
[catacomb] / symm / ofb-def.h
index 358ee54..e9eb503 100644 (file)
@@ -65,7 +65,9 @@
  * 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@ --- *                                            \
  *                                                                     \
@@ -306,7 +308,7 @@ static const gcipher_ops gops = {                                   \
 };                                                                     \
                                                                        \
 const gccipher pre##_ofb = {                                           \
-  #pre "-ofb", pre##_keysz, PRE##_BLKSZ,                               \
+  name "-ofb", pre##_keysz, PRE##_BLKSZ,                               \
   ginit                                                                        \
 };                                                                     \
                                                                        \
@@ -407,7 +409,7 @@ static void grfill(grand *r, void *p, size_t sz)                    \
 }                                                                      \
                                                                        \
 static const grand_ops grops = {                                       \
-  #pre "-ofb",                                                         \
+  name "-ofb",                                                         \
   GRAND_CRYPTO, 0,                                                     \
   grmisc, grdestroy,                                                   \
   grword, grbyte, grword, grand_defaultrange, grfill                   \
@@ -432,10 +434,12 @@ grand *pre##_ofbrand(const void *k, size_t sz)                            \
   return (&g->r);                                                      \
 }                                                                      \
                                                                        \
-OFB_TEST(PRE, pre)
+OFB_TESTX(PRE, pre, name, name)
 
 /*----- Test rig ----------------------------------------------------------*/
 
+#define OFB_TEST(PRE, pre) OFB_TESTX(PRE, pre, #pre, #pre)
+
 #ifdef TEST_RIG
 
 #include <stdio.h>
@@ -449,7 +453,7 @@ OFB_TEST(PRE, pre)
  * Use:                Standard test rig for OFB functions.
  */
 
-#define OFB_TEST(PRE, pre)                                             \
+#define OFB_TESTX(PRE, pre, name, fname)                                       \
                                                                        \
 /* --- Initial plaintext for the test --- */                           \
                                                                        \
@@ -486,7 +490,7 @@ int main(void)                                                              \
   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);                                           \
@@ -533,7 +537,7 @@ int main(void)                                                              \
 }
 
 #else
-#  define OFB_TEST(PRE, pre)
+#  define OFB_TESTX(PRE, pre, name, fname)
 #endif
 
 /*----- That's all, folks -------------------------------------------------*/