Process() public method

public Process ( System.Stream outStream ) : void
outStream System.Stream
return void
コード例 #1
0
        public void Process(Stream outStream)
        {
            if (Type == AESType.EMPTY)
            {
                return;
            }
            if (Type == AESType.SYMMETRIC)
            {
                if (_direction == Direction.DECRYPT)
                {
                    s_aesDecrypt.Process(outStream);
                }
                else
                {
                    s_aesEncrypt.Process(outStream);
                }
                return;
            }

            if (_direction == Direction.ENCRYPT)
            {
                Encrypt(new BufferWithOffset(outStream));
            }
            else
            {
                Decrypt(new BufferWithOffset(outStream));
            }
            if (_canRecycle)
            {
                this.ReturnPool();
            }
        }
コード例 #2
0
ファイル: RtmfpUtils.cs プロジェクト: zhujingcheng/csharprtmp
        public static void EncodeAndPack(AESEngine aesEncrypt, H2NBinaryWriter writer, uint farId, int ignore = 0)
        {
            var s = writer.BaseStream;

            if (aesEncrypt.Type != AESEngine.AESType.EMPTY)
            {
                var paddingBytesLength = (0xFFFFFFFF - (int)s.Length + ignore + 5) & 0x0F;
                s.Position = s.Length;
                for (var i = 0; i < paddingBytesLength; i++)
                {
                    writer.Write((byte)0xFF);
                }
                //writer.Write(Enumerable.Repeat((byte)0xFF, (int) paddingBytesLength).ToArray());
            }
            //writeCRC
            s.Position = 6 + ignore;
            var sum = CheckSum(s);

            s.Position = 4 + ignore;
            writer.Write(sum);
            //writeCRC end
            s.Position = 4 + ignore;

            aesEncrypt.Process(s);
            //pack
            s.Position = 4 + ignore;
            var result = s.ReadUInt() ^ s.ReadUInt() ^ farId;

            s.Position = ignore;
            writer.Write(result);
        }
コード例 #3
0
ファイル: RtmfpUtils.cs プロジェクト: zhujingcheng/csharprtmp
 public static bool Decode(AESEngine aesDecrypt, N2HBinaryReader packet)
 {
     //var pos = packet.BaseStream.Position;
     //var buffer = packet.ReadBytes((int) packet.BaseStream.GetAvaliableByteCounts());
     // Decrypt
     // packet.BaseStream.Position = pos;
     aesDecrypt.Process(packet.BaseStream as MemoryStream);
     //packet.BaseStream.Write(buffer,0,buffer.Length);
     return(ReadCRC(packet));
 }
コード例 #4
0
ファイル: RtmfpUtils.cs プロジェクト: langhuihui/csharprtmp
        public static bool Decode(AESEngine aesDecrypt,N2HBinaryReader packet)
        {
            //var pos = packet.BaseStream.Position;
            //var buffer = packet.ReadBytes((int) packet.BaseStream.GetAvaliableByteCounts());
	// Decrypt
           // packet.BaseStream.Position = pos;
            aesDecrypt.Process(packet.BaseStream as MemoryStream);
            //packet.BaseStream.Write(buffer,0,buffer.Length);
	        return ReadCRC(packet);
        }
コード例 #5
0
ファイル: RtmfpUtils.cs プロジェクト: langhuihui/csharprtmp
        public static void EncodeAndPack(AESEngine aesEncrypt, H2NBinaryWriter writer, uint farId,int ignore = 0)
        {
            var s = writer.BaseStream;
            if (aesEncrypt.Type != AESEngine.AESType.EMPTY)
            {
                var paddingBytesLength = (0xFFFFFFFF - (int)s.Length+ignore+ 5) & 0x0F;
                s.Position =s.Length;
                for (var i = 0; i < paddingBytesLength; i++)
                {
                    writer.Write((byte)0xFF);
                }
                //writer.Write(Enumerable.Repeat((byte)0xFF, (int) paddingBytesLength).ToArray());
            }
            //writeCRC
            s.Position = 6 + ignore;
            var sum = CheckSum(s);
            s.Position = 4 + ignore;
            writer.Write(sum);
            //writeCRC end
            s.Position = 4 + ignore;

            aesEncrypt.Process(s);
            //pack
            s.Position = 4 + ignore;
            var result = s.ReadUInt() ^ s.ReadUInt() ^ farId;
            s.Position = ignore;
            writer.Write(result);
        }