private void WriteInStreamMode(byte[] buffer, int offset, int size)
 {
     if (TcpStream.TRACESWITCH.TraceVerbose)
     {
         StackTrace stackTrace = new StackTrace();
         stackTrace.GetFrame(1).GetMethod();
     }
     for (int i = Math.Min(this.streamSizes.cbMaxMessage, size); i > 0; i = Math.Min(this.streamSizes.cbMaxMessage, size))
     {
         this.securityBuffers[0].offset = this.streamHeaderForWrite.Offset;
         this.securityBuffers[0].size   = this.streamHeaderForWrite.Count;
         this.securityBuffers[0].token  = this.streamHeaderForWrite.Array;
         this.securityBuffers[0].type   = 7;
         this.securityBuffers[1].offset = offset;
         this.securityBuffers[1].size   = i;
         this.securityBuffers[1].token  = buffer;
         this.securityBuffers[1].type   = 1;
         this.securityBuffers[2].offset = this.streamTrailerForWrite.Offset;
         this.securityBuffers[2].size   = this.streamTrailerForWrite.Count;
         this.securityBuffers[2].token  = this.streamTrailerForWrite.Array;
         this.securityBuffers[2].type   = 6;
         this.securityBuffers[3].offset = 0;
         this.securityBuffers[3].size   = 0;
         this.securityBuffers[3].token  = null;
         this.securityBuffers[3].type   = 0;
         int num = SSPIWrapper.EncryptMessage(ref this.securityContext.Handle, this.securityBuffers, ++this.sequenceNumberForWrite);
         if (num != 0)
         {
             throw new XmlaStreamException(new Win32Exception(num).Message);
         }
         base.Write();
         offset += i;
         size   -= i;
     }
 }
 private void WriteInBlockMode(byte[] buffer, int offset, int size)
 {
     for (int i = Math.Min(this.maxEncryptionBufferSize, size); i > 0; i = Math.Min(this.maxEncryptionBufferSize, size))
     {
         SecurityBufferClass securityBufferClass = this.securityBuffers[0];
         securityBufferClass.offset = offset;
         securityBufferClass.size   = i;
         securityBufferClass.token  = buffer;
         securityBufferClass.type   = 1;
         securityBufferClass        = this.securityBuffers[1];
         securityBufferClass.offset = 0;
         securityBufferClass.size   = this.maxTokenSize;
         securityBufferClass.token  = this.tokenBufferForWrite;
         securityBufferClass.type   = 2;
         int num = SSPIWrapper.EncryptMessage(ref this.securityContext.Handle, this.securityBuffers, ++this.sequenceNumberForWrite);
         if (num != 0)
         {
             throw new XmlaStreamException(new Win32Exception(num).Message);
         }
         base.Write();
         offset += i;
         size   -= i;
     }
 }