chiark / gitweb /
server/bulkcrypto.c: Abstract out MAC-failure tracing.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 14 May 2017 17:19:08 +0000 (18:19 +0100)
server/bulkcrypto.c

index b528bb5..26ae9ed 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)