summary refs log tree commit diff
path: root/crypto/src/math/ec/custom
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-07-19 00:42:58 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-07-19 00:42:58 +0700
commitb966a4c7e871e8a1bdf50c29626ce40450c3db0c (patch)
treeec7ebe55384a5f92233977dc01e0c541a04af581 /crypto/src/math/ec/custom
parentFactor out Unshuffle methods (diff)
downloadBouncyCastle.NET-ed25519-b966a4c7e871e8a1bdf50c29626ce40450c3db0c.tar.xz
Use intrinsics in several places
Diffstat (limited to 'crypto/src/math/ec/custom')
-rw-r--r--crypto/src/math/ec/custom/sec/SecT571Field.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecT571Field.cs b/crypto/src/math/ec/custom/sec/SecT571Field.cs
index 4d3f715fa..97bc08d67 100644
--- a/crypto/src/math/ec/custom/sec/SecT571Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecT571Field.cs
@@ -1,5 +1,9 @@
 using System;
 using System.Diagnostics;
+#if NET5_0_OR_GREATER
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+#endif
 
 using Org.BouncyCastle.Math.Raw;
 
@@ -399,6 +403,18 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         protected static void ImplMulwAcc(ulong[] u, ulong x, ulong y, ulong[] z, int zOff)
         {
+#if NET5_0_OR_GREATER
+            if (Pclmulqdq.IsSupported)
+            {
+                var X = Vector128.CreateScalar(x);
+                var Y = Vector128.CreateScalar(y);
+                var Z = Pclmulqdq.CarrylessMultiply(X, Y, 0x00);
+                z[zOff    ] ^= Z.GetElement(0);
+                z[zOff + 1] ^= Z.GetElement(1);
+                return;
+            }
+#endif
+
             //u[0] = 0;
             u[1] = y;
             for (int i = 2; i < 16; i += 2)