예제 #1
0
        public byte[] PublishTicket(ulong titleId, bool isProdEncryption, KeyConfiguration keyConfiguration)
        {
            AesKey externalContentKey = ExternalContentKeyGenerator.GetNcaExternalContentKey(!isProdEncryption ? (IHashCalculator) new HmacSha256HashCryptoDriver(HmacSha256KeyIndex.TitleKeyGenarateKey) : (keyConfiguration.GetProdTitleKeyGenarateKey() == null ? (IHashCalculator) new HsmHmacSha256HashCryptoDriver(HmacSha256KeyIndex.TitleKeyGenarateKey) : (IHashCalculator) new HmacSha256HashCryptoDriver(keyConfiguration.GetProdTitleKeyGenarateKey().Key)), titleId);

            Ticket.EncryptTitleKey(!isProdEncryption ? (ICbcModeEncryptor) new Aes128CbcCryptoDriver(Aes128KeyIndex.ETicketCommonKey) : (keyConfiguration.GetProdETicketCommonKey() == null ? (ICbcModeEncryptor) new HsmAes128CbcCryptoDriver(Aes128KeyIndex.ETicketCommonKey) : (ICbcModeEncryptor) new Aes128CbcCryptoDriver(keyConfiguration.GetProdETicketCommonKey().Key)), titleId, externalContentKey);
            ulong deviceId = 0;
            ulong ticketId = 0;

            byte[] rightsId = TicketUtility.CreateRightsId(titleId);
            this.m_TicketDataLength = !isProdEncryption ? (int)TicketPublication.PublishTicket(this.m_TicketData, (uint)this.m_TicketData.Length, externalContentKey.Key, deviceId, ticketId, rightsId, Encoding.ASCII.GetBytes("Root-CA00000004-XS00000020")) : (keyConfiguration.GetProdETicketSignKey() == null ? (int)TicketPublication.PublishTicket(this.m_TicketData, (uint)this.m_TicketData.Length, externalContentKey.Key, deviceId, ticketId, rightsId, Encoding.ASCII.GetBytes("Root-CA00000004-XS00000021")) : (int)TicketPublication.PublishTicket(this.m_TicketData, (uint)this.m_TicketData.Length, externalContentKey.Key, deviceId, ticketId, rightsId, Encoding.ASCII.GetBytes("Root-CA00000004-XS00000020")));
            if (isProdEncryption)
            {
                if (keyConfiguration.GetProdETicketSignKey() != null)
                {
                    RsaKey prodEticketSignKey = keyConfiguration.GetProdETicketSignKey();
                    this.SignTicket((ISigner) new Rsa2048Pkcs1Sha256SignCryptoDriver(prodEticketSignKey.KeyModulus, prodEticketSignKey.KeyPublicExponent, prodEticketSignKey.KeyPrivateExponent));
                }
                else
                {
                    this.SignTicket((ISigner) new HsmRsa2048Pkcs1Sha256SignCryptoDriver(Rsa2048Pkcs1Sha256KeyIndex.ETicket));
                }
            }
            else
            {
                byte[] numArray1 = new byte[Sign.GetModulusSize()];
                Sign.GetModulus_XS00000020(numArray1);
                byte[] numArray2 = new byte[Sign.GetPrivateExponentSize()];
                Sign.GetPrivateExponent_XS00000020(numArray2);
                this.SignTicket((ISigner) new Rsa2048Pkcs1Sha256SignCryptoDriver(numArray1, (byte[])null, numArray2));
            }
            return(this.m_TicketData);
        }
        public TicketCertificateSource(bool isProdEncryption, KeyConfiguration keyConfiguration)
        {
            int certificateSize = Certificate.GetCertificateSize();

            byte[] buffer = new byte[certificateSize];
            if (isProdEncryption)
            {
                if (keyConfiguration.GetProdETicketSignKey() != null)
                {
                    Certificate.GetCertificate_XS00000020(buffer);
                }
                else
                {
                    Certificate.GetCertificate_XS00000021(buffer);
                }
            }
            else
            {
                Certificate.GetCertificate_XS00000020(buffer);
            }
            this.CertificateBufferSource = (ISource) new MemorySource(buffer, 0, certificateSize);
        }