diff options
author | Damien Zammit <damien@zamaudio.com> | 2016-08-02 22:20:24 +1000 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2016-08-02 22:25:20 +1000 |
commit | 3cda7bcbfb441bcd9b0f0f7c56be4d5d73d592f9 (patch) | |
tree | ee8301c106e4edd27e62acae47291e123e9ad8a8 /libs/ptformat | |
parent | 480e0b2a5f9f3ced1c0dee6b0a6b178e35f9e89a (diff) |
ptformat: Decrypt ptf files exported from ptx sessions
Diffstat (limited to 'libs/ptformat')
-rw-r--r-- | libs/ptformat/ptfformat.cc | 28 | ||||
-rw-r--r-- | libs/ptformat/ptfformat.h | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/libs/ptformat/ptfformat.cc b/libs/ptformat/ptfformat.cc index 3d66ec025e..1dba1ac31a 100644 --- a/libs/ptformat/ptfformat.cc +++ b/libs/ptformat/ptfformat.cc @@ -234,6 +234,12 @@ PTFFormat::load(std::string path, int64_t targetsr) { unxor10(); } + // Special case when ptx is exported to ptf in PT + if (v == 3) { + version = 11; + unxor_ptx_to_ptf(); + } + if (version == 0 || version == 5 || version == 7) { /* Haven't detected version yet so decipher */ j = 0; @@ -306,6 +312,28 @@ PTFFormat::unxor10(void) } } +void +PTFFormat::unxor_ptx_to_ptf(void) +{ + unsigned char keyy[16] = { 0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70, + 0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0 + }; + uint64_t j; + uint8_t i; + + for (i = 0, j = 0x10; j < len; j++,i++) { + ptfunxored[j] ^= keyy[i]; + if ((j % 16) == 0) { + i = 0; + if (ptfunxored[j] % 2 == 0) { + ptfunxored[j]++; + } else { + ptfunxored[j]--; + } + } + } +} + int PTFFormat::parse(void) { if (version == 5) { diff --git a/libs/ptformat/ptfformat.h b/libs/ptformat/ptfformat.h index 785544daa0..3a702aa10b 100644 --- a/libs/ptformat/ptfformat.h +++ b/libs/ptformat/ptfformat.h @@ -119,6 +119,7 @@ private: bool foundin(std::string haystack, std::string needle); int parse(void); void unxor10(void); + void unxor_ptx_to_ptf(void); void setrates(void); void parse5header(void); void parse7header(void); |