From 7f0f37fca781a578c7736f59cf70c859fdde271a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 3 Aug 2020 13:18:43 -0400 Subject: 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. --- src/core/crypto/key_manager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core/crypto/key_manager.cpp') 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 { constexpr u64 CURRENT_CRYPTO_REVISION = 0x5; constexpr u64 FULL_TICKET_SIZE = 0x400; -using namespace Common; +using Common::AsArray; -const std::array eticket_source_hashes{ - "B71DB271DC338DF380AA2C4335EF8873B1AFD408E80B3582D8719FC81C5E511C"_array32, // eticket_rsa_kek_source - "E8965A187D30E57869F562D04383C996DE487BBA5761363D2D4D32391866A85C"_array32, // eticket_rsa_kekek_source +// clang-format off +constexpr std::array eticket_source_hashes{ + AsArray("B71DB271DC338DF380AA2C4335EF8873B1AFD408E80B3582D8719FC81C5E511C"), // eticket_rsa_kek_source + AsArray("E8965A187D30E57869F562D04383C996DE487BBA5761363D2D4D32391866A85C"), // eticket_rsa_kekek_source }; +// clang-format on const std::map, std::string> KEYS_VARIABLE_LENGTH{ {{S128KeyType::Master, 0}, "master_key_"}, -- cgit v1.2.3