From 2eccd45f0108e7bbffbbfbd4a20ea4457c3c92af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 10 Jun 2017 17:45:31 +0200 Subject: [PATCH] IOSC: Implement GetSizeForType Avoids duplicating sizes everywhere. --- Source/Core/Core/IOS/IOSC.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Source/Core/Core/IOS/IOSC.cpp b/Source/Core/Core/IOS/IOSC.cpp index f0f9b0123d..6a23a0e2b4 100644 --- a/Source/Core/Core/IOS/IOSC.cpp +++ b/Source/Core/Core/IOS/IOSC.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include @@ -25,6 +27,23 @@ namespace IOS { namespace HLE { +const std::map, size_t> s_type_to_size_map = {{ + {{IOSC::TYPE_SECRET_KEY, IOSC::SUBTYPE_AES128}, 16}, + {{IOSC::TYPE_SECRET_KEY, IOSC::SUBTYPE_MAC}, 20}, + {{IOSC::TYPE_SECRET_KEY, IOSC::SUBTYPE_ECC233}, 30}, + {{IOSC::TYPE_PUBLIC_KEY, IOSC::SUBTYPE_RSA2048}, 256}, + {{IOSC::TYPE_PUBLIC_KEY, IOSC::SUBTYPE_RSA4096}, 512}, + {{IOSC::TYPE_PUBLIC_KEY, IOSC::SUBTYPE_ECC233}, 60}, + {{IOSC::TYPE_DATA, IOSC::SUBTYPE_DATA}, 0}, + {{IOSC::TYPE_DATA, IOSC::SUBTYPE_VERSION}, 0}, +}}; + +static size_t GetSizeForType(IOSC::ObjectType type, IOSC::ObjectSubType subtype) +{ + const auto iterator = s_type_to_size_map.find({type, subtype}); + return iterator != s_type_to_size_map.end() ? iterator->second : 0; +} + IOSC::IOSC(ConsoleType console_type) { LoadDefaultEntries(console_type);