summary refs log tree commit diff
path: root/crypto/src/util
diff options
context:
space:
mode:
authorDavid Hook <dgh@cryptoworkshop.com>2021-03-19 15:25:57 +1100
committerDavid Hook <dgh@cryptoworkshop.com>2021-03-19 15:25:57 +1100
commit504554b718911423f64b9d7235eee6fdba9241ee (patch)
treec7e41b1a3769b9cfba3dea124f434d551a9c16ed /crypto/src/util
parentAdd SECURITY.md (diff)
downloadBouncyCastle.NET-ed25519-504554b718911423f64b9d7235eee6fdba9241ee.tar.xz
first cut FPE, TupleHash, ParallelHash, and GCM-SIV
Diffstat (limited to 'crypto/src/util')
-rw-r--r--crypto/src/util/Arrays.cs24
-rw-r--r--crypto/src/util/Bytes.cs10
-rw-r--r--crypto/src/util/Integers.cs3
-rw-r--r--crypto/src/util/Longs.cs3
4 files changed, 40 insertions, 0 deletions
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs
index 784d45efb..78c4e8ffc 100644
--- a/crypto/src/util/Arrays.cs
+++ b/crypto/src/util/Arrays.cs
@@ -467,6 +467,17 @@ namespace Org.BouncyCastle.Utilities
             return data == null ? null : (byte[])data.Clone();
         }
 
+        public static short[] Clone(short[] data)
+        {
+            return data == null ? null : (short[])data.Clone();
+        }
+
+        [CLSCompliantAttribute(false)]
+        public static ushort[] Clone(ushort[] data)
+        {
+            return data == null ? null : (ushort[])data.Clone();
+        }
+
         public static int[] Clone(int[] data)
         {
             return data == null ? null : (int[])data.Clone();
@@ -694,6 +705,19 @@ namespace Org.BouncyCastle.Utilities
             return rv;
         }
 
+        public static ushort[] Concatenate(ushort[] a, ushort[] b)
+        {
+            if (a == null)
+                return Clone(b);
+            if (b == null)
+                return Clone(a);
+
+            ushort[] rv = new ushort[a.Length + b.Length];
+            Array.Copy(a, 0, rv, 0, a.Length);
+            Array.Copy(b, 0, rv, a.Length, b.Length);
+            return rv;
+        }
+
         public static byte[] ConcatenateAll(params byte[][] vs)
         {
             byte[][] nonNull = new byte[vs.Length][];
diff --git a/crypto/src/util/Bytes.cs b/crypto/src/util/Bytes.cs
new file mode 100644
index 000000000..0d73d67ae
--- /dev/null
+++ b/crypto/src/util/Bytes.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Org.BouncyCastle.Utilities
+{
+    public abstract class Bytes
+    {
+        public static readonly uint BYTES = 1;
+        public static readonly uint SIZE = 8;
+    }
+}
diff --git a/crypto/src/util/Integers.cs b/crypto/src/util/Integers.cs
index b243b88b2..b7bd25ce6 100644
--- a/crypto/src/util/Integers.cs
+++ b/crypto/src/util/Integers.cs
@@ -6,6 +6,9 @@ namespace Org.BouncyCastle.Utilities
 {
     public abstract class Integers
     {
+        public static readonly uint BYTES = 4;
+        public static readonly uint SIZE = 32;
+
         private static readonly byte[] DeBruijnTZ = {
             0x00, 0x01, 0x02, 0x18, 0x03, 0x13, 0x06, 0x19, 0x16, 0x04, 0x14, 0x0A,
             0x10, 0x07, 0x0C, 0x1A, 0x1F, 0x17, 0x12, 0x05, 0x15, 0x09, 0x0F, 0x0B,
diff --git a/crypto/src/util/Longs.cs b/crypto/src/util/Longs.cs
index d206c1f81..892e57137 100644
--- a/crypto/src/util/Longs.cs
+++ b/crypto/src/util/Longs.cs
@@ -6,6 +6,9 @@ namespace Org.BouncyCastle.Utilities
 {
     public abstract class Longs
     {
+        public static readonly uint BYTES = 8;
+        public static readonly uint SIZE = 64;
+
         public static long Reverse(long i)
         {
             i = (long)Bits.BitPermuteStepSimple((ulong)i, 0x5555555555555555UL, 1);