mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-27 15:11:16 +00:00
235 lines
17 KiB
C++
235 lines
17 KiB
C++
/*
|
|
* Copyright (c) Atmosphère-NX
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include <stratosphere.hpp>
|
|
|
|
namespace ams::gc::impl {
|
|
|
|
namespace {
|
|
|
|
constexpr const u8 LibraryEmbeddedCa1Modulus[GcCrypto::GcRsaKeyLength] = {
|
|
0xAF, 0xB6, 0xA0, 0x1F, 0x7F, 0x8C, 0xEC, 0xD6, 0x62, 0xC9, 0xF9, 0x83, 0x69, 0x4F, 0x0E, 0x8E,
|
|
0xC3, 0x71, 0x70, 0x60, 0x63, 0xEB, 0x90, 0x2F, 0x1E, 0x3B, 0xA2, 0xCD, 0xD5, 0x7A, 0xAA, 0x45,
|
|
0x27, 0x61, 0xF9, 0x10, 0xC0, 0x0C, 0x72, 0xE7, 0xBD, 0x70, 0x2E, 0x32, 0xA0, 0xD0, 0x8A, 0x29,
|
|
0x43, 0x19, 0x12, 0x8C, 0x8D, 0x10, 0xE4, 0x04, 0xE0, 0x13, 0x7F, 0x26, 0x02, 0x1B, 0xFD, 0x44,
|
|
0xAF, 0x70, 0xD7, 0xBF, 0xDF, 0x97, 0xD2, 0x34, 0xFD, 0xBB, 0x51, 0x8D, 0x7C, 0x04, 0x9D, 0x30,
|
|
0xFF, 0xB1, 0xB4, 0xD3, 0xEF, 0x2C, 0xEE, 0xAD, 0x4C, 0x4A, 0x26, 0x94, 0x15, 0x13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9C,
|
|
0x2A, 0x40, 0x40, 0x05, 0x6B, 0xF1, 0x45, 0xDF, 0x22, 0x8B, 0x40, 0x61, 0xA4, 0x11, 0x06, 0x03,
|
|
0xA5, 0x53, 0x84, 0xC0, 0x12, 0xE1, 0x88, 0x9D, 0x55, 0x55, 0x07, 0x40, 0x88, 0x01, 0x8C, 0xAB,
|
|
0xA2, 0xFD, 0xFD, 0x19, 0x48, 0x25, 0xAB, 0x59, 0x59, 0x28, 0x63, 0x68, 0x69, 0x1B, 0x99, 0x73,
|
|
0x8D, 0xAB, 0x5A, 0xFA, 0x71, 0x60, 0x1B, 0x12, 0xE7, 0x99, 0x70, 0xF1, 0x99, 0x2A, 0x50, 0x18,
|
|
0x8B, 0x6B, 0x61, 0x90, 0xE2, 0x7E, 0x8B, 0x90, 0xD4, 0xD5, 0xC0, 0xCB, 0x7C, 0x08, 0x06, 0xD9,
|
|
};
|
|
|
|
constexpr const u8 LibraryEmbeddedCaPublicExponent[GcCrypto::GcRsaPublicExponentLength] = {
|
|
0x01, 0x00, 0x01
|
|
};
|
|
|
|
constexpr const u8 LibraryEmbeddedCa10Modulus[2][GcCrypto::GcRsaKeyLength] = {
|
|
{
|
|
0x98, 0xC7, 0x26, 0xB6, 0x0D, 0x0A, 0x50, 0xA7, 0x39, 0x21, 0x0A, 0xE3, 0x2F, 0xE4, 0x3E, 0x2E,
|
|
0x5B, 0xA2, 0x86, 0x75, 0xAA, 0x5C, 0xEE, 0x34, 0xF1, 0xA3, 0x3A, 0x7E, 0xBD, 0x90, 0x4E, 0xF7,
|
|
0x8D, 0xFA, 0x17, 0xAA, 0x6B, 0xC6, 0x36, 0x6D, 0x4C, 0x9A, 0x6D, 0x57, 0x2F, 0x80, 0xA2, 0xBC,
|
|
0x38, 0x4D, 0xDA, 0x99, 0xA1, 0xD8, 0xC3, 0xE2, 0x99, 0x79, 0x36, 0x71, 0x90, 0x20, 0x25, 0x9D,
|
|
0x4D, 0x11, 0xB8, 0x2E, 0x63, 0x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 0xB1, 0x41, 0xC6, 0x43, 0x2A, 0xD9, 0x45, 0x63,
|
|
0x4D, 0x8E, 0xCB, 0xA2, 0x79, 0x54, 0x94, 0x54, 0xE7, 0x34, 0xEA, 0xAD, 0xE9, 0x47, 0x52, 0x6C,
|
|
0x96, 0x22, 0xF2, 0xD6, 0xDC, 0xB7, 0x45, 0x03, 0xB6, 0xC8, 0x36, 0x92, 0x10, 0x4A, 0x40, 0x2B,
|
|
0x05, 0x34, 0x78, 0x2A, 0xAD, 0x6A, 0x8E, 0x7F, 0xA1, 0x22, 0x3A, 0xC5, 0xD1, 0x0A, 0x4D, 0xD8,
|
|
0x7A, 0x9A, 0x53, 0x9A, 0x00, 0xAF, 0x70, 0x76, 0xC1, 0xF9, 0x9C, 0x98, 0x02, 0xCB, 0x4C, 0xF5,
|
|
0x9E, 0x51, 0x29, 0x72, 0x4C, 0x13, 0x45, 0xCA, 0xB1, 0xA4, 0x4A, 0x4E, 0x32, 0xCC, 0x23, 0xA8,
|
|
0x69, 0xBE, 0x82, 0xD5, 0x86, 0x22, 0xA5, 0xEE, 0x97, 0x1A, 0xFF, 0x11, 0xF0, 0xE7, 0x66, 0x0B,
|
|
},
|
|
};
|
|
|
|
constexpr const u8 LibraryEmbeddedCardHeaderKey[2][GcCrypto::GcAesKeyLength] = {
|
|
{ 0x01, 0xC5, 0x8F, 0xE7, 0x00, 0x2D, 0x13, 0x5A, 0xB2, 0x9A, 0x3F, 0x69, 0x33, 0x95, 0x74, 0xB1, },
|
|
{ 0xCB, 0xA7, 0xB8, 0x75, 0xEB, 0x67, 0x05, 0xFB, 0x46, 0x0A, 0x33, 0xFD, 0x34, 0x09, 0x13, 0xB4, },
|
|
};
|
|
|
|
constexpr const u8 LibraryEmbeddedConcatenatedGcKeys[2][0x70] = {
|
|
{
|
|
0x98, 0x42, 0xD1, 0x45, 0x92, 0xEE, 0x79, 0xAE, 0xE3, 0xAA, 0xC9, 0xEA, 0x6A, 0x67, 0xC4, 0xB4,
|
|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22, 0x75,
|
|
0x78, 0x5A, 0x92, 0xE4, 0x91, 0x49, 0xD8, 0x28, 0x57, 0x57, 0x49, 0x68, 0x01, 0x0E, 0xA4, 0x10,
|
|
0x5B, 0x05, 0x47, 0x03, 0xD1, 0x1B, 0xA7, 0xCA, 0xD9, 0x06, 0x10, 0x02, 0x85, 0xA3, 0x99, 0x26,
|
|
},
|
|
};
|
|
|
|
constexpr const u8 LibraryEmbeddedSplEncryptedKek[GcCrypto::GcAesKeyLength] = {
|
|
0x42, 0xF1, 0xEB, 0xCB, 0xDD, 0xED, 0x82, 0xAF, 0x32, 0x4E, 0x0D, 0xF4, 0x84, 0xF2, 0xAB, 0x57,
|
|
};
|
|
|
|
constexpr const u8 LibraryEmbeddedIvForKek[2][GcCrypto::GcAesCbcIvLength] = {
|
|
{ 0xC6, 0x09, 0x0A, 0x32, 0x51, 0xA5, 0x26, 0xEC, 0x8F, 0x2B, 0xA9, 0x3E, 0xCC, 0x62, 0xF0, 0x92 },
|
|
{ 0x23, 0xA6, 0xFE, 0x53, 0xE7, 0x16, 0x86, 0xFB, 0x9B, 0xB5, 0x72, 0x32, 0x42, 0x01, 0xA3, 0xC7 },
|
|
};
|
|
|
|
}
|
|
|
|
constinit bool EmbeddedDataHolder::s_is_dev = false;
|
|
|
|
constinit const void *EmbeddedDataHolder::s_ca_public_exponent = LibraryEmbeddedCaPublicExponent;
|
|
constinit const void *EmbeddedDataHolder::s_ca1_modulus = LibraryEmbeddedCa1Modulus;
|
|
constinit const void *EmbeddedDataHolder::s_ca9_modulus = LibraryEmbeddedCa9Modulus;
|
|
constinit const void *EmbeddedDataHolder::s_ca10_modulus = LibraryEmbeddedCa10Modulus[0];
|
|
constinit const void *EmbeddedDataHolder::s_ca10_certificate_modulus = LibraryEmbeddedCa10CertificateModulus[0];
|
|
constinit const void *EmbeddedDataHolder::s_card_header_key = LibraryEmbeddedCardHeaderKey[0];
|
|
|
|
Result EmbeddedDataHolder::SetLibraryEmbeddedKeys(bool is_dev) {
|
|
ConcatenatedGcLibraryEmbeddedKeys embedded_keys;
|
|
R_TRY(DecryptoEmbeddedKeys(std::addressof(embedded_keys), sizeof(embedded_keys), is_dev));
|
|
|
|
{
|
|
/* TODO: Set hmac/cv keys. */
|
|
AMS_UNUSED(embedded_keys);
|
|
}
|
|
|
|
R_SUCCEED();
|
|
}
|
|
|
|
Result EmbeddedDataHolder::DecryptoEmbeddedKeys(ConcatenatedGcLibraryEmbeddedKeys *out, size_t out_size, bool is_dev) {
|
|
/* Determine key index. */
|
|
const auto key_idx = is_dev ? 1 : 0;
|
|
|
|
/* Set global pointers. */
|
|
s_is_dev = is_dev;
|
|
s_ca10_modulus = LibraryEmbeddedCa10Modulus[key_idx];
|
|
s_ca10_certificate_modulus = LibraryEmbeddedCa10CertificateModulus[key_idx];
|
|
s_card_header_key = LibraryEmbeddedCardHeaderKey[key_idx];
|
|
|
|
/* Get the keys/iv. */
|
|
ConcatenatedGcLibraryEmbeddedKeys keys;
|
|
std::memcpy(std::addressof(keys), LibraryEmbeddedConcatenatedGcKeys[key_idx], sizeof(keys));
|
|
static_assert(sizeof(LibraryEmbeddedConcatenatedGcKeys[0]) == sizeof(*out));
|
|
|
|
const void *iv_for_kek = LibraryEmbeddedIvForKek[key_idx];
|
|
|
|
/* Generate the kek. */
|
|
u8 kek[GcCrypto::GcAesKeyLength] = {};
|
|
crypto::Aes128CtrDecryptor aes_ctr;
|
|
ON_SCOPE_EXIT {
|
|
crypto::ClearMemory(kek, sizeof(kek));
|
|
aes_ctr.Initialize(kek, sizeof(kek), iv_for_kek, GcCrypto::GcAesCbcIvLength);
|
|
};
|
|
|
|
constexpr const auto KeyGeneration = 4;
|
|
R_TRY(GcCrypto::DecryptAesKeySpl(kek, sizeof(kek), LibraryEmbeddedSplEncryptedKek, sizeof(LibraryEmbeddedSplEncryptedKek), KeyGeneration, 0));
|
|
|
|
/* Decrypt the embedded keys. */
|
|
aes_ctr.Initialize(kek, sizeof(kek), iv_for_kek, GcCrypto::GcAesCbcIvLength);
|
|
aes_ctr.Update(out, out_size, std::addressof(keys), sizeof(keys));
|
|
|
|
R_SUCCEED();
|
|
}
|
|
|
|
}
|