From a9c643e69824f1cc92a890e5854e7cedca2b8537 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 1 Nov 2020 11:20:57 -0600 Subject: [PATCH] WiimoteEmu: Implement extension encryption edge case. --- Source/Core/Core/HW/WiimoteEmu/Encryption.cpp | 588 +++++++++++------- Source/Core/Core/HW/WiimoteEmu/Encryption.h | 11 +- 2 files changed, 358 insertions(+), 241 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteEmu/Encryption.cpp b/Source/Core/Core/HW/WiimoteEmu/Encryption.cpp index 83d5314f9f..9d60718e8d 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Encryption.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Encryption.cpp @@ -10,30 +10,106 @@ #include "Common/BitUtils.h" #include "Common/Logging/Log.h" - namespace { -constexpr u8 sboxes[18][256] = { - { - 0x70, 0x51, 0x03, 0x86, 0x40, 0x0d, 0x4f, 0xeb, 0x3e, 0xcc, 0xd1, 0x87, 0x35, 0xbd, 0xf5, - 0x0b, 0x5e, 0xd0, 0xf8, 0xf2, 0xd5, 0xe2, 0x6c, 0x31, 0x0c, 0xad, 0xfc, 0x21, 0xc3, 0x78, - 0xc1, 0x06, 0xc2, 0x4c, 0x55, 0xe6, 0x4a, 0x34, 0x48, 0x11, 0x1e, 0xda, 0xe7, 0x1a, 0x84, - 0xa0, 0x96, 0xa7, 0xe3, 0x7f, 0xaf, 0x63, 0x9c, 0xfa, 0x23, 0x5b, 0x79, 0xc8, 0x9e, 0xba, - 0xb2, 0xc9, 0x22, 0x12, 0x4b, 0xb3, 0xa1, 0xb6, 0x32, 0x49, 0xa2, 0xe1, 0x89, 0x39, 0x10, - 0x66, 0xc5, 0x07, 0x8f, 0x54, 0xea, 0x91, 0xca, 0x3f, 0xf9, 0x19, 0xf0, 0xd7, 0x46, 0xbc, - 0x28, 0x1b, 0x61, 0xe8, 0x2f, 0x6a, 0xae, 0x9d, 0xf6, 0x4e, 0x09, 0x14, 0x77, 0x4d, 0xdb, - 0x1f, 0x2e, 0x7b, 0x7c, 0xf1, 0x43, 0xa3, 0x00, 0xb8, 0x13, 0x8c, 0x85, 0xb9, 0x29, 0x75, - 0x88, 0xfd, 0xd2, 0x56, 0x1c, 0x50, 0x97, 0x41, 0xe5, 0x3b, 0x60, 0xb5, 0xc0, 0x64, 0xee, - 0x98, 0xd6, 0x2d, 0x25, 0xa4, 0xaa, 0xcd, 0x7d, 0xa8, 0x83, 0xc6, 0xab, 0xbe, 0x44, 0x99, - 0x26, 0x3c, 0xce, 0x9f, 0xbf, 0xd3, 0xcb, 0x76, 0x7a, 0x7e, 0x82, 0x01, 0x8a, 0x9a, 0x80, - 0x1d, 0x0e, 0xb0, 0x5c, 0xd4, 0x38, 0x62, 0xf4, 0x30, 0xe0, 0x8e, 0x53, 0xb7, 0x02, 0x57, - 0xac, 0xa6, 0x52, 0x0a, 0x6d, 0x92, 0x65, 0x17, 0x24, 0x33, 0x45, 0x72, 0x74, 0xb1, 0xb4, - 0xf7, 0x5d, 0xed, 0x2c, 0xff, 0x47, 0x37, 0x5a, 0x90, 0xbb, 0xdf, 0x2a, 0x16, 0x59, 0x95, - 0xd9, 0xc4, 0x27, 0x67, 0x73, 0xc7, 0x68, 0xfe, 0xa5, 0xdd, 0x6b, 0x5f, 0x93, 0xd8, 0xec, - 0x05, 0x3a, 0x8d, 0x6e, 0xfb, 0x3d, 0xa9, 0x69, 0x36, 0xf3, 0x94, 0xde, 0xef, 0x15, 0x6f, - 0x8b, 0x9b, 0x08, 0x0f, 0xdc, 0x81, 0x18, 0x20, 0x04, 0xe4, 0x71, 0xcf, 0xe9, 0x2b, 0x42, - 0x58, - }, +using WiimoteEmu::SBox; + +constexpr SBox fallback_sbox_1st_party_a = { + 0x00, 0x3b, 0x4c, 0x89, 0x7b, 0xa5, 0x77, 0x17, 0xff, 0x9e, 0x9b, 0x9c, 0x4d, 0xa3, 0xe1, 0x0c, + 0xf2, 0x47, 0x6a, 0xee, 0x3c, 0x8d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x2c, 0x59, 0x26, 0x21, + 0x38, 0xcc, 0x37, 0x29, 0x95, 0x1d, 0x16, 0x84, 0xf8, 0x9a, 0x7d, 0x6f, 0x56, 0xd2, 0xb2, 0x79, + 0x86, 0x6e, 0x3e, 0x1a, 0x7e, 0xed, 0x69, 0x08, 0xba, 0x5b, 0xf6, 0xa0, 0x11, 0x23, 0x02, 0x30, + 0xc2, 0xe5, 0xac, 0x82, 0xd8, 0x97, 0x8b, 0x20, 0x6b, 0xa1, 0xde, 0xdb, 0xaf, 0x5d, 0x76, 0xa4, +}; + +constexpr SBox fallback_sbox_1st_party_b = { + 0x00, 0xa1, 0xa8, 0x63, 0xd7, 0x3e, 0x84, 0xa6, 0xb7, 0xd5, 0xfb, 0x14, 0x67, 0x16, 0x08, 0xbc, + 0x5c, 0x15, 0x35, 0x27, 0x58, 0x73, 0x90, 0x55, 0x07, 0x4e, 0xf9, 0xb1, 0x5a, 0x75, 0x92, 0x98, + 0x8d, 0xf3, 0x44, 0xcc, 0xeb, 0x4f, 0xac, 0x11, 0x4b, 0xe4, 0xcb, 0xef, 0xde, 0xc7, 0x6e, 0x9e, + 0x89, 0x8f, 0x03, 0xcd, 0x09, 0xa9, 0x76, 0x95, 0x6c, 0x20, 0xb0, 0x29, 0xe5, 0x38, 0x78, 0x97, + 0x61, 0x70, 0x80, 0x17, 0x2f, 0xe7, 0x79, 0xb8, 0xc5, 0x47, 0x9b, 0x43, 0xaf, 0xb6, 0x7d, 0x42, + 0xb2, 0x23, 0x1b, 0x87, 0xc3, 0x33, 0x3c, 0x2c, 0x9d, 0xd3, 0x28, 0xe8, 0x62, 0x9a, 0xd0, 0x30, + 0x39, 0x5f, 0x1f, 0x37, 0x40, 0xba, 0x02, 0x19, 0x2a, 0x3f, 0xbe, 0x69, 0x60, 0xfd, 0x53, 0xc1, + 0xdf, 0xe1, 0x0b, 0x59, 0x12, 0x5b, 0x01, 0xbf, 0x1d, 0x91, 0x0f, 0x52, 0x13, 0xfc, 0xe3, 0x6f, + 0xbb, 0xcf, 0x25, 0x26, 0x45, 0x7e, 0x86, 0xa2, 0xa0, 0xd4, 0x51, 0x41, 0xe2, 0xf8, 0x82, 0xf6, + 0xc6, 0xa3, 0x34, 0xc9, 0xda, 0x18, 0xaa, 0x2e, 0x10, 0x24, 0xec, 0x32, 0x9f, 0x54, 0xe0, 0x49, + 0xae, 0x72, 0x85, 0xdb, 0x2b, 0xab, 0x50, 0xea, 0x9c, 0x94, 0xb3, 0xca, 0xe6, 0x71, 0x81, 0xff, + 0x4d, 0x64, 0x05, 0xee, 0xc4, 0xf0, 0xc2, 0x3b, 0xb5, 0xf4, 0x5e, 0x22, 0x88, 0xdc, 0x31, 0xa4, + 0x8a, 0xd2, 0xf7, 0xdd, 0x4c, 0x65, 0xd6, 0xf1, 0x8e, 0xed, 0x57, 0x36, 0x5d, 0xa5, 0x0c, 0x06, + 0x77, 0x8b, 0x2d, 0x0a, 0xb4, 0xd9, 0xc0, 0x1e, 0xe9, 0x3a, 0xf5, 0x4a, 0x1a, 0x46, 0x6d, 0x48, + 0x66, 0x7a, 0x93, 0xce, 0x74, 0x7f, 0x21, 0xd8, 0x7c, 0x3d, 0x96, 0x7b, 0xd1, 0x04, 0x6a, 0x0e, + 0x1c, 0xfa, 0x83, 0x99, 0x56, 0x8c, 0xf2, 0x6b, 0xbd, 0xad, 0xc8, 0xa7, 0xfe, 0xb9, 0x68, 0x0d, +}; + +constexpr SBox fallback_sbox_3rd_party_a = { + 0x00, 0xd8, 0x64, 0x01, 0x32, 0x7c, 0x2a, 0x1c, 0x84, 0xcc, 0xde, 0xee, 0xbe, 0xb2, 0x1a, 0xaf, + 0xd7, 0xa8, 0xc6, 0xb0, 0x11, 0x8a, 0x81, 0xbc, 0xd2, 0x50, 0x4c, 0x6a, 0x85, 0x83, 0xb3, 0x07, + 0x30, 0x31, 0x91, 0x5f, 0xf6, 0x26, 0x58, 0xbf, 0xc8, 0x54, 0x62, 0x6b, 0xba, 0xa0, 0x2d, 0x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0xac, 0xc0, 0xfa, 0x7b, 0xa2, 0x80, 0x4b, 0xf9, 0x40, 0x4d, + 0x4e, 0xe5, 0x5a, 0x86, 0xc7, 0x67, 0xc1, 0xe0, 0x74, 0x63, 0x0c, 0xa5, 0x55, 0x5c, 0x03, 0xec, +}; + +constexpr SBox fallback_sbox_3rd_party_b = { + 0x00, 0xf9, 0x8e, 0xa5, 0x0d, 0x22, 0x24, 0xdc, 0x6e, 0x70, 0x17, 0xd6, 0xa7, 0x59, 0x09, 0x94, + 0xe1, 0xf1, 0xcc, 0x84, 0x3d, 0x99, 0x75, 0xa1, 0x44, 0xbf, 0x9c, 0xfd, 0x37, 0x9a, 0x02, 0x67, + 0x9e, 0x68, 0x33, 0xb7, 0x1a, 0xe5, 0x9d, 0xaf, 0x5a, 0x4b, 0x54, 0x01, 0x45, 0x1e, 0xd3, 0x8d, + 0x7f, 0xc1, 0x5f, 0xa3, 0x87, 0x28, 0x32, 0x30, 0x16, 0x52, 0xd7, 0xc5, 0x69, 0xb4, 0xb8, 0xf0, + 0xab, 0x86, 0xa0, 0x3e, 0x6a, 0x76, 0x63, 0xe6, 0x57, 0x88, 0x07, 0x19, 0x34, 0x48, 0xfa, 0xc6, + 0x64, 0x2f, 0x4d, 0x35, 0x6d, 0xb0, 0x90, 0x13, 0x2d, 0x55, 0xbe, 0xe3, 0x74, 0x61, 0x7a, 0x40, + 0xbc, 0x95, 0x05, 0xb3, 0x96, 0xc7, 0x25, 0x2e, 0x21, 0x8b, 0x2a, 0x79, 0xae, 0xeb, 0xf3, 0x10, + 0xd5, 0x39, 0x4f, 0xca, 0xd8, 0x0f, 0x60, 0xde, 0x62, 0x51, 0xcf, 0x65, 0x1f, 0x0e, 0x23, 0x78, + 0x31, 0xc8, 0xc4, 0xad, 0xf4, 0xda, 0xba, 0xc0, 0xed, 0xf2, 0xf8, 0xa8, 0x3f, 0x36, 0x9b, 0x8c, + 0x20, 0x3b, 0x6b, 0xa2, 0x9f, 0xff, 0x11, 0x29, 0x27, 0xf6, 0x04, 0x71, 0x7d, 0x03, 0x85, 0x06, + 0x7e, 0xdd, 0xea, 0xfe, 0x83, 0x6f, 0xe4, 0x73, 0xb6, 0x98, 0x08, 0xee, 0x8f, 0x15, 0x56, 0x1b, + 0x38, 0x41, 0x4a, 0xfb, 0xdb, 0x14, 0x4c, 0xe0, 0x26, 0xd4, 0xb9, 0x43, 0xcb, 0xaa, 0x42, 0x49, + 0x80, 0x5e, 0x72, 0x3a, 0xd9, 0xe2, 0x2c, 0xc2, 0xec, 0x8a, 0xe9, 0x53, 0x18, 0x3c, 0x47, 0xd2, + 0xef, 0x93, 0x92, 0xf7, 0x0c, 0xbb, 0x97, 0xd0, 0x5b, 0x81, 0xc3, 0xbd, 0x58, 0x12, 0xdf, 0xe8, + 0x5c, 0xac, 0xf5, 0x2b, 0x89, 0xb1, 0xc9, 0x50, 0xd1, 0x1d, 0x4e, 0x46, 0x0b, 0xfc, 0x7c, 0x77, + 0x1c, 0xa4, 0x66, 0xb5, 0x6c, 0x82, 0xce, 0xe7, 0xb2, 0xa6, 0x5d, 0x7b, 0x91, 0xcd, 0xa9, 0x0a, +}; + +constexpr SBox keygen_sbox_1st_party = { + 0x70, 0x51, 0x03, 0x86, 0x40, 0x0d, 0x4f, 0xeb, 0x3e, 0xcc, 0xd1, 0x87, 0x35, 0xbd, 0xf5, 0x0b, + 0x5e, 0xd0, 0xf8, 0xf2, 0xd5, 0xe2, 0x6c, 0x31, 0x0c, 0xad, 0xfc, 0x21, 0xc3, 0x78, 0xc1, 0x06, + 0xc2, 0x4c, 0x55, 0xe6, 0x4a, 0x34, 0x48, 0x11, 0x1e, 0xda, 0xe7, 0x1a, 0x84, 0xa0, 0x96, 0xa7, + 0xe3, 0x7f, 0xaf, 0x63, 0x9c, 0xfa, 0x23, 0x5b, 0x79, 0xc8, 0x9e, 0xba, 0xb2, 0xc9, 0x22, 0x12, + 0x4b, 0xb3, 0xa1, 0xb6, 0x32, 0x49, 0xa2, 0xe1,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x58, +}; + +constexpr std::array sboxes_1st_party = {{ { 0x01, 0xa0, 0xa9, 0x62, 0xd6, 0x3f, 0x85, 0xa7, 0xb6, 0xd4, 0xfa, 0x15, 0x66, 0x17, 0x09, 0xbd, 0x5d, 0x14, 0x34, 0x26, 0x59, 0x72, 0x91, 0x54, 0x06, 0x4f, 0xf8, 0xb0, 0x5b, 0x74, @@ -194,212 +270,214 @@ constexpr u8 sboxes[18][256] = { 0x54, 0x73, 0x3a, 0x14, 0x4e, 0x01, 0x1d, 0xb6, 0xfd, 0x37, 0x48, 0x4d, 0x39, 0xcb, 0xe0, 0x32, }, - { - 0x54, 0x29, 0x28, 0x4e, 0x0f, 0xfc, 0xa4, 0x6c, 0x87, 0x50, 0x49, 0x3c, 0xf2, 0xb4, 0xb1, - 0xf9, 0xc3, 0x58, 0x2e, 0x83, 0x5f, 0x71, 0x8a, 0x9b, 0x82, 0xca, 0xc2, 0xbe, 0xba, 0x75, - 0x91, 0x60, 0x78, 0xa8, 0x2a, 0x4c, 0x25, 0x5b, 0x8b, 0xb0, 0xda, 0xaf, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xa4, 0x38, 0x33, 0x69, 0xd4, 0xf5, 0x6a, 0xa8, 0xd7, 0xec, 0x74, 0xa6, - 0x7b, 0xc7, 0x3c, 0x41, 0xb7, 0x21, 0x98, 0x4a, 0x8d, 0xc8, 0x28, 0xf3, 0xf8, 0x32, 0x91, - 0xab, 0xad, 0x34, 0x86, 0x30, 0x4c, 0xbc, 0xff, 0xce, 0x14, 0x1e, 0x2e, 0xf9, 0x31, 0x59, - 0x85, 0x87, 0xfc, 0xc2, 0xfd, 0x3e, 0xbb, 0x56, 0x88, 0x8b, 0xbf, 0x47, 0x61, 0x92, 0xb1, - 0x94, 0x7a, 0x51, 0x9c, 0x8f, 0xb0, 0x49, 0x9b, 0xb9, 0x05, 0x36, 0x10, 0x3b, 0xd5, 0xd3, - 0x0c, 0x96, 0xcb, 0x79, 0x60, 0x4e, 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d, 0xff, 0x92, 0x68, 0xe0, 0x81, 0x69, 0x62, - 0xab, 0x75, 0x59, 0x11, 0xf2, 0xc9, 0x07, 0xe9, 0xc7, 0xa1, 0xc2, 0x78, 0x33, 0x17, 0x6c, - 0xf9, - }, - { - 0xc4, 0xb8, 0xb9, 0xdc, 0x27, 0x90, 0xbc, 0xfb, 0x70, 0xaa, 0xe8, 0x96, 0x73, 0x39, 0xf4, - 0xc3, 0x77, 0x87, 0xde, 0x00, 0xa2, 0x9a, 0xe2, 0x7b, 0xfa, 0x36, 0x65, 0x6d, 0x20, 0xd7, - 0x57, 0x5c, 0x37, 0x8f, 0x4d, 0x9e, 0x47, 0xa9, 0xe5, 0xcc, 0x99, 0x8d, 0x76, 0x50, 0xba, - 0xe6, 0x82, 0x21, 0xb0, 0x0d, 0xeb, 0x75, 0x6d, 0x22, 0xce, 0xe7, 0x63, 0x2c, 0xde, 0xe2, - 0xf5, 0x45, 0xba, 0x44, 0x95, 0x1f, 0xe5, 0x39, 0xd7, 0xa5, 0xb5, 0x8d, 0x07, 0x93, 0xfd, - 0xbc, 0x62, 0x7e, 0x89, 0xb3, 0x48, 0x59, 0x7f, 0xd3, 0xbe, 0xd0, 0xf2, 0x36, 0x53, 0x9f, - 0xe6, 0xb1, 0x82, 0xc0, 0x94, 0xb8, 0x2f, 0x03, 0x24, 0x3c, 0x00, 0x0a, 0x42, 0x65, 0xe8, - 0x5c, 0x96, 0xd5, 0xa9, 0x90, 0xb9, 0x85, 0xe9, 0xea, 0x0e, 0x16, 0x7b, 0x84, 0x29, 0x4e, - 0x5e, 0x87, 0x9d, 0x35, 0x06, 0x86, 0xe1, 0xe0, 0xe3, 0xec, 0xef, 0xc8, 0x52, 0x5f, 0x64, - 0xe4, 0x46, 0x30, 0x5a, 0xcd, 0xed, 0xd1, 0x51, 0x81, 0x0c, 0x3a, 0x66, 0xfe, 0x04, 0x67, - 0x1e, 0xd6, 0xf7, 0x8c, 0xbd, 0x33, 0xb2, 0x91, 0xd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e3, 0x18, 0xb9, 0x4b, 0x74, 0xe5, 0x01, - 0x8e, 0xb1, 0x27, 0x35, 0xb4, 0x3d, 0x26, 0x48, 0x1f, 0xfa, 0xbb, 0x90, 0xd3, 0x98, 0xdf, - 0xa4, 0x37, 0x67, 0x5d, 0x80, 0xd2, 0x62, 0xe1, 0x6f, 0x96, 0x2d, 0xa8, 0x6a, 0x97, 0x30, - 0x89, 0xea, 0x3a, 0xbe, 0x22, 0x19, 0x41, 0xac, 0x79, 0xf1, 0x85, 0xee, 0x70, 0xc0, 0x0a, - 0x1b, 0x7f, 0xc1, 0xd0, 0xa6, 0xf4, 0x16, 0xfc, 0xba, 0x4e, 0x4a, 0xc9, 0x12, 0x8a, 0x1a, - 0x9d, 0xc5, 0x38, 0xd4, 0xde, 0xad, 0xc4, 0x43, 0x03, 0xb3, 0xf7, 0xa9, 0x59, 0x6d, 0xa3, - 0x20, 0x36, 0x4d, 0x86, 0x5b, 0xae, 0x61, 0x17, 0xa5, 0x93, 0xdc, 0x50, 0x2c, 0xef, 0x2a, - 0x68, 0x75, 0x7a, 0x8b, 0xd6, 0xfb, 0x00, 0x9e, 0x2e, 0x02, 0xcd, 0xed, 0x47, 0xab, 0x82, - 0xbd, 0x71, 0x11, 0xb2, 0x66, 0x5e, 0x3c, 0x7c, 0x08, 0x6e, 0xf6, 0x09, 0x45, 0x3f, 0x5a, - 0x0f, 0x84, 0xcc, 0xdd, 0x73, 0x0d, 0xf8, 0x92, 0xe8, 0x0b, 0xe9, 0xcf, 0x4f, 0x1c, 0xda, - 0x10, 0x0e, 0x9f, 0xa2, 0x58, 0xff, 0x40, 0x87, 0x77, 0x2f, 0x60, 0x4c, 0xc3, 0x28, 0x88, - 0x15, 0x81, 0x06, 0x56, 0xd1, 0x55, 0x8d, 0x9b, 0x57, 0x83, 0x65, 0x91, 0x34, 0xce, 0x53, - 0x42, - }, - { - 0x04, 0x0c, 0x46, 0x7d, 0x07, 0x29, 0xfe, 0x24, 0x2b, 0x6c,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+}}; + +constexpr SBox keygen_sbox_3rd_party = { + 0xa4, 0x38, 0x33, 0x69, 0xd4, 0xf5, 0x6a, 0xa8, 0xd7, 0xec, 0x74, 0xa6, 0x7b, 0xc7, 0x3c, 0x41, + 0xb7, 0x21, 0x98, 0x4a, 0x8d, 0xc8, 0x28, 0xf3, 0xf8, 0x32, 0x91, 0xab, 0xad, 0x34, 0x86, 0x30, + 0x4c, 0xbc, 0xff, 0xce, 0x14, 0x1e, 0x2e, 0xf9, 0x31, 0x59, 0x85, 0x87, 0xfc, 0xc2, 0xfd, 0x3e, + 0xbb, 0x56, 0x88, 0x8b, 0xbf, 0x47, 0x61, 0x92, 0xb1, 0x94, 0x7a, 0x51, 0x9c, 0x8f, 0xb0, 0x49, + 0x9b, 0xb9, 0x05, 0x36, 0x10, 0x3b, 0xd5, 0xd3, 0x0c, 0x96, 0xcb, 0x79, 0x60, 0x4e, 0xa2, 0xb5, + 0xd1, 0xee, 0x17, 0xba, 0x1f, 0x09, 0x78, 0x93, 0xb4, 0x35, 0x3a, 0x9d, 0x1d, 0x39, 0xc9, 0x3f, + 0x7c, 0x2f, 0xca, 0x0b, 0x37, 0xe6, 0x1b, 0xd0, 0x67, 0xd9, 0x18, 0x84, 0xe1, 0x42, 0x5a, 0x7e, + 0xb8, 0x97, 0xdf, 0x54, 0x70, 0x03, 0x6e, 0xdb, 0x63, 0xae, 0x55, 0x5d, 0xc4, 0x4b, 0x89, 0xcc, + 0x13, 0xb3, 0x90, 0xf6, 0xe9, 0xb2, 0xa3, 0xbe, 0x2d, 0x19, 0x73, 0x23, 0x20, 0x7f, 0x40, 0x02, + 0x9e, 0xc3, 0x6b, 0x1a, 0x52, 0xda, 0x29, 0x80, 0x0d, 0x5f, 0xd6, 0x8e, 0x0e, 0x22, 0xe3, 0x6d, + 0xdc, 0x58, 0x75, 0xe0, 0x01, 0x0a, 0x26, 0x50, 0x08, 0xa9, 0xfe, 0x4d, 0x15, 0xf7, 0x6c, 0xcf, + 0x4f, 0xf0, 0x64, 0x5e, 0xc6, 0x68, 0x8a, 0xac, 0xde, 0xb6, 0x48, 0x66, 0xed, 0x6f, 0x71, 0x45, + 0x3d, 0xeb, 0x9f, 0x04, 0x25, 0x5c, 0xbd, 0x65, 0xdd, 0x53, 0xcd, 0x24, 0xef, 0x72, 0xe8, 0x9a, + 0xe7, 0x16, 0xc1, 0x00, 0x77, 0x2c, 0x7d, 0xa5, 0x2a, 0x44, 0x62, 0x27, 0xf4, 0xc0, 0x07, 0x1c, + 0x5b, 0x99, 0x82, 0x57, 0x06, 0xfa, 0xfb, 0x12, 0xaf, 0xa7, 0xd2, 0xaa, 0x2b, 0x8c, 0xf2, 0xd8, + 0x83, 0xa0, 0x76, 0x11, 0xc5, 0x43, 0x81, 0x46, 0xe5, 0xf1, 0xea, 0x95, 0xe2, 0xe4, 0x0f, 0xa1, }; +constexpr std::array sboxes_3rd_party = {{ + { + 0x2b, 0xd2, 0xa5, 0x8e, 0x26, 0x09, 0x0f, 0xf7, 0x45, 0x5b, 0x3c, 0xfd, 0x8c, 0x72, 0x22, + 0xbf, 0xca, 0xda, 0xe7, 0xaf, 0x16, 0xb2, 0x5e, 0x8a, 0x6f, 0x94, 0xb7, 0xd6, 0x1c, 0xb1, + 0x29, 0x4c, 0xb5, 0x43, 0x18, 0x9c, 0x31, 0xce, 0xb6, 0x84, 0x71, 0x60, 0x7f, 0x2a, 0x6e, + 0x35, 0xf8, 0xa6, 0x54, 0xea, 0x74, 0x88, 0xac, 0x03, 0x19, 0x1b, 0x3d, 0x79, 0xfc, 0xee, + 0x42, 0x9f, 0x93, 0xdb, 0x80, 0xad, 0x8b, 0x15, 0x41, 0x5d, 0x48, 0xcd, 0x7c, 0xa3, 0x2c, + 0x32, 0x1f, 0x63, 0xd1, 0xed, 0x4f, 0x04, 0x66, 0x1e, 0x46, 0x9b, 0xbb, 0x38, 0x06, 0x7e, + 0x95, 0xc8, 0x5f, 0x4a, 0x51, 0x6b, 0x97, 0xbe, 0x2e, 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0x67, 0xba, 0xea, 0xc6, 0x0f, 0xd7, 0x74, 0x85, 0xb6, 0xd8, 0x0e, 0x4c, 0x93, 0x15, + 0xbd, 0xe6, 0x78, 0x03, 0x05, 0x32, 0xf7, 0x34, 0xe4, 0xad, 0x30, 0x98, 0xa1, 0x27, 0x9e, + 0xf6, 0x43, 0x64, 0x3c, 0x49, 0xbc, 0xf0, 0x99, 0xdd, 0x12, 0xd1, 0xc9, 0x5d, 0x7c, 0x22, + 0x75, 0x1f, 0x28, 0x2f, 0x09, 0xc2, 0x84, 0x6d, 0xfa, 0x23, 0x3f, 0x7d, 0x91, 0x89, 0x82, + 0x86, 0x58, 0xdf, 0x76, 0xe9, 0xaa, 0xdb, 0xac, 0x2b, 0xf5, 0x90, 0x42, 0x20, 0xe1, 0xa0, + 0xed, 0xd4, 0x52, 0x10, 0xef, 0x3e, 0xe3, 0x1c, 0xda, 0x96, 0xb0, 0x72, 0x38, 0x9f, 0x7a, + 0x1b, 0xde, 0x02, 0xa6, 0x4e, 0x97, 0x33, 0x36, 0x6e, 0xe0, 0xc8, 0x4f, 0xfc, 0x37, 0x71, + 0xec, 0x94, 0x00, 0x95, 0xd0, 0xa7, 0xcb, 0xf1, 0x70, 0xa9, 0x8b, 0x40, 0xf2, 0x4b, 0x46, + 0x45, 0xee, 0x51, 0x8d, 0xcc, 0x6c, 0xca, 0xeb, 0x7f, 0x68, 0x07, 0xae, 0x5e, 0x57, 0x08, + 0xe7, + }, +}}; + } // namespace namespace WiimoteEmu { -void EncryptionKey::GenerateTables(const RandData& rand, const KeyData& key, const u32 idx, - const u8 offset) +void EncryptionKey::GenerateTables(const RandData& rand, const KeyData& key, const SBox& sbox_a, + const SBox& sbox_b) { - ft[0] = sboxes[idx][key[4] + offset] ^ sboxes[idx + 1][rand[3] + offset]; - ft[1] = sboxes[idx][key[2] + offset] ^ sboxes[idx + 1][rand[5] + offset]; - ft[2] = sboxes[idx][key[5] + offset] ^ sboxes[idx + 1][rand[7] + offset]; - ft[3] = sboxes[idx][key[0] + offset] ^ sboxes[idx + 1][rand[2] + offset]; - ft[4] = sboxes[idx][key[1] + offset] ^ sboxes[idx + 1][rand[4] + offset]; - ft[5] = sboxes[idx][key[3] + offset] ^ sboxes[idx + 1][rand[9] + offset]; - ft[6] = sboxes[idx][rand[0] + offset] ^ sboxes[idx + 1][rand[6] + offset]; - ft[7] = sboxes[idx][rand[1] + offset] ^ sboxes[idx + 1][rand[8] + offset]; + ft[0] = sbox_a[key[4]] ^ sbox_b[rand[3]]; + ft[1] = sbox_a[key[2]] ^ sbox_b[rand[5]]; + ft[2] = sbox_a[key[5]] ^ sbox_b[rand[7]]; + ft[3] = sbox_a[key[0]] ^ sbox_b[rand[2]]; + ft[4] = sbox_a[key[1]] ^ sbox_b[rand[4]]; + ft[5] = sbox_a[key[3]] ^ sbox_b[rand[9]]; + ft[6] = sbox_a[rand[0]] ^ sbox_b[rand[6]]; + ft[7] = sbox_a[rand[1]] ^ sbox_b[rand[8]]; - sb[0] = sboxes[idx][key[0] + offset] ^ sboxes[idx + 1][rand[1] + offset]; - sb[1] = sboxes[idx][key[5] + offset] ^ sboxes[idx + 1][rand[4] + offset]; - sb[2] = sboxes[idx][key[3] + offset] ^ sboxes[idx + 1][rand[0] + offset]; - sb[3] = sboxes[idx][key[2] + offset] ^ sboxes[idx + 1][rand[9] + offset]; - sb[4] = sboxes[idx][key[4] + offset] ^ sboxes[idx + 1][rand[7] + offset]; - sb[5] = sboxes[idx][key[1] + offset] ^ sboxes[idx + 1][rand[8] + offset]; - sb[6] = sboxes[idx][rand[3] + offset] ^ sboxes[idx + 1][rand[5] + offset]; - sb[7] = sboxes[idx][rand[2] + offset] ^ sboxes[idx + 1][rand[6] + offset]; + sb[0] = sbox_a[key[0]] ^ sbox_b[rand[1]]; + sb[1] = sbox_a[key[5]] ^ sbox_b[rand[4]]; + sb[2] = sbox_a[key[3]] ^ sbox_b[rand[0]]; + sb[3] = sbox_a[key[2]] ^ sbox_b[rand[9]]; + sb[4] = sbox_a[key[4]] ^ sbox_b[rand[7]]; + sb[5] = sbox_a[key[1]] ^ sbox_b[rand[8]]; + sb[6] = sbox_a[rand[3]] ^ sbox_b[rand[5]]; + sb[7] = sbox_a[rand[2]] ^ sbox_b[rand[6]]; } // Generate key from the 0x40-0x4f data in the extension register. @@ -421,17 +499,10 @@ EncryptionKey KeyGen::GenerateFromExtensionKeyData(const ExtKeyData& ext_key) co return GenerateTables(rand, key, idx); } - // Some homebrew apparently sends "ext_key" filled with 0x00. - // On a real extension this produces tables filled with 0x17 or 0x97 (same effect). - // This is not something that the Wii's algorithm is capable of and our brute force will fail. - WARN_LOG(WIIMOTE, "Extension key generation failed. Filling tables with 0x17."); - - // There must be some not understood math behind the extension's table generation. - - EncryptionKey result; - result.ft.fill(0x17); - result.sb.fill(0x17); - return result; + // Retail games never hit this path but some homebrew fills encryption key with 0x00. + // Real extensions seem to then use entirely differnet "sboxes" for table generation. + WARN_LOG(WIIMOTE, "Extension key gen did not match any idx. Generating fallback tables."); + return GenerateFallbackTables(rand, key); } EncryptionKey::KeyData KeyGen1stParty::GenerateKeyData(const EncryptionKey::RandData& rand, @@ -446,11 +517,9 @@ EncryptionKey::KeyData KeyGen1stParty::GenerateKeyData(const EncryptionKey::Rand auto& ans = ans_tbl[idx]; - auto& sbox = sboxes[0]; - EncryptionKey::RandData t0; for (std::size_t i = 0; i != t0.size(); ++i) - t0[i] = sbox[rand[i]]; + t0[i] = keygen_sbox_1st_party[rand[i]]; auto& ror8 = Common::RotateRight; @@ -467,13 +536,18 @@ EncryptionKey::KeyData KeyGen1stParty::GenerateKeyData(const EncryptionKey::Rand EncryptionKey::KeyData KeyGen3rdParty::GenerateKeyData(const EncryptionKey::RandData& rand, const u32 idx) const { - auto& sbox = sboxes[9]; + constexpr u8 ans_tbl[7][6] = { + {0x54, 0x29, 0x28, 0x4e, 0x0f, 0xfc}, {0xa4, 0x6c, 0x87, 0x50, 0x49, 0x3c}, + {0xf2, 0xb4, 0xb1, 0xf9, 0xc3, 0x58}, {0x2e, 0x83, 0x5f, 0x71, 0x8a, 0x9b}, + {0x82, 0xca, 0xc2, 0xbe, 0xba, 0x75}, {0x91, 0x60, 0x78, 0xa8, 0x2a, 0x4c}, + {0x25, 0x5b, 0x8b, 0xb0, 0xda, 0xaf}, + }; + + auto& ans = ans_tbl[idx]; EncryptionKey::RandData t0; for (std::size_t i = 0; i != t0.size(); ++i) - t0[i] = sbox[rand[i] + 0x30]; - - const auto ans = &sbox[idx * 6]; + t0[i] = keygen_sbox_3rd_party[rand[i]]; auto& rol8 = Common::RotateLeft; @@ -491,7 +565,7 @@ EncryptionKey KeyGen1stParty::GenerateTables(const EncryptionKey::RandData& rand const EncryptionKey::KeyData& key, u32 idx) const { EncryptionKey result; - result.GenerateTables(rand, key, idx + 1, 0); + result.GenerateTables(rand, key, sboxes_1st_party[idx], sboxes_1st_party[idx + 1]); return result; } @@ -499,7 +573,41 @@ EncryptionKey KeyGen3rdParty::GenerateTables(const EncryptionKey::RandData& rand const EncryptionKey::KeyData& key, u32 idx) const { EncryptionKey result; - result.GenerateTables(rand, key, idx + 10, 0x30); + result.GenerateTables(rand, key, sboxes_3rd_party[idx], sboxes_3rd_party[idx + 1]); + return result; +} + +EncryptionKey KeyGen1stParty::GenerateFallbackTables(const EncryptionKey::RandData& rand, + const EncryptionKey::KeyData& key) const +{ + // Reverse engineering did not produce exact tables, only the XOR effect of each. + // This is the XOR difference between the tables. + // This also works with 0x97. + constexpr u8 fallback_sbox_xor = 0x17; + + EncryptionKey result; + result.GenerateTables(rand, key, fallback_sbox_1st_party_a, fallback_sbox_1st_party_b); + for (auto& ft : result.ft) + ft ^= fallback_sbox_xor; + for (auto& sb : result.sb) + sb ^= fallback_sbox_xor; + return result; +} + +EncryptionKey KeyGen3rdParty::GenerateFallbackTables(const EncryptionKey::RandData& rand, + const EncryptionKey::KeyData& key) const +{ + // Reverse engineering did not produce exact tables, only the XOR effect of each. + // This is the XOR difference between the tables. + // This also works with 0x20, 0x60, or 0xa0 + constexpr u8 fallback_sbox_xor = 0xe0; + + EncryptionKey result; + result.GenerateTables(rand, key, fallback_sbox_3rd_party_a, fallback_sbox_3rd_party_b); + for (auto& ft : result.ft) + ft ^= fallback_sbox_xor; + for (auto& sb : result.sb) + sb ^= fallback_sbox_xor; return result; } diff --git a/Source/Core/Core/HW/WiimoteEmu/Encryption.h b/Source/Core/Core/HW/WiimoteEmu/Encryption.h index 0d5a258489..7de742c2f8 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Encryption.h +++ b/Source/Core/Core/HW/WiimoteEmu/Encryption.h @@ -12,6 +12,8 @@ namespace WiimoteEmu { +using SBox = std::array; + class EncryptionKey { public: @@ -21,7 +23,8 @@ public: using RandData = std::array; using KeyData = std::array; - void GenerateTables(const RandData& rand, const KeyData& key, const u32 idx, const u8 offset); + void GenerateTables(const RandData& rand, const KeyData& key, const SBox& sbox_a, + const SBox& sbox_b); std::array ft = {}; std::array sb = {}; @@ -41,6 +44,8 @@ protected: u32 idx) const = 0; virtual EncryptionKey GenerateTables(const EncryptionKey::RandData& rand, const EncryptionKey::KeyData& key, u32 idx) const = 0; + virtual EncryptionKey GenerateFallbackTables(const EncryptionKey::RandData& rand, + const EncryptionKey::KeyData& key) const = 0; }; class KeyGen1stParty final : public KeyGen @@ -50,6 +55,8 @@ private: u32 idx) const final override; EncryptionKey GenerateTables(const EncryptionKey::RandData& rand, const EncryptionKey::KeyData& key, u32 idx) const final override; + EncryptionKey GenerateFallbackTables(const EncryptionKey::RandData& rand, + const EncryptionKey::KeyData& key) const final override; }; class KeyGen3rdParty final : public KeyGen @@ -59,6 +66,8 @@ private: u32 idx) const final override; EncryptionKey GenerateTables(const EncryptionKey::RandData& rand, const EncryptionKey::KeyData& key, u32 idx) const final override; + EncryptionKey GenerateFallbackTables(const EncryptionKey::RandData& rand, + const EncryptionKey::KeyData& key) const final override; }; } // namespace WiimoteEmu