CRY

From Mania Tech Wiki
Revision as of 09:57, 19 June 2017 by Xymph (talk | contribs) (space in name)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

.cry files are weakly encrypted text files used in Virtual Skipper and early versions of TrackMania. For example, the VskBoatImporter of Virtual Skipper creates an Info.cry from the Info.txt with the basic information about the boat (name, website, author) and adds it to the boat zip file. As a cipher, XOR encryption is used with a rotating key. After encryption, the ciphertext is compressed by LZO.

File structure

uint32 uncompressedSize
uint32 compressedSize
compressedData[compressedSize]

Restore the plaintext

After the data block is decompressed, the text string can be decrypted by applying the bitwise XOR operator to each character with the given key. The default key is rotated bitwise to the left, depending on the length of the text. The new key is then extended to the text length by repeating it:

uint64 key = 0xCF08317C90460052;
uint32 shift = uncompressedSize & 0x3F;
uint64 rotkey = (key << shift) | (key >> (64 - shift));
for (int i = 0; i < uncompressedSize; i++)
    uncompressedData[i] ^= *( (byte*)&rotkey + (i & 0x7) );