private void setFieldIdentifier() { if (ECAlgorithms.isFpCurve(curve)) { fieldIdentifier = prime_field; } else if (ECAlgorithms.isF2mCurve(curve)) { fieldIdentifier = characteristic_two_field; } else { throw new IllegalArgumentException("This type of ECCurve is not implemented"); } }
private void setFieldIdentifier() { if (ECAlgorithms.isFpCurve(curve)) { fieldIdentifier = prime_field; } else if (ECAlgorithms.isF2mCurve(curve)) { fieldIdentifier = characteristic_two_field; } else { throw new IllegalArgumentException("This type of ECCurve is not implemented"); } }
public static void printRootZ(X9ECParameters x9) { if (!ECAlgorithms.isF2mCurve(x9.getCurve())) { throw new IllegalArgumentException("Sqrt optimization only defined over characteristic-2 fields"); } implPrintRootZ(x9); }
public static void printNonZeroTraceBits(X9ECParameters x9) { if (!ECAlgorithms.isF2mCurve(x9.getCurve())) { throw new IllegalArgumentException("Trace only defined over characteristic-2 fields"); } implPrintNonZeroTraceBits(x9); }
public static void main(String[] args) { SortedSet names = new TreeSet(enumToList(ECNamedCurveTable.getNames())); names.addAll(enumToList(CustomNamedCurves.getNames())); Iterator it = names.iterator(); while (it.hasNext()) { String name = (String)it.next(); X9ECParameters x9 = CustomNamedCurves.getByName(name); if (x9 == null) { x9 = ECNamedCurveTable.getByName(name); } if (x9 != null && ECAlgorithms.isF2mCurve(x9.getCurve())) { System.out.print(name + ":"); implPrintRootZ(x9); } } }
public static void main(String[] args) { SortedSet names = new TreeSet(enumToList(ECNamedCurveTable.getNames())); names.addAll(enumToList(CustomNamedCurves.getNames())); Iterator it = names.iterator(); while (it.hasNext()) { String name = (String)it.next(); X9ECParameters x9 = CustomNamedCurves.getByName(name); if (x9 == null) { x9 = ECNamedCurveTable.getByName(name); } if (x9 != null && ECAlgorithms.isF2mCurve(x9.getCurve())) { System.out.print(name + ":"); implPrintNonZeroTraceBits(x9); } } }
public static byte[] serializeECPoint(short[] ecPointFormats, ECPoint point) throws IOException { ECCurve curve = point.getCurve(); /* * RFC 4492 5.7. ...an elliptic curve point in uncompressed or compressed format. Here, the * format MUST conform to what the server has requested through a Supported Point Formats * Extension if this extension was used, and MUST be uncompressed if this extension was not * used. */ boolean compressed = false; if (ECAlgorithms.isFpCurve(curve)) { compressed = isCompressionPreferred(ecPointFormats, ECPointFormat.ansiX962_compressed_prime); } else if (ECAlgorithms.isF2mCurve(curve)) { compressed = isCompressionPreferred(ecPointFormats, ECPointFormat.ansiX962_compressed_char2); } return point.getEncoded(compressed); }
public static byte[] serializeECPoint(short[] ecPointFormats, ECPoint point) throws IOException { ECCurve curve = point.getCurve(); /* * RFC 4492 5.7. ...an elliptic curve point in uncompressed or compressed format. Here, the * format MUST conform to what the server has requested through a Supported Point Formats * Extension if this extension was used, and MUST be uncompressed if this extension was not * used. */ boolean compressed = false; if (ECAlgorithms.isFpCurve(curve)) { compressed = isCompressionPreferred(ecPointFormats, ECPointFormat.ansiX962_compressed_prime); } else if (ECAlgorithms.isF2mCurve(curve)) { compressed = isCompressionPreferred(ecPointFormats, ECPointFormat.ansiX962_compressed_char2); } return point.getEncoded(compressed); }
else if (ECAlgorithms.isF2mCurve(curve))
else if (ECAlgorithms.isF2mCurve(curve))
case 0x03: // compressed if (ECAlgorithms.isF2mCurve(curve))
case 0x03: // compressed if (ECAlgorithms.isF2mCurve(curve))
public DSTU4145ECBinary(ECDomainParameters params) { ECCurve curve = params.getCurve(); if (!ECAlgorithms.isF2mCurve(curve)) { throw new IllegalArgumentException("only binary domain is possible"); } // We always use big-endian in parameter encoding PolynomialExtensionField field = (PolynomialExtensionField)curve.getField(); int[] exponents = field.getMinimalPolynomial().getExponentsPresent(); if (exponents.length == 3) { f = new DSTU4145BinaryField(exponents[2], exponents[1]); } else if (exponents.length == 5) { f = new DSTU4145BinaryField(exponents[4], exponents[1], exponents[2], exponents[3]); } else { throw new IllegalArgumentException("curve must have a trinomial or pentanomial basis"); } a = new ASN1Integer(curve.getA().toBigInteger()); b = new DEROctetString(curve.getB().getEncoded()); n = new ASN1Integer(params.getN()); bp = new DEROctetString(DSTU4145PointEncoder.encodePoint(params.getG())); }
public DSTU4145ECBinary(ECDomainParameters params) { ECCurve curve = params.getCurve(); if (!ECAlgorithms.isF2mCurve(curve)) { throw new IllegalArgumentException("only binary domain is possible"); } // We always use big-endian in parameter encoding PolynomialExtensionField field = (PolynomialExtensionField)curve.getField(); int[] exponents = field.getMinimalPolynomial().getExponentsPresent(); if (exponents.length == 3) { f = new DSTU4145BinaryField(exponents[2], exponents[1]); } else if (exponents.length == 5) { f = new DSTU4145BinaryField(exponents[4], exponents[1], exponents[2], exponents[3]); } a = new ASN1Integer(curve.getA().toBigInteger()); b = new DEROctetString(curve.getB().getEncoded()); n = new ASN1Integer(params.getN()); bp = new DEROctetString(DSTU4145PointEncoder.encodePoint(params.getG())); }
else if (ECAlgorithms.isF2mCurve(curve))
else if (ECAlgorithms.isF2mCurve(curve))