IOSC: Implement GetSizeForType
Avoids duplicating sizes everywhere.
This commit is contained in:
parent
965773bf67
commit
2eccd45f01
|
@ -6,6 +6,8 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <map>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <mbedtls/md.h>
|
#include <mbedtls/md.h>
|
||||||
|
@ -25,6 +27,23 @@ namespace IOS
|
||||||
{
|
{
|
||||||
namespace HLE
|
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)
|
IOSC::IOSC(ConsoleType console_type)
|
||||||
{
|
{
|
||||||
LoadDefaultEntries(console_type);
|
LoadDefaultEntries(console_type);
|
||||||
|
|
Loading…
Reference in New Issue