Show / Hide Table of Contents

    Class SymmetricEncryptStream

    The implementation of SilverbackCryptoStream based on a SymmetricAlgorithm used to encrypt the messages.

    Inheritance
    object
    MarshalByRefObject
    Stream
    SilverbackCryptoStream
    SymmetricEncryptStream
    Implements
    IAsyncDisposable
    IDisposable
    Inherited Members
    SilverbackCryptoStream.CanRead
    SilverbackCryptoStream.CanSeek
    SilverbackCryptoStream.CanWrite
    SilverbackCryptoStream.Length
    SilverbackCryptoStream.Position
    SilverbackCryptoStream.Flush()
    SilverbackCryptoStream.FlushAsync(CancellationToken)
    SilverbackCryptoStream.Seek(long, SeekOrigin)
    SilverbackCryptoStream.SetLength(long)
    SilverbackCryptoStream.Write(byte[], int, int)
    SilverbackCryptoStream.WriteAsync(byte[], int, int, CancellationToken)
    SilverbackCryptoStream.Close()
    Stream.Null
    Stream.BeginRead(byte[], int, int, AsyncCallback, object)
    Stream.BeginWrite(byte[], int, int, AsyncCallback, object)
    Stream.CopyTo(Stream)
    Stream.CopyTo(Stream, int)
    Stream.CopyToAsync(Stream)
    Stream.CopyToAsync(Stream, int)
    Stream.CopyToAsync(Stream, int, CancellationToken)
    Stream.CopyToAsync(Stream, CancellationToken)
    Stream.CreateWaitHandle()
    Stream.Dispose()
    Stream.DisposeAsync()
    Stream.EndRead(IAsyncResult)
    Stream.EndWrite(IAsyncResult)
    Stream.FlushAsync()
    Stream.ObjectInvariant()
    Stream.Read(Span<byte>)
    Stream.ReadAsync(byte[], int, int)
    Stream.ReadAsync(Memory<byte>, CancellationToken)
    Stream.ReadByte()
    Stream.Synchronized(Stream)
    Stream.Write(ReadOnlySpan<byte>)
    Stream.WriteAsync(byte[], int, int)
    Stream.WriteAsync(ReadOnlyMemory<byte>, CancellationToken)
    Stream.WriteByte(byte)
    Stream.CanTimeout
    Stream.ReadTimeout
    Stream.WriteTimeout
    MarshalByRefObject.GetLifetimeService()
    MarshalByRefObject.InitializeLifetimeService()
    MarshalByRefObject.MemberwiseClone(bool)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Silverback.Messaging.Encryption
    Assembly: Silverback.Integration.dll
    Syntax
    public class SymmetricEncryptStream : SilverbackCryptoStream, IAsyncDisposable, IDisposable

    Constructors

    | Improve this doc View source

    SymmetricEncryptStream(Stream, SymmetricEncryptionSettings)

    Initializes a new instance of the SymmetricEncryptStream class.

    Declaration
    public SymmetricEncryptStream(Stream stream, SymmetricEncryptionSettings settings)
    Parameters
    Type Name Description
    Stream stream

    The inner Stream to read the clear-text message from.

    SymmetricEncryptionSettings settings

    The SymmetricEncryptionSettings specifying the cryptographic algorithm settings.

    Properties

    | Improve this doc View source

    CryptoStream

    Gets the underlying CryptoStream.

    Declaration
    protected override CryptoStream CryptoStream { get; }
    Property Value
    Type Description
    CryptoStream
    Overrides
    SilverbackCryptoStream.CryptoStream

    Methods

    | Improve this doc View source

    Dispose(bool)

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    Overrides
    Stream.Dispose(bool)
    | Improve this doc View source

    Read(byte[], int, int)

    Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

    Declaration
    public override int Read(byte[] buffer, int offset, int count)
    Parameters
    Type Name Description
    byte[] buffer

    An array of bytes. A maximum of count bytes are read from the current stream and stored in buffer.

    int offset

    The byte offset in buffer at which to begin storing the data read from the current stream.

    int count

    The maximum number of bytes to be read from the current stream.

    Returns
    Type Description
    int

    The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached.

    Overrides
    SilverbackCryptoStream.Read(byte[], int, int)
    Exceptions
    Type Condition
    NotSupportedException

    The CryptoStreamMode associated with current CryptoStream object does not match the underlying stream. For example, this exception is thrown when using Read with an underlying stream that is write only.

    ArgumentOutOfRangeException

    The offset parameter is less than zero.
    -or-
    The count parameter is less than zero.

    ArgumentException

    The sum of the count and offset parameters is longer than the length of the buffer.

    | Improve this doc View source

    ReadAsync(byte[], int, int, CancellationToken)

    Reads a sequence of bytes from the current stream asynchronously, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

    Declaration
    public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    byte[] buffer

    The buffer to write the data into.

    int offset

    The byte offset in buffer at which to begin writing data from the stream.

    int count

    The maximum number of bytes to read.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests. The default value is None.

    Returns
    Type Description
    Task<int>

    A task that represents the asynchronous read operation. The value of the task object's TResult parameter contains the total number of bytes read into the buffer. The result can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the stream has been reached.

    Overrides
    SilverbackCryptoStream.ReadAsync(byte[], int, int, CancellationToken)
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null.

    ArgumentOutOfRangeException

    offset or count is negative.

    ArgumentException

    The sum of offset and count is larger than the buffer length.

    NotSupportedException

    The stream does not support reading.

    ObjectDisposedException

    The stream has been disposed.

    InvalidOperationException

    The stream is currently in use by a previous read operation.

    Implements

    IAsyncDisposable
    IDisposable
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini