66 [MemberNotNull(
"_lazyAsyncActiveSemaphore")]
69 [MemberNotNull(
"_lazyAsyncActiveSemaphore")]
77 : this(
stream, transform, mode, leaveOpen: false)
83 if (transform ==
null)
150 if (!cryptoStream.HasFlushedFinalBlock)
152 await cryptoStream.FlushFinalBlockAsync(useAsync,
cancellationToken).ConfigureAwait(continueOnCapturedContext:
false);
255 return base.ReadByte();
266 base.WriteByte(
value);
450 int bytesToWrite =
buffer.Length;
451 int currentInputIndex = 0;
478 while (bytesToWrite > 0)
487 int numOutputBytes2 = 0;
490 numOutputBytes2 = TransformBlock(
_transform,
buffer.Slice(currentInputIndex, numWholeBlocksInBytes), tempOutputBuffer, 0);
499 currentInputIndex += numWholeBlocksInBytes;
500 bytesToWrite -= numWholeBlocksInBytes;
503 tempOutputBuffer =
null;
535 return transform.
TransformBlock(segment.Array, segment.Offset, inputBuffer.
Length, outputBuffer, outputOffset);
539 fixed (
byte* ptr = &
array[0])
561 fixed (
byte* ptr = &
array[0])
600 while (bytesRead > 0);
644 protected override void Dispose(
bool disposing)
680 base.Dispose(disposing);
691 return base.DisposeAsync();
static unsafe void Clear(Array array)
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
static ArrayPool< T > Shared
static void ValidateBufferArguments(byte[] buffer, int offset, int count)
Task WriteAsync(byte[] buffer, int offset, int count)
int Read(byte[] buffer, int offset, int count)
Task< int > ReadAsync(byte[] buffer, int offset, int count)
void Write(byte[] buffer, int offset, int count)
virtual ValueTask DisposeAsync()
static byte Min(byte val1, byte val2)
static string ArgumentOutOfRange_NeedPosNum
static string Cryptography_CryptoStream_FlushFinalBlockTwice
static string Argument_InvalidValue
static string Argument_StreamNotWritable
static string Format(string resourceFormat, object p1)
static string NotSupported_UnseekableStream
static string NotSupported_UnwritableStream
static string Argument_StreamNotReadable
static string NotSupported_UnreadableStream
override ValueTask DisposeAsync()
async ValueTask DisposeAsyncCore()
async ValueTask WriteAsyncInternal(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
SemaphoreSlim _lazyAsyncActiveSemaphore
override void Write(byte[] buffer, int offset, int count)
bool HasFlushedFinalBlock
async ValueTask< int > ReadAsyncCore(Memory< byte > buffer, CancellationToken cancellationToken, bool useAsync)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
SemaphoreSlim AsyncActiveSemaphore
ValueTask FlushFinalBlockAsync(CancellationToken cancellationToken=default(CancellationToken))
CryptoStream(Stream stream, ICryptoTransform transform, CryptoStreamMode mode, bool leaveOpen)
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override Task FlushAsync(CancellationToken cancellationToken)
bool _finalBlockTransformed
override int Read(byte[] buffer, int offset, int count)
override long Seek(long offset, SeekOrigin origin)
void CheckReadArguments(byte[] buffer, int offset, int count)
override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
readonly ICryptoTransform _transform
override void WriteByte(byte value)
CryptoStream(Stream stream, ICryptoTransform transform, CryptoStreamMode mode)
void CheckCopyToArguments(Stream destination, int bufferSize)
void CheckWriteArguments(byte[] buffer, int offset, int count)
static void EnsureNotDisposed(Stream stream, string objectName)
async ValueTask< int > ReadAsyncInternal(Memory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
async ValueTask FlushFinalBlockAsync(bool useAsync, CancellationToken cancellationToken)
override void EndWrite(IAsyncResult asyncResult)
async ValueTask WriteAsyncCore(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken, bool useAsync)
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override int EndRead(IAsyncResult asyncResult)
unsafe override void CopyTo(Stream destination, int bufferSize)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override void Dispose(bool disposing)
override void SetLength(long value)
async Task CopyToAsyncInternal(Stream destination, int bufferSize, CancellationToken cancellationToken)
static void ZeroMemory(Span< byte > buffer)
static IAsyncResult Begin(Task task, AsyncCallback callback, object state)
static void End(IAsyncResult asyncResult)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
static Task FromCanceled(CancellationToken cancellationToken)
static Task CompletedTask
void CopyTo(Memory< T > destination)
void CopyTo(Span< T > destination)
static GCHandle Alloc(object? value)
static CancellationToken None
static ValueTask FromCanceled(CancellationToken cancellationToken)
ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)
static ValueTask FromException(Exception exception)
ValueTaskAwaiter GetAwaiter()