Implement support for parsing/interacting with NCAs. (#942)
* fs: implement support for interacting with ncas. * spl: extend to use virtual keyslots
This commit is contained in:
@@ -75,7 +75,7 @@ void __appInit(void) {
|
||||
R_ABORT_UNLESS(fsInitialize());
|
||||
lr::Initialize();
|
||||
R_ABORT_UNLESS(fsldrInitialize());
|
||||
R_ABORT_UNLESS(splInitialize());
|
||||
spl::Initialize();
|
||||
});
|
||||
|
||||
ams::CheckApiVersion();
|
||||
@@ -83,7 +83,7 @@ void __appInit(void) {
|
||||
|
||||
void __appExit(void) {
|
||||
/* Cleanup services. */
|
||||
splExit();
|
||||
spl::Finalize();
|
||||
fsldrExit();
|
||||
lr::Finalize();
|
||||
fsExit();
|
||||
@@ -121,9 +121,9 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Configure development. */
|
||||
/* NOTE: Nintendo really does call the getter function three times instead of caching the value. */
|
||||
ldr::SetDevelopmentForAcidProductionCheck(spl::IsDevelopmentHardware());
|
||||
ldr::SetDevelopmentForAntiDowngradeCheck(spl::IsDevelopmentHardware());
|
||||
ldr::SetDevelopmentForAcidSignatureCheck(spl::IsDevelopmentHardware());
|
||||
ldr::SetDevelopmentForAcidProductionCheck(spl::IsDevelopment());
|
||||
ldr::SetDevelopmentForAntiDowngradeCheck(spl::IsDevelopment());
|
||||
ldr::SetDevelopmentForAcidSignatureCheck(spl::IsDevelopment());
|
||||
|
||||
/* Add services to manager. */
|
||||
R_ABORT_UNLESS((g_server_manager.RegisterServer<ldr::pm::ProcessManagerInterface>(ProcessManagerServiceName, ProcessManagerMaxSessions)));
|
||||
|
||||
@@ -101,13 +101,7 @@ namespace ams::ldr {
|
||||
}
|
||||
|
||||
const u8 *GetAcidSignatureModulus(u32 key_generation) {
|
||||
AMS_ASSERT(key_generation <= fssystem::AcidSignatureKeyGenerationMax);
|
||||
const u32 used_keygen = (key_generation % (fssystem::AcidSignatureKeyGenerationMax + 1));
|
||||
if (IsDevelopmentForAcidSignatureCheck()) {
|
||||
return fssystem::AcidSignatureKeyModulusDev[used_keygen];
|
||||
} else {
|
||||
return fssystem::AcidSignatureKeyModulusProd[used_keygen];
|
||||
}
|
||||
return fssystem::GetAcidSignatureKeyModulus(!IsDevelopmentForAcidSignatureCheck(), key_generation);
|
||||
}
|
||||
|
||||
Result ValidateAcidSignature(Meta *meta) {
|
||||
@@ -122,8 +116,8 @@ namespace ams::ldr {
|
||||
const size_t sig_size = sizeof(meta->acid->signature);
|
||||
const u8 *mod = GetAcidSignatureModulus(meta->npdm->signature_key_generation);
|
||||
const size_t mod_size = fssystem::AcidSignatureKeyModulusSize;
|
||||
const u8 *exp = fssystem::AcidSignatureKeyExponent;
|
||||
const size_t exp_size = fssystem::AcidSignatureKeyExponentSize;
|
||||
const u8 *exp = fssystem::GetAcidSignatureKeyPublicExponent();
|
||||
const size_t exp_size = fssystem::AcidSignatureKeyPublicExponentSize;
|
||||
const u8 *msg = meta->acid->modulus;
|
||||
const size_t msg_size = meta->acid->size;
|
||||
const bool is_signature_valid = crypto::VerifyRsa2048PssSha256(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size);
|
||||
|
||||
@@ -224,8 +224,8 @@ namespace ams::ldr {
|
||||
const size_t sig_size = sizeof(code_info.signature);
|
||||
const u8 *mod = static_cast<u8 *>(meta->modulus);
|
||||
const size_t mod_size = crypto::Rsa2048PssSha256Verifier::ModulusSize;
|
||||
const u8 *exp = fssystem::AcidSignatureKeyExponent;
|
||||
const size_t exp_size = fssystem::AcidSignatureKeyExponentSize;
|
||||
const u8 *exp = fssystem::GetAcidSignatureKeyPublicExponent();
|
||||
const size_t exp_size = fssystem::AcidSignatureKeyPublicExponentSize;
|
||||
const u8 *hsh = code_info.hash;
|
||||
const size_t hsh_size = sizeof(code_info.hash);
|
||||
const bool is_signature_valid = crypto::VerifyRsa2048PssSha256WithHash(sig, sig_size, mod, mod_size, exp, exp_size, hsh, hsh_size);
|
||||
|
||||
Reference in New Issue
Block a user