exo2: implement SmcModularExponentiate(ByStorageKey)

This commit is contained in:
Michael Scire 2020-05-20 08:10:54 -07:00 committed by SciresM
parent ccba70abfe
commit 8a4019151b
3 changed files with 190 additions and 10 deletions

View file

@ -20,6 +20,8 @@ namespace ams::secmon {
namespace {
constexpr const u8 RsaPublicKey[] = { 0x00, 0x01, 0x00, 0x01 };
constinit u8 g_rsa_moduli[ImportRsaKey_Count][se::RsaSize] = {};
constinit bool g_rsa_modulus_committed[ImportRsaKey_Count] = {};
@ -80,6 +82,10 @@ namespace ams::secmon {
se::SetRsaKey(slot, GetRsaKeyModulus(which), se::RsaSize, GetRsaKeyPrivateExponent(which), se::RsaSize);
}
void LoadProvisionalRsaPublicKey(int slot, ImportRsaKey which) {
se::SetRsaKey(slot, GetRsaKeyModulus(which), se::RsaSize, RsaPublicKey, sizeof(RsaPublicKey));
}
void SetMasterKey(int generation, const void *src, size_t size) {
const int index = generation - pkg1::KeyGeneration_Min;
se::EncryptAes128(GetMasterKeyStorage(index), se::AesBlockSize, pkg1::AesKeySlot_RandomForKeyStorageWrap, src, size);