This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Savedata Encryption/Decryption
#1
So, after a couple of weeks of absense on my side, I'm finally back to reveal my findings on the intrinsics of the module chnnlsv.prx, which is reponsible for handling savedata encryption/decryption in the PSP.
Thanks to all the rest of the dev's team, Darth1701 and BlackDaemon's help, I was finally able to fully reverse engineer this module and unterstand it's crypto algorithms, which were still unknown until today.

The purpose of this post is to offer and disclose a brief pseudo code shaped summary of my findings before commiting anything to JPCSP/PCSP.
Please remember that this post is solely for investigational purposes!

-----------------------------------------------------------------------------------
[CHNNLSV.PRX]:

- Structs:
SDCtx1 {
int mode;
int unk;
byte[16] buf;
}

SDCtx2 {
int mode;
byte[16] result;
byte[16] key;
int keylength
}

- Functions' prototypes:
sceSdSetIndex(SDCtx2 ctx, int encMode);
sceSdCreateList(SDCtx1 ctx, int encMode, int genMode, byte[] data, byte[] key);
sceSdRemoveValue(SDCtx2 ctx, byte[] data, int length);
sceSdGetLastIndex(SDCtx2 ctx, byte[] hash, byte[] key);
sceSdSetMember(SDCtx1 ctx, byte[] data, int length);
sceChnnlsv_21BE78B4(SDCtx1 ctx);

- Details:
-> sceSdSetIndex: This function is responsible for initializing ctx's params to 0 and set ctx.mode to encMode.
-> sceSdCreateList: This is the main key generating function. The param genMode can be 1 for encryption or 2 for decryption. In the first case, a random pseudo number is encrypted and appended to decrypted data and it will be used as encrypting key after being XORed with the param key (if specified). In decryption, the first 16-bytes of data represent this generated hash, and all that happens is the XORing with the param key (if specified) and subsequent saving of this key for further use.
-> sceSdRemoveValue: This function is used in hash generation. This only matters in encryption processes, and it's used to collect and generate a key from the main encrypted data.
-> sceSdGetLastIndex: This function is also used in hash generation. It's called to generate a hash based on the context collected by sceSdRemoveValue. The hashes processed by this function must be written to the SAVEDATA_PARAMS field of the existing PARAM.SFO file when encrypting data to validate it.
-> sceSdSetMember: This is the main encryption/decryption function. It works by generating a binary list using a part of the key obtained by sceSdCreateList and a few custom algorithmic steps. Depending on which encMode is specified, different calls to KIRK CMDs can be used and different private CHNNLSV SD keys are XORed with the obtained key before generating the list (check the keys section). The final step consists on decrypting with KIRK CMD7 this binary list, and the result will then be XORed with the encrypted/decrypted data giving a decrypted/encrypted output.
-> sceChnnlsv_21BE78B4: Just clears the ctx struct. Pretty much like a sceSdSetIndex but for SDCtx1 instead.

- SD Keys (located in the chnnlsv.prx's subsection sceChnnlsv_driver):
Code:
Key1 = {0x40, 0xE6, 0x53, 0x3F, 0x05, 0x11, 0x3A, 0x4E, 0xA1, 0x4B, 0xDA, 0xD6, 0x72, 0x7C, 0x53, 0x4C};
Key2 = {0xFA, 0xAA, 0x50, 0xEC, 0x2F, 0xDE, 0x54, 0x93, 0xAD, 0x14, 0xB2, 0xCE, 0xA5, 0x30, 0x05, 0xDF};
Key3 = {0x36, 0xA5, 0x3E, 0xAC, 0xC5, 0x26, 0x9E, 0xA3, 0x83, 0xD9, 0xEC, 0x25, 0x6C, 0x48, 0x48, 0x72};
Key4 = {0xD8, 0xC0, 0xB0, 0xF3, 0x3E, 0x6B, 0x76, 0x85, 0xFD, 0xFB, 0x4D, 0x7D, 0x45, 0x1E, 0x92, 0x03};
Key5 = {0xCB, 0x15, 0xF4, 0x07, 0xF9, 0x6A, 0x52, 0x3C, 0x04, 0xB9, 0xB2, 0xEE, 0x5C, 0x53, 0xFA, 0x86};
Key6 = {0x70, 0x44, 0xA3, 0xAE, 0xEF, 0x5D, 0xA5, 0xF2, 0x85, 0x7F, 0xF2, 0xD6, 0x94, 0xF5, 0x36, 0x3B};
Key7 = {0xEC, 0x6D, 0x29, 0x59, 0x26, 0x35, 0xA5, 0x7F, 0x97, 0x2A, 0x0D, 0xBC, 0xA3, 0x26, 0x33, 0x00};

Key3 and Key4 were the first encryption/decryption keys being used (up to firmware 2.5.2). Key6 and Key7 are the keys associated with the new mode being used since then.
Key2 and Key5 are used in hash generation and Key1 is still unknown.

-----------------------------------------------------------------------------------

Enjoy! Smile
Reply


Messages In This Thread
Savedata Encryption/Decryption - by Hykem - 02-16-2011, 05:52 PM
RE: Savedata Encryption/Decryption - by rbgbenny5 - 07-30-2011, 04:32 AM
RE: Savedata Encryption/Decryption - by skyeyes83 - 02-17-2011, 10:17 AM
RE: Savedata Encryption/Decryption - by Hykem - 02-17-2011, 08:11 PM
RE: Savedata Encryption/Decryption - by oliox - 02-17-2011, 10:39 PM
RE: Savedata Encryption/Decryption - by Kai3213 - 02-17-2011, 11:05 PM
RE: Savedata Encryption/Decryption - by Hykem - 02-18-2011, 04:40 PM
RE: Savedata Encryption/Decryption - by Hykem - 02-18-2011, 05:42 PM
RE: Savedata Encryption/Decryption - by Kai3213 - 02-19-2011, 03:00 PM
RE: Savedata Encryption/Decryption - by Hykem - 02-19-2011, 04:31 PM
RE: Savedata Encryption/Decryption - by Zekro - 02-20-2011, 10:24 AM
RE: Savedata Encryption/Decryption - by oliox - 02-20-2011, 08:34 PM
RE: Savedata Encryption/Decryption - by Kai3213 - 02-20-2011, 09:03 PM
RE: Savedata Encryption/Decryption - by oliox - 02-20-2011, 09:25 PM
RE: Savedata Encryption/Decryption - by Kai3213 - 03-15-2011, 12:59 AM
RE: Savedata Encryption/Decryption - by Kai3213 - 03-15-2011, 01:31 AM
RE: Savedata Encryption/Decryption - by beanclr - 03-15-2011, 01:48 AM
RE: Savedata Encryption/Decryption - by beanclr - 03-15-2011, 04:04 AM
RE: Savedata Encryption/Decryption - by beanclr - 03-15-2011, 10:06 PM
RE: Savedata Encryption/Decryption - by beanclr - 03-15-2011, 10:58 PM
RE: Savedata Encryption/Decryption - by Darth1701 - 03-16-2011, 07:24 AM
RE: Savedata Encryption/Decryption - by oliox - 03-16-2011, 02:00 PM
RE: Savedata Encryption/Decryption - by Darth1701 - 03-16-2011, 02:13 PM
RE: Savedata Encryption/Decryption - by Malicii - 05-27-2011, 07:10 AM
RE: Savedata Encryption/Decryption - by Hykem - 11-14-2011, 10:38 PM
RE: Savedata Encryption/Decryption - by Itaru - 11-15-2011, 01:16 PM
RE: Savedata Encryption/Decryption - by Hykem - 11-15-2011, 08:00 PM
RE: Savedata Encryption/Decryption - by AthenaADP - 11-17-2011, 07:48 AM
RE: Savedata Encryption/Decryption - by Itaru - 11-17-2011, 02:02 PM
RE: Savedata Encryption/Decryption - by Hykem - 11-23-2011, 06:04 AM
RE: Savedata Encryption/Decryption - by serio - 11-27-2011, 05:37 AM
RE: Savedata Encryption/Decryption - by serio - 12-26-2011, 11:41 AM
RE: Savedata Encryption/Decryption - by Hykem - 12-26-2011, 03:26 PM
RE: Savedata Encryption/Decryption - by popsdeco - 01-04-2012, 11:46 AM
RE: Savedata Encryption/Decryption - by Hykem - 01-04-2012, 03:37 PM
RE: Savedata Encryption/Decryption - by AthenaADP - 01-05-2012, 03:54 AM
RE: Savedata Encryption/Decryption - by Hykem - 01-05-2012, 03:04 PM
RE: Savedata Encryption/Decryption - by serio - 04-08-2012, 06:55 PM
RE: Savedata Encryption/Decryption - by popsdeco - 06-13-2012, 01:30 AM
RE: Savedata Encryption/Decryption - by Zekro - 06-13-2012, 12:16 PM
RE: Savedata Encryption/Decryption - by serio - 06-13-2012, 12:40 PM
RE: Savedata Encryption/Decryption - by popsdeco - 06-13-2012, 02:54 PM
RE: Savedata Encryption/Decryption - by serio - 07-03-2012, 03:01 AM
RE: Savedata Encryption/Decryption - by popsdeco - 07-06-2012, 04:12 AM
RE: Savedata Encryption/Decryption - by Hykem - 10-10-2013, 11:04 PM
RE: Savedata Encryption/Decryption - by popsdeco - 10-11-2013, 01:43 AM
RE: Savedata Encryption/Decryption - by Hykem - 10-12-2013, 07:53 PM
RE: Savedata Encryption/Decryption - by popsdeco - 10-13-2013, 06:56 AM
RE: Savedata Encryption/Decryption - by Hykem - 10-13-2013, 03:58 PM
RE: Savedata Encryption/Decryption - by popsdeco - 10-14-2013, 07:02 AM
RE: Savedata Encryption/Decryption - by Itaru - 10-14-2013, 04:09 PM
RE: Savedata Encryption/Decryption - by Hykem - 10-21-2013, 06:39 PM
RE: Savedata Encryption/Decryption - by popsdeco - 10-22-2013, 10:32 AM
RE: Savedata Encryption/Decryption - by Hykem - 10-24-2013, 07:49 PM
RE: Savedata Encryption/Decryption - by popsdeco - 10-22-2013, 12:38 PM
RE: Savedata Encryption/Decryption - by Hykem - 10-27-2013, 07:43 PM
RE: Savedata Encryption/Decryption - by popsdeco - 10-28-2013, 08:48 AM
RE: Savedata Encryption/Decryption - by Hykem - 10-28-2013, 08:37 PM
RE: Savedata Encryption/Decryption - by popsdeco - 11-02-2013, 07:04 PM
RE: Savedata Encryption/Decryption - by Hykem - 11-04-2013, 08:53 PM
RE: Savedata Encryption/Decryption - by serio - 11-05-2013, 05:19 PM
RE: Savedata Encryption/Decryption - by popsdeco - 11-10-2013, 06:10 PM
RE: Savedata Encryption/Decryption - by Hykem - 11-11-2013, 05:34 AM
RE: Savedata Encryption/Decryption - by onelight - 11-16-2013, 01:39 AM
RE: Savedata Encryption/Decryption - by Hykem - 11-23-2013, 11:41 PM
RE: Savedata Encryption/Decryption - by onelight - 11-24-2013, 02:46 PM
RE: Savedata Encryption/Decryption - by popsdeco - 11-25-2013, 06:58 PM
RE: Savedata Encryption/Decryption - by popsdeco - 11-29-2013, 01:44 PM
RE: Savedata Encryption/Decryption - by onelight - 01-11-2014, 08:49 AM
RE: Savedata Encryption/Decryption - by Hykem - 01-13-2014, 07:48 PM
RE: Savedata Encryption/Decryption - by onelight - 01-14-2014, 05:49 AM
RE: Savedata Encryption/Decryption - by Hykem - 01-14-2014, 03:29 PM
RE: Savedata Encryption/Decryption - by akaya - 01-14-2014, 06:53 PM
RE: Savedata Encryption/Decryption - by akaya - 01-14-2014, 12:31 AM
RE: Savedata Encryption/Decryption - by Hykem - 01-15-2014, 07:41 PM
RE: Savedata Encryption/Decryption - by akaya - 01-15-2014, 08:50 PM
RE: Savedata Encryption/Decryption - by Hykem - 01-16-2014, 03:06 PM
RE: Savedata Encryption/Decryption - by popsdeco - 01-17-2014, 11:33 AM
RE: Savedata Encryption/Decryption - by Hykem - 01-17-2014, 03:45 PM
RE: Savedata Encryption/Decryption - by popsdeco - 01-18-2014, 04:30 PM
RE: Savedata Encryption/Decryption - by popsdeco - 01-16-2014, 09:35 AM
RE: Savedata Encryption/Decryption - by akaya - 01-17-2014, 01:50 AM
RE: Savedata Encryption/Decryption - by thelight - 01-17-2014, 07:08 AM
RE: Savedata Encryption/Decryption - by Hykem - 01-18-2014, 05:54 PM
RE: Savedata Encryption/Decryption - by akaya - 01-18-2014, 06:12 PM
RE: Savedata Encryption/Decryption - by onelight - 02-09-2014, 06:42 AM
RE: Savedata Encryption/Decryption - by sum2012 - 02-09-2014, 12:57 PM
RE: Savedata Encryption/Decryption - by popsdeco - 02-10-2014, 12:23 PM
RE: Savedata Encryption/Decryption - by popsdeco - 02-11-2014, 08:49 AM
RE: Savedata Encryption/Decryption - by onelight - 02-11-2014, 11:48 AM
RE: Savedata Encryption/Decryption - by shadow - 02-11-2014, 10:24 AM
RE: Savedata Encryption/Decryption - by popsdeco - 02-11-2014, 10:54 AM
RE: Savedata Encryption/Decryption - by shadow - 02-11-2014, 11:14 AM
RE: Savedata Encryption/Decryption - by popsdeco - 02-11-2014, 12:13 PM
RE: Savedata Encryption/Decryption - by popsdeco - 02-12-2014, 07:27 AM
RE: Savedata Encryption/Decryption - by popsdeco - 02-13-2014, 04:46 AM
RE: Savedata Encryption/Decryption - by Hykem - 02-14-2014, 07:49 PM
RE: Savedata Encryption/Decryption - by popsdeco - 02-17-2014, 11:17 AM
RE: Savedata Encryption/Decryption - by Hykem - 03-04-2014, 09:18 PM
RE: Savedata Encryption/Decryption - by popsdeco - 04-13-2014, 04:30 AM
RE: Savedata Encryption/Decryption - by Hykem - 04-13-2014, 01:59 PM
RE: Savedata Encryption/Decryption - by popsdeco - 04-14-2014, 08:57 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)