A queue for bytes.

This file could be more optimized.

コード例 #1
0
 public TlsProtocol(System.IO.Stream input, System.IO.Stream output, SecureRandom secureRandom)
 {
     this.mApplicationDataQueue = new ByteQueue();
     this.mAlertQueue           = new ByteQueue(2);
     this.mHandshakeQueue       = new ByteQueue();
     this.mAppDataSplitEnabled  = true;
     this.mBlocking             = true;
     this.mRecordStream         = new RecordStream(this, input, output);
     this.mSecureRandom         = secureRandom;
 }
コード例 #2
0
 public TlsProtocol(SecureRandom secureRandom)
 {
     this.mApplicationDataQueue = new ByteQueue();
     this.mAlertQueue           = new ByteQueue(2);
     this.mHandshakeQueue       = new ByteQueue();
     this.mAppDataSplitEnabled  = true;
     this.mBlocking             = true;
     this.mBlocking             = false;
     this.mInputBuffers         = new ByteQueueStream();
     this.mOutputBuffer         = new ByteQueueStream();
     this.mRecordStream         = new RecordStream(this, this.mInputBuffers, this.mOutputBuffer);
     this.mSecureRandom         = secureRandom;
 }
コード例 #3
0
ファイル: ByteQueue.cs プロジェクト: aata/flashcards-wp7
 /// <summary>Add some data to our buffer.</summary>
 /// <param name="data">A byte-array to read data from.</param>
 /// <param name="offset">How many bytes to skip at the beginning of the array.</param>
 /// <param name="len">How many bytes to read from the array.</param>
 public void AddData(
     byte[]  data,
     int offset,
     int len)
 {
     if ((skipped + available + len) > databuf.Length)
     {
         byte[] tmp = new byte[ByteQueue.NextTwoPow(data.Length)];
         Array.Copy(databuf, skipped, tmp, 0, available);
         skipped = 0;
         databuf = tmp;
     }
     Array.Copy(data, offset, databuf, skipped + available, len);
     available += len;
 }
コード例 #4
0
 public void Shrink()
 {
     if (available == 0)
     {
         databuf = TlsUtilities.EmptyBytes;
         skipped = 0;
     }
     else
     {
         int desiredSize = ByteQueue.NextTwoPow(available);
         if (desiredSize < databuf.Length)
         {
             byte[] tmp = new byte[desiredSize];
             Array.Copy(databuf, skipped, tmp, 0, available);
             databuf = tmp;
             skipped = 0;
         }
     }
 }
コード例 #5
0
 public void AddData(byte[] data, int offset, int len)
 {
     if (this.skipped + this.available + len > this.databuf.Length)
     {
         int num = ByteQueue.NextTwoPow(this.available + len);
         if (num > this.databuf.Length)
         {
             byte[] destinationArray = new byte[num];
             Array.Copy(this.databuf, this.skipped, destinationArray, 0, this.available);
             this.databuf = destinationArray;
         }
         else
         {
             Array.Copy(this.databuf, this.skipped, this.databuf, 0, this.available);
         }
         this.skipped = 0;
     }
     Array.Copy(data, offset, this.databuf, this.skipped + this.available, len);
     this.available += len;
 }
コード例 #6
0
ファイル: ByteQueue.cs プロジェクト: EnergonV/BestCS
        /// <summary>Add some data to our buffer.</summary>
        /// <param name="data">A byte-array to read data from.</param>
        /// <param name="offset">How many bytes to skip at the beginning of the array.</param>
        /// <param name="len">How many bytes to read from the array.</param>
        public void AddData(
            byte[]      data,
            int offset,
            int len)
        {
            if ((skipped + available + len) > databuf.Length)
            {
                int desiredSize = ByteQueue.NextTwoPow(available + len);
                if (desiredSize > databuf.Length)
                {
                    byte[] tmp = new byte[desiredSize];
                    Array.Copy(databuf, skipped, tmp, 0, available);
                    databuf = tmp;
                }
                else
                {
                    Array.Copy(databuf, skipped, databuf, 0, available);
                }
                skipped = 0;
            }

            Array.Copy(data, offset, databuf, skipped + available, len);
            available += len;
        }
コード例 #7
0
 public ByteQueueStream()
     : this()
 {
     buffer = new ByteQueue();
 }
コード例 #8
0
 public ByteQueueStream()
 {
     this.buffer = new ByteQueue();
 }
コード例 #9
0
 public ByteQueueStream()
 {
     this.buffer = new ByteQueue();
 }