当前位置: 首页>>代码示例>>Java>>正文


Java EllipticCurve类代码示例

本文整理汇总了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());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:EC5Util.java

示例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");
    }
}
 
开发者ID:tsenger,项目名称:animamea,代码行数:20,代码来源:ECDSA5Test.java

示例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());
    }
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:21,代码来源:EllipticCurveParameters.java

示例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;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:JCEECPrivateKey.java

示例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;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:JCEECPublicKey.java

示例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!!!");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:JcaPublicKeyConverter.java

示例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;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:BCDSTU4145PrivateKey.java

示例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;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:BCDSTU4145PublicKey.java

示例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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:BCECPrivateKey.java

示例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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:BCECPublicKey.java

示例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); 
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:EC5Util.java

示例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;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:BCECGOST3410PrivateKey.java

示例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;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:BCECGOST3410PublicKey.java

示例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);
}
 
开发者ID:wolfSSL,项目名称:wolfcrypt-jni,代码行数:26,代码来源:Ecc.java

示例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));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:DOMKeyValue.java


注:本文中的java.security.spec.EllipticCurve类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。