From 3fc5f0e61be2f9f6169d88b143e8c196d5e63b5e Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 29 Jul 2019 22:15:23 +0700 Subject: Fix field reduction for custom secp128r1 curve - see https://github.com/bcgit/bc-java/issues/566 --- crypto/src/math/ec/custom/sec/SecP128R1Field.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crypto/src/math/ec/custom') diff --git a/crypto/src/math/ec/custom/sec/SecP128R1Field.cs b/crypto/src/math/ec/custom/sec/SecP128R1Field.cs index d1ac009b3..cf91c7e5d 100644 --- a/crypto/src/math/ec/custom/sec/SecP128R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP128R1Field.cs @@ -134,6 +134,11 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec x = (uint)c; } + + if (z[3] >= P3 && Nat128.Gte(z, P)) + { + AddPInvTo(z); + } } public static void Square(uint[] x, uint[] z) -- cgit 1.5.1