本文整理汇总了Java中java.security.spec.EllipticCurve类的典型用法代码示例。如果您正苦于以下问题:Java EllipticCurve类的具体用法?Java EllipticCurve怎么用?Java EllipticCurve使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EllipticCurve类属于java.security.spec包,在下文中一共展示了EllipticCurve类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: mapNonceGMWithECDH
import java.security.spec.EllipticCurve; //导入依赖的package包/类
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 (!toBouncyCastleECPoint(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);
}
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:19,代码来源:JseCryptoHelper.java
示例17: mapNonceGMWithECDH
import java.security.spec.EllipticCurve; //导入依赖的package包/类
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);
}
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:19,代码来源:JseCryptoHelper.java
示例18: CfcaCurve
import java.security.spec.EllipticCurve; //导入依赖的package包/类
public static ECParameterSpec CfcaCurve() {
// 素数P
BigInteger p = new BigInteger("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF", 16);
// 基于素数P的有限域
ECFieldFp gfp = new ECFieldFp(p);
// 在有限域上的椭圆曲线y2 = x3 + ax + b
EllipticCurve ellipticCurve = new EllipticCurve(gfp,
new BigInteger("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC", 16),
new BigInteger("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93", 16));
// 基点G
ECPoint G = new ECPoint(new BigInteger("32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7", 16),
new BigInteger("BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0", 16));
// G的阶
BigInteger n = new BigInteger("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123", 16);
// 设置基点
ECParameterSpec ecParameterSpec = new ECParameterSpec(ellipticCurve, G, n, 1);
return ecParameterSpec;
}
开发者ID:bubicn,项目名称:bubichain-sdk-java,代码行数:24,代码来源:Sm2keyCFCA.java
示例19: getECParameterSpec
import java.security.spec.EllipticCurve; //导入依赖的package包/类
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;
}
开发者ID:google,项目名称:conscrypt,代码行数:24,代码来源:OpenSSLECGroupContext.java
示例20: 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:Legostaev,项目名称:xmlsec-gost,代码行数:19,代码来源:DOMKeyValue.java
注:本文中的java.security.spec.EllipticCurve类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论