Skip to content

Commit 3e761ae

Browse files
committed
Configure basepoints
1 parent eafbf9f commit 3e761ae

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

core/src/main/java/org/bouncycastle/asn1/ua/DSTU4145NamedCurves.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.bouncycastle.crypto.params.ECDomainParameters;
77
import org.bouncycastle.math.ec.ECCurve;
88
import org.bouncycastle.math.ec.ECPoint;
9+
import org.bouncycastle.math.ec.WNafUtil;
910

1011
public class DSTU4145NamedCurves
1112
{
@@ -19,6 +20,13 @@ public class DSTU4145NamedCurves
1920
//where X is the curve number 0-9
2021
static final String oidBase = UAObjectIdentifiers.dstu4145le.getId() + ".2.";
2122

23+
private static ECPoint configureBasepoint(ECCurve curve, BigInteger x, BigInteger y)
24+
{
25+
ECPoint G = curve.createPoint(x, y);
26+
WNafUtil.configureBasepoint(G);
27+
return G;
28+
}
29+
2230
static
2331
{
2432
BigInteger[] n_s = new BigInteger[10];
@@ -58,16 +66,16 @@ public class DSTU4145NamedCurves
5866
curves[9] = new ECCurve.F2m(431, 1, 3, 5, ONE, new BigInteger("03CE10490F6A708FC26DFE8C3D27C4F94E690134D5BFF988D8D28AAEAEDE975936C66BAC536B18AE2DC312CA493117DAA469C640CAF3", 16), n_s[9], h_s[9]);
5967

6068
ECPoint[] points = new ECPoint[10];
61-
points[0] = curves[0].createPoint(new BigInteger("2E2F85F5DD74CE983A5C4237229DAF8A3F35823BE", 16), new BigInteger("3826F008A8C51D7B95284D9D03FF0E00CE2CD723A", 16));
62-
points[1] = curves[1].createPoint(new BigInteger("7A1F6653786A68192803910A3D30B2A2018B21CD54", 16), new BigInteger("5F49EB26781C0EC6B8909156D98ED435E45FD59918", 16));
63-
points[2] = curves[2].createPoint(new BigInteger("4D41A619BCC6EADF0448FA22FAD567A9181D37389CA", 16), new BigInteger("10B51CC12849B234C75E6DD2028BF7FF5C1CE0D991A1", 16));
64-
points[3] = curves[3].createPoint(new BigInteger("6BA06FE51464B2BD26DC57F48819BA9954667022C7D03", 16), new BigInteger("25FBC363582DCEC065080CA8287AAFF09788A66DC3A9E", 16));
65-
points[4] = curves[4].createPoint(new BigInteger("714114B762F2FF4A7912A6D2AC58B9B5C2FCFE76DAEB7129", 16), new BigInteger("29C41E568B77C617EFE5902F11DB96FA9613CD8D03DB08DA", 16));
66-
points[5] = curves[5].createPoint(new BigInteger("3FCDA526B6CDF83BA1118DF35B3C31761D3545F32728D003EEB25EFE96", 16), new BigInteger("9CA8B57A934C54DEEDA9E54A7BBAD95E3B2E91C54D32BE0B9DF96D8D35", 16));
67-
points[6] = curves[6].createPoint(new BigInteger("02A29EF207D0E9B6C55CD260B306C7E007AC491CA1B10C62334A9E8DCD8D20FB7", 16), new BigInteger("10686D41FF744D4449FCCF6D8EEA03102E6812C93A9D60B978B702CF156D814EF", 16));
68-
points[7] = curves[7].createPoint(new BigInteger("216EE8B189D291A0224984C1E92F1D16BF75CCD825A087A239B276D3167743C52C02D6E7232AA", 16), new BigInteger("5D9306BACD22B7FAEB09D2E049C6E2866C5D1677762A8F2F2DC9A11C7F7BE8340AB2237C7F2A0", 16));
69-
points[8] = curves[8].createPoint(new BigInteger("324A6EDDD512F08C49A99AE0D3F961197A76413E7BE81A400CA681E09639B5FE12E59A109F78BF4A373541B3B9A1", 16), new BigInteger("1AB597A5B4477F59E39539007C7F977D1A567B92B043A49C6B61984C3FE3481AAF454CD41BA1F051626442B3C10", 16));
70-
points[9] = curves[9].createPoint(new BigInteger("1A62BA79D98133A16BBAE7ED9A8E03C32E0824D57AEF72F88986874E5AAE49C27BED49A2A95058068426C2171E99FD3B43C5947C857D", 16), new BigInteger("70B5E1E14031C1F70BBEFE96BDDE66F451754B4CA5F48DA241F331AA396B8D1839A855C1769B1EA14BA53308B5E2723724E090E02DB9", 16));
69+
points[0] = configureBasepoint(curves[0], new BigInteger("2E2F85F5DD74CE983A5C4237229DAF8A3F35823BE", 16), new BigInteger("3826F008A8C51D7B95284D9D03FF0E00CE2CD723A", 16));
70+
points[1] = configureBasepoint(curves[1], new BigInteger("7A1F6653786A68192803910A3D30B2A2018B21CD54", 16), new BigInteger("5F49EB26781C0EC6B8909156D98ED435E45FD59918", 16));
71+
points[2] = configureBasepoint(curves[2], new BigInteger("4D41A619BCC6EADF0448FA22FAD567A9181D37389CA", 16), new BigInteger("10B51CC12849B234C75E6DD2028BF7FF5C1CE0D991A1", 16));
72+
points[3] = configureBasepoint(curves[3], new BigInteger("6BA06FE51464B2BD26DC57F48819BA9954667022C7D03", 16), new BigInteger("25FBC363582DCEC065080CA8287AAFF09788A66DC3A9E", 16));
73+
points[4] = configureBasepoint(curves[4], new BigInteger("714114B762F2FF4A7912A6D2AC58B9B5C2FCFE76DAEB7129", 16), new BigInteger("29C41E568B77C617EFE5902F11DB96FA9613CD8D03DB08DA", 16));
74+
points[5] = configureBasepoint(curves[5], new BigInteger("3FCDA526B6CDF83BA1118DF35B3C31761D3545F32728D003EEB25EFE96", 16), new BigInteger("9CA8B57A934C54DEEDA9E54A7BBAD95E3B2E91C54D32BE0B9DF96D8D35", 16));
75+
points[6] = configureBasepoint(curves[6], new BigInteger("02A29EF207D0E9B6C55CD260B306C7E007AC491CA1B10C62334A9E8DCD8D20FB7", 16), new BigInteger("10686D41FF744D4449FCCF6D8EEA03102E6812C93A9D60B978B702CF156D814EF", 16));
76+
points[7] = configureBasepoint(curves[7], new BigInteger("216EE8B189D291A0224984C1E92F1D16BF75CCD825A087A239B276D3167743C52C02D6E7232AA", 16), new BigInteger("5D9306BACD22B7FAEB09D2E049C6E2866C5D1677762A8F2F2DC9A11C7F7BE8340AB2237C7F2A0", 16));
77+
points[8] = configureBasepoint(curves[8], new BigInteger("324A6EDDD512F08C49A99AE0D3F961197A76413E7BE81A400CA681E09639B5FE12E59A109F78BF4A373541B3B9A1", 16), new BigInteger("1AB597A5B4477F59E39539007C7F977D1A567B92B043A49C6B61984C3FE3481AAF454CD41BA1F051626442B3C10", 16));
78+
points[9] = configureBasepoint(curves[9], new BigInteger("1A62BA79D98133A16BBAE7ED9A8E03C32E0824D57AEF72F88986874E5AAE49C27BED49A2A95058068426C2171E99FD3B43C5947C857D", 16), new BigInteger("70B5E1E14031C1F70BBEFE96BDDE66F451754B4CA5F48DA241F331AA396B8D1839A855C1769B1EA14BA53308B5E2723724E090E02DB9", 16));
7179

7280
for (int i = 0; i < params.length; i++)
7381
{

core/src/main/java/org/bouncycastle/crypto/params/SAKKEPublicKeyParameters.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.bouncycastle.crypto.digests.SHA256Digest;
77
import org.bouncycastle.math.ec.ECCurve;
88
import org.bouncycastle.math.ec.ECPoint;
9+
import org.bouncycastle.math.ec.WNafUtil;
910
import org.bouncycastle.util.encoders.Hex;
1011

1112
/**
@@ -36,6 +37,13 @@
3637
public class SAKKEPublicKeyParameters
3738
extends AsymmetricKeyParameter
3839
{
40+
private static ECPoint configureBasepoint(ECCurve curve, BigInteger x, BigInteger y)
41+
{
42+
ECPoint G = curve.createPoint(x, y);
43+
WNafUtil.configureBasepoint(G);
44+
return G;
45+
}
46+
3947
/**
4048
* Prime modulus p defining the finite field F_p (RFC 6508, Section 2.1).
4149
* Value from RFC 6509 Appendix A.
@@ -102,7 +110,7 @@ public class SAKKEPublicKeyParameters
102110
* Base point P on the elliptic curve E(F_p) (RFC 6508, Section 3.1).
103111
* Coordinates from RFC 6509 Appendix A.
104112
*/
105-
static final ECPoint P = curve.createPoint(Px, Py);
113+
static final ECPoint P = configureBasepoint(curve, Px, Py);
106114
/** KMS Public Key Z_S = [z_S]P (RFC 6508, Section 2.2) */
107115
private final ECPoint Z;
108116
/** User's Identifier (RFC 6508, Section 2.2) */

0 commit comments

Comments
 (0)