Changes

Jump to navigation Jump to search
988 bytes added ,  06:38, 9 April 2011
no edit summary
Line 1: Line 1:  +
=== Encryption ===
 +
 
On the 3DS savegames are stored much like on the DS, that is on an EEPROM in the gamecart. On the DS these savegames were stored in plaintext but on the 3DS a layer of encryption was added. This is highly likely a streamcipher, as the contents of several savegames exhibit the odd behaviour that xor-ing certain parts of the savegame together will result in the plaintext appearing.
 
On the 3DS savegames are stored much like on the DS, that is on an EEPROM in the gamecart. On the DS these savegames were stored in plaintext but on the 3DS a layer of encryption was added. This is highly likely a streamcipher, as the contents of several savegames exhibit the odd behaviour that xor-ing certain parts of the savegame together will result in the plaintext appearing.
   Line 5: Line 7:  
So how do you use this to decrypt a savegame on a 3DS? First off, you chunk up the savegame into 512 byte chunks. Then, you bin these chunks by their contents, discarding any that contain only FF. Now look for the most common chunk. This is your keystream. Now XOR the keystream with your original savegame and you should have a fully decrypted savegame. XOR with the keystream again to produce an encrypted savegame.
 
So how do you use this to decrypt a savegame on a 3DS? First off, you chunk up the savegame into 512 byte chunks. Then, you bin these chunks by their contents, discarding any that contain only FF. Now look for the most common chunk. This is your keystream. Now XOR the keystream with your original savegame and you should have a fully decrypted savegame. XOR with the keystream again to produce an encrypted savegame.
   −
   
+
=== Wearleveling ===
 +
 
 +
The 3DS employs a wearleveling scheme on the savegame FLASH chips. This is done trough blockmaps. Depending on the size of the flashchip, these are located somewhere at the beginning of the flashchip, in the first sector. The structure is as follows:
 +
 
 +
struct sector_entry {
 +
        uint8_t virt_sec;      // Mapped to sector
 +
        uint8_t prev_virt_sec; // Physical sector previously mapped to
 +
        uint8_t phys_sec;      // Mapped from sector
 +
        uint8_t prev_phys_sec;  // Virtual sector previously mapped to
 +
        uint8_t virt_realloc_cnt;      // Amount of times virtual sector has been remapped
 +
        uint8_t phys_realloc_cnt;      // Amount of times physical sector has been remapped
 +
        uint8_t chksums[8];
 +
} __attribute__((packed));
 +
 
 +
struct long_sector_entry{
 +
        struct sector_entry sector;
 +
        struct sector_entry dupe;
 +
        uint32_t magic;
 +
};
 +
 
 +
With magic being a constant 0x080d6ce0.
 +
 
 +
=== Filesystem ===
 
   
 
   
 
Savefiles stored on the EEPROM are using a custom FS.
 
Savefiles stored on the EEPROM are using a custom FS.
25

edits

Navigation menu