Пример #1
0
        public void Encrypt(byte[] data)
        {
            if (!IsInitialized)
            {
                throw new InvalidOperationException("PacketCrypt not initialized!");
            }

            SARC4Encrypt.ProcessBuffer(data, 4);
        }
Пример #2
0
        public void Initialize(byte[] sessionKey)
        {
            SARC4Encrypt = new SARC4();
            SARC4Decrypt = new SARC4();

            DecryptSHA1 = new HMACSHA1(ServerDecryptionKey);
            EncryptSHA1 = new HMACSHA1(ServerEncryptionKey);

            SARC4Encrypt.PrepareKey(EncryptSHA1.ComputeHash(sessionKey));
            SARC4Decrypt.PrepareKey(DecryptSHA1.ComputeHash(sessionKey));

            byte[] PacketEncryptionDummy = new byte[0x400];
            byte[] PacketDecryptionDummy = new byte[0x400];

            SARC4Encrypt.ProcessBuffer(PacketEncryptionDummy, PacketEncryptionDummy.Length);
            SARC4Decrypt.ProcessBuffer(PacketDecryptionDummy, PacketDecryptionDummy.Length);

            IsInitialized = true;
        }
Пример #3
0
        public void Initialize(byte[] sessionKey)
        {
            if (IsInitialized)
            {
                throw new InvalidOperationException("PacketCrypt already initialized!");
            }

            SARC4Encrypt = new SARC4();
            SARC4Decrypt = new SARC4();

            SARC4Encrypt.PrepareKey(ComputeHMACHash(sessionKey, ServerEncryptionKey));
            SARC4Decrypt.PrepareKey(ComputeHMACHash(sessionKey, ServerDecryptionKey));

            byte[] PacketEncryptionDummy = new byte[0x400];
            byte[] PacketDecryptionDummy = new byte[0x400];

            SARC4Encrypt.ProcessBuffer(PacketEncryptionDummy, PacketEncryptionDummy.Length);
            SARC4Decrypt.ProcessBuffer(PacketDecryptionDummy, PacketDecryptionDummy.Length);

            IsInitialized = true;
        }
Пример #4
0
        public void Initialize(byte[] sessionKey)
        {
            if (IsInitialized)
                throw new InvalidOperationException("PacketCrypt already initialized!");

            SARC4Encrypt = new SARC4();
            SARC4Decrypt = new SARC4();

            DecryptSHA1 = new HMACSHA1(ServerDecryptionKey);
            EncryptSHA1 = new HMACSHA1(ServerEncryptionKey);

            SARC4Encrypt.PrepareKey(EncryptSHA1.ComputeHash(sessionKey));
            SARC4Decrypt.PrepareKey(DecryptSHA1.ComputeHash(sessionKey));

            byte[] PacketEncryptionDummy = new byte[0x400];
            byte[] PacketDecryptionDummy = new byte[0x400];

            SARC4Encrypt.ProcessBuffer(PacketEncryptionDummy, PacketEncryptionDummy.Length);
            SARC4Decrypt.ProcessBuffer(PacketDecryptionDummy, PacketDecryptionDummy.Length);

            IsInitialized = true;
        }
Пример #5
0
        public void Initialize(byte[] sessionKey, byte[] serverSeed, byte[] clientSeed)
        {
            if (IsInitialized)
            {
                throw new InvalidOperationException("PacketCrypt already initialized!");
            }

            SARC4Encrypt = new SARC4();
            SARC4Decrypt = new SARC4();

            var encryptSHA1 = new HMACSHA1(serverSeed);
            var decryptSHA1 = new HMACSHA1(clientSeed);

            SARC4Encrypt.PrepareKey(encryptSHA1.ComputeHash(sessionKey));
            SARC4Decrypt.PrepareKey(decryptSHA1.ComputeHash(sessionKey));

            var PacketEncryptionDummy = new byte[0x400];
            var PacketDecryptionDummy = new byte[0x400];

            SARC4Encrypt.ProcessBuffer(PacketEncryptionDummy, PacketEncryptionDummy.Length);
            SARC4Decrypt.ProcessBuffer(PacketDecryptionDummy, PacketDecryptionDummy.Length);

            IsInitialized = true;
        }
Пример #6
0
 public void Encrypt(byte[] data)
 {
     SARC4Encrypt.ProcessBuffer(data, 4);
 }