| | |
| | | 0x8E, 0x93, 0xB5, 0x44, 0x8D, 0x42, 0x22, 0x84, 0x95, 0x33, 0x22, 0x93, |
| | | 0x42, 0x82, 0xA3, 0x35, 0x91, 0x33, 0x13, 0x93, 0x71, 0x21, 0x01, 0x71, |
| | | 0x37, 0x9F, 0xA6, 0x68, 0x92, 0x86, 0x46, 0x72, 0x43, 0x62, 0x12, 0x52, |
| | | 0x5D, 0x85, 0x93, 0x86, 0x82, 0x46, 0x31, 0x86, 0x57, 0x48, 0x16, 0x88, |
| | | // 扇区14密码 (基于扇区13的XOR密钥重新计算为27562CCFE9F7) |
| | | 0x5D, 0xE5, 0x93, 0x86, 0x82, 0x46, 0x31, 0x86, 0x57, 0x48, 0x16, 0x88, |
| | | 0x97, 0x73, 0xB5, 0x47, 0x95, 0x55, 0x36, 0x69, 0x49, 0x58, 0x18, 0x6A, |
| | | 0xEA, 0x46, 0x84, 0x93, 0x82, 0x19, 0x29, 0x91, 0x31, 0x1C, 0x0C, 0x7D |
| | | }; |
| | |
| | | return nullptr; |
| | | } |
| | | |
| | | // __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Decrypting sector %d", sector); |
| | | // __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Encrypted data: %02X %02X %02X %02X %02X %02X", |
| | | // encrypted_data[0], encrypted_data[1], encrypted_data[2], |
| | | // encrypted_data[3], encrypted_data[4], encrypted_data[5]); |
| | | // __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Using XOR key: %02X %02X %02X %02X %02X %02X", |
| | | // XOR_KEYS[sector][0], XOR_KEYS[sector][1], XOR_KEYS[sector][2], |
| | | // XOR_KEYS[sector][3], XOR_KEYS[sector][4], XOR_KEYS[sector][5]); |
| | | __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Decrypting sector %d", sector); |
| | | __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Encrypted data: %02X %02X %02X %02X %02X %02X", |
| | | encrypted_data[0], encrypted_data[1], encrypted_data[2], |
| | | encrypted_data[3], encrypted_data[4], encrypted_data[5]); |
| | | __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Using XOR key: %02X %02X %02X %02X %02X %02X", |
| | | XOR_KEYS[sector][0], XOR_KEYS[sector][1], XOR_KEYS[sector][2], |
| | | XOR_KEYS[sector][3], XOR_KEYS[sector][4], XOR_KEYS[sector][5]); |
| | | |
| | | unsigned char decrypted[6]; |
| | | for (int i = 0; i < 6; i++) { |
| | | decrypted[i] = encrypted_data[i] ^ XOR_KEYS[sector][i]; |
| | | // __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Byte %d: %02X ^ %02X = %02X", |
| | | // i, encrypted_data[i], XOR_KEYS[sector][i], decrypted[i]); |
| | | __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Byte %d: %02X ^ %02X = %02X", |
| | | i, encrypted_data[i], XOR_KEYS[sector][i], decrypted[i]); |
| | | } |
| | | |
| | | std::string result; |
| | |
| | | result += hex; |
| | | } |
| | | |
| | | // __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Decrypted result: %s", result.c_str()); |
| | | __android_log_print(ANDROID_LOG_INFO, "GeBaseHelper", "Decrypted result: %s", result.c_str()); |
| | | return env->NewStringUTF(result.c_str()); |
| | | } |
| | | |
| | |
| | | |
| | | // 解密并转换每个扇区密钥 |
| | | for (size_t i = 0; i < numKeys; i++) { |
| | | // __android_log_print(ANDROID_LOG_DEBUG, "M1Card", "处理扇区 %zu 的密钥", i); |
| | | __android_log_print(ANDROID_LOG_DEBUG, "M1Card", "处理扇区 %zu 的密钥", i); |
| | | |
| | | // 确保不会越界访问 |
| | | if (i * 12 + 6 > sizeof(ENCRYPTED_SECTOR_KEYS)) { |
| | |
| | | jstring decrypted_str = decrypt_key(env, ENCRYPTED_SECTOR_KEYS + (i * 12), 6); |
| | | |
| | | if (!decrypted_str) { |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to decrypt key for sector %zu", i); |
| | | __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to decrypt key for sector %zu", i); |
| | | continue; |
| | | } |
| | | |