public static byte[] GetDefaultKey(int index)
 {
     return(Aes128XtsCryptoDriver.GetDefaultKey(index));
 }
Exemple #2
0
 private void SetCryptor(KeyConfiguration config)
 {
     if (this.m_fileSystemInfo.isProdEncryption)
     {
         this.m_bodyEncryptionKeyEncryptor = this.m_keyConfig.GetProdKeyAreaEncryptionKey() == null ? (IEncryptor) new HsmAes128CryptoDriver(Aes128KeyIndex.NcaContentKey) : (IEncryptor) new Aes128CryptoDriver(this.m_keyConfig.GetProdKeyAreaEncryptionKey().Key);
         byte[][] numArray1 = new byte[2][]
         {
             new byte[16],
             new byte[16]
         };
         byte[][] numArray2 = new byte[2][]
         {
             new byte[16]
             {
                 (byte)90,
                 (byte)62,
                 (byte)216,
                 (byte)79,
                 (byte)222,
                 (byte)192,
                 (byte)216,
                 (byte)38,
                 (byte)49,
                 (byte)247,
                 (byte)226,
                 (byte)93,
                 (byte)25,
                 (byte)123,
                 (byte)245,
                 (byte)208
             },
             new byte[16]
             {
                 (byte)28,
                 (byte)155,
                 (byte)123,
                 (byte)250,
                 (byte)246,
                 (byte)40,
                 (byte)24,
                 (byte)61,
                 (byte)113,
                 (byte)246,
                 (byte)77,
                 (byte)115,
                 (byte)241,
                 (byte)80,
                 (byte)185,
                 (byte)210
             }
         };
         IEncryptor encryptor = this.m_keyConfig.GetProdNcaHeaderEncryptionKek() == null ? (IEncryptor) new HsmAes128CryptoDriver(Aes128KeyIndex.NcaHeader) : (IEncryptor) new Aes128CryptoDriver(this.m_keyConfig.GetProdNcaHeaderEncryptionKek().Key);
         encryptor.DecryptBlock(numArray2[0], 0, 16, numArray1[0], 0);
         encryptor.DecryptBlock(numArray2[1], 0, 16, numArray1[1], 0);
         this.m_headerEncryptor = (IXtsModeEncryptor) new Aes128XtsCryptoDriver(numArray1[0], numArray1[1]);
         if (this.m_keyConfig.GetNcaHeader1SignKey() != null)
         {
             RsaKey ncaHeader1SignKey = this.m_keyConfig.GetNcaHeader1SignKey();
             this.m_header1Signer = (ISigner) new Rsa2048PssSha256SignCryptoDriver(ncaHeader1SignKey.KeyModulus, ncaHeader1SignKey.KeyPublicExponent, ncaHeader1SignKey.KeyPrivateExponent);
         }
         else
         {
             this.m_header1Signer = (ISigner) new HsmRsa2048PssSha256SignCryptoDriver(Rsa2048PssSha256KeyIndex.NcaHeader1);
         }
         if (this.m_fileSystemInfo.contentType != (byte)0)
         {
             this.m_header2Signer = (ISigner)null;
         }
         else
         {
             RsaKey randomRsaKey = this.m_keyConfig.GetRandomRsaKey();
             this.m_header2Signer = (ISigner) new Rsa2048PssSha256SignCryptoDriver(randomRsaKey.KeyModulus, randomRsaKey.KeyPublicExponent, randomRsaKey.KeyPrivateExponent);
         }
         if (this.m_keyConfig.GetAcidSignKey() != null)
         {
             RsaKey acidSignKey = this.m_keyConfig.GetAcidSignKey();
             this.m_acidSigner = (ISigner) new Rsa2048PssSha256SignCryptoDriver(acidSignKey.KeyModulus, acidSignKey.KeyPublicExponent, acidSignKey.KeyPrivateExponent);
         }
         else
         {
             this.m_acidSigner = (ISigner) new HsmRsa2048PssSha256SignCryptoDriver(Rsa2048PssSha256KeyIndex.Acid);
         }
         RsaKey randomRsaKey1 = this.m_keyConfig.GetRandomRsaKey();
         this.m_nrrSigner = (ISigner) new Rsa2048PssSha256SignCryptoDriver(randomRsaKey1.KeyModulus, randomRsaKey1.KeyPublicExponent, randomRsaKey1.KeyPrivateExponent);
         if (this.m_keyConfig.GetNrrCertificateSignKey() != null)
         {
             RsaKey certificateSignKey = this.m_keyConfig.GetNrrCertificateSignKey();
             this.m_nrrCertificateSigner = (ISigner) new Rsa2048PssSha256SignCryptoDriver(certificateSignKey.KeyModulus, certificateSignKey.KeyPublicExponent, certificateSignKey.KeyPrivateExponent);
         }
         else
         {
             this.m_nrrCertificateSigner = (ISigner) new HsmRsa2048PssSha256SignCryptoDriver(Rsa2048PssSha256KeyIndex.NrrCertificate);
         }
     }
     else
     {
         this.m_bodyEncryptionKeyEncryptor = (IEncryptor) new Aes128CryptoDriver(this.m_keyConfig.GetKeyAreaEncryptionKey((uint)this.m_fileSystemInfo.keyAreaEncryptionKeyIndex).Key);
         this.m_headerEncryptor            = (IXtsModeEncryptor) new Aes128XtsCryptoDriver(Aes128XtsCryptoDriver.GetDefaultKey(2), Aes128XtsCryptoDriver.GetDefaultKey(3));
         this.m_header1Signer        = (ISigner) new Rsa2048PssSha256SignCryptoDriver(Rsa2048PssSha256KeyIndex.NcaHeader1);
         this.m_header2Signer        = this.m_fileSystemInfo.contentType != (byte)0 || this.m_fileSystemInfo.header2SignKeyModulus == null || (this.m_fileSystemInfo.header2SignKeyPublicExponent == null || this.m_fileSystemInfo.header2SignKeyPrivateExponent == null) ? (ISigner)null : (ISigner) new Rsa2048PssSha256SignCryptoDriver(this.m_fileSystemInfo.header2SignKeyModulus, this.m_fileSystemInfo.header2SignKeyPublicExponent, this.m_fileSystemInfo.header2SignKeyPrivateExponent);
         this.m_acidSigner           = (ISigner)null;
         this.m_nrrSigner            = (ISigner) new Rsa2048PssSha256SignCryptoDriver(Rsa2048PssSha256KeyIndex.NrrCertificate);
         this.m_nrrCertificateSigner = (ISigner) new Rsa2048PssSha256SignCryptoDriver(Rsa2048PssSha256KeyIndex.NrrCertificate);
     }
 }