Updated CryptoEngine

This commit is contained in:
codestation 2011-07-21 21:12:27 -04:30
parent b8f554dbde
commit 21fbdd1aef

View file

@ -127,6 +127,88 @@ public class CryptoEngine {
int[] keys330_2 = {0xAB, 0x82, 0x25, 0xD7, 0x43, 0x6F, 0x6C, 0xC1, 0x95, 0xC5, 0xF7, 0xF0, 0x63, 0x73, 0x3F, 0xE7};
int[] keys330_3 = {0xA8, 0xB1, 0x47, 0x77, 0xDC, 0x49, 0x6A, 0x6F, 0x38, 0x4C, 0x4D, 0x96, 0xBD, 0x49, 0xEC, 0x9B};
int[] keys330_4 = {0xEC, 0x3B, 0xD2, 0xC0, 0xFA, 0xC1, 0xEE, 0xB9, 0x9A, 0xBC, 0xFF, 0xA3, 0x89, 0xF2, 0x60, 0x1F};
int[] keys360_0 = {0x3C, 0x2B, 0x51, 0xD4, 0x2D, 0x85, 0x47, 0xDA, 0x2D, 0xCA, 0x18, 0xDF, 0xFE, 0x54, 0x09, 0xED};
int[] keys360_1 = {0x31, 0x1F, 0x98, 0xD5, 0x7B, 0x58, 0x95, 0x45, 0x32, 0xAB, 0x3A, 0xE3, 0x89, 0x32, 0x4B, 0x34};
int[] keys370_0 = {0x26, 0x38, 0x0A, 0xAC, 0xA5, 0xD8, 0x74, 0xD1, 0x32, 0xB7, 0x2A, 0xBF, 0x79, 0x9E, 0x6D, 0xDB};
int[] keys370_1 = {0x53, 0xE7, 0xAB, 0xB9, 0xC6, 0x4A, 0x4B, 0x77, 0x92, 0x17, 0xB5, 0x74, 0x0A, 0xDA, 0xA9, 0xEA};
int[] keys370_2 = {0x71, 0x10, 0xF0, 0xA4, 0x16, 0x14, 0xD5, 0x93, 0x12, 0xFF, 0x74, 0x96, 0xDF, 0x1F, 0xDA, 0x89};
int[] keys390_0 = {0x45, 0xEF, 0x5C, 0x5D, 0xED, 0x81, 0x99, 0x84, 0x12, 0x94, 0x8F, 0xAB, 0xE8, 0x05, 0x6D, 0x7D};
int[] keys390_1 = {0x70, 0x1B, 0x08, 0x25, 0x22, 0xA1, 0x4D, 0x3B, 0x69, 0x21, 0xF9, 0x71, 0x0A, 0xA8, 0x41, 0xA9};
int[] keys500_0 = {0xEB, 0x1B, 0x53, 0x0B, 0x62, 0x49, 0x32, 0x58, 0x1F, 0x83, 0x0A, 0xF4, 0x99, 0x3D, 0x75, 0xD0};
int[] keys500_1 = {0xBA, 0xE2, 0xA3, 0x12, 0x07, 0xFF, 0x04, 0x1B, 0x64, 0xA5, 0x11, 0x85, 0xF7, 0x2F, 0x99, 0x5B};
int[] keys500_2 = {0x2C, 0x8E, 0xAF, 0x1D, 0xFF, 0x79, 0x73, 0x1A, 0xAD, 0x96, 0xAB, 0x09, 0xEA, 0x35, 0x59, 0x8B};
int[] keys500_c = {0xA3, 0x5D, 0x51, 0xE6, 0x56, 0xC8, 0x01, 0xCA, 0xE3, 0x77, 0xBF, 0xCD, 0xFF, 0x24, 0xDA, 0x4D};
int[] keys505_a = {0x7B, 0x94, 0x72, 0x27, 0x4C, 0xCC, 0x54, 0x3B, 0xAE, 0xDF, 0x46, 0x37, 0xAC, 0x01, 0x4D, 0x87};
int[] keys505_0 = {0x2E, 0x8E, 0x97, 0xA2, 0x85, 0x42, 0x70, 0x73, 0x18, 0xDA, 0xA0, 0x8A, 0xF8, 0x62, 0xA2, 0xB0};
int[] keys505_1 = {0x58, 0x2A, 0x4C, 0x69, 0x19, 0x7B, 0x83, 0x3D, 0xD2, 0x61, 0x61, 0xFE, 0x14, 0xEE, 0xAA, 0x11};
int[] keys570_5k = {0x6D, 0x72, 0xA4, 0xBA, 0x7F, 0xBF, 0xD1, 0xF1, 0xA9, 0xF3, 0xBB, 0x07, 0x1B, 0xC0, 0xB3, 0x66};
int[] keys600_1 = {0xE3, 0x52, 0x39, 0x97, 0x3B, 0x84, 0x41, 0x1C, 0xC3, 0x23, 0xF1, 0xB8, 0xA9, 0x09, 0x4B, 0xF0};
int[] keys600_2 = {0xE1, 0x45, 0x93, 0x2C, 0x53, 0xE2, 0xAB, 0x06, 0x6F, 0xB6, 0x8F, 0x0B, 0x66, 0x91, 0xE7, 0x1E};
int[] keys620_0 = {0xD6, 0xBD, 0xCE, 0x1E, 0x12, 0xAF, 0x9A, 0xE6, 0x69, 0x30, 0xDE, 0xDA, 0x88, 0xB8, 0xFF, 0xFB};
int[] keys620_1 = {0x1D, 0x13, 0xE9, 0x50, 0x04, 0x73, 0x3D, 0xD2, 0xE1, 0xDA, 0xB9, 0xC1, 0xE6, 0x7B, 0x25, 0xA7};
int[] keys620_a = {0xAC, 0x34, 0xBA, 0xB1, 0x97, 0x8D, 0xAE, 0x6F, 0xBA, 0xE8, 0xB1, 0xD6, 0xDF, 0xDF, 0xF1, 0xA2};
int[] keys620_e = {0xB1, 0xB3, 0x7F, 0x76, 0xC3, 0xFB, 0x88, 0xE6, 0xF8, 0x60, 0xD3, 0x35, 0x3C, 0xA3, 0x4E, 0xF3};
int[] keys620_5 = {0xF1, 0xBC, 0x17, 0x07, 0xAE, 0xB7, 0xC8, 0x30, 0xD8, 0x34, 0x9D, 0x40, 0x6A, 0x8E, 0xDF, 0x4E};
int[] keys620_5k = {0x41, 0x8A, 0x35, 0x4F, 0x69, 0x3A, 0xDF, 0x04, 0xFD, 0x39, 0x46, 0xA2, 0x5C, 0x2D, 0xF2, 0x21};
int[] keys620_5v = {0xF2, 0x8F, 0x75, 0xA7, 0x31, 0x91, 0xCE, 0x9E, 0x75, 0xBD, 0x27, 0x26, 0xB4, 0xB4, 0x0C, 0x32};
int[] keys630_k1 = {0x36, 0xB0, 0xDC, 0xFC, 0x59, 0x2A, 0x95, 0x1D, 0x80, 0x2D, 0x80, 0x3F, 0xCD, 0x30, 0xA0, 0x1B};
int[] keys630_k2 = {0xd4, 0x35, 0x18, 0x02, 0x29, 0x68, 0xfb, 0xa0, 0x6a, 0xa9, 0xa5, 0xed, 0x78, 0xfd, 0x2e, 0x9d};
int[] keys630_k3 = {0x23, 0x8D, 0x3D, 0xAE, 0x41, 0x50, 0xA0, 0xFA, 0xF3, 0x2F, 0x32, 0xCE, 0xC7, 0x27, 0xCD, 0x50};
int[] keys630_k4 = {0xAA, 0xA1, 0xB5, 0x7C, 0x93, 0x5A, 0x95, 0xBD, 0xEF, 0x69, 0x16, 0xFC, 0x2B, 0x92, 0x31, 0xDD};
int[] keys630_k5 = {0x87, 0x37, 0x21, 0xCC, 0x65, 0xAE, 0xAA, 0x5F, 0x40, 0xF6, 0x6F, 0x2A, 0x86, 0xC7, 0xA1, 0xC8};
int[] keys630_k6 = {0x8D, 0xDB, 0xDC, 0x5C, 0xF2, 0x70, 0x2B, 0x40, 0xB2, 0x3D, 0x00, 0x09, 0x61, 0x7C, 0x10, 0x60};
int[] keys630_k7 = {0x77, 0x1C, 0x06, 0x5F, 0x53, 0xEC, 0x3F, 0xFC, 0x22, 0xCE, 0x5A, 0x27, 0xFF, 0x78, 0xA8, 0x48};
int[] keys630_k8 = {0x81, 0xD1, 0x12, 0x89, 0x35, 0xC8, 0xEA, 0x8B, 0xE0, 0x02, 0x2D, 0x2D, 0x6A, 0x18, 0x67, 0xB8};
int[] keys636_k1 = {0x07, 0xE3, 0x08, 0x64, 0x7F, 0x60, 0xA3, 0x36, 0x6A, 0x76, 0x21, 0x44, 0xC9, 0xD7, 0x06, 0x83};
int[] keys636_k2 = {0x91, 0xF2, 0x02, 0x9E, 0x63, 0x32, 0x30, 0xA9, 0x1D, 0xDA, 0x0B, 0xA8, 0xB7, 0x41, 0xA3, 0xCC};
int[] keys638_k4 = {0x98, 0x43, 0xFF, 0x85, 0x68, 0xB2, 0xDB, 0x3B, 0xD4, 0x22, 0xD0, 0x4F, 0xAB, 0x5F, 0x0A, 0x31};
int[] keys639_k3 = {0x01, 0x7B, 0xF0, 0xE9, 0xBE, 0x9A, 0xDD, 0x54, 0x37, 0xEA, 0x0E, 0xC4, 0xD6, 0x4D, 0x8E, 0x9E};
int[] key_21C0 = {0x6A, 0x19, 0x71, 0xF3, 0x18, 0xDE, 0xD3, 0xA2, 0x6D, 0x3B, 0xDE, 0xC7, 0xBE, 0x98, 0xE2, 0x4C};
int[] key_2250 = {0x50, 0xCC, 0x03, 0xAC, 0x3F, 0x53, 0x1A, 0xFA, 0x0A, 0xA4, 0x34, 0x23, 0x86, 0x61, 0x7F, 0x97};
int[] key_22E0 = {0x66, 0x0F, 0xCB, 0x3B, 0x30, 0x75, 0xE3, 0x10, 0x0A, 0x95, 0x65, 0xC7, 0x3C, 0x93, 0x87, 0x22};
int[] key_2D80 = {0x40, 0x02, 0xC0, 0xBF, 0x20, 0x02, 0xC0, 0xBF, 0x5C, 0x68, 0x2B, 0x95, 0x5F, 0x40, 0x7B, 0xB8};
int[] key_2D90 = {0x55, 0x19, 0x35, 0x10, 0x48, 0xD8, 0x2E, 0x46, 0xA8, 0xB1, 0x47, 0x77, 0xDC, 0x49, 0x6A, 0x6F};
int[] key_2DA8 = {0x80, 0x02, 0xC0, 0xBF, 0x00, 0x0A, 0xC0, 0xBF, 0x40, 0x03, 0xC0, 0xBF, 0x40, 0x00, 0x00, 0x00};
int[] key_2DB8 = {0x4C, 0x2D, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xB8, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
int[] key_D91605F0 = {0xB8, 0x8C, 0x45, 0x8B, 0xB6, 0xE7, 0x6E, 0xB8, 0x51, 0x59, 0xA6, 0x53, 0x7C, 0x5E, 0x86, 0x31};
int[] key_D91606F0 = {0xED, 0x10, 0xE0, 0x36, 0xC4, 0xFE, 0x83, 0xF3, 0x75, 0x70, 0x5E, 0xF6, 0xA4, 0x40, 0x05, 0xF7};
int[] key_D91608F0 = {0x5C, 0x77, 0x0C, 0xBB, 0xB4, 0xC2, 0x4F, 0xA2, 0x7E, 0x3B, 0x4E, 0xB4, 0xB4, 0xC8, 0x70, 0xAF};
int[] key_D91609F0 = {0xD0, 0x36, 0x12, 0x75, 0x80, 0x56, 0x20, 0x43, 0xC4, 0x30, 0x94, 0x3E, 0x1C, 0x75, 0xD1, 0xBF};
int[] key_D9160AF0 = {0x10, 0xA9, 0xAC, 0x16, 0xAE, 0x19, 0xC0, 0x7E, 0x3B, 0x60, 0x77, 0x86, 0x01, 0x6F, 0xF2, 0x63};
int[] key_D9160BF0 = {0x83, 0x83, 0xF1, 0x37, 0x53, 0xD0, 0xBE, 0xFC, 0x8D, 0xA7, 0x32, 0x52, 0x46, 0x0A, 0xC2, 0xC2};
int[] key_D91611F0 = {0x61, 0xB0, 0xC0, 0x58, 0x71, 0x57, 0xD9, 0xFA, 0x74, 0x67, 0x0E, 0x5C, 0x7E, 0x6E, 0x95, 0xB9};
int[] key_D91612F0 = {0x9E, 0x20, 0xE1, 0xCD, 0xD7, 0x88, 0xDE, 0xC0, 0x31, 0x9B, 0x10, 0xAF, 0xC5, 0xB8, 0x73, 0x23};
int[] key_D91613F0 = {0xEB, 0xFF, 0x40, 0xD8, 0xB4, 0x1A, 0xE1, 0x66, 0x91, 0x3B, 0x8F, 0x64, 0xB6, 0xFC, 0xB7, 0x12};
int[] key_D91614F0 = {0xFD, 0xF7, 0xB7, 0x3C, 0x9F, 0xD1, 0x33, 0x95, 0x11, 0xB8, 0xB5, 0xBB, 0x54, 0x23, 0x73, 0x85};
int[] key_D91615F0 = {0xC8, 0x03, 0xE3, 0x44, 0x50, 0xF1, 0xE7, 0x2A, 0x6A, 0x0D, 0xC3, 0x61, 0xB6, 0x8E, 0x5F, 0x51};
int[] key_D91616F0 = {0x53, 0x03, 0xB8, 0x6A, 0x10, 0x19, 0x98, 0x49, 0x1C, 0xAF, 0x30, 0xE4, 0x25, 0x1B, 0x6B, 0x28};
int[] key_D91617F0 = {0x02, 0xFA, 0x48, 0x73, 0x75, 0xAF, 0xAE, 0x0A, 0x67, 0x89, 0x2B, 0x95, 0x4B, 0x09, 0x87, 0xA3};
int[] key_D91618F0 = {0x96, 0x96, 0x7C, 0xC3, 0xF7, 0x12, 0xDA, 0x62, 0x1B, 0xF6, 0x9A, 0x9A, 0x44, 0x44, 0xBC, 0x48};
int[] key_D91619F0 = {0xE0, 0x32, 0xA7, 0x08, 0x6B, 0x2B, 0x29, 0x2C, 0xD1, 0x4D, 0x5B, 0xEE, 0xA8, 0xC8, 0xB4, 0xE9};
int[] key_D9161AF0 = {0x27, 0xE5, 0xA7, 0x49, 0x52, 0xE1, 0x94, 0x67, 0x35, 0x66, 0x91, 0x0C, 0xE8, 0x9A, 0x25, 0x24};
int[] key_D91620F0 = {0x52, 0x1C, 0xB4, 0x5F, 0x40, 0x3B, 0x9A, 0xDD, 0xAC, 0xFC, 0xEA, 0x92, 0xFD, 0xDD, 0xF5, 0x90};
int[] key_D91621F0 = {0xD1, 0x91, 0x2E, 0xA6, 0x21, 0x14, 0x29, 0x62, 0xF6, 0xED, 0xAE, 0xCB, 0xDD, 0xA3, 0xBA, 0xFE};
int[] key_D91622F0 = {0x59, 0x5D, 0x78, 0x4D, 0x21, 0xB2, 0x01, 0x17, 0x6C, 0x9A, 0xB5, 0x1B, 0xDA, 0xB7, 0xF9, 0xE6};
int[] key_D91623F0 = {0xAA, 0x45, 0xEB, 0x4F, 0x62, 0xFB, 0xD1, 0x0D, 0x71, 0xD5, 0x62, 0xD2, 0xF5, 0xBF, 0xA5, 0x2F};
int[] key_D91624F0 = {0x61, 0xB7, 0x26, 0xAF, 0x8B, 0xF1, 0x41, 0x58, 0x83, 0x6A, 0xC4, 0x92, 0x12, 0xCB, 0xB1, 0xE9};
int[] key_D91628F0 = {0x49, 0xA4, 0xFC, 0x66, 0xDC, 0xE7, 0x62, 0x21, 0xDB, 0x18, 0xA7, 0x50, 0xD6, 0xA8, 0xC1, 0xB6};
int[] key_D91680F0 = {0x2C, 0x22, 0x9B, 0x12, 0x36, 0x74, 0x11, 0x67, 0x49, 0xD1, 0xD1, 0x88, 0x92, 0xF6, 0xA1, 0xD8};
int[] key_D91681F0 = {0x52, 0xB6, 0x36, 0x6C, 0x8C, 0x46, 0x7F, 0x7A, 0xCC, 0x11, 0x62, 0x99, 0xC1, 0x99, 0xBE, 0x98};
int[] key_2E5E10F0 = {0x9D, 0x5C, 0x5B, 0xAF, 0x8C, 0xD8, 0x69, 0x7E, 0x51, 0x9F, 0x70, 0x96, 0xE6, 0xD5, 0xC4, 0xE8};
int[] key_2E5E12F0 = {0x8A, 0x7B, 0xC9, 0xD6, 0x52, 0x58, 0x88, 0xEA, 0x51, 0x83, 0x60, 0xCA, 0x16, 0x79, 0xE2, 0x07};
int[] key_2E5E13F0 = {0xFF, 0xA4, 0x68, 0xC3, 0x31, 0xCA, 0xB7, 0x4C, 0xF1, 0x23, 0xFF, 0x01, 0x65, 0x3D, 0x26, 0x36};
int[] key_2FD30BF0 = {0xD8, 0x58, 0x79, 0xF9, 0xA4, 0x22, 0xAF, 0x86, 0x90, 0xAC, 0xDA, 0x45, 0xCE, 0x60, 0x40, 0x3F};
int[] key_2FD311F0 = {0x3A, 0x6B, 0x48, 0x96, 0x86, 0xA5, 0xC8, 0x80, 0x69, 0x6C, 0xE6, 0x4B, 0xF6, 0x04, 0x17, 0x44};
int[] key_2FD312F0 = {0xC5, 0xFB, 0x69, 0x03, 0x20, 0x7A, 0xCF, 0xBA, 0x2C, 0x90, 0xF8, 0xB8, 0x4D, 0xD2, 0xF1, 0xDE};
int[] keys02G_E = {0x9D, 0x09, 0xFD, 0x20, 0xF3, 0x8F, 0x10, 0x69, 0x0D, 0xB2, 0x6F, 0x00, 0xCC, 0xC5, 0x51, 0x2E};
int[] keys03G_E = {0x4F, 0x44, 0x5C, 0x62, 0xB3, 0x53, 0xC4, 0x30, 0xFC, 0x3A, 0xA4, 0x5B, 0xEC, 0xFE, 0x51, 0xEA};
int[] keys05G_E = {0x5D, 0xAA, 0x72, 0xF2, 0x26, 0x60, 0x4D, 0x1C, 0xE7, 0x2D, 0xC8, 0xA3, 0x2F, 0x79, 0xC5, 0x54};
int[] oneseg_310 = {0xC7, 0x27, 0x72, 0x85, 0xAB, 0xA7, 0xF7, 0xF0, 0x4C, 0xC1, 0x86, 0xCC, 0xE3, 0x7F, 0x17, 0xCA};
int[] oneseg_300 = {0x76, 0x40, 0x9E, 0x08, 0xDB, 0x9B, 0x3B, 0xA1, 0x47, 0x8A, 0x96, 0x8E, 0xF3, 0xF7, 0x62, 0x92};
int[] oneseg_280 = {0x23, 0xDC, 0x3B, 0xB5, 0xA9, 0x82, 0xD6, 0xEA, 0x63, 0xA3, 0x6E, 0x2B, 0x2B, 0xE9, 0xE1, 0x54};
int[] oneseg_260_271 = {0x22, 0x43, 0x57, 0x68, 0x2F, 0x41, 0xCE, 0x65, 0x4C, 0xA3, 0x7C, 0xC6, 0xC4, 0xAC, 0xF3, 0x60};
int[] oneseg_slim = {0x12, 0x57, 0x0D, 0x8A, 0x16, 0x6D, 0x87, 0x06, 0x03, 0x7D, 0xC8, 0x8B, 0x62, 0xA3, 0x32, 0xA9};
int[] ms_app_main = {0x1E, 0x2E, 0x38, 0x49, 0xDA, 0xD4, 0x16, 0x08, 0x27, 0x2E, 0xF3, 0xBC, 0x37, 0x75, 0x80, 0x93};
int[] demokeys_280 = {0x12, 0x99, 0x70, 0x5E, 0x24, 0x07, 0x6C, 0xD0, 0x2D, 0x06, 0xFE, 0x7E, 0xB3, 0x0C, 0x11, 0x26};
int[] demokeys_3XX_1 = {0x47, 0x05, 0xD5, 0xE3, 0x56, 0x1E, 0x81, 0x9B, 0x09, 0x2F, 0x06, 0xDB, 0x6B, 0x12, 0x92, 0xE0};
int[] demokeys_3XX_2 = {0xF6, 0x62, 0x39, 0x6E, 0x26, 0x22, 0x4D, 0xCA, 0x02, 0x64, 0x16, 0x99, 0x7B, 0x9A, 0xE7, 0xB8};
@ -138,59 +220,10 @@ public class CryptoEngine {
int[] gameshare_280 = {0x2D, 0x86, 0x77, 0x3A, 0x56, 0xA4, 0x4F, 0xDD, 0x3C, 0x16, 0x71, 0x93, 0xAA, 0x8E, 0x11, 0x43};
int[] gameshare_300 = {0x78, 0x1A, 0xD2, 0x87, 0x24, 0xBD, 0xA2, 0x96, 0x18, 0x3F, 0x89, 0x36, 0x72, 0x90, 0x92, 0x85};
int[] gameshare_310 = {0xC9, 0x7D, 0x3E, 0x0A, 0x54, 0x81, 0x6E, 0xC7, 0x13, 0x74, 0x99, 0x74, 0x62, 0x18, 0xE7, 0xDD};
int[] keys360_0 = {0x3C, 0x2B, 0x51, 0xD4, 0x2D, 0x85, 0x47, 0xDA, 0x2D, 0xCA, 0x18, 0xDF, 0xFE, 0x54, 0x09, 0xED};
int[] keys360_1 = {0x31, 0x1F, 0x98, 0xD5, 0x7B, 0x58, 0x95, 0x45, 0x32, 0xAB, 0x3A, 0xE3, 0x89, 0x32, 0x4B, 0x34};
int[] keys370_0 = {0x26, 0x38, 0x0A, 0xAC, 0xA5, 0xD8, 0x74, 0xD1, 0x32, 0xB7, 0x2A, 0xBF, 0x79, 0x9E, 0x6D, 0xDB};
int[] keys370_1 = {0x53, 0xE7, 0xAB, 0xB9, 0xC6, 0x4A, 0x4B, 0x77, 0x92, 0x17, 0xB5, 0x74, 0x0A, 0xDA, 0xA9, 0xEA};
int[] keys370_2 = {0x71, 0x10, 0xF0, 0xA4, 0x16, 0x14, 0xD5, 0x93, 0x12, 0xFF, 0x74, 0x96, 0xDF, 0x1F, 0xDA, 0x89};
int[] oneseg_310 = {0xC7, 0x27, 0x72, 0x85, 0xAB, 0xA7, 0xF7, 0xF0, 0x4C, 0xC1, 0x86, 0xCC, 0xE3, 0x7F, 0x17, 0xCA};
int[] oneseg_300 = {0x76, 0x40, 0x9E, 0x08, 0xDB, 0x9B, 0x3B, 0xA1, 0x47, 0x8A, 0x96, 0x8E, 0xF3, 0xF7, 0x62, 0x92};
int[] oneseg_280 = {0x23, 0xDC, 0x3B, 0xB5, 0xA9, 0x82, 0xD6, 0xEA, 0x63, 0xA3, 0x6E, 0x2B, 0x2B, 0xE9, 0xE1, 0x54};
int[] oneseg_260_271 = {0x22, 0x43, 0x57, 0x68, 0x2F, 0x41, 0xCE, 0x65, 0x4C, 0xA3, 0x7C, 0xC6, 0xC4, 0xAC, 0xF3, 0x60};
int[] oneseg_slim = {0x12, 0x57, 0x0D, 0x8A, 0x16, 0x6D, 0x87, 0x06, 0x03, 0x7D, 0xC8, 0x8B, 0x62, 0xA3, 0x32, 0xA9};
int[] ms_app_main = {0x1E, 0x2E, 0x38, 0x49, 0xDA, 0xD4, 0x16, 0x08, 0x27, 0x2E, 0xF3, 0xBC, 0x37, 0x75, 0x80, 0x93};
int[] keys390_0 = {0x45, 0xEF, 0x5C, 0x5D, 0xED, 0x81, 0x99, 0x84, 0x12, 0x94, 0x8F, 0xAB, 0xE8, 0x05, 0x6D, 0x7D};
int[] keys390_1 = {0x70, 0x1B, 0x08, 0x25, 0x22, 0xA1, 0x4D, 0x3B, 0x69, 0x21, 0xF9, 0x71, 0x0A, 0xA8, 0x41, 0xA9};
int[] keys500_0 = {0xEB, 0x1B, 0x53, 0x0B, 0x62, 0x49, 0x32, 0x58, 0x1F, 0x83, 0x0A, 0xF4, 0x99, 0x3D, 0x75, 0xD0};
int[] keys500_1 = {0xBA, 0xE2, 0xA3, 0x12, 0x07, 0xFF, 0x04, 0x1B, 0x64, 0xA5, 0x11, 0x85, 0xF7, 0x2F, 0x99, 0x5B};
int[] keys500_2 = {0x2C, 0x8E, 0xAF, 0x1D, 0xFF, 0x79, 0x73, 0x1A, 0xAD, 0x96, 0xAB, 0x09, 0xEA, 0x35, 0x59, 0x8B};
int[] keys500_c = {0xA3, 0x5D, 0x51, 0xE6, 0x56, 0xC8, 0x01, 0xCA, 0xE3, 0x77, 0xBF, 0xCD, 0xFF, 0x24, 0xDA, 0x4D};
int[] keys505_a = {0x7B, 0x94, 0x72, 0x27, 0x4C, 0xCC, 0x54, 0x3B, 0xAE, 0xDF, 0x46, 0x37, 0xAC, 0x01, 0x4D, 0x87};
int[] keys505_0 = {0x2E, 0x8E, 0x97, 0xA2, 0x85, 0x42, 0x70, 0x73, 0x18, 0xDA, 0xA0, 0x8A, 0xF8, 0x62, 0xA2, 0xB0};
int[] keys505_1 = {0x58, 0x2A, 0x4C, 0x69, 0x19, 0x7B, 0x83, 0x3D, 0xD2, 0x61, 0x61, 0xFE, 0x14, 0xEE, 0xAA, 0x11};
int[] keys02G_E = {0x9D, 0x09, 0xFD, 0x20, 0xF3, 0x8F, 0x10, 0x69, 0x0D, 0xB2, 0x6F, 0x00, 0xCC, 0xC5, 0x51, 0x2E};
int[] keys03G_E = {0x4F, 0x44, 0x5C, 0x62, 0xB3, 0x53, 0xC4, 0x30, 0xFC, 0x3A, 0xA4, 0x5B, 0xEC, 0xFE, 0x51, 0xEA};
int[] key_D91609F0 = {0xD0, 0x36, 0x12, 0x75, 0x80, 0x56, 0x20, 0x43, 0xC4, 0x30, 0x94, 0x3E, 0x1C, 0x75, 0xD1, 0xBF};
int[] key_D9160AF0 = {0x10, 0xA9, 0xAC, 0x16, 0xAE, 0x19, 0xC0, 0x7E, 0x3B, 0x60, 0x77, 0x86, 0x01, 0x6F, 0xF2, 0x63};
int[] key_D9160BF0 = {0x83, 0x83, 0xF1, 0x37, 0x53, 0xD0, 0xBE, 0xFC, 0x8D, 0xA7, 0x32, 0x52, 0x46, 0x0A, 0xC2, 0xC2};
int[] key_D91611F0 = {0x61, 0xB0, 0xC0, 0x58, 0x71, 0x57, 0xD9, 0xFA, 0x74, 0x67, 0x0E, 0x5C, 0x7E, 0x6E, 0x95, 0xB9};
int[] key_D91612F0 = {0x9E, 0x20, 0xE1, 0xCD, 0xD7, 0x88, 0xDE, 0xC0, 0x31, 0x9B, 0x10, 0xAF, 0xC5, 0xB8, 0x73, 0x23};
int[] key_D91613F0 = {0xEB, 0xFF, 0x40, 0xD8, 0xB4, 0x1A, 0xE1, 0x66, 0x91, 0x3B, 0x8F, 0x64, 0xB6, 0xFC, 0xB7, 0x12};
int[] key_D91614F0 = {0xFD, 0xF7, 0xB7, 0x3C, 0x9F, 0xD1, 0x33, 0x95, 0x11, 0xB8, 0xB5, 0xBB, 0x54, 0x23, 0x73, 0x85};
int[] key_2E5E10F0 = {0x9D, 0x5C, 0x5B, 0xAF, 0x8C, 0xD8, 0x69, 0x7E, 0x51, 0x9F, 0x70, 0x96, 0xE6, 0xD5, 0xC4, 0xE8};
int[] key_2E5E12F0 = {0x8A, 0x7B, 0xC9, 0xD6, 0x52, 0x58, 0x88, 0xEA, 0x51, 0x83, 0x60, 0xCA, 0x16, 0x79, 0xE2, 0x07};
int[] key_2E5E13F0 = {0xFF, 0xA4, 0x68, 0xC3, 0x31, 0xCA, 0xB7, 0x4C, 0xF1, 0x23, 0xFF, 0x01, 0x65, 0x3D, 0x26, 0x36};
int[] keys600_u1_457B0BF0 = {0x7B, 0x94, 0x72, 0x27, 0x4C, 0xCC, 0x54, 0x3B, 0xAE, 0xDF, 0x46, 0x37, 0xAC, 0x01, 0x4D, 0x87};
int[] keys600_u1_457B0CF0 = {0xAC, 0x34, 0xBA, 0xB1, 0x97, 0x8D, 0xAE, 0x6F, 0xBA, 0xE8, 0xB1, 0xD6, 0xDF, 0xDF, 0xF1, 0xA2};
int[] keys05G_E = {0x5D, 0xAA, 0x72, 0xF2, 0x26, 0x60, 0x4D, 0x1C, 0xE7, 0x2D, 0xC8, 0xA3, 0x2F, 0x79, 0xC5, 0x54};
int[] keys570_5k = {0x6D, 0x72, 0xA4, 0xBA, 0x7F, 0xBF, 0xD1, 0xF1, 0xA9, 0xF3, 0xBB, 0x07, 0x1B, 0xC0, 0xB3, 0x66};
int[] keys620_0 = {0xD6, 0xBD, 0xCE, 0x1E, 0x12, 0xAF, 0x9A, 0xE6, 0x69, 0x30, 0xDE, 0xDA, 0x88, 0xB8, 0xFF, 0xFB};
int[] keys620_1 = {0x1D, 0x13, 0xE9, 0x50, 0x04, 0x73, 0x3D, 0xD2, 0xE1, 0xDA, 0xB9, 0xC1, 0xE6, 0x7B, 0x25, 0xA7};
int[] keys620_3 = {0xA3, 0x5D, 0x51, 0xE6, 0x56, 0xC8, 0x01, 0xCA, 0xE3, 0x77, 0xBF, 0xCD, 0xFF, 0x24, 0xDA, 0x4D};
int[] keys620_e = {0xB1, 0xB3, 0x7F, 0x76, 0xC3, 0xFB, 0x88, 0xE6, 0xF8, 0x60, 0xD3, 0x35, 0x3C, 0xA3, 0x4E, 0xF3};
int[] keys620_5 = {0xF1, 0xBC, 0x17, 0x07, 0xAE, 0xB7, 0xC8, 0x30, 0xD8, 0x34, 0x9D, 0x40, 0x6A, 0x8E, 0xDF, 0x4E};
int[] keys620_5k = {0x41, 0x8A, 0x35, 0x4F, 0x69, 0x3A, 0xDF, 0x04, 0xFD, 0x39, 0x46, 0xA2, 0x5C, 0x2D, 0xF2, 0x21};
int[] keys620_5v = {0xF2, 0x8F, 0x75, 0xA7, 0x31, 0x91, 0xCE, 0x9E, 0x75, 0xBD, 0x27, 0x26, 0xB4, 0xB4, 0x0C, 0x32};
int[] key_21C0 = {0x6A, 0x19, 0x71, 0xF3, 0x18, 0xDE, 0xD3, 0xA2, 0x6D, 0x3B, 0xDE, 0xC7, 0xBE, 0x98, 0xE2, 0x4C};
int[] key_2250 = {0x50, 0xCC, 0x03, 0xAC, 0x3F, 0x53, 0x1A, 0xFA, 0x0A, 0xA4, 0x34, 0x23, 0x86, 0x61, 0x7F, 0x97};
int[] key_22E0 = {0x66, 0x0F, 0xCB, 0x3B, 0x30, 0x75, 0xE3, 0x10, 0x0A, 0x95, 0x65, 0xC7, 0x3C, 0x93, 0x87, 0x22};
int[] key_2D80 = {0x40, 0x02, 0xC0, 0xBF, 0x20, 0x02, 0xC0, 0xBF, 0x5C, 0x68, 0x2B, 0x95, 0x5F, 0x40, 0x7B, 0xB8};
int[] key_2D90 = {0x55, 0x19, 0x35, 0x10, 0x48, 0xD8, 0x2E, 0x46, 0xA8, 0xB1, 0x47, 0x77, 0xDC, 0x49, 0x6A, 0x6F};
int[] key_2DA8 = {0x80, 0x02, 0xC0, 0xBF, 0x00, 0x0A, 0xC0, 0xBF, 0x40, 0x03, 0xC0, 0xBF, 0x40, 0x00, 0x00, 0x00};
int[] key_2DB8 = {0x4C, 0x2D, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xB8, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
int[] key_4c9484f0 = {0x36, 0xB0, 0xDC, 0xFC, 0x59, 0x2A, 0x95, 0x1D, 0x80, 0x2D, 0x80, 0x3F, 0xCD, 0x30, 0xA0, 0x1B};
int[] key_457b80f0 = {0xd4, 0x35, 0x18, 0x02, 0x29, 0x68, 0xfb, 0xa0, 0x6a, 0xa9, 0xa5, 0xed, 0x78, 0xfd, 0x2e, 0x9d};
int[] key_380280f0 = {0x97, 0x09, 0x12, 0xD3, 0xDB, 0x02, 0xBD, 0xD8, 0xE7, 0x74, 0x51, 0xFE, 0xF0, 0xEA, 0x6C, 0x5C};
int[] key_380210F0 = {0x32, 0x2C, 0xFA, 0x75, 0xE4, 0x7E, 0x93, 0xEB, 0x9F, 0x22, 0x80, 0x85, 0x57, 0x08, 0x98, 0x48};
int[] key_380280F0 = {0x97, 0x09, 0x12, 0xD3, 0xDB, 0x02, 0xBD, 0xD8, 0xE7, 0x74, 0x51, 0xFE, 0xF0, 0xEA, 0x6C, 0x5C};
int[] key_380283F0 = {0x34, 0x20, 0x0C, 0x8E, 0xA1, 0x86, 0x79, 0x84, 0xAF, 0x13, 0xAE, 0x34, 0x77, 0x6F, 0xEA, 0x89};
int[] key_407810F0 = {0xAF, 0xAD, 0xCA, 0xF1, 0x95, 0x59, 0x91, 0xEC, 0x1B, 0x27, 0xD0, 0x4E, 0x8A, 0xF3, 0x3D, 0xE7};
int[] drmkeys_6XX_1 = {0x36, 0xEF, 0x82, 0x4E, 0x74, 0xFB, 0x17, 0x5B, 0x14, 0x14, 0x05, 0xF3, 0xB3, 0x8A, 0x76, 0x18};
int[] drmkeys_6XX_2 = {0x21, 0x52, 0x5D, 0x76, 0xF6, 0x81, 0x0F, 0x15, 0x2F, 0x4A, 0x40, 0x89, 0x63, 0xA0, 0x10, 0x55};
@ -356,32 +389,37 @@ public class CryptoEngine {
}
private TAG_INFO g_tagInfo[] = {
new TAG_INFO(0x380280f0, key_380280f0, 0x5A),
new TAG_INFO(0x4C9484F0, key_4c9484f0, 0x43),
new TAG_INFO(0x457b80f0, key_457b80f0, 0x5B),
new TAG_INFO(0x4C940FF0, key_2DA8, 0x43),
new TAG_INFO(0x4467415D, key_22E0, 0x59),
new TAG_INFO(0x00000000, key_21C0, 0x42),
new TAG_INFO(0x01000000, key_2250, 0x43),
new TAG_INFO(0x4C948CF0, keys639_k3, 0x43),
new TAG_INFO(0x4C948DF0, keys638_k4, 0x43),
new TAG_INFO(0x4C948BF0, keys636_k2, 0x43),
new TAG_INFO(0x4C948AF0, keys636_k1, 0x43),
new TAG_INFO(0x4C9487F0, keys630_k8, 0x43),
new TAG_INFO(0x457B83F0, keys630_k7, 0x5B),
new TAG_INFO(0x4C9486F0, keys630_k6, 0x43),
new TAG_INFO(0x457B82F0, keys630_k5, 0x5B),
new TAG_INFO(0x457B81F0, keys630_k4, 0x5B),
new TAG_INFO(0x4C9485F0, keys630_k3, 0x43),
new TAG_INFO(0x457B80F0, keys630_k2, 0x5B),
new TAG_INFO(0x4C9484F0, keys630_k1, 0x43),
new TAG_INFO(0x457B28F0, keys620_e, 0x5B),
new TAG_INFO(0x457B0CF0, keys620_a, 0x5B),
new TAG_INFO(0x380228F0, keys620_5v, 0x5A),
new TAG_INFO(0x4C942AF0, keys620_5k, 0x43),
new TAG_INFO(0x4C9428F0, keys620_5, 0x43),
new TAG_INFO(0x4C9429F0, keys570_5k, 0x43),
new TAG_INFO(0x4C941DF0, keys620_1, 0x43),
new TAG_INFO(0x4C941CF0, keys620_0, 0x43),
new TAG_INFO(0x457B1EF0, keys620_3, 0x5B),
new TAG_INFO(0x457B0BF0, keys600_u1_457B0BF0, 0x5B),
new TAG_INFO(0x457B0CF0, keys600_u1_457B0CF0, 0x5B),
new TAG_INFO(0x4C9419F0, keys500_1, 0x43),
new TAG_INFO(0x4C9418F0, keys500_0, 0x43),
new TAG_INFO(0x4C9422F0, keys600_2, 0x43),
new TAG_INFO(0x4C941EF0, keys600_1, 0x43),
new TAG_INFO(0x4C9429F0, keys570_5k, 0x43),
new TAG_INFO(0x457B0BF0, keys505_a, 0x5B),
new TAG_INFO(0x4C9419F0, keys505_1, 0x43),
new TAG_INFO(0x4C9418F0, keys505_0, 0x43),
new TAG_INFO(0x457B1EF0, keys500_c, 0x5B),
new TAG_INFO(0x4C941FF0, keys500_2, 0x43),
new TAG_INFO(0x4C9417F0, keys500_1, 0x43),
new TAG_INFO(0x4C9416F0, keys500_0, 0x43),
new TAG_INFO(0x4C9414F0, keys390_0, 0x43),
new TAG_INFO(0x4C9415F0, keys390_1, 0x43),
new TAG_INFO(0xD82310F0, keys02G_E, 0x51),
new TAG_INFO(0xD8231EF0, keys03G_E, 0x51),
new TAG_INFO(0xD82328F0, keys05G_E, 0x51),
new TAG_INFO(0x4C9412F0, keys370_0, 0x43),
new TAG_INFO(0x4C9413F0, keys370_1, 0x43),
new TAG_INFO(0x457B10F0, keys370_2, 0x5B),
@ -406,7 +444,49 @@ public class CryptoEngine {
new TAG_INFO(0x16D59E03, keys260_0, 0x62),
new TAG_INFO(0x76202403, keys260_1, 0x5B),
new TAG_INFO(0x0F037303, keys260_2, 0x5A),
new TAG_INFO(0x457B28F0, keys620_e, 0x5B),
new TAG_INFO(0x4C940FF0, key_2DA8, 0x43),
new TAG_INFO(0x4467415D, key_22E0, 0x59),
new TAG_INFO(0x00000000, key_21C0, 0x42),
new TAG_INFO(0x01000000, key_2250, 0x43),
new TAG_INFO(0x2E5E10F0, key_2E5E10F0, 0x48),
new TAG_INFO(0x2E5E12F0, key_2E5E12F0, 0x48),
new TAG_INFO(0x2E5E13F0, key_2E5E13F0, 0x48),
new TAG_INFO(0x2FD30BF0, key_2FD30BF0, 0x47),
new TAG_INFO(0x2FD311F0, key_2FD311F0, 0x47),
new TAG_INFO(0x2FD312F0, key_2FD312F0, 0x47),
new TAG_INFO(0xD91605F0, key_D91605F0, 0x5D),
new TAG_INFO(0xD91606F0, key_D91606F0, 0x5D),
new TAG_INFO(0xD91608F0, key_D91608F0, 0x5D),
new TAG_INFO(0xD91609F0, key_D91609F0, 0x5D),
new TAG_INFO(0xD9160AF0, key_D9160AF0, 0x5D),
new TAG_INFO(0xD9160BF0, key_D9160BF0, 0x5D),
new TAG_INFO(0xD91611F0, key_D91611F0, 0x5D),
new TAG_INFO(0xD91612F0, key_D91612F0, 0x5D),
new TAG_INFO(0xD91613F0, key_D91613F0, 0x5D),
new TAG_INFO(0xD91614F0, key_D91614F0, 0x5D),
new TAG_INFO(0xD91615F0, key_D91615F0, 0x5D),
new TAG_INFO(0xD91616F0, key_D91616F0, 0x5D),
new TAG_INFO(0xD91617F0, key_D91617F0, 0x5D),
new TAG_INFO(0xD91618F0, key_D91618F0, 0x5D),
new TAG_INFO(0xD91619F0, key_D91619F0, 0x5D),
new TAG_INFO(0xD9161AF0, key_D9161AF0, 0x5D),
new TAG_INFO(0xD91620F0, key_D91620F0, 0x5D),
new TAG_INFO(0xD91621F0, key_D91621F0, 0x5D),
new TAG_INFO(0xD91622F0, key_D91622F0, 0x5D),
new TAG_INFO(0xD91623F0, key_D91623F0, 0x5D),
new TAG_INFO(0xD91624F0, key_D91624F0, 0x5D),
new TAG_INFO(0xD91628F0, key_D91628F0, 0x5D),
new TAG_INFO(0xD91680F0, key_D91680F0, 0x5D),
new TAG_INFO(0xD91681F0, key_D91681F0, 0x5D),
new TAG_INFO(0xD82310F0, keys02G_E, 0x51),
new TAG_INFO(0xD8231EF0, keys03G_E, 0x51),
new TAG_INFO(0xD82328F0, keys05G_E, 0x51),
new TAG_INFO(0x279D08F0, oneseg_310, 0x61),
new TAG_INFO(0x279D06F0, oneseg_300, 0x61),
new TAG_INFO(0x279D05F0, oneseg_280, 0x61),
new TAG_INFO(0xD66DF703, oneseg_260_271, 0x61),
new TAG_INFO(0x279D10F0, oneseg_slim, 0x61),
new TAG_INFO(0x3C2A08F0, ms_app_main, 0x67),
new TAG_INFO(0xADF305F0, demokeys_280, 0x60),
new TAG_INFO(0xADF306F0, demokeys_3XX_1, 0x60),
new TAG_INFO(0xADF308F0, demokeys_3XX_2, 0x60),
@ -414,26 +494,14 @@ public class CryptoEngine {
new TAG_INFO(0xD91605F0, ebootbin_280_new, 0x5D),
new TAG_INFO(0xD91606F0, ebootbin_300_new, 0x5D),
new TAG_INFO(0xD91608F0, ebootbin_310_new, 0x5D),
new TAG_INFO(0xD91609F0, key_D91609F0, 0x5D),
new TAG_INFO(0x2E5E10F0, key_2E5E10F0, 0x48),
new TAG_INFO(0x2E5E12F0, key_2E5E12F0, 0x48),
new TAG_INFO(0x2E5E12F0, key_2E5E13F0, 0x48),
new TAG_INFO(0xD9160AF0, key_D9160AF0, 0x5D),
new TAG_INFO(0xD9160BF0, key_D9160BF0, 0x5D),
new TAG_INFO(0xD91611F0, key_D91611F0, 0x5D),
new TAG_INFO(0xD91612F0, key_D91612F0, 0x5D),
new TAG_INFO(0xD91613F0, key_D91613F0, 0x5D),
new TAG_INFO(0xD91614F0, key_D91614F0, 0x5D),
new TAG_INFO(0x0A35EA03, gameshare_260_271, 0x5E),
new TAG_INFO(0x7B0505F0, gameshare_280, 0x5E),
new TAG_INFO(0x7B0506F0, gameshare_300, 0x5E),
new TAG_INFO(0x7B0508F0, gameshare_310, 0x5E),
new TAG_INFO(0x279D08F0, oneseg_310, 0x61),
new TAG_INFO(0x279D06F0, oneseg_300, 0x61),
new TAG_INFO(0x279D05F0, oneseg_280, 0x61),
new TAG_INFO(0xD66DF703, oneseg_260_271, 0x61),
new TAG_INFO(0x279D10F0, oneseg_slim, 0x61),
new TAG_INFO(0x3C2A08F0, ms_app_main, 0x67),
new TAG_INFO(0x380210F0, key_380210F0, 0x5A),
new TAG_INFO(0x380280F0, key_380280F0, 0x5A),
new TAG_INFO(0x380283F0, key_380283F0, 0x5A),
new TAG_INFO(0x407810F0, key_407810F0, 0x6A),
new TAG_INFO(0xE92410F0, drmkeys_6XX_1, 0x40),
new TAG_INFO(0x692810F0, drmkeys_6XX_2, 0x40)};
@ -1889,10 +1957,10 @@ public class CryptoEngine {
buffer[1] = 0x45;
buffer[2] = 0x4C;
buffer[3] = 0x46;
buffer[4] = 0x01;
buffer[4] = 0x00;
buffer[5] = 0x01;
buffer[6] = 0x01;
buffer[7] = 0x00;
buffer[7] = 0x01;
buffer[8] = 0x00;
buffer[9] = 0x00;
buffer[10] = 0x00;
@ -2112,6 +2180,219 @@ public class CryptoEngine {
return retsize;
}
public int DecryptPRX3(byte[] inbuf, byte[] outbuf, int size, int tag) {
int keyType = 0;
// Read the .PRX user tag and find it in the list.
TAG_INFO pti = GetTagInfo(Integer.reverseBytes(tag));
if (pti == null) {
return -1;
}
// Check the final ELF size.
int retsize = ((inbuf[0xB3] & 0xFF) << 24) | ((inbuf[0xB2] & 0xFF) << 16) |
((inbuf[0xB1] & 0xFF) << 8) | ((inbuf[0xB0] & 0xFF));
// Setup all buffers.
byte[] header = new byte[0x150];
byte[] key = new byte[0x90 + 0x14];
byte[] sig = new byte[0x60 + 0x14];
// Fully copy the contents of the encrypted file.
System.arraycopy(inbuf, 0, outbuf, 0, size);
// Copy the ~PSP header to header.
System.arraycopy(outbuf, 0, header, 0, 0x150);
// Set keyType based on blacklisted tags.
if (tag == 0x380280f0) {
keyType = 3;
} else if (tag == 0x4C9484F0) {
keyType = 3;
} else if (tag == 0x457b80f0) {
keyType = 3;
} else if (tag == 0x4C941DF0) {
keyType = 2;
} else if (tag == 0x4C940FF0) {
keyType = 2;
} else if (tag == 0x4C941CF0) {
keyType = 2;
} else if (tag == 0x4C940AF0) {
keyType = 2;
} else if (tag == 0xCFEF08F0) {
keyType = 2;
} else if (tag == 0xCFEF06F0) {
keyType = 2;
} else if (tag == 0xCFEF05F0) {
keyType = 2;
} else if (tag == 0x16D59E03) {
keyType = 2;
} else if (tag == 0x4467415D) {
keyType = 1;
} else if (tag == 0x00000000) {
keyType = 0;
} else if (tag == 0x01000000) {
keyType = 0;
}
if (keyType == 2 || keyType == 3) {
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 0x10; j++) {
key[0x14 + ((i << 4) + j)] = (byte) pti.key[j];
}
key[0x14 + ((i << 4))] = (byte) i;
}
} else {
System.arraycopy(key, 0x14, pti.key, 0, 0x90);
}
ScramblePRX(key, 0x90, (byte) (pti.code & 0xFF));
// Regenerate sig check.
if (keyType == 2 || keyType == 3) {
System.arraycopy(header, 0xD0, outbuf, 0, 0x5C);
System.arraycopy(header, 0x140, outbuf, 0x5C, 0x10);
System.arraycopy(header, 0x12C, outbuf, 0x6C, 0x14);
System.arraycopy(header, 0x80, outbuf, 0x80, 0x30);
System.arraycopy(header, 0xC0, outbuf, 0xB0, 0x10);
System.arraycopy(header, 0xB0, outbuf, 0xC0, 0x10);
System.arraycopy(header, 0, outbuf, 0xD0, 0x80);
} else {
System.arraycopy(header, 0xD0, outbuf, 0, 0x80);
System.arraycopy(header, 0x80, outbuf, 0x80, 0x50);
System.arraycopy(header, 0, outbuf, 0xD0, 0x80);
}
if (keyType == 1) {
// Copy sig check.
System.arraycopy(outbuf, 0x10, sig, 0x14, 0xA0);
// Scramble the sig.
ScramblePRX(sig, 0xA0, (byte) (pti.code & 0xFF));
} else if (keyType == 2 || keyType == 3) {
// Copy sig check.
System.arraycopy(outbuf, 0x5C, sig, 0x14, 0x60);
// Scramble the sig.
ScramblePRX(sig, 0x60, (byte) (pti.code & 0xFF));
}
if (keyType == 2 || keyType == 3) {
// Copy the sig again.
System.arraycopy(sig, 0, outbuf, 0x5C, 0x60);
System.arraycopy(outbuf, 0x6C, sig, 0, 0x14);
System.arraycopy(outbuf, 0x5C, outbuf, 0x70, 0x10);
if (keyType == 3) {
System.arraycopy(outbuf, 0x60, outbuf, 0x80, 0x20);
for (int k = 0; k < 0x38; k++) {
outbuf[k + 0x18] = 0;
}
} else {
for (int k = 0; k < 0x58; k++) {
outbuf[k + 0x18] = 0;
}
}
System.arraycopy(outbuf, 0, outbuf, 0x4, 0x4);
// Set the SHA1 block size to digest.
outbuf[0] = 0x00;
outbuf[1] = 0x00;
outbuf[2] = 0x01;
outbuf[3] = 0x4C;
System.arraycopy(key, 0, outbuf, 0x8, 0x10);
} else {
// Set the SHA1 block size to digest.
outbuf[0] = 0x00;
outbuf[1] = 0x00;
outbuf[2] = 0x01;
outbuf[3] = 0x4C;
System.arraycopy(key, 0, outbuf, 0x4, 0x14);
}
// Generate SHA1 hash.
ByteBuffer bSHA1Out = ByteBuffer.wrap(outbuf);
hleUtilsBufferCopyWithRange(bSHA1Out, size, bSHA1Out, size, 0x0B);
if (keyType == 2 || keyType == 3) {
// Apply XOR calculation on sig.
for (int iXOR = 0; iXOR < 0x40; iXOR++) {
sig[iXOR + 0x14] = (byte) (outbuf[iXOR + 0x80] ^ key[iXOR + 0x10]);
}
ScramblePRX(sig, 0x40, (byte) (pti.code & 0xFF));
for (int iXOR = 0x3F; iXOR >= 0; iXOR--) {
outbuf[iXOR + 0x40] = (byte) (sig[iXOR] ^ key[iXOR + 0x50]);
}
for (int k = 0; k < 0x30; k++) {
outbuf[k + 0x80] = 0;
}
// Set mode field to 1.
outbuf[0xA0] = 0x0;
outbuf[0xA1] = 0x0;
outbuf[0xA2] = 0x0;
outbuf[0xA3] = 0x1;
if (keyType == 3) {
for (int k = 0; k < 0x10; k++) {
outbuf[k + 0xA0] = 0;
}
// Set mode field to 1.
outbuf[0xA0] = 0x0;
outbuf[0xA1] = 0x0;
outbuf[0xA2] = 0x0;
outbuf[0xA3] = 0x1;
outbuf[0xA4] = 0x0;
outbuf[0xA5] = 0x0;
outbuf[0xA6] = 0x0;
outbuf[0xA7] = 0x1;
} else {
for (int k = 0; k < 0x30; k++) {
outbuf[k + 0x80] = 0;
}
// Set mode field to 1.
outbuf[0xA0] = 0x0;
outbuf[0xA1] = 0x0;
outbuf[0xA2] = 0x0;
outbuf[0xA3] = 0x1;
}
} else {
// Apply XOR calculation on sig.
for (int iXOR = 0; iXOR < 0x70; iXOR++) {
sig[iXOR + 0x14] = (byte) (outbuf[iXOR + 0x40] ^ key[iXOR + 0x14]);
}
ScramblePRX(sig, 0x70, (byte) (pti.code & 0xFF));
for (int iXOR = 0x6F; iXOR >= 0; iXOR--) {
outbuf[iXOR + 0x2C] = (byte) (sig[iXOR] ^ key[iXOR + 0x20]);
}
System.arraycopy(key, 0xB0, outbuf, 0xB0, 0xA0);
}
// Set mode field to 1.
outbuf[0xA0] = 0x0;
outbuf[0xA1] = 0x0;
outbuf[0xA2] = 0x0;
outbuf[0xA3] = 0x1;
System.arraycopy(outbuf, 0xC0, outbuf, 0xB0, 0x10);
for (int k = 0; k < 0x10; k++) {
outbuf[k + 0xC0] = 0;
}
// Call KIRK CMD1 for final decryption.
ByteBuffer bDataOut = ByteBuffer.wrap(outbuf);
ByteBuffer bHeaderIn = bDataOut.duplicate();
bHeaderIn.position(0x40);
hleUtilsBufferCopyWithRange(bDataOut, size, bHeaderIn, size, 0x01);
// Restore first line of ELF data (for JPCSP only).
PatchELFTag(outbuf);
if (retsize < 0x150) {
for (int k = 0; k < (0x150 - retsize); k++) {
outbuf[k + retsize] = 0;
}
}
return retsize;
}
public byte[] DecryptSavedata(byte[] inbuf, int size, byte[] key, int mode) {
// Setup the crypto and keygen modes and initialize both context structs.
int sdEncMode = 0;