summary refs log tree commit diff
path: root/crypto/src/crypto/operators/DefaultMacResult.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/crypto/operators/DefaultMacResult.cs')
-rw-r--r--crypto/src/crypto/operators/DefaultMacResult.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/crypto/src/crypto/operators/DefaultMacResult.cs b/crypto/src/crypto/operators/DefaultMacResult.cs
new file mode 100644
index 000000000..9a45d6792
--- /dev/null
+++ b/crypto/src/crypto/operators/DefaultMacResult.cs
@@ -0,0 +1,27 @@
+using System;
+
+using Org.BouncyCastle.Security;
+
+namespace Org.BouncyCastle.Crypto.Operators
+{
+    public sealed class DefaultMacResult
+        : IBlockResult
+    {
+        private readonly IMac m_mac;
+
+        public DefaultMacResult(IMac mac)
+        {
+            m_mac = mac;
+        }
+
+        public byte[] Collect() => MacUtilities.DoFinal(m_mac);
+
+        public int Collect(byte[] buf, int off) => m_mac.DoFinal(buf, off);
+
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+        public int Collect(Span<byte> output) => m_mac.DoFinal(output);
+#endif
+
+        public int GetMaxResultLength() => m_mac.GetMacSize();
+    }
+}