diff options
author | andreasnaive <andreasnaive@gmail.com> | 2015-01-23 12:41:46 +0100 |
---|---|---|
committer | andreasnaive <andreasnaive@gmail.com> | 2015-01-23 12:41:46 +0100 |
commit | 34e78381dd791754effd2a9c59980e9aca3b0fa1 (patch) | |
tree | aade5d27cf8059003a098076868da1fe0501cf8b | |
parent | 2d38bb00cac913f56744d115cdb76f61b9a4c0be (diff) |
315-5881_crypt.c: Key scheduling simplifications [Andreas Naive]
-rw-r--r-- | src/mame/machine/315-5881_crypt.c | 50 | ||||
-rw-r--r-- | src/mame/machine/315-5881_crypt.h | 4 |
2 files changed, 25 insertions, 29 deletions
diff --git a/src/mame/machine/315-5881_crypt.c b/src/mame/machine/315-5881_crypt.c index 3ba3f0281c4..6431303016b 100644 --- a/src/mame/machine/315-5881_crypt.c +++ b/src/mame/machine/315-5881_crypt.c @@ -234,10 +234,10 @@ const sega_315_5881_crypt_device::sbox sega_315_5881_crypt_device::fn1_sboxes[4] { { - 2,2,2,3,1,1,0,1,0,1,2,2,3,3,0,2,0,3,2,3,3,0,2,1,0,3,1,0,0,2,3,2, - 3,2,0,3,2,0,1,0,3,3,1,1,2,2,2,0,2,1,3,1,1,1,1,2,2,2,3,0,1,3,0,0, + 2,2,2,3,1,1,0,1,3,3,1,1,2,2,2,0,0,3,2,3,3,0,2,1,2,2,3,0,1,3,0,0, + 3,2,0,3,2,0,1,0,0,1,2,2,3,3,0,2,2,1,3,1,1,1,1,2,0,3,1,0,0,2,3,2, }, - {1,2,5,6,7,-1}, + {1,2,5,6,7,6}, {2,7} }, @@ -341,10 +341,10 @@ const sega_315_5881_crypt_device::sbox sega_315_5881_crypt_device::fn2_sboxes[4] { { - 0,2,3,2,1,1,0,0,2,1,0,3,3,0,0,0,3,2,0,2,1,1,2,1,0,0,3,1,2,2,3,1, - 3,1,3,0,0,0,1,3,1,0,0,3,2,2,3,1,1,3,0,0,2,1,3,3,1,3,1,2,3,1,2,1, + 0,1,3,0,1,1,2,3,2,0,0,3,2,1,3,1,3,3,0,0,1,0,0,3,0,3,3,2,3,2,0,1, + 3,2,3,2,2,1,3,1,1,1,0,3,3,2,2,1,1,2,0,2,0,1,1,0,1,0,1,1,2,0,3,0, }, - {0,3,5,6,-1,-1}, + {0,3,5,6,5,0}, {1,2} }, @@ -387,10 +387,10 @@ const sega_315_5881_crypt_device::sbox sega_315_5881_crypt_device::fn2_sboxes[4] { { - 1,2,3,2,0,3,2,3,0,1,1,0,0,2,2,3,2,0,0,3,0,2,3,3,2,2,1,0,2,1,0,3, - 1,0,2,0,1,1,0,1,0,0,1,0,3,0,3,3,2,2,0,2,1,1,1,0,3,0,1,3,2,3,2,1, + 1,0,3,0,0,1,2,1,0,0,1,0,0,0,2,3,2,2,0,2,0,1,3,0,2,0,1,3,2,3,0,1, + 1,2,2,2,1,3,0,3,0,1,1,0,3,2,3,3,2,0,0,3,1,2,1,3,3,2,1,0,2,1,2,3, }, - {2,3,4,6,7,-1}, + {2,3,4,6,7,2}, {2,3} }, @@ -406,10 +406,10 @@ const sega_315_5881_crypt_device::sbox sega_315_5881_crypt_device::fn2_sboxes[4] { // 3rd round { { - 0,3,0,1,0,2,3,3,1,0,1,3,2,2,1,1,3,3,3,0,2,0,2,0,0,0,2,3,1,1,0,0, - 3,3,0,3,3,0,0,2,1,1,1,0,2,2,2,0,3,0,3,1,2,2,0,3,0,0,3,2,0,3,2,1, + 0,3,0,1,3,0,0,2,1,0,1,3,2,2,2,0,3,3,3,0,2,2,0,3,0,0,2,3,0,3,2,1, + 3,3,0,3,0,2,3,3,1,1,1,0,2,2,1,1,3,0,3,1,2,0,2,0,0,0,3,2,1,1,0,0, }, - {1,4,5,6,7,-1}, + {1,4,5,6,7,5}, {0,5} }, @@ -424,11 +424,11 @@ const sega_315_5881_crypt_device::sbox sega_315_5881_crypt_device::fn2_sboxes[4] { { - 2,2,3,2,0,3,2,3,1,1,2,0,2,3,1,3,0,0,0,3,2,0,1,0,1,3,2,3,3,3,1,0, + 2,2,0,3,0,3,1,0,1,1,2,3,2,3,1,0,0,0,3,2,2,0,2,3,1,3,2,0,3,3,1,3, // unused? 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, }, - {1,2,4,7,-1,-1}, + {1,2,4,7,2,-1}, {2,4} }, @@ -481,19 +481,18 @@ const sega_315_5881_crypt_device::sbox sega_315_5881_crypt_device::fn2_sboxes[4] }; const int sega_315_5881_crypt_device::fn1_game_key_scheduling[FN1GK][2] = { - {1,29}, {1,71}, {2,4}, {2,54}, {3,8}, {4,56}, {4,73}, {5,11}, - {6,51}, {7,92}, {8,89}, {9,9}, {9,39}, {9,41}, {9,58}, {9,86}, - {10,90}, {11,6}, {12,64}, {13,49}, {14,44}, {15,40}, {16,69}, {17,15}, - {18,23}, {18,43}, {19,82}, {20,81}, {21,32}, {22,5}, {23,66}, {24,13}, - {24,45}, {25,12}, {25,35}, {26,61}, {27,10}, {27,59}, {28,25} + {1,29}, {1,71}, {2,4}, {2,54}, {3,8}, {4,56}, {4,73}, {5,11}, + {6,51}, {7,92}, {8,89}, {9,9}, {9,39}, {9,58}, {9,86}, {10,90}, + {11,6}, {12,64}, {13,49}, {14,44}, {15,40}, {16,69}, {17,15}, {18,23}, + {18,43}, {19,82}, {20,81}, {21,32}, {22,5}, {23,66}, {24,13}, {24,45}, + {25,12}, {25,35}, {26,61}, {27,10}, {27,59}, {28,25} }; const int sega_315_5881_crypt_device::fn2_game_key_scheduling[FN2GK][2] = { - {0,0}, {1,3}, {2,11}, {3,20}, {4,22}, {5,23}, {6,29}, {7,38}, - {8,39}, {9,55}, {9,86}, {9,87}, {9,90}, {10,50}, {10,53}, {11,57}, - {12,59}, {13,61}, {13,64}, {14,63}, {15,67}, {16,72}, {17,83}, {18,88}, - {19,94}, {20,35}, {21,17}, {22,6}, {22,11}, {23,85}, {24,16}, {25,25}, - {26,92}, {27,47}, {28,28} + {0,0}, {1,3}, {2,11}, {3,20}, {4,22}, {5,23}, {6,29}, {7,38}, + {8,39}, {9,55}, {9,86}, {9,87}, {9,90}, {10,50}, {11,57}, {12,59}, + {13,61}, {14,63}, {15,67}, {16,72}, {17,83}, {18,88}, {19,94}, {20,35}, + {21,17}, {22,6}, {23,85}, {24,16}, {25,25}, {26,92}, {27,47}, {28,28} }; const int sega_315_5881_crypt_device::fn1_sequence_key_scheduling[20][2] = { @@ -583,9 +582,6 @@ UINT16 sega_315_5881_crypt_device::block_decrypt(UINT32 game_key, UINT16 sequenc } } - // subkeys bits 10 & 41 - fn2_subkeys[0] ^= (BIT(sequence_key, 2) << 10); - fn2_subkeys[1] ^= (BIT(sequence_key, 4) << 17); /**************************************************************/ // First Feistel Network diff --git a/src/mame/machine/315-5881_crypt.h b/src/mame/machine/315-5881_crypt.h index 15a4661d2b5..3fb0f01bde1 100644 --- a/src/mame/machine/315-5881_crypt.h +++ b/src/mame/machine/315-5881_crypt.h @@ -74,8 +74,8 @@ private: static const sbox fn1_sboxes[4][4]; static const sbox fn2_sboxes[4][4]; - static const int FN1GK = 39; - static const int FN2GK = 35; + static const int FN1GK = 38; + static const int FN2GK = 32; static const int fn1_game_key_scheduling[FN1GK][2]; static const int fn2_game_key_scheduling[FN2GK][2]; static const int fn1_sequence_key_scheduling[20][2]; |