From a1f86a681335aa2a87b887cee756455344bdd738 Mon Sep 17 00:00:00 2001 From: jakcron Date: Mon, 11 Apr 2022 18:01:05 +0800 Subject: [PATCH 1/2] Add support for processing InitialData CryptoTypes 1-2 --- .../deps/libnintendo-n3ds/include/ntd/n3ds/cci.h | 4 +++- ctrtool/src/CciProcess.cpp | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/cci.h b/ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/cci.h index f2ac0a8..57f62fd 100644 --- a/ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/cci.h +++ b/ctrtool/deps/libnintendo-n3ds/include/ntd/n3ds/cci.h @@ -167,7 +167,9 @@ struct CciHeader enum CryptoType { - CryptoType_Secure = 0, // Secure initial data key (keyX bootrom, keyY initial data seed) (used in production ROMs) + CryptoType_Secure0 = 0, // Secure initial data key (keyX bootrom, keyY initial data seed) (used in production ROMs) + CryptoType_Secure1 = 1, // Secure initial data key (keyX bootrom, keyY initial data seed) (used in production ROMs) + CryptoType_Secure2 = 2, // Secure initial data key (keyX bootrom, keyY initial data seed) (used in production ROMs) CryptoType_FixedKey = 3, // Zeros initial data key (used in non-HSM enviroments like development) }; diff --git a/ctrtool/src/CciProcess.cpp b/ctrtool/src/CciProcess.cpp index fccad6f..f286edf 100644 --- a/ctrtool/src/CciProcess.cpp +++ b/ctrtool/src/CciProcess.cpp @@ -171,8 +171,10 @@ void ctrtool::CciProcess::importHeader() ctrtool::KeyBag::Aes128Key initial_data_key; bool initial_data_key_available = false; - // crypto_type 0 is the normal "secure" initial data key - if (mHeader.card_info.flag.crypto_type == ntd::n3ds::CciHeader::CryptoType_Secure) + // crypto_type 0-2 is the normal "secure" initial data key + if (mHeader.card_info.flag.crypto_type == ntd::n3ds::CciHeader::CryptoType_Secure0 || + mHeader.card_info.flag.crypto_type == ntd::n3ds::CciHeader::CryptoType_Secure1 || + mHeader.card_info.flag.crypto_type == ntd::n3ds::CciHeader::CryptoType_Secure2) { if (mKeyBag.brom_static_key_x.find(mKeyBag.KEYSLOT_INITIAL_DATA) != mKeyBag.brom_static_key_x.end()) { @@ -530,8 +532,14 @@ std::string ctrtool::CciProcess::getCryptoTypeString(byte_t crypto_type) switch(crypto_type) { - case ntd::n3ds::CciHeader::CryptoType_Secure : - ret_str = "Secure"; + case ntd::n3ds::CciHeader::CryptoType_Secure0 : + ret_str = "Secure0"; + break; + case ntd::n3ds::CciHeader::CryptoType_Secure1 : + ret_str = "Secure1"; + break; + case ntd::n3ds::CciHeader::CryptoType_Secure2 : + ret_str = "Secure2"; break; case ntd::n3ds::CciHeader::CryptoType_FixedKey : ret_str = "FixedKey"; From 5c584f4d36b246e3d7b25b2be30cd29f86d59b49 Mon Sep 17 00:00:00 2001 From: jakcron Date: Mon, 11 Apr 2022 18:01:44 +0800 Subject: [PATCH 2/2] Bump version. --- ctrtool/src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctrtool/src/version.h b/ctrtool/src/version.h index 2ee7a9f..27dba3b 100644 --- a/ctrtool/src/version.h +++ b/ctrtool/src/version.h @@ -3,5 +3,5 @@ #define BIN_NAME "ctrtool" #define VER_MAJOR 1 #define VER_MINOR 0 -#define VER_PATCH 3 +#define VER_PATCH 4 #define AUTHORS "jakcron" \ No newline at end of file