2017-01-01 13:58:02 +01:00
|
|
|
// Copyright 2017 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstddef>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
namespace HW {
|
|
|
|
namespace AES {
|
|
|
|
|
2018-09-06 22:03:28 +02:00
|
|
|
enum KeySlotID : std::size_t {
|
2018-08-09 23:02:53 +02:00
|
|
|
|
|
|
|
// Used to decrypt the SSL client cert/private-key stored in ClCertA.
|
|
|
|
SSLKey = 0x0D,
|
|
|
|
|
2018-07-28 17:30:54 +02:00
|
|
|
// AES keyslots used to decrypt NCCH
|
|
|
|
NCCHSecure1 = 0x2C,
|
|
|
|
NCCHSecure2 = 0x25,
|
|
|
|
NCCHSecure3 = 0x18,
|
|
|
|
NCCHSecure4 = 0x1B,
|
|
|
|
|
2018-08-09 23:02:53 +02:00
|
|
|
// AES Keyslot used to generate the UDS data frame CCMP key.
|
2017-06-14 21:21:35 +02:00
|
|
|
UDSDataKey = 0x2D,
|
2018-07-28 17:30:54 +02:00
|
|
|
|
|
|
|
// AES keyslot used for APT:Wrap/Unwrap functions
|
2017-01-01 13:58:02 +01:00
|
|
|
APTWrap = 0x31,
|
|
|
|
|
|
|
|
MaxKeySlotID = 0x40,
|
|
|
|
};
|
|
|
|
|
2018-09-06 22:03:28 +02:00
|
|
|
constexpr std::size_t AES_BLOCK_SIZE = 16;
|
2017-01-01 13:58:02 +01:00
|
|
|
|
|
|
|
using AESKey = std::array<u8, AES_BLOCK_SIZE>;
|
|
|
|
|
|
|
|
void InitKeys();
|
|
|
|
|
|
|
|
void SetGeneratorConstant(const AESKey& key);
|
2018-09-06 22:03:28 +02:00
|
|
|
void SetKeyX(std::size_t slot_id, const AESKey& key);
|
|
|
|
void SetKeyY(std::size_t slot_id, const AESKey& key);
|
|
|
|
void SetNormalKey(std::size_t slot_id, const AESKey& key);
|
2017-01-01 13:58:02 +01:00
|
|
|
|
2018-09-06 22:03:28 +02:00
|
|
|
bool IsNormalKeyAvailable(std::size_t slot_id);
|
|
|
|
AESKey GetNormalKey(std::size_t slot_id);
|
2017-01-01 13:58:02 +01:00
|
|
|
|
2018-03-09 18:54:43 +01:00
|
|
|
} // namespace AES
|
2017-01-01 13:58:02 +01:00
|
|
|
} // namespace HW
|