From 10f12f49e7ba69724c3d64ddb30f9068f0730bf3 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 15 May 2020 11:10:28 -0700 Subject: [PATCH] exo2: implement SmcGenerateAesKek, SmcLoadAesKey --- .../include/exosphere/pkg1/pkg1_key_generation.hpp | 8 ++++++++ libexosphere/include/exosphere/pkg1/pkg1_se_key_slots.hpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/libexosphere/include/exosphere/pkg1/pkg1_key_generation.hpp b/libexosphere/include/exosphere/pkg1/pkg1_key_generation.hpp index 711f36ba..5e58876f 100644 --- a/libexosphere/include/exosphere/pkg1/pkg1_key_generation.hpp +++ b/libexosphere/include/exosphere/pkg1/pkg1_key_generation.hpp @@ -44,4 +44,12 @@ namespace ams::pkg1 { constexpr inline const int OldMasterKeyCount = KeyGeneration_Count - 1; constexpr inline const int OldDeviceMasterKeyCount = KeyGeneration_Count - KeyGeneration_4_0_0; + constexpr bool IsValidDeviceUniqueKeyGeneration(int generation) { + return generation == KeyGeneration_1_0_0 || (KeyGeneration_4_0_0 <= generation && generation <= KeyGeneration_Current); + } + + constexpr bool IsValidKeyGeneration(int generation) { + return KeyGeneration_Min <= generation && generation <= KeyGeneration_Current; + } + } diff --git a/libexosphere/include/exosphere/pkg1/pkg1_se_key_slots.hpp b/libexosphere/include/exosphere/pkg1/pkg1_se_key_slots.hpp index 614aa5a3..e7c7074f 100644 --- a/libexosphere/include/exosphere/pkg1/pkg1_se_key_slots.hpp +++ b/libexosphere/include/exosphere/pkg1/pkg1_se_key_slots.hpp @@ -53,4 +53,8 @@ namespace ams::pkg1 { RsaKeySlot_PrivateKey = 1, }; + constexpr bool IsUserAesKeySlot(int slot) { + return AesKeySlot_UserStart <= slot && slot < AesKeySlot_UserEnd; + } + }