diff options
-rw-r--r-- | src/cipher/turing/turing.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/src/cipher/turing/turing.cpp b/src/cipher/turing/turing.cpp index 16420a1ed..204771e06 100644 --- a/src/cipher/turing/turing.cpp +++ b/src/cipher/turing/turing.cpp @@ -95,26 +95,30 @@ void Turing::generate() 0x6131A7D0, 0xB11AE4B7, 0x78DEE220, 0xA8F5A147, 0x958864EE, 0x45A32789, 0xEF72A3F1, 0x3F59E096, 0x0224253F, 0xD20F6658 }; - const byte OFFSETS[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 14, 15, 16, 0, 0, 0, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 0, 2, 3, 4, 0, 0, 0, 10, 11, 12, 13, 14, 15, - 16, 0, 1, 5, 7, 8, 9, 0, 0, 0, 15, 16, 0, 1, 2, 3, 4, 5, 6, 10, - 12, 13, 14, 0, 0, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 0, 1, 2, - 0, 0, 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 3, 5, 6, 7, 0, 0, 0, - 13, 14, 15, 16, 0, 1, 2, 3, 4, 8, 10, 11, 12, 0, 0, 0, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 13, 15, 16, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 1, 3, 4, 5, 0, 0, 0, 11, 12, 13, 14, 15, 16, 0, 1, - 2, 6, 8, 9, 10, 0, 0, 0, 16, 0, 1, 2, 3, 4, 5, 6, 7, 11, 13, 14, - 15, 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 1, 2, 3, 0, 0, 0, - 9, 10, 11, 12, 13, 14, 15, 16, 0, 4, 6, 7, 8, 0, 0, 0, 14, 15, - 16, 0, 1, 2, 3, 4, 5, 9, 11, 12, 13, 0, 0, 0, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 14, 16, 0, 1, 0, 0, 0, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 2, 4, 5, 6, 0, 0, 0, 12, 13, 14, 15, 16, 0, 1, 2, 3, 7, 9, - 10, 11, 0, 0, 0 }; + const byte OFFSETS[221] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 14, 15, 16, +5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 2, 3, 4, +10, 11, 12, 13, 14, 15, 16, 0, 1, 5, 7, 8, 9, +15, 16, 0, 1, 2, 3, 4, 5, 6, 10, 12, 13, 14, +3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 0, 1, 2, +8, 9, 10, 11, 12, 13, 14, 15, 16, 3, 5, 6, 7, +13, 14, 15, 16, 0, 1, 2, 3, 4, 8, 10, 11, 12, +1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 15, 16, 0, +6, 7, 8, 9, 10, 11, 12, 13, 14, 1, 3, 4, 5, +11, 12, 13, 14, 15, 16, 0, 1, 2, 6, 8, 9, 10, +16, 0, 1, 2, 3, 4, 5, 6, 7, 11, 13, 14, 15, +4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 1, 2, 3, +9, 10, 11, 12, 13, 14, 15, 16, 0, 4, 6, 7, 8, +14, 15, 16, 0, 1, 2, 3, 4, 5, 9, 11, 12, 13, +2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 16, 0, 1, +7, 8, 9, 10, 11, 12, 13, 14, 15, 2, 4, 5, 6, +12, 13, 14, 15, 16, 0, 1, 2, 3, 7, 9, 10, 11, + + }; for(u32bit j = 0; j != 17; ++j) { - const byte* R_off = OFFSETS + 16*j; + const byte* R_off = OFFSETS + 13*j; u32bit R0 = R[R_off[0]]; u32bit R1 = R[R_off[1]]; @@ -127,11 +131,11 @@ void Turing::generate() const u32bit R8 = R[R_off[8]]; const u32bit R9 = R[R_off[9]]; const u32bit R10 = R[R_off[10]]; - // yes, R_off[11] unused!! - const u32bit R11 = R[R_off[12]]; + const u32bit R11 = R[R_off[11]]; + const u32bit R12 = R[R_off[12]]; R[R_off[0]] = R0 = - ((R0 << 8) ^ MULT_TAB[(R0 >> 24) & 0xFF]) ^ R[R_off[11]] ^ R4; + ((R0 << 8) ^ MULT_TAB[(R0 >> 24) & 0xFF]) ^ R11 ^ R4; u32bit A = R0; u32bit B = R10; @@ -157,7 +161,7 @@ void Turing::generate() A += E; B += E; C += E; D += E; R[R_off[1]] = R1 = - ((R1 << 8) ^ MULT_TAB[(R1 >> 24) & 0xFF]) ^ R11 ^ R5; + ((R1 << 8) ^ MULT_TAB[(R1 >> 24) & 0xFF]) ^ R12 ^ R5; R[R_off[2]] = R2 = ((R2 << 8) ^ MULT_TAB[(R2 >> 24) & 0xFF]) ^ R0 ^ R6; @@ -169,7 +173,7 @@ void Turing::generate() R[R_off[4]] = ((R4 << 8) ^ MULT_TAB[(R4 >> 24) & 0xFF]) ^ R2 ^ R8; A += R1; - B += R11; + B += R12; C += R9; D += R5; |