summaryrefslogtreecommitdiff
path: root/src/core/crypto/key_manager.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2020-08-03 13:18:43 -0400
committerGravatar Lioncash2020-08-06 02:41:58 -0400
commit7f0f37fca781a578c7736f59cf70c859fdde271a (patch)
treeff15936ae29e9c0c416f2b62516d3ec3dedf1ef0 /src/core/crypto/key_manager.cpp
parentipc: Allow all trivially copyable objects to be passed directly into WriteBuf... (diff)
downloadyuzu-7f0f37fca781a578c7736f59cf70c859fdde271a.tar.gz
yuzu-7f0f37fca781a578c7736f59cf70c859fdde271a.tar.xz
yuzu-7f0f37fca781a578c7736f59cf70c859fdde271a.zip
partition_data_manager: Make data arrays constexpr
Previously the constructor for all of these would run at program startup, consuming time before the application can enter main(). This is also particularly dangerous, given the logging system wouldn't have been initialized properly yet, yet the program would use the logs to signify an error. To rectify this, we can replace the literals with constexpr functions that perform the conversion at compile-time, completely eliminating the runtime cost of initializing these arrays.
Diffstat (limited to 'src/core/crypto/key_manager.cpp')
-rw-r--r--src/core/crypto/key_manager.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp
index f87fe0abc..c09f7ad41 100644
--- a/src/core/crypto/key_manager.cpp
+++ b/src/core/crypto/key_manager.cpp
@@ -40,12 +40,14 @@ namespace Core::Crypto {
40constexpr u64 CURRENT_CRYPTO_REVISION = 0x5; 40constexpr u64 CURRENT_CRYPTO_REVISION = 0x5;
41constexpr u64 FULL_TICKET_SIZE = 0x400; 41constexpr u64 FULL_TICKET_SIZE = 0x400;
42 42
43using namespace Common; 43using Common::AsArray;
44 44
45const std::array<SHA256Hash, 2> eticket_source_hashes{ 45// clang-format off
46 "B71DB271DC338DF380AA2C4335EF8873B1AFD408E80B3582D8719FC81C5E511C"_array32, // eticket_rsa_kek_source 46constexpr std::array eticket_source_hashes{
47 "E8965A187D30E57869F562D04383C996DE487BBA5761363D2D4D32391866A85C"_array32, // eticket_rsa_kekek_source 47 AsArray("B71DB271DC338DF380AA2C4335EF8873B1AFD408E80B3582D8719FC81C5E511C"), // eticket_rsa_kek_source
48 AsArray("E8965A187D30E57869F562D04383C996DE487BBA5761363D2D4D32391866A85C"), // eticket_rsa_kekek_source
48}; 49};
50// clang-format on
49 51
50const std::map<std::pair<S128KeyType, u64>, std::string> KEYS_VARIABLE_LENGTH{ 52const std::map<std::pair<S128KeyType, u64>, std::string> KEYS_VARIABLE_LENGTH{
51 {{S128KeyType::Master, 0}, "master_key_"}, 53 {{S128KeyType::Master, 0}, "master_key_"},