mirror of
https://github.com/PabloMK7/citra.git
synced 2024-12-29 11:06:12 +00:00
service/ps: Address review
This commit is contained in:
parent
b34847d59e
commit
0f65dac964
|
@ -23,16 +23,18 @@ enum class AlgorithmType : u8 {
|
|||
};
|
||||
|
||||
constexpr std::array<u8, 10> KeyTypes{{
|
||||
0x0D,
|
||||
0x2D,
|
||||
0x31,
|
||||
0x38,
|
||||
0x32,
|
||||
0x39,
|
||||
0x2E,
|
||||
0, /* invalid */
|
||||
0x36,
|
||||
0x39,
|
||||
HW::AES::SSLKey,
|
||||
HW::AES::UDSDataKey,
|
||||
HW::AES::APTWrap,
|
||||
HW::AES::BOSSDataKey,
|
||||
0x32, // unknown
|
||||
HW::AES::DLPDataKey,
|
||||
HW::AES::CECDDataKey,
|
||||
0, // invalid
|
||||
HW::AES::FRDKey,
|
||||
// Note: According to 3dbrew the KeyY is overridden by Process9 when using this key type.
|
||||
// TODO: implement this behaviour?
|
||||
HW::AES::NFCKey,
|
||||
}};
|
||||
|
||||
void PS_PS::EncryptDecryptAes(Kernel::HLERequestContext& ctx) {
|
||||
|
@ -65,9 +67,11 @@ void PS_PS::EncryptDecryptAes(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
if (algorithm == AlgorithmType::CCM_Encrypt || algorithm == AlgorithmType::CCM_Decrypt) {
|
||||
// AES-CCM is not supported with this function
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
||||
rb.Push(ResultCode(ErrorDescription::InvalidSection, ErrorModule::PS,
|
||||
ErrorSummary::WrongArgument, ErrorLevel::Status));
|
||||
rb.PushMappedBuffer(source);
|
||||
rb.PushMappedBuffer(destination);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -120,8 +124,8 @@ void PS_PS::EncryptDecryptAes(Kernel::HLERequestContext& ctx) {
|
|||
std::array<u8, AES::BLOCKSIZE> new_iv;
|
||||
if (algorithm == AlgorithmType::CTR_Encrypt || algorithm == AlgorithmType::CTR_Decrypt) {
|
||||
new_iv = HW::AES::Add128(iv, src_size / 16);
|
||||
} else if (algorithm == AlgorithmType::CBC_Encrypt) { // For AES-CBC, The new IV is the last
|
||||
// block of ciphertext
|
||||
} else if (algorithm == AlgorithmType::CBC_Encrypt) {
|
||||
// For AES-CBC, The new IV is the last block of ciphertext
|
||||
std::copy_n(dst_buffer.end() - new_iv.size(), new_iv.size(), new_iv.begin());
|
||||
} else {
|
||||
std::copy_n(src_buffer.end() - new_iv.size(), new_iv.size(), new_iv.begin());
|
||||
|
|
|
@ -24,6 +24,21 @@ enum KeySlotID : std::size_t {
|
|||
// AES Keyslot used to generate the UDS data frame CCMP key.
|
||||
UDSDataKey = 0x2D,
|
||||
|
||||
// AES Keyslot used to encrypt the BOSS container data.
|
||||
BOSSDataKey = 0x38,
|
||||
|
||||
// AES Keyslot used to calculate DLP data frame checksum.
|
||||
DLPDataKey = 0x39,
|
||||
|
||||
// AES Keyslot used to generate the StreetPass CCMP key.
|
||||
CECDDataKey = 0x2E,
|
||||
|
||||
// AES Keyslot used by the friends module.
|
||||
FRDKey = 0x36,
|
||||
|
||||
// AES Keyslot used by the NFC module.
|
||||
NFCKey = 0x39,
|
||||
|
||||
// AES keyslot used for APT:Wrap/Unwrap functions
|
||||
APTWrap = 0x31,
|
||||
|
||||
|
|
Loading…
Reference in a new issue