Skip to content
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

Merged
merged 8 commits into from Jun 12, 2017
Merged

IOSC additions and fixes #5598

merged 8 commits into from Jun 12, 2017

Conversation

leoetlino
Copy link
Member

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.

  • Add structures for certificates and signatures.
  • Clearer handle checks.
  • Add support for the root key handle.
  • Implement VerifyPublicKeySign and ImportCertificate.
  • Fix ImportPublicKey to work with RSA public keys.

}
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.

This comment was marked as off-topic.


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.

This comment was marked as off-topic.

@@ -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.

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.

SignatureRSA4096 signature;
CertHeader header;
// 0x100, not 0x200 bytes.
u8 public_key[0x100];

This comment was marked as off-topic.

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.

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.

@@ -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.

Avoids duplicating sizes everywhere.
Same as VerifyPublicKeySign, we currently only support RSA keys
(which is all we need right now).
@leoetlino leoetlino merged commit 9b8feb8 into dolphin-emu:master Jun 12, 2017
@leoetlino leoetlino deleted the iosc-fixes branch June 12, 2017 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants