本文整理汇总了Java中org.bouncycastle.math.ec.ECAlgorithms.isFpCurve方法的典型用法代码示例。如果您正苦于以下问题:Java ECAlgorithms.isFpCurve方法的具体用法?Java ECAlgorithms.isFpCurve怎么用?Java ECAlgorithms.isFpCurve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.math.ec.ECAlgorithms
的用法示例。
在下文中一共展示了ECAlgorithms.isFpCurve方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeECPoint
import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
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);
}
示例2: discoverEndomorphisms
import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static void discoverEndomorphisms(X9ECParameters x9)
{
if (x9 == null)
{
throw new NullPointerException("x9");
}
ECCurve c = x9.getCurve();
if (ECAlgorithms.isFpCurve(c))
{
BigInteger characteristic = c.getField().getCharacteristic();
if (c.getA().isZero() && characteristic.mod(ECConstants.THREE).equals(ECConstants.ONE))
{
System.out.println("Curve has a 'GLV Type B' endomorphism with these parameters:");
printGLVTypeBParameters(x9);
}
}
}
示例3: discoverEndomorphism
import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
private static void discoverEndomorphism(String curveName)
{
X9ECParameters x9 = ECNamedCurveTable.getByName(curveName);
if (x9 == null)
{
System.err.println("Unknown curve: " + curveName);
return;
}
ECCurve c = x9.getCurve();
if (ECAlgorithms.isFpCurve(c))
{
BigInteger characteristic = c.getField().getCharacteristic();
if (c.getA().isZero() && characteristic.mod(ECConstants.THREE).equals(ECConstants.ONE))
{
System.out.println("Curve '" + curveName + "' has a 'GLV Type B' endomorphism with these parameters: ");
printGLVTypeBParameters(x9);
}
}
}
示例4: setFieldIdentifier
import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
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");
}
}
示例5: X9ECParameters
import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public X9ECParameters(
ECCurve curve,
X9ECPoint g,
BigInteger n,
BigInteger h,
byte[] seed)
{
this.curve = curve;
this.g = g;
this.n = n;
this.h = h;
this.seed = seed;
if (ECAlgorithms.isFpCurve(curve))
{
this.fieldID = new X9FieldID(curve.getField().getCharacteristic());
}
else if (ECAlgorithms.isF2mCurve(curve))
{
PolynomialExtensionField field = (PolynomialExtensionField)curve.getField();
int[] exponents = field.getMinimalPolynomial().getExponentsPresent();
if (exponents.length == 3)
{
this.fieldID = new X9FieldID(exponents[2], exponents[1]);
}
else if (exponents.length == 5)
{
this.fieldID = new X9FieldID(exponents[4], exponents[1], exponents[2], exponents[3]);
}
else
{
throw new IllegalArgumentException("Only trinomial and pentomial curves are supported");
}
}
else
{
throw new IllegalArgumentException("'curve' is of an unsupported type");
}
}
示例6: X9ECParameters
import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public X9ECParameters(
ECCurve curve,
ECPoint g,
BigInteger n,
BigInteger h,
byte[] seed)
{
this.curve = curve;
this.g = g.normalize();
this.n = n;
this.h = h;
this.seed = seed;
if (ECAlgorithms.isFpCurve(curve))
{
this.fieldID = new X9FieldID(curve.getField().getCharacteristic());
}
else if (ECAlgorithms.isF2mCurve(curve))
{
PolynomialExtensionField field = (PolynomialExtensionField)curve.getField();
int[] exponents = field.getMinimalPolynomial().getExponentsPresent();
if (exponents.length == 3)
{
this.fieldID = new X9FieldID(exponents[2], exponents[1]);
}
else if (exponents.length == 5)
{
this.fieldID = new X9FieldID(exponents[4], exponents[1], exponents[2], exponents[3]);
}
else
{
throw new IllegalArgumentException("Only trinomial and pentomial curves are supported");
}
}
else
{
throw new IllegalArgumentException("'curve' is of an unsupported type");
}
}
示例7: deserializeECPoint
import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static ECPoint deserializeECPoint(short[] ecPointFormats, ECCurve curve, byte[] encoding) throws IOException
{
if (encoding == null || encoding.length < 1)
{
throw new TlsFatalAlert(AlertDescription.illegal_parameter);
}
short actualFormat;
switch (encoding[0])
{
case 0x02: // compressed
case 0x03: // compressed
{
if (ECAlgorithms.isF2mCurve(curve))
{
actualFormat = ECPointFormat.ansiX962_compressed_char2;
}
else if (ECAlgorithms.isFpCurve(curve))
{
actualFormat = ECPointFormat.ansiX962_compressed_prime;
}
else
{
throw new TlsFatalAlert(AlertDescription.illegal_parameter);
}
break;
}
case 0x04: // uncompressed
{
actualFormat = ECPointFormat.uncompressed;
break;
}
case 0x00: // infinity
case 0x06: // hybrid
case 0x07: // hybrid
default:
throw new TlsFatalAlert(AlertDescription.illegal_parameter);
}
if (actualFormat != ECPointFormat.uncompressed
&& (ecPointFormats == null || !Arrays.contains(ecPointFormats, actualFormat)))
{
throw new TlsFatalAlert(AlertDescription.illegal_parameter);
}
return curve.decodePoint(encoding);
}
示例8: writeExplicitECParameters
import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static void writeExplicitECParameters(short[] ecPointFormats, ECDomainParameters ecParameters,
OutputStream output) throws IOException
{
ECCurve curve = ecParameters.getCurve();
if (ECAlgorithms.isFpCurve(curve))
{
TlsUtils.writeUint8(ECCurveType.explicit_prime, output);
writeECParameter(curve.getField().getCharacteristic(), output);
}
else if (ECAlgorithms.isF2mCurve(curve))
{
PolynomialExtensionField field = (PolynomialExtensionField)curve.getField();
int[] exponents = field.getMinimalPolynomial().getExponentsPresent();
TlsUtils.writeUint8(ECCurveType.explicit_char2, output);
int m = exponents[exponents.length - 1];
TlsUtils.checkUint16(m);
TlsUtils.writeUint16(m, output);
if (exponents.length == 3)
{
TlsUtils.writeUint8(ECBasisType.ec_basis_trinomial, output);
writeECExponent(exponents[1], output);
}
else if (exponents.length == 5)
{
TlsUtils.writeUint8(ECBasisType.ec_basis_pentanomial, output);
writeECExponent(exponents[1], output);
writeECExponent(exponents[2], output);
writeECExponent(exponents[3], output);
}
else
{
throw new IllegalArgumentException("Only trinomial and pentomial curves are supported");
}
}
else
{
throw new IllegalArgumentException("'ecParameters' not a known curve type");
}
writeECFieldElement(curve.getA(), output);
writeECFieldElement(curve.getB(), output);
TlsUtils.writeOpaque8(serializeECPoint(ecPointFormats, ecParameters.getG()), output);
writeECParameter(ecParameters.getN(), output);
writeECParameter(ecParameters.getH(), output);
}