From 7b0dbc753f1abe498c7308706d1948fed0e59828 Mon Sep 17 00:00:00 2001 From: jakcron Date: Fri, 7 Jul 2017 10:18:08 +1000 Subject: [PATCH] [nx] Fix namespace collision in NXCrypto.h --- lib/nx/NXCrypto.h | 66 ++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/lib/nx/NXCrypto.h b/lib/nx/NXCrypto.h index 56390fe..ca2e6e8 100644 --- a/lib/nx/NXCrypto.h +++ b/lib/nx/NXCrypto.h @@ -1,36 +1,37 @@ #pragma once // AES -namespace nx +namespace crypto { - namespace crypto - { - /* - Keys mentioned in Content Archive Authoring library - private RsaKey m_NcaHeader1SignKey; - private RsaKey m_AcidSignKey; - private RsaKey m_NrrCertificateSignKey; - private AesKey m_ProdKeyAreaEncryptionKey; - private AesKey m_ProdNcaHeaderEncryptionKek; - private RsaKey m_ProdXciHeaderSignKey; - private AesKey m_ProdXciInitialDataEncryptionKey; - private AesKey m_ProdTitleKeyGenarateKey; - private AesKey m_ProdETicketCommonKey; - private RsaKey m_ProdETicketSignKey; - */ - namespace aes - { - /* - public static AesKey GetNcaExternalContentKey(IHashCalculator hashCalculator, ulong titleId) - { - Trace.Assert(hashCalculator != null, "IHashCalculator is null."); - byte[] array = BitConverter.GetBytes(titleId).Reverse().ToArray(); - byte[] numArray = new byte[hashCalculator.HashSize]; - hashCalculator.CalculateHash(array, 0, (int)array.Length, numArray, 0); - return new AesKey(((IEnumerable)numArray).Where((byte name, int index) => index < 16).ToArray()); - } - */ + /* + Keys mentioned in Content Archive Authoring library + private RsaKey m_NcaHeader1SignKey; + private RsaKey m_AcidSignKey; + private RsaKey m_NrrCertificateSignKey; + private AesKey m_ProdKeyAreaEncryptionKey; + private AesKey m_ProdNcaHeaderEncryptionKek; + private RsaKey m_ProdXciHeaderSignKey; + private AesKey m_ProdXciInitialDataEncryptionKey; + private AesKey m_ProdTitleKeyGenarateKey; + private AesKey m_ProdETicketCommonKey; + private RsaKey m_ProdETicketSignKey; + */ + namespace aes + { + + /* + public static AesKey GetNcaExternalContentKey(IHashCalculator hashCalculator, ulong titleId) + { + Trace.Assert(hashCalculator != null, "IHashCalculator is null."); + byte[] array = BitConverter.GetBytes(titleId).Reverse().ToArray(); + byte[] numArray = new byte[hashCalculator.HashSize]; + hashCalculator.CalculateHash(array, 0, (int)array.Length, numArray, 0); + return new AesKey(((IEnumerable)numArray).Where((byte name, int index) => index < 16).ToArray()); + } + */ + namespace nx + { enum Aes128KeyId { NcaContentKey, @@ -70,9 +71,12 @@ namespace nx // aeskey, related to m_KeyAreaEncryptionKeyList (first in list?) u8 unk_aes_key[0x10] = { 0x3A, 0x7C, 0x3E, 0x38, 0x4A, 0x8F, 0x22, 0xFF, 0x4B, 0x21, 0x57, 0x19, 0xB7, 0x81, 0xAD, 0x0C }; } + } - // RSA - namespace rsa + // RSA + namespace rsa + { + namespace nx { enum Rsa2048PssKeyId // sign/validate { @@ -116,5 +120,7 @@ namespace nx u8 xci_keyarea_mod[0x100] = { 0xA6, 0x1A, 0x3F, 0x5E, 0x16, 0x94, 0x4D, 0x5F, 0x88, 0x07, 0x45, 0x92, 0x42, 0x02, 0x5C, 0xF8, 0xF8, 0x01, 0xA6, 0x8F, 0xF0, 0x77, 0x76, 0x06, 0x06, 0x4B, 0x67, 0x02, 0x35, 0x2F, 0xC2, 0xF6, 0xCD, 0x74, 0xBC, 0x57, 0x36, 0xA0, 0x61, 0x1D, 0xD6, 0x66, 0x35, 0x79, 0x6E, 0xB7, 0xFF, 0xC1, 0x05, 0xC6, 0x59, 0xD9, 0x1E, 0xC9, 0xC3, 0x1F, 0x5B, 0x17, 0xA9, 0x24, 0x46, 0xB3, 0xAB, 0x1D, 0x7B, 0x79, 0xA8, 0xF2, 0x80, 0xC8, 0x6F, 0xA7, 0x9B, 0x2D, 0xE8, 0xBF, 0x91, 0xD7, 0xD4, 0xA2, 0x07, 0x53, 0x98, 0x82, 0x7D, 0x91, 0x8A, 0x68, 0x79, 0x9B,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