diff options
| author | Léo Lam <leo@innovatetechnologi.es> | 2017-06-10 17:45:31 +0200 |
|---|---|---|
| committer | Léo Lam <leo@innovatetechnologi.es> | 2017-06-12 20:33:53 +0200 |
| commit | 2eccd45f0108e7bbffbbfbd4a20ea4457c3c92af (patch) | |
| tree | ce4c6bd1d6ab1cbc8f62009dbdd0afee294a313e /Source/Core | |
| parent | 965773bf67ed187c3ec06b2a788a1b5fd29d3b03 (diff) | |
IOSC: Implement GetSizeForType
Avoids duplicating sizes everywhere.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/IOS/IOSC.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
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 <array> #include <cstddef> #include <cstring> +#include <map> +#include <utility> #include <vector> #include <mbedtls/md.h> @@ -25,6 +27,23 @@ namespace IOS { namespace HLE { +const std::map<std::pair<IOSC::ObjectType, IOSC::ObjectSubType>, 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); |
