diff options
Diffstat (limited to 'crypto/src/crypto/io/DigestSink.cs')
-rw-r--r-- | crypto/src/crypto/io/DigestSink.cs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/crypto/src/crypto/io/DigestSink.cs b/crypto/src/crypto/io/DigestSink.cs index 283bda28b..4e0e7d54a 100644 --- a/crypto/src/crypto/io/DigestSink.cs +++ b/crypto/src/crypto/io/DigestSink.cs @@ -1,4 +1,8 @@ using System; +#if NETCOREAPP1_0_OR_GREATER || NET45_OR_GREATER || NETSTANDARD1_0_OR_GREATER +using System.Threading; +using System.Threading.Tasks; +#endif using Org.BouncyCastle.Utilities.IO; @@ -11,7 +15,7 @@ namespace Org.BouncyCastle.Crypto.IO public DigestSink(IDigest digest) { - m_digest = digest; + m_digest = digest ?? throw new ArgumentNullException(nameof(digest)); } public IDigest Digest => m_digest; @@ -26,6 +30,13 @@ namespace Org.BouncyCastle.Crypto.IO } } +#if NETCOREAPP1_0_OR_GREATER || NET45_OR_GREATER || NETSTANDARD1_0_OR_GREATER + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return Streams.WriteAsyncDirect(this, buffer, offset, count, cancellationToken); + } +#endif + #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public override void Write(ReadOnlySpan<byte> buffer) { @@ -34,6 +45,11 @@ namespace Org.BouncyCastle.Crypto.IO m_digest.BlockUpdate(buffer); } } + + public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default) + { + return Streams.WriteAsyncDirect(this, buffer, cancellationToken); + } #endif public override void WriteByte(byte value) |