summary refs log tree commit diff
path: root/crypto/src/util/Spans.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-08-31 01:48:36 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-08-31 01:48:36 +0700
commitf01393e0ce47b124d711e7c3512bd2fab50e98bf (patch)
treecd27c8543ef6a99b43af92dc710485481c2a0f08 /crypto/src/util/Spans.cs
parentFix exceptions (diff)
downloadBouncyCastle.NET-ed25519-f01393e0ce47b124d711e7c3512bd2fab50e98bf.tar.xz
Span-based variants for IAeadCipher.ProcessByte(s)
Diffstat (limited to 'crypto/src/util/Spans.cs')
-rw-r--r--crypto/src/util/Spans.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto/src/util/Spans.cs b/crypto/src/util/Spans.cs
new file mode 100644
index 000000000..5e1b3737c
--- /dev/null
+++ b/crypto/src/util/Spans.cs
@@ -0,0 +1,18 @@
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+using System;
+using System.Runtime.CompilerServices;
+
+#nullable enable
+
+namespace Org.BouncyCastle.Utilities
+{
+    internal static class Spans
+    {
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static Span<T> FromNullable<T>(T[]? array, int start)
+        {
+            return array == null ? Span<T>.Empty : array.AsSpan(start);
+        }
+    }
+}
+#endif