summary refs log tree commit diff
path: root/crypto/src/crypto/io/MacSink.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/crypto/io/MacSink.cs')
-rw-r--r--crypto/src/crypto/io/MacSink.cs25
1 files changed, 16 insertions, 9 deletions
diff --git a/crypto/src/crypto/io/MacSink.cs b/crypto/src/crypto/io/MacSink.cs

index aa72e9047..cc5d93b37 100644 --- a/crypto/src/crypto/io/MacSink.cs +++ b/crypto/src/crypto/io/MacSink.cs
@@ -4,20 +4,17 @@ using Org.BouncyCastle.Utilities.IO; namespace Org.BouncyCastle.Crypto.IO { - public class MacSink + public sealed class MacSink : BaseOutputStream { - private readonly IMac mMac; + private readonly IMac m_mac; public MacSink(IMac mac) { - this.mMac = mac; + m_mac = mac; } - public virtual IMac Mac - { - get { return mMac; } - } + public IMac Mac => m_mac; public override void Write(byte[] buffer, int offset, int count) { @@ -25,13 +22,23 @@ namespace Org.BouncyCastle.Crypto.IO if (count > 0) { - mMac.BlockUpdate(buffer, offset, count); + m_mac.BlockUpdate(buffer, offset, count); + } + } + +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public override void Write(ReadOnlySpan<byte> buffer) + { + if (!buffer.IsEmpty) + { + m_mac.BlockUpdate(buffer); } } +#endif public override void WriteByte(byte value) { - mMac.Update(value); + m_mac.Update(value); } } }