summary refs log tree commit diff
path: root/crypto/src/math/ec/rfc8032/Ed448.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-11-20 17:43:39 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-11-20 17:43:39 +0700
commitb791c4a030f0e06f5abab52a68a4225a33878207 (patch)
tree2e4617dde901f5edd8fd84e64a5a706b9f4e93bf /crypto/src/math/ec/rfc8032/Ed448.cs
parentIntrinsics for shuffles (diff)
downloadBouncyCastle.NET-ed25519-b791c4a030f0e06f5abab52a68a4225a33878207.tar.xz
Refactoring in Math.EC.Rfc8032
Diffstat (limited to '')
-rw-r--r--crypto/src/math/ec/rfc8032/Ed448.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/crypto/src/math/ec/rfc8032/Ed448.cs b/crypto/src/math/ec/rfc8032/Ed448.cs
index 7baa221a5..75629c293 100644
--- a/crypto/src/math/ec/rfc8032/Ed448.cs
+++ b/crypto/src/math/ec/rfc8032/Ed448.cs
@@ -298,6 +298,16 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032
         private static void Dom4(IXof d, byte phflag, byte[] ctx)
         {
             int n = Dom4Prefix.Length;
+
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+            Span<byte> t = stackalloc byte[n + 2 + ctx.Length];
+            Dom4Prefix.CopyTo(t);
+            t[n] = phflag;
+            t[n + 1] = (byte)ctx.Length;
+            ctx.CopyTo(t.Slice(n + 2));
+
+            d.BlockUpdate(t);
+#else
             byte[] t = new byte[n + 2 + ctx.Length];
             Dom4Prefix.CopyTo(t, 0);
             t[n] = phflag;
@@ -305,6 +315,7 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032
             ctx.CopyTo(t, n + 2);
 
             d.BlockUpdate(t, 0, t.Length);
+#endif
         }
 
         private static int EncodePoint(ref PointProjective p, byte[] r, int rOff)