java.security.spec.EllipticCurve.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中java.security.spec.EllipticCurve.<init>()方法的一些代码示例,展示了EllipticCurve.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EllipticCurve.<init>()方法的具体详情如下:
包路径:java.security.spec.EllipticCurve
类名称:EllipticCurve
方法名:<init>

EllipticCurve.<init>介绍

[英]Creates a new EllipticCurve with the specified field and coefficients.
[中]使用指定的字段和系数创建新的椭圆曲线。

代码示例

代码示例来源:origin: SeanDragon/protools

EllipticCurve ellipticCurve = new EllipticCurve(ecFieldFp, a, b);

代码示例来源:origin: i2p/i2p.i2p

public ECParameterSpec genSpec() {
    BigInteger pb = new NativeBigInteger(ps);
    BigInteger nb = new NativeBigInteger(ns);
    BigInteger sb = new NativeBigInteger(ss.replace(" ", ""), 16);
    BigInteger bb = new NativeBigInteger(bs.replace(" ", ""), 16);
    BigInteger gxb = new NativeBigInteger(gxs.replace(" ", ""), 16);
    BigInteger gyb = new NativeBigInteger(gys.replace(" ", ""), 16);
    BigInteger ab = new NativeBigInteger(A.mod(pb));
    ECField field = new ECFieldFp(pb);
    EllipticCurve curve = new EllipticCurve(field, ab, bb, sb.toByteArray());
    ECPoint g = new ECPoint(gxb, gyb);
    return new ECParameterSpec(curve, g, nb, H);
  }
}

代码示例来源:origin: jenkinsci/trilead-ssh2

public ECDSASha2Nistp521() {
  super("SHA512withECDSA", "nistp521",
      new ECParameterSpec(
        new EllipticCurve(
          new ECFieldFp(new BigInteger("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 16)),
          new BigInteger("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC", 16),
          new BigInteger("0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00", 16)
        ),
        new ECPoint(
          new BigInteger("00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66", 16),
          new BigInteger("011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650", 16)
        ),
        new BigInteger("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409", 16),
      1)
  );
}

代码示例来源:origin: jenkinsci/trilead-ssh2

public ECDSASha2Nistp384() {
  super("SHA384withECDSA", "nistp384",
      new ECParameterSpec(
        new EllipticCurve(
          new ECFieldFp(new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF", 16)),
          new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC", 16),
          new BigInteger("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF", 16)
        ),
        new ECPoint(
          new BigInteger("AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7", 16),
          new BigInteger("3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F", 16)
        ),
        new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973", 16),
      1)
  );
}

代码示例来源:origin: com.google.crypto.tink/tink

private static ECParameterSpec getNistCurveSpec(
  String decimalP, String decimalN, String hexB, String hexGX, String hexGY) {
 final BigInteger p = new BigInteger(decimalP);
 final BigInteger n = new BigInteger(decimalN);
 final BigInteger three = new BigInteger("3");
 final BigInteger a = p.subtract(three);
 final BigInteger b = new BigInteger(hexB, 16);
 final BigInteger gx = new BigInteger(hexGX, 16);
 final BigInteger gy = new BigInteger(hexGY, 16);
 final int h = 1;
 ECFieldFp fp = new ECFieldFp(p);
 java.security.spec.EllipticCurve curveSpec = new java.security.spec.EllipticCurve(fp, a, b);
 ECPoint g = new ECPoint(gx, gy);
 ECParameterSpec ecSpec = new ECParameterSpec(curveSpec, g, n, h);
 return ecSpec;
}

代码示例来源:origin: jenkinsci/trilead-ssh2

public ECDSASha2Nistp256() {
  super("SHA256withECDSA", "nistp256",
      new ECParameterSpec(
        new EllipticCurve(
          new ECFieldFp(new BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)),
          new BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", 16),
          new BigInteger("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16)
        ),
        new ECPoint(
          new BigInteger("6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", 16),
          new BigInteger("4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", 16)
        ),
        new BigInteger("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", 16),
      1)
  );
}

代码示例来源:origin: dnsjava/dnsjava

ECKeyInfo(int length, String p_str, String a_str, String b_str,
     String gx_str, String gy_str, String n_str)
  {
    this.length = length;
    p = new BigInteger(p_str, 16);
    a = new BigInteger(a_str, 16);
    b = new BigInteger(b_str, 16);
    gx = new BigInteger(gx_str, 16);
    gy = new BigInteger(gy_str, 16);
    n = new BigInteger(n_str, 16);
    curve = new EllipticCurve(new ECFieldFp(p), a, b);
    spec = new ECParameterSpec(curve, new ECPoint(gx, gy), n, 1);
  }
}

代码示例来源:origin: tiandawu/IotXmpp

ECKeyInfo(int length, String p_str, String a_str, String b_str,
     String gx_str, String gy_str, String n_str)
  {
    this.length = length;
    p = new BigInteger(p_str, 16);
    a = new BigInteger(a_str, 16);
    b = new BigInteger(b_str, 16);
    gx = new BigInteger(gx_str, 16);
    gy = new BigInteger(gy_str, 16);
    n = new BigInteger(n_str, 16);
    curve = new EllipticCurve(new ECFieldFp(p), a, b);
    spec = new ECParameterSpec(curve, new ECPoint(gx, gy), n, 1);
  }
}

代码示例来源:origin: org.apache.santuario/xmlsec

private static Curve initializeCurve(String name, String oid,
    String sfield, String a, String b,
    String x, String y, String n, int h) {
  BigInteger p = bigInt(sfield);
  ECField field = new ECFieldFp(p);
  EllipticCurve curve = new EllipticCurve(field, bigInt(a),
                      bigInt(b));
  ECPoint g = new ECPoint(bigInt(x), bigInt(y));
  return new Curve(name, oid, curve, g, bigInt(n), h);
}

代码示例来源:origin: ibinti/bugvm

public ECParameterSpec getECParameterSpec() {
    final String curveName = NativeCrypto.EC_GROUP_get_curve_name(groupCtx);

    final byte[][] curveParams = NativeCrypto.EC_GROUP_get_curve(groupCtx);
    final BigInteger p = new BigInteger(curveParams[0]);
    final BigInteger a = new BigInteger(curveParams[1]);
    final BigInteger b = new BigInteger(curveParams[2]);

    final ECField field;
    final int type = NativeCrypto.get_EC_GROUP_type(groupCtx);
    if (type == NativeCrypto.EC_CURVE_GFP) {
      field = new ECFieldFp(p);
    } else if (type == NativeCrypto.EC_CURVE_GF2M) {
      field = new ECFieldF2m(p.bitLength() - 1, p);
    } else {
      throw new RuntimeException("unknown curve type " + type);
    }

    final EllipticCurve curve = new EllipticCurve(field, a, b);

    final OpenSSLECPointContext generatorCtx = new OpenSSLECPointContext(this,
        NativeCrypto.EC_GROUP_get_generator(groupCtx));
    final ECPoint generator = generatorCtx.getECPoint();

    final BigInteger order = new BigInteger(NativeCrypto.EC_GROUP_get_order(groupCtx));
    final BigInteger cofactor = new BigInteger(NativeCrypto.EC_GROUP_get_cofactor(groupCtx));

    return new ECParameterSpec(curve, generator, order, cofactor.intValue(), curveName);
  }
}

代码示例来源:origin: org.conscrypt/conscrypt-openjdk-uber

ECParameterSpec getECParameterSpec() {
    final String curveName = NativeCrypto.EC_GROUP_get_curve_name(groupCtx);

    final byte[][] curveParams = NativeCrypto.EC_GROUP_get_curve(groupCtx);
    final BigInteger p = new BigInteger(curveParams[0]);
    final BigInteger a = new BigInteger(curveParams[1]);
    final BigInteger b = new BigInteger(curveParams[2]);

    final ECField field = new ECFieldFp(p);

    final EllipticCurve curve = new EllipticCurve(field, a, b);

    final OpenSSLECPointContext generatorCtx = new OpenSSLECPointContext(this,
        new NativeRef.EC_POINT(NativeCrypto.EC_GROUP_get_generator(groupCtx)));
    final ECPoint generator = generatorCtx.getECPoint();

    final BigInteger order = new BigInteger(NativeCrypto.EC_GROUP_get_order(groupCtx));
    final BigInteger cofactor = new BigInteger(NativeCrypto.EC_GROUP_get_cofactor(groupCtx));

    ECParameterSpec spec = new ECParameterSpec(curve, generator, order, cofactor.intValue());
    Platform.setCurveName(spec, curveName);
    return spec;
  }
}

代码示例来源:origin: org.conscrypt/conscrypt-openjdk

ECParameterSpec getECParameterSpec() {
    final String curveName = NativeCrypto.EC_GROUP_get_curve_name(groupCtx);

    final byte[][] curveParams = NativeCrypto.EC_GROUP_get_curve(groupCtx);
    final BigInteger p = new BigInteger(curveParams[0]);
    final BigInteger a = new BigInteger(curveParams[1]);
    final BigInteger b = new BigInteger(curveParams[2]);

    final ECField field = new ECFieldFp(p);

    final EllipticCurve curve = new EllipticCurve(field, a, b);

    final OpenSSLECPointContext generatorCtx = new OpenSSLECPointContext(this,
        new NativeRef.EC_POINT(NativeCrypto.EC_GROUP_get_generator(groupCtx)));
    final ECPoint generator = generatorCtx.getECPoint();

    final BigInteger order = new BigInteger(NativeCrypto.EC_GROUP_get_order(groupCtx));
    final BigInteger cofactor = new BigInteger(NativeCrypto.EC_GROUP_get_cofactor(groupCtx));

    ECParameterSpec spec = new ECParameterSpec(curve, generator, order, cofactor.intValue());
    Platform.setCurveName(spec, curveName);
    return spec;
  }
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

private static EllipticCurve convertCurve(
  ECCurve  curve,
  byte[]   seed)
{
  ECField field = convertField(curve.getField());
  BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
  return new EllipticCurve(field, a, b, seed);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

public static EllipticCurve convertCurve(
  ECCurve curve, 
  byte[]  seed)
{
  ECField field = convertField(curve.getField());
  BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
  // TODO: the Sun EC implementation doesn't currently handle the seed properly
  // so at the moment it's set to null. Should probably look at making this configurable
  return new EllipticCurve(field, a, b, null);
}

代码示例来源:origin: com.madgag.spongycastle/pkix

private static EllipticCurve convertCurve(
  ECCurve curve)
{
  ECField field = convertField(curve.getField());
  BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
  // TODO: the Sun EC implementation doesn't currently handle the seed properly
  // so at the moment it's set to null. Should probably look at making this configurable
  return new EllipticCurve(field, a, b, null);
}

代码示例来源:origin: com.madgag.spongycastle/prov

public static EllipticCurve convertCurve(
  ECCurve curve, 
  byte[]  seed)
{
  ECField field = convertField(curve.getField());
  BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
  // TODO: the Sun EC implementation doesn't currently handle the seed properly
  // so at the moment it's set to null. Should probably look at making this configurable
  return new EllipticCurve(field, a, b, null);
}

代码示例来源:origin: com.madgag.spongycastle/prov

private static EllipticCurve convertCurve(
  ECCurve  curve,
  byte[]   seed)
{
  ECField field = convertField(curve.getField());
  BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
  return new EllipticCurve(field, a, b, seed);
}

代码示例来源:origin: com.madgag.spongycastle/bcpkix-jdk15on

private static EllipticCurve convertCurve(
  ECCurve curve)
{
  ECField field = convertField(curve.getField());
  BigInteger a = curve.getA().toBigInteger(), b = curve.getB().toBigInteger();
  // TODO: the Sun EC implementation doesn't currently handle the seed properly
  // so at the moment it's set to null. Should probably look at making this configurable
  return new EllipticCurve(field, a, b, null);
}

代码示例来源:origin: es.gob.afirma.jmulticard/jmulticard

private static ECParameterSpec mapNonceGMWithECDH(final BigInteger nonceS,
                         final ECPoint sharedSecretPointH,
                         final ECParameterSpec params) {
  // D~ = (p, a, b, G~, n, h) where G~ = [s]G + H
  final ECPoint generator = params.getGenerator();
  final EllipticCurve curve = params.getCurve();
  final BigInteger a = curve.getA();
  final BigInteger b = curve.getB();
  final ECFieldFp field = (ECFieldFp)curve.getField();
  final BigInteger p = field.getP();
  final BigInteger order = params.getOrder();
  final int cofactor = params.getCofactor();
  final ECPoint ephemeralGenerator = add(multiply(nonceS, generator, params), sharedSecretPointH, params);
  if (!toSpongyCastleECPoint(ephemeralGenerator, params).isValid()) {
    LOGGER.warning("Se ha generado un punto invalido"); //$NON-NLS-1$
  }
  return new ECParameterSpec(new EllipticCurve(new ECFieldFp(p), a, b), ephemeralGenerator, order, cofactor);
}

代码示例来源:origin: ibinti/bugvm

private static EllipticCurve convertCurve(
  ECCurve  curve,
  byte[]   seed)
{
  if (curve instanceof ECCurve.Fp)
  {
    return new EllipticCurve(new ECFieldFp(((ECCurve.Fp)curve).getQ()), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
  }
  else
  {
    ECCurve.F2m curveF2m = (ECCurve.F2m)curve;
    int ks[];
    
    if (curveF2m.isTrinomial())
    {
      ks = new int[] { curveF2m.getK1() };
      
      return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
    }
    else
    {
      ks = new int[] { curveF2m.getK3(), curveF2m.getK2(), curveF2m.getK1() };
      return new EllipticCurve(new ECFieldF2m(curveF2m.getM(), ks), curve.getA().toBigInteger(), curve.getB().toBigInteger(), seed);
    } 
  }
}

相关文章