X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..a90d420cbe87490c844ae422c966e746d3134b07:/symm/rc2.c diff --git a/symm/rc2.c b/symm/rc2.c index 4ea85b6c..97963fef 100644 --- a/symm/rc2.c +++ b/symm/rc2.c @@ -36,7 +36,6 @@ #include "gcipher.h" #include "paranoia.h" #include "rc2.h" -#include "rc2-tab.h" /*----- Global variables --------------------------------------------------*/ @@ -44,7 +43,7 @@ const octet rc2_keysz[] = { KSZ_RANGE, RC2_KEYSZ, 1, 128, 1 }; /*----- Important tables --------------------------------------------------*/ -static const octet pi[256] = RC2_PI; +extern const octet rc2_pi[256]; /*----- Main code ---------------------------------------------------------*/ @@ -85,15 +84,15 @@ void rc2_braindamage(rc2_ctx *k, const void *buf, size_t sz, unsigned eb) memcpy(l, buf, sz); for (i = sz; i < sizeof(l); i++) - l[i] = pi[U8(l[i - 1] + l[i - sz])]; + l[i] = rc2_pi[U8(l[i - 1] + l[i - sz])]; /* --- Braindamage the key --- */ i = sizeof(l) - t8; - l[i] = pi[l[i] & tm]; + l[i] = rc2_pi[l[i] & tm]; while (i) { i--; - l[i] = pi[U8(l[i + 1] ^ l[i + t8])]; + l[i] = rc2_pi[U8(l[i + 1] ^ l[i + t8])]; } /* --- Write it to the key block --- */ @@ -251,6 +250,7 @@ void rc2_dblk(const rc2_ctx *k, const uint32 *s, uint32 *dst) #ifdef TEST_RIG +#include #include #include @@ -277,7 +277,7 @@ static int verify(dstr *v) BLKC_MOVE(RC2, d, p); rc2_eblk(&k, d, d); BLKC_STORE(RC2, b.buf, d); - if (memcmp(b.buf, v[3].buf, RC2_BLKSZ)) { + if (MEMCMP(b.buf, !=, v[3].buf, RC2_BLKSZ)) { ok = 0; printf("\nfail encryption:" "\n\tkey = "); @@ -294,7 +294,7 @@ static int verify(dstr *v) BLKC_MOVE(RC2, d, c); rc2_dblk(&k, d, d); BLKC_STORE(RC2, b.buf, d); - if (memcmp(b.buf, v[2].buf, RC2_BLKSZ)) { + if (MEMCMP(b.buf, !=, v[2].buf, RC2_BLKSZ)) { ok = 0; printf("\nfail decryption:" "\n\tkey = ");