X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..e5b61a8dec3586f96d25bd3ef454176526ff0f69:/symm/safer.c diff --git a/symm/safer.c b/symm/safer.c index 055a5f6..8dd31cb 100644 --- a/symm/safer.c +++ b/symm/safer.c @@ -36,7 +36,6 @@ #include "gcipher.h" #include "paranoia.h" #include "safer.h" -#include "safer-tab.h" /*----- Global variables --------------------------------------------------*/ @@ -44,7 +43,9 @@ const octet safer_keysz[] = { KSZ_SET, 8, 16, 0 }; /*----- Important tables --------------------------------------------------*/ -static const octet s[265] = SAFER_S, si[256] = SAFER_SI; +extern const octet safer_s[256], safer_si[256]; +#define S safer_s +#define SI safer_si /*----- Main code ---------------------------------------------------------*/ @@ -91,7 +92,7 @@ static void next(struct ksched *t, octet *k) memcpy(k, t->x, 8); if (t->i > 1) { for (i = 0; i < 8; i++) - k[i] += s[s[U8(9*t->i + i + 1)]]; + k[i] += S[S[U8(9*t->i + i + 1)]]; } } for (i = 0; i < 8; i++) @@ -112,7 +113,7 @@ static void next_sk(struct ksched *t, octet *k) } if (t->i > 1) { for (i = 0; i < 8; i++) - k[i] += s[s[U8(9*t->i + i + 1)]]; + k[i] += S[S[U8(9*t->i + i + 1)]]; } } for (i = 0; i < 9; i++) @@ -216,8 +217,8 @@ void safersk_init(safer_ctx *k, const void *buf, size_t sz) e ^= *k++; f += *k++; g += *k++; h ^= *k++; \ } while (0) #define SUB(a, b, c, d, e, f, g, h) do { \ - a = s[U8(a)]; b = si[U8(b)]; c = si[U8(c)]; d = s[U8(d)]; \ - e = s[U8(e)]; f = si[U8(f)]; g = si[U8(g)]; h = s[U8(h)]; \ + a = S[U8(a)]; b = SI[U8(b)]; c = SI[U8(c)]; d = S[U8(d)]; \ + e = S[U8(e)]; f = SI[U8(f)]; g = SI[U8(g)]; h = S[U8(h)]; \ } while (0) #define KAX(k, a, b, c, d, e, f, g, h) do { \ a += *k++; b ^= *k++; c ^= *k++; d += *k++; \ @@ -229,8 +230,8 @@ void safersk_init(safer_ctx *k, const void *buf, size_t sz) d ^= *--k; c -= *--k; b -= *--k; a ^= *--k; \ } while (0) #define ISUB(a, b, c, d, e, f, g, h) do { \ - a = si[U8(a)]; b = s[U8(b)]; c = s[U8(c)]; d = si[U8(d)]; \ - e = si[U8(e)]; f = s[U8(f)]; g = s[U8(g)]; h = si[U8(h)]; \ + a = SI[U8(a)]; b = S[U8(b)]; c = S[U8(c)]; d = SI[U8(d)]; \ + e = SI[U8(e)]; f = S[U8(f)]; g = S[U8(g)]; h = SI[U8(h)]; \ } while (0) #define KSX(k, a, b, c, d, e, f, g, h) do { \ h -= *--k; g ^= *--k; f ^= *--k; e -= *--k; \