/// <summary>
        /// Encrypts the message data and put a result into the specified output stream.
        /// </summary>
        /// <param name="input">The stream containing the serialized message.</param>
        /// <param name="output">The result stream with the data being sent to the remote host.</param>
        public override void Encrypt(Stream input, GenuineChunkedStream output)
        {
#if DEBUG
            input.Position = 0;
#endif

            output.WriteByte(1);

            lock (this)
            {
                // write encrypted content
                if (this._encryptor != null)
                {
                    GenuineUtility.CopyStreamToStream(new CryptoStream(new FinishReadingStream(input), this._encryptor, CryptoStreamMode.Read), output);
                }
                else
                {
                    output.WriteStream(input);
                }

                if (this.KeyedHashAlgorithm != null)
                {
                    // and write down the calculated message hash
                    input.Position = 0;
                    output.WriteBuffer(this.KeyedHashAlgorithm.ComputeHash(input), -1);

                    // it's in the content, reset its position
                    if (this._encryptor == null)
                    {
                        input.Position = 0;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Encrypts the message data and put a result into the specified output stream.
        /// </summary>
        /// <param name="input">The stream containing the serialized message.</param>
        /// <param name="output">The result stream with the data being sent to the remote host.</param>
        public override void Encrypt(Stream input, GenuineChunkedStream output)
        {
            // write session established flag
            output.WriteByte(1);

            // serialize messages into the output stream
            this.SspiSecurityContext.EncryptMessage(input, output, this.KeyProvider_SspiServer.RequiredFeatures);
        }
Beispiel #3
0
 /// <summary>
 /// Encrypts the message data and put a result into the specified output stream.
 /// </summary>
 /// <param name="input">The stream containing the serialized message.</param>
 /// <param name="output">The result stream with the data being sent to the remote host.</param>
 public override void Encrypt(Stream input, GenuineChunkedStream output)
 {
     output.WriteByte(1);
     lock (this._encryptor)
         GenuineUtility.CopyStreamToStream(new CryptoStream(new FinishReadingStream(input), this._encryptor, CryptoStreamMode.Read), output);
 }