Citra: Support for AES engine keys/loading encrypted ROMs.

Created on 21 May 2017  路  4Comments  路  Source: citra-emu/citra

At the moment, Citra has no mechanism for loading encrypted ROMs, and doesn't support performing crypto with arbitrary AES engine keyslots.

Since bootroms can be dumped by anyone with a console now, perhaps add support for initializing keyslots/decrypting ROMs if the user provides the bootrom and their OTP (for console unique key initialization)?

Could also have user provide a .txt file containing their keys, I suppose.

A-filesystem enhancement

Most helpful comment

There is already some key infrastructure in place: https://github.com/citra-emu/citra/tree/master/src/core/hw/aes
However, right now it's only used for the APT:Wrap functions. For encrypted file support the loaders and filesystem code would have to be modified to support that.

I think it's a good idea to first re-work how we handle our filesystem stuff by decoupling the VFS implementations from our FS HLE. Then they can be re-used for the loaders too and would lead to better code overall. I plan on working on this soon.

All 4 comments

There is already some key infrastructure in place: https://github.com/citra-emu/citra/tree/master/src/core/hw/aes
However, right now it's only used for the APT:Wrap functions. For encrypted file support the loaders and filesystem code would have to be modified to support that.

I think it's a good idea to first re-work how we handle our filesystem stuff by decoupling the VFS implementations from our FS HLE. Then they can be re-used for the loaders too and would lead to better code overall. I plan on working on this soon.

I started working on generating all the keys using boot9. I've got all the common keys matching the values I get from yellows8/boot9_tools, and I intend to optionally generate the console-unique keys if the OTP/movable.sed are available. (That might be useful for, e.g., importing files directly from a 3DS SD card.) The only thing used from aes_keys.txt would be the key generator constant.

If I can find the time, I'll get it finished up and make an RFC PR in a few days. The biggest question I have is regarding design - I refactored the code into an AESEngine class that encapsulates the key slots and keygen constant, and holds the logic for initializing the keyslots. I then created a singleton instance in hw.cpp. Is that OK?

@flubberwurst An engine loading keys from boot9 and otp is welcome (and the AESEngine stuff sound fine to me). However, if you are also going to implement ROM decryption, you probably want to talk to @yuriks since we are going to have a FS rework first (https://github.com/citra-emu/citra/projects/1)

Support for loading encrypted roms and keys has been added now.

Was this page helpful?
0 / 5 - 0 ratings