motoharu-gosuto / psvpfstools

Tools for decrypting PS Vita PFS filesystem
127 stars 22 forks source link

Provide an interface for F00DKeyEncryptor #19

Open motoharu-gosuto opened 6 years ago

motoharu-gosuto commented 6 years ago

Started from : https://github.com/motoharu-gosuto/psvpfstools/issues/9

motoharu-gosuto commented 6 years ago
  1. Add interface IF00DKeyEncryptor with virtual method: int encrypt_key(const unsigned char key, int key_size, unsigned char drv_key);
  2. Rename F00DKeyEncryptor to F00DUrlKeyEncryptor and implement IF00DKeyEncryptor interface.
  3. Create F00DFileKeyEncryptor and implement IF00DKeyEncryptor interface.
  4. Add new command line option that will allow to select food encryptor type.
  5. Create F00DKeyEncryptorFactory. Move get_F00D_encryptor function to factory. Add create_F00D_encryptor function. Create encryptor instance and store it in global variable upon parsing command line options. get_F00D_encryptor will return that global variable.
  6. Move std::string g_F00D_url; to F00DUrlKeyEncryptor.
motoharu-gosuto commented 6 years ago

Implemented in https://github.com/motoharu-gosuto/psvpfstools/tree/f00d-service-interface branch

motoharu-gosuto commented 6 years ago

@tomazzz369 Due to circumstances I am returning to the developement of psvpfstools. I have implemented this request in a separate branch called f00d-service-interface. Please consider looking at readme and using --f00d_cache option. Let me know if this works for you. Thanks! I hope it is not late.

tomazzz369 commented 6 years ago

awesome. i will test new version on weekend

thanks

motoharu-gosuto commented 6 years ago

@tomazzz369 Were you able to test this functionality?

tomazzz369 commented 6 years ago

not yet, i have a lot of work, but if if find a while i will check on 100%

regards

tomazzz369 commented 6 years ago

tested branch: f00d-service-interface tested only one content atm, later i will check more

issues:

working: JP0106-PCSG00987_00-BLUEREFTHEME0001 5893db34c38cc3e574bae719ccac1f98 442ee328ef9b093ce098d937946a1160 EP9000-PCSF00536_00-ETH0000000000018 2cde53b828d9250194a53c3b7f444b7c 73ee4ef09c663d88ab5007b753f5af0b

not working - Header signature is invalid JP0106-PCSG00987_00-BLUEREFTHEME0001 5893db34c38cc3e574bae719ccac1f98 442ee328ef9b093ce098d937946a1160 EP9000-PCSF00536_00-ETH0000000000018 2cde53b828d9250194a53c3b7f444b7c 73ee4ef09c663d88ab5007b753f5af0b EP9000-PCSF00536_00-ETH0000000000018 2cde53b828d9250194a53c3b7f444b7c 73ee4ef09c663d88ab5007b753f5af0b

or non proper line

working: EP9000-PCSF00536_00-ETH0000000000018 2cde53b828d9250194a53c3b7f444b7c 73ee4ef09c663d88ab5007b753f5af0b

not working - Header signature is invalid EP9000-PCSF00536_00-ETH0000000000018 2cde53b828d9250194a53c3b7f444b7c 73ee4ef09c663d88ab5007b753f5af0b only one space in 2nd line

annoying situation, after 10 minutes i figured out what's going on, because my f00d cache starts with line // content id,klicensee,encrypted key //

motoharu-gosuto commented 6 years ago

@tomazzz369 Thank you very much for testing and suggestions! I will try to implement it. Current functionality is supposed to be bare minimum that is working. But indeed proper error handling should be implemented.

tomazzz369 commented 6 years ago

tested with 4 changes and seems to everything is fine


added at the beginning

https://github.com/motoharu-gosuto/psvpfstools/blob/crypto-interface/psvpfsparser/F00DFileKeyEncryptor.cpp#L108

if(!boost::filesystem::exists(m_filePath)) { throw std::runtime_error("F00D cache file is missing"); }


https://github.com/motoharu-gosuto/psvpfstools/blob/crypto-interface/psvpfsparser/F00DFileKeyEncryptor.cpp#L26

replaced all return -1; with continue;


https://github.com/motoharu-gosuto/psvpfstools/blob/crypto-interface/psvpfsparser/F00DFileKeyEncryptor.cpp#L115

replaced return -1; with

throw std::runtime_error("F00D cache file not supported");


https://github.com/motoharu-gosuto/psvpfstools/blob/crypto-interface/psvpfsparser/F00DFileKeyEncryptor.cpp#L137

replaced return -1; with

throw std::runtime_error("Unable to find klicensee in F00D cache file");

motoharu-gosuto commented 5 years ago

Just making notes to myself. I need to add those changes.