-static const octet q0[256] = TWOFISH_Q0, q1[256] = TWOFISH_Q1;
-static const uint32 qmds[4][256] = TWOFISH_QMDS;
-static const octet rslog[] = TWOFISH_RSLOG, rsexp[] = TWOFISH_RSEXP;
-static const octet rs[32] = TWOFISH_RS;
+extern const octet twofish_q0[256], twofish_q1[256];
+extern const uint32 twofish_qmds[4][256];
+extern const octet twofish_rslog[], twofish_rsexp[];
+extern const octet twofish_rs[32];
+
+#define Q0 twofish_q0
+#define Q1 twofish_q1
+#define QMDS twofish_qmds
+#define RSLOG twofish_rslog
+#define RSEXP twofish_rsexp
+#define RS twofish_rs
/* --- Apply a series of @q@ tables to an integer --- */
# define Q(x, qa, qb, qc, qd) \
/* --- Apply a series of @q@ tables to an integer --- */
# define Q(x, qa, qb, qc, qd) \
(qc[((x) >> 16) & 0xff] << 16) | \
(qd[((x) >> 24) & 0xff] << 24))
/* --- Grind through the tables --- */
switch (k) {
(qc[((x) >> 16) & 0xff] << 16) | \
(qd[((x) >> 24) & 0xff] << 24))
/* --- Grind through the tables --- */
switch (k) {
- case 4: x = Q(x, q1, q0, q0, q1) ^ l[3];
- case 3: x = Q(x, q1, q1, q0, q0) ^ l[2];
- case 2: x = Q(x, q0, q1, q0, q1) ^ l[1];
- x = Q(x, q0, q0, q1, q1) ^ l[0];
+ case 4: x = Q(x, Q1, Q0, Q0, Q1) ^ l[3];
+ case 3: x = Q(x, Q1, Q1, Q0, Q0) ^ l[2];
+ case 2: x = Q(x, Q0, Q1, Q0, Q1) ^ l[1];
+ x = Q(x, Q0, Q0, Q1, Q1) ^ l[0];
- return (qmds[0][U8(x >> 0)] ^ qmds[1][U8(x >> 8)] ^
- qmds[2][U8(x >> 16)] ^ qmds[3][U8(x >> 24)]);
+ return (QMDS[0][U8(x >> 0)] ^ QMDS[1][U8(x >> 8)] ^
+ QMDS[2][U8(x >> 16)] ^ QMDS[3][U8(x >> 24)]);
- { q1, q0, q0, q1, q1 },
- { q0, q0, q1, q1, q0 },
- { q1, q1, q0, q0, q0 },
- { q0, q1, q1, q0, q1 }
+ { Q1, Q0, Q0, Q1, Q1 },
+ { Q0, Q0, Q1, Q1, Q0 },
+ { Q1, Q1, Q0, Q0, Q0 },
+ { Q0, Q1, Q1, Q0, Q1 }
- for (i = 0; i < 4; i++) pt[i] = 0; twofish_eblk(&k, pt, ct);
+ for (i = 0; i < 4; i++) pt[i] = 0;
+ twofish_eblk(&k, pt, ct);
for (i = 0; i < 4; i++) STORE32_L(fk->t1 + i * 4, ct[i]);
pt[0] = 1; twofish_eblk(&k, pt, ct);
for (i = 0; i < 4; i++) STORE32_L(fk->t1 + 4 + i * 4, ct[i]);
for (i = 0; i < 4; i++) STORE32_L(fk->t1 + i * 4, ct[i]);
pt[0] = 1; twofish_eblk(&k, pt, ct);
for (i = 0; i < 4; i++) STORE32_L(fk->t1 + 4 + i * 4, ct[i]);