symm/gcm-arm64-pmull.S (mul192): Fix commentary.
[catacomb] / symm / desx.c
index d65ffa7..e3737cc 100644 (file)
 #include "des-base.h"
 #include "des.h"
 #include "desx.h"
-#include "desx-tab.h"
 #include "gcipher.h"
+#include "permute.h"
 
 /*----- Tables ------------------------------------------------------------*/
 
-static const octet s[256] = DESX_S;
+extern const octet desx_s[256];
 
 /*----- Global variables --------------------------------------------------*/
 
@@ -62,7 +62,7 @@ const octet desx_keysz[] = { KSZ_SET, 23, 7, 8, 15, 16, 24, 0 };
  * Use:                Initializes a DESX key buffer.  The key buffer contains, in
  *             order, a single-DES key (either 7 or 8 bytes), an optional
  *             8-byte pre-whitening key, and an optional 8-byte
- *             port-whitening key.  If no whitening keys are specified, the
+ *             post-whitening key.  If no whitening keys are specified, the
  *             algorithm becomes the same as single-DES.
  */
 
@@ -71,7 +71,7 @@ static void mangle(octet *b, const octet *p)
   unsigned i;
 
   for (i = 0; i < 8; i++)
-    b[i] = *p++ ^ s[b[i] ^ b[(i + 1) & 7u]];
+    b[i] = *p++ ^ desx_s[b[i] ^ b[(i + 1) & 7u]];
 }
 
 void desx_init(desx_ctx *k, const void *buf, size_t sz)
@@ -124,6 +124,9 @@ void desx_init(desx_ctx *k, const void *buf, size_t sz)
 
 void desx_eblk(const desx_ctx *k, const uint32 *s, uint32 *d)
 {
+#define REGWD 32
+  typedef uint32 regty;
+
   uint32 x = s[0], y = s[1];
   x ^= k->prea; y ^= k->preb;
   DES_IP(x, y);
@@ -131,10 +134,15 @@ void desx_eblk(const desx_ctx *k, const uint32 *s, uint32 *d)
   DES_IPINV(x, y);
   x ^= k->posta; y ^= k->postb;
   d[0] = x, d[1] = y;
+
+#undef REGWD
 }
 
 void desx_dblk(const desx_ctx *k, const uint32 *s, uint32 *d)
 {
+#define REGWD 32
+  typedef uint32 regty;
+
   uint32 x = s[0], y = s[1];
   x ^= k->posta; y ^= k->postb;
   DES_IP(x, y);
@@ -142,6 +150,8 @@ void desx_dblk(const desx_ctx *k, const uint32 *s, uint32 *d)
   DES_IPINV(x, y);
   x ^= k->prea; y ^= k->preb;
   d[0] = x, d[1] = y;
+
+#undef REGWD
 }
 
 BLKC_TEST(DESX, desx)