mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-25 19:25:37 +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{{
|
constexpr std::array<u8, 10> KeyTypes{{
|
||||||
0x0D,
|
HW::AES::SSLKey,
|
||||||
0x2D,
|
HW::AES::UDSDataKey,
|
||||||
0x31,
|
HW::AES::APTWrap,
|
||||||
0x38,
|
HW::AES::BOSSDataKey,
|
||||||
0x32,
|
0x32, // unknown
|
||||||
0x39,
|
HW::AES::DLPDataKey,
|
||||||
0x2E,
|
HW::AES::CECDDataKey,
|
||||||
0, /* invalid */
|
0, // invalid
|
||||||
0x36,
|
HW::AES::FRDKey,
|
||||||
0x39,
|
// 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) {
|
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) {
|
if (algorithm == AlgorithmType::CCM_Encrypt || algorithm == AlgorithmType::CCM_Decrypt) {
|
||||||
// AES-CCM is not supported with this function
|
// 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,
|
rb.Push(ResultCode(ErrorDescription::InvalidSection, ErrorModule::PS,
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Status));
|
ErrorSummary::WrongArgument, ErrorLevel::Status));
|
||||||
|
rb.PushMappedBuffer(source);
|
||||||
|
rb.PushMappedBuffer(destination);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,8 +124,8 @@ void PS_PS::EncryptDecryptAes(Kernel::HLERequestContext& ctx) {
|
||||||
std::array<u8, AES::BLOCKSIZE> new_iv;
|
std::array<u8, AES::BLOCKSIZE> new_iv;
|
||||||
if (algorithm == AlgorithmType::CTR_Encrypt || algorithm == AlgorithmType::CTR_Decrypt) {
|
if (algorithm == AlgorithmType::CTR_Encrypt || algorithm == AlgorithmType::CTR_Decrypt) {
|
||||||
new_iv = HW::AES::Add128(iv, src_size / 16);
|
new_iv = HW::AES::Add128(iv, src_size / 16);
|
||||||
} else if (algorithm == AlgorithmType::CBC_Encrypt) { // For AES-CBC, The new IV is the last
|
} else if (algorithm == AlgorithmType::CBC_Encrypt) {
|
||||||
// block of ciphertext
|
// 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());
|
std::copy_n(dst_buffer.end() - new_iv.size(), new_iv.size(), new_iv.begin());
|
||||||
} else {
|
} else {
|
||||||
std::copy_n(src_buffer.end() - new_iv.size(), new_iv.size(), new_iv.begin());
|
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.
|
// AES Keyslot used to generate the UDS data frame CCMP key.
|
||||||
UDSDataKey = 0x2D,
|
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
|
// AES keyslot used for APT:Wrap/Unwrap functions
|
||||||
APTWrap = 0x31,
|
APTWrap = 0x31,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue