| 1 | // 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 |
|---|
| 2 | |
|---|
| 3 | // Processing Key |
|---|
| 4 | static unsigned char processing_key[16] = {0x09,0xF9,0x11,0x02,0x9D,0x74,0xE3,0x5B,0xD8,0x41,0x56,0xC5,0x63,0x56,0x88,0xC0}; |
|---|
| 5 | |
|---|
| 6 | // Encrypted C Value |
|---|
| 7 | static unsigned char encrypted_c_value[16] = {0x6D,0x02,0xCA,0xC6,0x7B,0x1A,0x7E,0x95,0xC2,0x16,0xEF,0xD4,0xC9,0x28,0x09,0xCF}; |
|---|
| 8 | |
|---|
| 9 | // Decrypted C Value |
|---|
| 10 | static unsigned char decrypted_c_value[16]; |
|---|
| 11 | static unsigned char uv[4] = {0x00,0x00,0x00,0x01}; |
|---|
| 12 | |
|---|
| 13 | // Media Key |
|---|
| 14 | static unsigned char media_key[16]; |
|---|
| 15 | |
|---|
| 16 | // Encrypted Verification Data (King Kong) |
|---|
| 17 | static unsigned char encrypted_verification_data[16] = {0x87,0xB8,0xA2,0xB7,0xC1,0x0B,0x9F,0xAD,0xF8,0xC4,0x36,0x1E,0x23,0x86,0x59,0xE5}; |
|---|
| 18 | |
|---|
| 19 | // Decrypted Verification Data Should Be |
|---|
| 20 | static unsigned char decrypted_verification_data_should_be[8] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; |
|---|
| 21 | |
|---|
| 22 | // Decrypted Verification Data |
|---|
| 23 | static unsigned char decrypted_verification_data[16]; |
|---|
| 24 | |
|---|
| 25 | // Volume ID |
|---|
| 26 | static unsigned char volume_id[16] = {0x40,0x00,0x09,0x18,0x20,0x06,0x08,0x41,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x00}; |
|---|
| 27 | |
|---|
| 28 | // Decrypted Volume ID |
|---|
| 29 | static unsigned char decrypted_volumeid[16]; |
|---|
| 30 | |
|---|
| 31 | // Volume Unique Key |
|---|
| 32 | static unsigned char volume_unqiue_key[16]; |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | // First decrypt the C-value with the processing key |
|---|
| 36 | oRijndael.MakeKey((char *)processing_key, CRijndael::sm_chain0, 16, 16); |
|---|
| 37 | oRijndael.DecryptBlock((char *)encrypted_c_value, (char *)decrypted_c_value); |
|---|
| 38 | |
|---|
| 39 | // Then XOR it with with the uv (of the corresponding C-value) |
|---|
| 40 | for (j = 0; j < 16; j++) |
|---|
| 41 | { |
|---|
| 42 | if (j < 12) |
|---|
| 43 | { |
|---|
| 44 | media_key[j] = decrypted_c_value[j]; |
|---|
| 45 | } |
|---|
| 46 | else |
|---|
| 47 | { |
|---|
| 48 | media_key[j] = decrypted_c_value[j]^uv[j-12]; |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | // Then check if the resulting media key is correct using the verify media key record |
|---|
| 53 | oRijndael.MakeKey((char *)media_key, CRijndael::sm_chain0, 16, 16); |
|---|
| 54 | oRijndael.DecryptBlock((char *)encrypted_verification_data, (char *)decrypted_verification_data); |
|---|
| 55 | |
|---|
| 56 | if (!memcmp(decrypted_verification_data_should_be, decrypted_verification_data, 8)) |
|---|
| 57 | { |
|---|
| 58 | for (j = 0; j < 16; j++) |
|---|
| 59 | { |
|---|
| 60 | printf("%02X ", decrypted_verification_data[j]); |
|---|
| 61 | } |
|---|
| 62 | } |
|---|
| 63 | printf("\n"); |
|---|
| 64 | |
|---|
| 65 | // Then do a AES-G (basicly a decrypt and an XOR) on the media key + volumeID |
|---|
| 66 | oRijndael.MakeKey((char *)media_key, CRijndael::sm_chain0, 16, 16); |
|---|
| 67 | oRijndael.DecryptBlock((char *)volume_id, (char *)decrypted_volumeid); |
|---|
| 68 | for (j = 0; j < 16; j++) |
|---|
| 69 | { |
|---|
| 70 | volume_unqiue_key[j] = volume_id[j]^decrypted_volumeid[j]; |
|---|
| 71 | } |
|---|
| 72 | printf("\n"); |
|---|
| 73 | |
|---|
| 74 | // This results in the Volume Unique Key |
|---|
| 75 | for (j = 0; j < 16; j++) |
|---|
| 76 | { |
|---|
| 77 | printf("%02X ", volume_unqiue_key[j]); |
|---|
| 78 | } |
|---|
| 79 | printf("\n"); |
|---|