diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-09-24 02:51:44 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-10-07 19:15:11 +0200 |
commit | c79d2ca6cf076bb5704ad221ff2a500cb8a94b84 (patch) | |
tree | bf9560a0a047d0cbf63ad4ea02dc3588b4f5dd8d /src/core/crypto | |
parent | key_manager: Add support for crypto revisions past 04 (diff) | |
download | yuzu-c79d2ca6cf076bb5704ad221ff2a500cb8a94b84.tar yuzu-c79d2ca6cf076bb5704ad221ff2a500cb8a94b84.tar.gz yuzu-c79d2ca6cf076bb5704ad221ff2a500cb8a94b84.tar.bz2 yuzu-c79d2ca6cf076bb5704ad221ff2a500cb8a94b84.tar.lz yuzu-c79d2ca6cf076bb5704ad221ff2a500cb8a94b84.tar.xz yuzu-c79d2ca6cf076bb5704ad221ff2a500cb8a94b84.tar.zst yuzu-c79d2ca6cf076bb5704ad221ff2a500cb8a94b84.zip |
Diffstat (limited to 'src/core/crypto')
-rw-r--r-- | src/core/crypto/key_manager.cpp | 10 | ||||
-rw-r--r-- | src/core/crypto/key_manager.h | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 85776cdcb..0f1a86d1e 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -21,6 +21,8 @@ namespace Core::Crypto { +constexpr u64 CURRENT_CRYPTO_REVISION = 0x5; + Key128 GenerateKeyEncryptionKey(Key128 source, Key128 master, Key128 kek_seed, Key128 key_seed) { Key128 out{}; @@ -37,6 +39,14 @@ Key128 GenerateKeyEncryptionKey(Key128 source, Key128 master, Key128 kek_seed, K return out; } +Key128 DeriveKeyblobKey(Key128 sbk, Key128 tsec, Key128 source) { + AESCipher<Key128> sbk_cipher(sbk, Mode::ECB); + AESCipher<Key128> tsec_cipher(tsec, Mode::ECB); + tsec_cipher.Transcode(source.data(), source.size(), source.data(), Op::Decrypt); + sbk_cipher.Transcode(source.data(), source.size(), source.data(), Op::Decrypt); + return source; +} + boost::optional<Key128> DeriveSDSeed() { const FileUtil::IOFile save_43(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000043", diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index ffc13fa8f..b2c386bfb 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -109,6 +109,8 @@ public: private: boost::container::flat_map<KeyIndex<S128KeyType>, Key128> s128_keys; boost::container::flat_map<KeyIndex<S256KeyType>, Key256> s256_keys; + std::array<std::array<u8, 0xB0>, 0x20> encrypted_keyblobs{}; + std::array<std::array<u8, 0x90>, 0x20> keyblobs{}; bool dev_mode; void LoadFromFile(const std::string& filename, bool is_title_keys); @@ -122,6 +124,8 @@ private: }; Key128 GenerateKeyEncryptionKey(Key128 source, Key128 master, Key128 kek_seed, Key128 key_seed); +Key128 DeriveKeyblobKey(Key128 sbk, Key128 tsec, Key128 source); + boost::optional<Key128> DeriveSDSeed(); Loader::ResultStatus DeriveSDKeys(std::array<Key256, 2>& sd_keys, const KeyManager& keys); |