From 0d4a0348b579b39c0c9ff6245ce00705430b941e Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 25 Apr 2019 11:36:23 -0700 Subject: [PATCH] spl: Loosen keyslot restrictions on 1.0.0 --- stratosphere/spl/source/spl_secmon_wrapper.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/stratosphere/spl/source/spl_secmon_wrapper.cpp b/stratosphere/spl/source/spl_secmon_wrapper.cpp index e4ca99a31..13ab731af 100644 --- a/stratosphere/spl/source/spl_secmon_wrapper.cpp +++ b/stratosphere/spl/source/spl_secmon_wrapper.cpp @@ -560,6 +560,12 @@ Result SecureMonitorWrapper::ComputeCmac(Cmac *out_cmac, u32 keyslot, const void } Result SecureMonitorWrapper::AllocateAesKeyslot(u32 *out_keyslot, const void *owner) { + if (GetRuntimeFirmwareVersion() <= FirmwareVersion_100) { + /* On 1.0.0, keyslots were kind of a wild west. */ + *out_keyslot = 0; + return ResultSuccess; + } + for (size_t i = 0; i < GetMaxKeyslots(); i++) { if (this->keyslot_owners[i] == 0) { this->keyslot_owners[i] = owner; @@ -576,13 +582,18 @@ Result SecureMonitorWrapper::ValidateAesKeyslot(u32 keyslot, const void *owner) if (keyslot >= GetMaxKeyslots()) { return ResultSplInvalidKeyslot; } - if (this->keyslot_owners[keyslot] != owner) { + if (this->keyslot_owners[keyslot] != owner && GetRuntimeFirmwareVersion() > FirmwareVersion_100) { return ResultSplInvalidKeyslot; } return ResultSuccess; } Result SecureMonitorWrapper::FreeAesKeyslot(u32 keyslot, const void *owner) { + if (GetRuntimeFirmwareVersion() <= FirmwareVersion_100) { + /* On 1.0.0, keyslots were kind of a wild west. */ + return ResultSuccess; + } + Result rc = ValidateAesKeyslot(keyslot, owner); if (R_FAILED(rc)) { return rc;