summary refs log tree commit diff
path: root/crypto/src/tls
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-03-09 16:17:26 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-03-09 16:17:26 +0700
commit95db89f0bcf07e49ed86b235f3953718a50b6f54 (patch)
tree3354d8f3687f37f14800eb75627bf34630d90fdf /crypto/src/tls
parentFix some warnings (diff)
downloadBouncyCastle.NET-ed25519-95db89f0bcf07e49ed86b235f3953718a50b6f54.tar.xz
Refactoring around Stream usage
Diffstat (limited to 'crypto/src/tls')
-rw-r--r--crypto/src/tls/TlsStream.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crypto/src/tls/TlsStream.cs b/crypto/src/tls/TlsStream.cs

index 5c07da2bf..d7d79a6fa 100644 --- a/crypto/src/tls/TlsStream.cs +++ b/crypto/src/tls/TlsStream.cs
@@ -1,5 +1,9 @@ using System; using System.IO; +using System.Threading; +using System.Threading.Tasks; + +using Org.BouncyCastle.Utilities.IO; namespace Org.BouncyCastle.Tls { @@ -28,6 +32,18 @@ namespace Org.BouncyCastle.Tls get { return true; } } +#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public override void CopyTo(Stream destination, int bufferSize) + { + Streams.CopyTo(this, destination, bufferSize); + } +#endif + + public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) + { + return Streams.CopyToAsync(this, destination, bufferSize, cancellationToken); + } + protected override void Dispose(bool disposing) { if (disposing) @@ -63,6 +79,11 @@ namespace Org.BouncyCastle.Tls { return m_handler.ReadApplicationData(buffer); } + + public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default) + { + return Streams.ReadAsync(this, buffer, cancellationToken); + } #endif public override int ReadByte() @@ -92,6 +113,11 @@ namespace Org.BouncyCastle.Tls { m_handler.WriteApplicationData(buffer); } + + public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default) + { + return Streams.WriteAsync(this, buffer, cancellationToken); + } #endif public override void WriteByte(byte value)