summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2020-07-07 19:17:41 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2020-07-07 19:17:41 +0700
commitc43f275ac1aca8af3010dd4d94efa1511ca18f42 (patch)
tree9ebad3642950a439b0bbdd70229bc895f4730b48 /crypto/src/math/ec/custom/sec/SecP128R1Curve.cs
parentEC updates from bc-java (diff)
downloadBouncyCastle.NET-ed25519-c43f275ac1aca8af3010dd4d94efa1511ca18f42.tar.xz
Fermat inversion for all custom curves
- also customized random FE gen
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP128R1Curve.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/SecP128R1Curve.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs
index e92aca75b..b4a150ca0 100644
--- a/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs
+++ b/crypto/src/math/ec/custom/sec/SecP128R1Curve.cs
@@ -1,6 +1,7 @@
 using System;
 
 using Org.BouncyCastle.Math.Raw;
+using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities.Encoders;
 
 namespace Org.BouncyCastle.Math.EC.Custom.Sec
@@ -93,6 +94,20 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return new SecP128R1LookupTable(this, table, len);
         }
 
+        public override ECFieldElement RandomFieldElement(SecureRandom r)
+        {
+            uint[] x = Nat128.Create();
+            SecP128R1Field.Random(r, x);
+            return new SecP128R1FieldElement(x);
+        }
+
+        public override ECFieldElement RandomFieldElementMult(SecureRandom r)
+        {
+            uint[] x = Nat128.Create();
+            SecP128R1Field.RandomMult(r, x);
+            return new SecP128R1FieldElement(x);
+        }
+
         private class SecP128R1LookupTable
             : AbstractECLookupTable
         {