chiark / gitweb /
server/bulkcrypto.c: Abstract out MAC-failure tracing.
[tripe] / server / bulkcrypto.c
index 144a8301068e9f2811249bb09f5368ab88edf4bd..26ae9ede1233022bf8cdad553237013529361dcf 100644 (file)
   trace_block(T_CRYPTO, "crypto: computed MAC", (qmac), (tagsz));      \
 }) } while (0)
 
+#define TRACE_MACERR(pmac, tagsz) do { IF_TRACING(T_KEYSET, {          \
+  trace(T_KEYSET, "keyset: incorrect MAC: decryption failed");         \
+  trace_block(T_CRYPTO, "crypto: expected MAC", (pmac), (tagsz));      \
+}) } while (0)
+
 #define CHECK_MAC(h, pmac, tagsz) do {                                 \
   ghash *_h = (h);                                                     \
   const octet *_pmac = (pmac);                                         \
   TRACE_MAC(_mac, _tagsz);                                             \
   GH_DESTROY(_h);                                                      \
   if (!_eq) {                                                          \
-    IF_TRACING(T_KEYSET, {                                             \
-      trace(T_KEYSET, "keyset: incorrect MAC: decryption failed");     \
-      trace_block(T_CRYPTO, "crypto: expected MAC", _pmac, _tagsz);    \
-    })                                                                 \
+    TRACE_MACERR(_pmac, _tagsz);                                       \
     return (KSERR_DECRYPT);                                            \
   }                                                                    \
 } while (0)
@@ -358,7 +360,7 @@ static int iiv_decrypt(keyset *ks, unsigned ty, buf *b, buf *bb, uint32 *seq)
 
 /*----- Bulk crypto transform table ---------------------------------------*/
 
-const bulkcrypto bulktab[] = {
+const bulkops bulktab[] = {
 
 #define BULK(name, pre, prim)                                          \
   { name, prim, pre##_check, pre##_overhead, pre##_encrypt, pre##_decrypt }