コード例 #1
0
 public Command12(RijndaelParameters keys)
 {
     m_Keys    = keys;
     m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.RSA, 0x12);
     m_Command.Write((byte)0x12);
     m_Command.Write((ushort)m_Keys.BlockSize);
     m_Command.Write((ushort)m_Keys.FeedbackSize);
     m_Command.Write((ushort)m_Keys.KeySize);
     m_Command.Write((byte)m_Keys.Mode);
     m_Command.Write((byte)m_Keys.Padding);
     m_Command.Write((byte)m_Keys.IV.Length);
     m_Command.Write(m_Keys.IV);
     m_Command.Write((byte)m_Keys.Key.Length);
     m_Command.Write(m_Keys.Key);
 }
コード例 #2
0
ファイル: Command12.cs プロジェクト: Steeslice/StealthNet-Alt
 public Command12(RijndaelParameters keys)
 {
     m_Keys = keys;
     m_Command = new CommandBuilder(CommandBuilder.EncryptionMethod.RSA, 0x12);
     m_Command.Write((byte)0x12);
     m_Command.Write((ushort)m_Keys.BlockSize);
     m_Command.Write((ushort)m_Keys.FeedbackSize);
     m_Command.Write((ushort)m_Keys.KeySize);
     m_Command.Write((byte)m_Keys.Mode);
     m_Command.Write((byte)m_Keys.Padding);
     m_Command.Write((byte)m_Keys.IV.Length);
     m_Command.Write(m_Keys.IV);
     m_Command.Write((byte)m_Keys.Key.Length);
     m_Command.Write(m_Keys.Key);
 }
コード例 #3
0
ファイル: Core.cs プロジェクト: Steeslice/StealthNet-Alt
        public static byte[] RijndaelEncrypt(RijndaelParameters keys, byte[] data)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            RijndaelManaged rijndael = keys.Export();
            MemoryStream memoryStream = new MemoryStream(Constants.MaximumCommandLength);
            CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndael.CreateEncryptor(), CryptoStreamMode.Write);
            cryptoStream.Write(data, 0, data.Length);
            cryptoStream.FlushFinalBlock();
            byte[] encryptedData = memoryStream.ToArray();
            cryptoStream.Close();
            rijndael.Clear();
            return encryptedData;
        }
コード例 #4
0
ファイル: Core.cs プロジェクト: Steeslice/StealthNet-Alt
        public static byte[] RijndaelDecrypt(RijndaelParameters keys, byte[] encryptedData)
        {
            if (encryptedData == null)
                throw new ArgumentNullException("encryptedData");

            RijndaelManaged rijndael = keys.Export();
            MemoryStream memoryStream = new MemoryStream(encryptedData);
            CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndael.CreateDecryptor(), CryptoStreamMode.Read);
            byte[] decryptedData = new byte[encryptedData.Length];
            cryptoStream.Read(decryptedData, 0, decryptedData.Length);
            cryptoStream.Close();
            rijndael.Clear();
            return decryptedData;
        }