本文整理匯總了Java中java.security.spec.EllipticCurve類的典型用法代碼示例。如果您正苦於以下問題:Java EllipticCurve類的具體用法?Java EllipticCurve怎麽用?Java EllipticCurve使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EllipticCurve類屬於java.security.spec包,在下文中一共展示了EllipticCurve類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertSpec
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public static ECParameterSpec convertSpec(
EllipticCurve ellipticCurve,
org.bouncycastle.jce.spec.ECParameterSpec spec)
{
if (spec instanceof ECNamedCurveParameterSpec)
{
return new ECNamedCurveSpec(
((ECNamedCurveParameterSpec)spec).getName(),
ellipticCurve,
new ECPoint(
spec.getG().getX().toBigInteger(),
spec.getG().getY().toBigInteger()),
spec.getN(),
spec.getH());
}
else
{
return new ECParameterSpec(
ellipticCurve,
new ECPoint(
spec.getG().getX().toBigInteger(),
spec.getG().getY().toBigInteger()),
spec.getN(),
spec.getH().intValue());
}
}
示例2: decodeTest
import java.security.spec.EllipticCurve; //導入依賴的package包/類
private void decodeTest()
{
EllipticCurve curve = new EllipticCurve(
new ECFieldFp(new BigInteger("6277101735386680763835789423207666416083908700390324961279")), // q
new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b
ECPoint p = ECPointUtil.decodePoint(curve, Hex.decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"));
if (!p.getAffineX().equals(new BigInteger("188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", 16)))
{
fail("x uncompressed incorrectly");
}
if (!p.getAffineY().equals(new BigInteger("7192b95ffc8da78631011ed6b24cdd573f977a11e794811", 16)))
{
fail("y uncompressed incorrectly");
}
}
示例3: encodeECParameterSpec
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public static ECParameterSpec encodeECParameterSpec(EllipticCurveParameters params) {
// Field
final BigInteger pInt = new BigInteger(1, params.getP());
final ECField field = new ECFieldFp(pInt);
final BigInteger aInt = new BigInteger(1, params.getA());
final BigInteger bInt = new BigInteger(1, params.getB());
final EllipticCurve curve = new EllipticCurve(field, aInt, bInt);
// Fixed Point G
final BigInteger xInt = new BigInteger(1, params.getX());
final BigInteger yInt = new BigInteger(1, params.getY());
final ECPoint g = new ECPoint(xInt, yInt);
// Order N
final BigInteger nInt = new BigInteger(1, params.getN());
return new ECParameterSpec(curve, g, nInt, params.getH());
}
示例4: JCEECPrivateKey
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public JCEECPrivateKey(
String algorithm,
org.bouncycastle.jce.spec.ECPrivateKeySpec spec)
{
this.algorithm = algorithm;
this.d = spec.getD();
if (spec.getParams() != null) // can be null if implicitlyCA
{
ECCurve curve = spec.getParams().getCurve();
EllipticCurve ellipticCurve;
ellipticCurve = EC5Util.convertCurve(curve, spec.getParams().getSeed());
this.ecSpec = EC5Util.convertSpec(ellipticCurve, spec.getParams());
}
else
{
this.ecSpec = null;
}
}
示例5: JCEECPublicKey
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public JCEECPublicKey(
String algorithm,
org.bouncycastle.jce.spec.ECPublicKeySpec spec)
{
this.algorithm = algorithm;
this.q = spec.getQ();
if (spec.getParams() != null) // can be null if implictlyCa
{
ECCurve curve = spec.getParams().getCurve();
EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, spec.getParams().getSeed());
this.ecSpec = EC5Util.convertSpec(ellipticCurve, spec.getParams());
}
else
{
if (q.getCurve() == null)
{
org.bouncycastle.jce.spec.ECParameterSpec s = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
q = s.getCurve().createPoint(q.getX().toBigInteger(), q.getY().toBigInteger(), false);
}
this.ecSpec = null;
}
}
示例6: convertCurve
import java.security.spec.EllipticCurve; //導入依賴的package包/類
private static ECCurve convertCurve(
EllipticCurve ec)
{
ECField field = ec.getField();
BigInteger a = ec.getA();
BigInteger b = ec.getB();
if (field instanceof ECFieldFp)
{
return new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
}
else
{
throw new IllegalStateException("not implemented yet!!!");
}
}
示例7: BCDSTU4145PrivateKey
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public BCDSTU4145PrivateKey(
org.bouncycastle.jce.spec.ECPrivateKeySpec spec)
{
this.d = spec.getD();
if (spec.getParams() != null) // can be null if implicitlyCA
{
ECCurve curve = spec.getParams().getCurve();
EllipticCurve ellipticCurve;
ellipticCurve = EC5Util.convertCurve(curve, spec.getParams().getSeed());
this.ecSpec = EC5Util.convertSpec(ellipticCurve, spec.getParams());
}
else
{
this.ecSpec = null;
}
}
示例8: BCDSTU4145PublicKey
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public BCDSTU4145PublicKey(
org.bouncycastle.jce.spec.ECPublicKeySpec spec)
{
this.q = spec.getQ();
if (spec.getParams() != null) // can be null if implictlyCa
{
ECCurve curve = spec.getParams().getCurve();
EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, spec.getParams().getSeed());
this.ecSpec = EC5Util.convertSpec(ellipticCurve, spec.getParams());
}
else
{
if (q.getCurve() == null)
{
org.bouncycastle.jce.spec.ECParameterSpec s = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
q = s.getCurve().createPoint(q.getX().toBigInteger(), q.getY().toBigInteger(), false);
}
this.ecSpec = null;
}
}
示例9: BCECPrivateKey
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public BCECPrivateKey(
String algorithm,
org.bouncycastle.jce.spec.ECPrivateKeySpec spec,
ProviderConfiguration configuration)
{
this.algorithm = algorithm;
this.d = spec.getD();
if (spec.getParams() != null) // can be null if implicitlyCA
{
ECCurve curve = spec.getParams().getCurve();
EllipticCurve ellipticCurve;
ellipticCurve = EC5Util.convertCurve(curve, spec.getParams().getSeed());
this.ecSpec = EC5Util.convertSpec(ellipticCurve, spec.getParams());
}
else
{
this.ecSpec = null;
}
this.configuration = configuration;
}
示例10: BCECPublicKey
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public BCECPublicKey(
String algorithm,
ECPublicKeyParameters params,
ECParameterSpec spec,
ProviderConfiguration configuration)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.q = params.getQ();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = createSpec(ellipticCurve, dp);
}
else
{
this.ecSpec = spec;
}
this.configuration = configuration;
}
示例11: convertCurve
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public static ECCurve convertCurve(
EllipticCurve ec)
{
ECField field = ec.getField();
BigInteger a = ec.getA();
BigInteger b = ec.getB();
if (field instanceof ECFieldFp)
{
return new ECCurve.Fp(((ECFieldFp)field).getP(), a, b);
}
else
{
ECFieldF2m fieldF2m = (ECFieldF2m)field;
int m = fieldF2m.getM();
int ks[] = ECUtil.convertMidTerms(fieldF2m.getMidTermsOfReductionPolynomial());
return new ECCurve.F2m(m, ks[0], ks[1], ks[2], a, b);
}
}
示例12: BCECGOST3410PrivateKey
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public BCECGOST3410PrivateKey(
org.bouncycastle.jce.spec.ECPrivateKeySpec spec)
{
this.d = spec.getD();
if (spec.getParams() != null) // can be null if implicitlyCA
{
ECCurve curve = spec.getParams().getCurve();
EllipticCurve ellipticCurve;
ellipticCurve = EC5Util.convertCurve(curve, spec.getParams().getSeed());
this.ecSpec = EC5Util.convertSpec(ellipticCurve, spec.getParams());
}
else
{
this.ecSpec = null;
}
}
示例13: BCECGOST3410PublicKey
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public BCECGOST3410PublicKey(
org.bouncycastle.jce.spec.ECPublicKeySpec spec)
{
this.q = spec.getQ();
if (spec.getParams() != null) // can be null if implictlyCa
{
ECCurve curve = spec.getParams().getCurve();
EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, spec.getParams().getSeed());
this.ecSpec = EC5Util.convertSpec(ellipticCurve, spec.getParams());
}
else
{
if (q.getCurve() == null)
{
org.bouncycastle.jce.spec.ECParameterSpec s = BouncyCastleProvider.CONFIGURATION.getEcImplicitlyCa();
q = s.getCurve().createPoint(q.getX().toBigInteger(), q.getY().toBigInteger(), false);
}
this.ecSpec = null;
}
}
示例14: getCurveName
import java.security.spec.EllipticCurve; //導入依賴的package包/類
public static String getCurveName(ECParameterSpec spec)
throws InvalidAlgorithmParameterException
{
int curve_id;
/* Ecc object doesn't need to be initialied before call */
if (!(spec.getCurve().getField() instanceof ECFieldFp)) {
throw new InvalidAlgorithmParameterException(
"Currently only ECFieldFp fields supported");
}
ECFieldFp field = (ECFieldFp)spec.getCurve().getField();
EllipticCurve curve = spec.getCurve();
curve_id = wc_ecc_get_curve_id_from_params(
field.getFieldSize(),
field.getP().toByteArray(),
curve.getA().toByteArray(),
curve.getB().toByteArray(),
spec.getOrder().toByteArray(),
spec.getGenerator().getAffineX().toByteArray(),
spec.getGenerator().getAffineY().toByteArray(),
spec.getCofactor());
return wc_ecc_get_curve_name_from_id(curve_id);
}
示例15: decodePoint
import java.security.spec.EllipticCurve; //導入依賴的package包/類
private static ECPoint decodePoint(byte[] data, EllipticCurve curve)
throws IOException {
if ((data.length == 0) || (data[0] != 4)) {
throw new IOException("Only uncompressed point format " +
"supported");
}
// Per ANSI X9.62, an encoded point is a 1 byte type followed by
// ceiling(log base 2 field-size / 8) bytes of x and the same of y.
int n = (data.length - 1) / 2;
if (n != ((curve.getField().getFieldSize() + 7) >> 3)) {
throw new IOException("Point does not match field size");
}
byte[] xb = Arrays.copyOfRange(data, 1, 1 + n);
byte[] yb = Arrays.copyOfRange(data, n + 1, n + 1 + n);
return new ECPoint(new BigInteger(1, xb), new BigInteger(1, yb));
}