diff options
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecT193Field.cs')
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecT193Field.cs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecT193Field.cs b/crypto/src/math/ec/custom/sec/SecT193Field.cs index 4aa3ad5c2..3d9937f75 100644 --- a/crypto/src/math/ec/custom/sec/SecT193Field.cs +++ b/crypto/src/math/ec/custom/sec/SecT193Field.cs @@ -41,7 +41,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec z[3] = x[3]; } - private static void AddTo(ulong[] x, ulong[] z) + public static void AddTo(ulong[] x, ulong[] z) { z[0] ^= x[0]; z[1] ^= x[1]; @@ -183,6 +183,11 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec AddExt(zz, tt, zz); } + public static void SquareExt(ulong[] x, ulong[] zz) + { + ImplSquare(x, zz); + } + public static void SquareN(ulong[] x, int n, ulong[] z) { Debug.Assert(n > 0); @@ -349,8 +354,22 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec protected static void ImplSquare(ulong[] x, ulong[] zz) { - Interleave.Expand64To128(x, 0, 3, zz, 0); zz[6] = (x[3] & M01); + +#if NETCOREAPP3_0_OR_GREATER + if (Bmi2.X64.IsSupported) + { + zz[5] = Bmi2.X64.ParallelBitDeposit(x[2] >> 32, 0x5555555555555555UL); + zz[4] = Bmi2.X64.ParallelBitDeposit(x[2] , 0x5555555555555555UL); + zz[3] = Bmi2.X64.ParallelBitDeposit(x[1] >> 32, 0x5555555555555555UL); + zz[2] = Bmi2.X64.ParallelBitDeposit(x[1] , 0x5555555555555555UL); + zz[1] = Bmi2.X64.ParallelBitDeposit(x[0] >> 32, 0x5555555555555555UL); + zz[0] = Bmi2.X64.ParallelBitDeposit(x[0] , 0x5555555555555555UL); + return; + } +#endif + + Interleave.Expand64To128(x, 0, 3, zz, 0); } } } |