Ejemplo n.º 1
0
        public override DecryptionArgsContainer GetDecryptionArgsContainer()
        {
            DecryptionArgsContainer DArgsContainer = new DecryptionArgsContainer();
            DArgsContainer.ARC4DecryptArgs = new ARC4DecryptionArgs();
            DArgsContainer.ARC4DecryptArgs.Transformer = m_DecryptTransformer;

            return DArgsContainer;
        }
Ejemplo n.º 2
0
        public override MemoryStream DecryptPacket(PacketStream EncryptedPacket, DecryptionArgsContainer DecryptionArgs)
        {
            CryptoStream CStream = new CryptoStream(EncryptedPacket, m_DecryptTransformer, CryptoStreamMode.Read);

            byte[] DecryptedBuffer = new byte[DecryptionArgs.UnencryptedLength];
            CStream.Read(DecryptedBuffer, 0, DecryptedBuffer.Length);

            return(new MemoryStream(DecryptedBuffer));
        }
Ejemplo n.º 3
0
        public override DecryptionArgsContainer GetDecryptionArgsContainer()
        {
            DecryptionArgsContainer DArgsContainer = new DecryptionArgsContainer();

            DArgsContainer.ARC4DecryptArgs             = new ARC4DecryptionArgs();
            DArgsContainer.ARC4DecryptArgs.Transformer = m_DecryptTransformer;

            return(DArgsContainer);
        }
Ejemplo n.º 4
0
        public override MemoryStream DecryptPacket(PacketStream EncryptedPacket, DecryptionArgsContainer DecryptionArgs)
        {
            CryptoStream CStream = new CryptoStream(EncryptedPacket, m_DecryptTransformer, CryptoStreamMode.Read);

            byte[] DecryptedBuffer = new byte[DecryptionArgs.UnencryptedLength];
            CStream.Read(DecryptedBuffer, 0, DecryptedBuffer.Length);

            return new MemoryStream(DecryptedBuffer);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new DecryptionArgsContainer instance containing this AESEncryptor's NOnce and PrivateKey.
        /// </summary>
        /// <returns>A new DecryptionArgsContainer.</returns>
        public override DecryptionArgsContainer GetDecryptionArgsContainer()
        {
            DecryptionArgsContainer Container = new DecryptionArgsContainer();

            Container.AESDecryptArgs            = new AESDecryptionArgs();
            Container.AESDecryptArgs.NOnce      = m_NOnce;
            Container.AESDecryptArgs.PrivateKey = m_PrivateKey;

            return(Container);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Decrypts the contents of the provided PacketStream instance.
        /// </summary>
        /// <param name="EncryptedPacket">An encrypted PacketStream instance.</param>
        /// <param name="DecryptionArgs">A DecryptionArgsContainer instance.</param>
        /// <returns>A MemoryStream instance with the decrypted data.</returns>
        public override MemoryStream DecryptPacket(PacketStream EncryptedPacket, DecryptionArgsContainer DecryptionArgs)
        {
            byte[] EncryptedData = new byte[EncryptedPacket.Length - (int)PacketHeaders.ENCRYPTED];
            EncryptedPacket.Read(EncryptedData, 0, EncryptedData.Length);

            byte[] DecryptedData = StaticStaticDiffieHellman.Decrypt(m_PrivateKey,
                                                                     ECDiffieHellmanCngPublicKey.FromByteArray(m_PublicKey, CngKeyBlobFormat.EccPublicBlob),
                                                                     m_NOnce, EncryptedData);

            return(new MemoryStream(DecryptedData));
        }
Ejemplo n.º 7
0
		/// <summary>
		/// Creates a new DecryptionArgsContainer instance containing this AESEncryptor's NOnce and PrivateKey.
		/// </summary>
		/// <returns>A new DecryptionArgsContainer.</returns>
		public override DecryptionArgsContainer GetDecryptionArgsContainer()
		{
			DecryptionArgsContainer Container = new DecryptionArgsContainer();
			Container.AESDecryptArgs = new AESDecryptionArgs();
			Container.AESDecryptArgs.NOnce = m_NOnce;
			Container.AESDecryptArgs.PrivateKey = m_PrivateKey;
			Container.AESDecryptArgs.Challenge = m_Challenge;

			return Container;
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Decrypts the contents of the provided PacketStream instance.
		/// </summary>
		/// <param name="EncryptedPacket">An encrypted PacketStream instance.</param>
		/// <param name="DecryptionArgs">A DecryptionArgsContainer instance.</param>
		/// <returns>A MemoryStream instance with the decrypted data.</returns>
		public override MemoryStream DecryptPacket(PacketStream EncryptedPacket, DecryptionArgsContainer DecryptionArgs)
		{
			try
			{
				byte[] EncryptedData = new byte[EncryptedPacket.Length - (int)PacketHeaders.ENCRYPTED];
				EncryptedPacket.Read(EncryptedData, 0, EncryptedData.Length);

				byte[] DecryptedData = StaticStaticDiffieHellman.Decrypt(m_PrivateKey,
					ECDiffieHellmanCngPublicKey.FromByteArray(m_PublicKey, CngKeyBlobFormat.EccPublicBlob),
					m_NOnce, EncryptedData);

				return new MemoryStream(DecryptedData);
			}
			catch (Exception e)
			{
				Debug.WriteLine("Exception in DecryptPacket: " + e.ToString());
				return null;
			}
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Decrypts the data in this PacketStream.
 /// WARNING: ASSUMES THAT THE 7-BYTE HEADER
 /// HAS BEEN READ (ID, LENGTH, DECRYPTEDLENGTH)!
 /// </summary>
 /// <param name="Key">The client's en/decryptionkey.</param>
 /// <param name="Service">The client's DESCryptoServiceProvider instance.</param>
 /// <param name="UnencryptedLength">The packet's unencrypted length (third byte in the header).</param>
 public abstract MemoryStream DecryptPacket(PacketStream EncryptedPacket, DecryptionArgsContainer DecryptionArgs);
Ejemplo n.º 10
0
 /// <summary>
 /// Decrypts the data in this PacketStream.
 /// WARNING: ASSUMES THAT THE 7-BYTE HEADER
 /// HAS BEEN READ (ID, LENGTH, DECRYPTEDLENGTH)!
 /// </summary>
 /// <param name="Key">The client's en/decryptionkey.</param>
 /// <param name="Service">The client's DESCryptoServiceProvider instance.</param>
 /// <param name="UnencryptedLength">The packet's unencrypted length (third byte in the header).</param>
 public abstract MemoryStream DecryptPacket(PacketStream EncryptedPacket, DecryptionArgsContainer DecryptionArgs);