New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOSC additions and fixes #5598
IOSC additions and fixes #5598
Conversation
Source/Core/Core/IOS/IOSC.cpp
Outdated
} | ||
case SUBTYPE_ECC233: | ||
ERROR_LOG(IOS, "VerifyPublicKeySign: SUBTYPE_ECC233 is unimplemented"); | ||
// Fallthrough intended. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/IOS/IOSC.cpp
Outdated
|
||
mbedtls_mpi_read_binary(&rsa.N, entry->data.data(), entry->data.size()); | ||
mbedtls_mpi_read_binary(&rsa.E, entry->misc_data.data(), entry->misc_data.size()); | ||
rsa.len = (mbedtls_mpi_bitlen(&rsa.N) + 7) >> 3; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/IOS/IOSC.h
Outdated
@@ -171,8 +171,9 @@ class IOSC final | |||
// Import a secret, encrypted key into dest_handle, which will be decrypted using decrypt_handle. | |||
ReturnCode ImportSecretKey(Handle dest_handle, Handle decrypt_handle, u8* iv, | |||
const u8* encrypted_key, u32 pid); | |||
// Import a public key. | |||
ReturnCode ImportPublicKey(Handle dest_handle, const u8* public_key, u32 pid); | |||
// Import a public key. public_key_exponent should be passed for RSA keys. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
reinterpret_cast<const char*>(m_bytes.data() + offsetof(Ticket, signature_issuer)); | ||
return std::string(bytes, strnlen(bytes, sizeof(Ticket::signature_issuer))); | ||
reinterpret_cast<const char*>(m_bytes.data() + offsetof(Ticket, signature.issuer)); | ||
return std::string(bytes, strnlen(bytes, sizeof(Ticket::signature.issuer))); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/IOS/IOSC.h
Outdated
SignatureRSA4096 signature; | ||
CertHeader header; | ||
// 0x100, not 0x200 bytes. | ||
u8 public_key[0x100]; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/IOS/IOSC.h
Outdated
SignatureType type; | ||
u8 sig[0x200]; | ||
u8 fill[60]; | ||
char issuer[0x40]; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Makes it slightly less likely to forget a check and end up doing an out-of-bounds access. Also makes it obvious that we *are* indeed checking whether the handle is valid, instead of hiding it in HasOwnership (which won't handle the root key handle case properly).
Will be used to store the exponent for RSA keys.
It contains a RSA4096 public key used to validate all other Nintendo certificates.
Partial implementation which doesn't support ECC stuff, but good enough for our purposes.
}; | ||
static_assert(sizeof(CertRSA2048) == 0x300, "Wrong size for CertRSA2048"); | ||
|
||
union Cert |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -22,6 +26,23 @@ namespace IOS | |||
{ | |||
namespace HLE | |||
{ | |||
const std::map<std::pair<IOSC::ObjectType, IOSC::ObjectSubType>, size_t> s_type_to_size_map = {{ |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Avoids duplicating sizes everywhere.
Same as VerifyPublicKeySign, we currently only support RSA keys (which is all we need right now).
A set of additions and fixes to IOSC that will be used in a follow-up PR. Split from a branch to make reviewing easier.