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


Java SECNamedCurves类代码示例

本文整理汇总了Java中org.bouncycastle.asn1.sec.SECNamedCurves的典型用法代码示例。如果您正苦于以下问题:Java SECNamedCurves类的具体用法?Java SECNamedCurves怎么用?Java SECNamedCurves使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SECNamedCurves类属于org.bouncycastle.asn1.sec包,在下文中一共展示了SECNamedCurves类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getParametersForNamedCurve

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
public static ECDomainParameters getParametersForNamedCurve(int namedCurve)
{
    String curveName = getNameOfNamedCurve(namedCurve);
    if (curveName == null)
    {
        return null;
    }

    // Lazily created the first time a particular curve is accessed
    X9ECParameters ecP = SECNamedCurves.getByName(curveName);

    if (ecP == null)
    {
        return null;
    }

    // It's a bit inefficient to do this conversion every time
    return new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:TlsECCUtils.java

示例2: getByName

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
/**
 * return a X9ECParameters object representing the passed in named
 * curve. The routine returns null if the curve is not present.
 *
 * @param name the name of the curve requested
 * @return an X9ECParameters object or null if the curve is not available.
 */
public static X9ECParameters getByName(
    String name)
{
    X9ECParameters ecP = X962NamedCurves.getByName(name);

    if (ecP == null)
    {
        ecP = SECNamedCurves.getByName(name);
    }

    if (ecP == null)
    {
        ecP = TeleTrusTNamedCurves.getByName(name);
    }

    if (ecP == null)
    {
        ecP = NISTNamedCurves.getByName(name);
    }

    return ecP;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:ECNamedCurveTable.java

示例3: getByOID

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
/**
 * return a X9ECParameters object representing the passed in named
 * curve.
 *
 * @param oid the object id of the curve requested
 * @return an X9ECParameters object or null if the curve is not available.
 */
public static X9ECParameters getByOID(
    ASN1ObjectIdentifier oid)
{
    X9ECParameters ecP = X962NamedCurves.getByOID(oid);

    if (ecP == null)
    {
        ecP = SECNamedCurves.getByOID(oid);
    }

    if (ecP == null)
    {
        ecP = TeleTrusTNamedCurves.getByOID(oid);
    }

    return ecP;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:ECNamedCurveTable.java

示例4: getNamedCurveOid

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
public static ASN1ObjectIdentifier getNamedCurveOid(
    String name)
{
    ASN1ObjectIdentifier oid = X962NamedCurves.getOID(name);
    
    if (oid == null)
    {
        oid = SECNamedCurves.getOID(name);
        if (oid == null)
        {
            oid = NISTNamedCurves.getOID(name);
        }
        if (oid == null)
        {
            oid = TeleTrusTNamedCurves.getOID(name);
        }
        if (oid == null)
        {
            oid = ECGOST3410NamedCurves.getOID(name);
        }
    }

    return oid;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:ECUtil.java

示例5: getNamedCurveByOid

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
public static X9ECParameters getNamedCurveByOid(
    ASN1ObjectIdentifier oid)
{
    X9ECParameters params = X962NamedCurves.getByOID(oid);
    
    if (params == null)
    {
        params = SECNamedCurves.getByOID(oid);
        if (params == null)
        {
            params = NISTNamedCurves.getByOID(oid);
        }
        if (params == null)
        {
            params = TeleTrusTNamedCurves.getByOID(oid);
        }
    }

    return params;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:ECUtil.java

示例6: getCurveName

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
public static String getCurveName(
    ASN1ObjectIdentifier oid)
{
    String name = X962NamedCurves.getName(oid);
    
    if (name == null)
    {
        name = SECNamedCurves.getName(oid);
        if (name == null)
        {
            name = NISTNamedCurves.getName(oid);
        }
        if (name == null)
        {
            name = TeleTrusTNamedCurves.getName(oid);
        }
        if (name == null)
        {
            name = ECGOST3410NamedCurves.getName(oid);
        }
    }

    return name;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:ECUtil.java

示例7: getByOID

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
/**
 * return a X9ECParameters object representing the passed in named
 * curve.
 *
 * @param oid the object id of the curve requested
 * @return an X9ECParameters object or null if the curve is not available.
 */
public static X9ECParameters getByOID(
    ASN1ObjectIdentifier oid)
{
    X9ECParameters ecP = X962NamedCurves.getByOID(oid);

    if (ecP == null)
    {
        ecP = SECNamedCurves.getByOID(oid);
    }

    // NOTE: All the NIST curves are currently from SEC, so no point in redundant OID lookup

    if (ecP == null)
    {
        ecP = TeleTrusTNamedCurves.getByOID(oid);
    }

    if (ecP == null)
    {
        ecP = ANSSINamedCurves.getByOID(oid);
    }

    return ecP;
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:32,代码来源:ECNamedCurveTable.java

示例8: ECDSAgeneratePublicAndPrivateKey

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
/*************
 * This method will create the ECDSA public and private key which is returned in a Byte array of Byte arrays, index 0 is the private key and
 * index 1 of the array will return the ECDSA public key
 * 
 * -Wisdom: This guy didn't check whether the returned Private Key would be more than 32.
 * @return
 
 */
private byte[][] ECDSAgeneratePublicAndPrivateKey(){
       int length = 0;
       byte[][] keys;
       
    do{
        
	ECKeyPairGenerator gen = new ECKeyPairGenerator();
	SecureRandom secureRandom = new SecureRandom();
        X9ECParameters secnamecurves = SECNamedCurves.getByName("secp256k1");
	ECDomainParameters ecParams = new ECDomainParameters(secnamecurves.getCurve(), secnamecurves.getG(), secnamecurves.getN(), secnamecurves.getH());
	ECKeyGenerationParameters keyGenParam = new ECKeyGenerationParameters(ecParams, secureRandom);
	gen.init(keyGenParam);
	AsymmetricCipherKeyPair kp = gen.generateKeyPair();
	ECPrivateKeyParameters privatekey = (ECPrivateKeyParameters)kp.getPrivate();
	ECPoint dd = secnamecurves.getG().multiply(privatekey.getD());
	byte[] publickey=new byte[65];
	System.arraycopy(dd.getY().toBigInteger().toByteArray(), 0, publickey, 64-dd.getY().toBigInteger().toByteArray().length+1, dd.getY().toBigInteger().toByteArray().length);
	System.arraycopy(dd.getX().toBigInteger().toByteArray(), 0, publickey, 32-dd.getX().toBigInteger().toByteArray().length+1, dd.getX().toBigInteger().toByteArray().length);
	publickey[0]=4;
        length = privatekey.getD().toByteArray().length;
        keys = new byte[][]{privatekey.getD().toByteArray(),publickey};
        
    }while(length != 32);
	return keys;
}
 
开发者ID:wisdomcsharp,项目名称:SSI_Bitcoin-Storage,代码行数:34,代码来源:Address.java

示例9: getNamedCurveByOid

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
public static X9ECParameters getNamedCurveByOid(
    ASN1ObjectIdentifier oid)
{
    X9ECParameters params = CustomNamedCurves.getByOID(oid);

    if (params == null)
    {
        params = X962NamedCurves.getByOID(oid);
        if (params == null)
        {
            params = SECNamedCurves.getByOID(oid);
        }
        if (params == null)
        {
            params = NISTNamedCurves.getByOID(oid);
        }
        if (params == null)
        {
            params = TeleTrusTNamedCurves.getByOID(oid);
        }
    }

    return params;
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:25,代码来源:ECUtil.java

示例10: getNamedCurveByName

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
public static X9ECParameters getNamedCurveByName(
    String curveName)
{
    X9ECParameters params = CustomNamedCurves.getByName(curveName);

    if (params == null)
    {
        params = X962NamedCurves.getByName(curveName);
        if (params == null)
        {
            params = SECNamedCurves.getByName(curveName);
        }
        if (params == null)
        {
            params = NISTNamedCurves.getByName(curveName);
        }
        if (params == null)
        {
            params = TeleTrusTNamedCurves.getByName(curveName);
        }
    }

    return params;
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:25,代码来源:ECUtil.java

示例11: verifyUsingSecp256k1

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
public static boolean verifyUsingSecp256k1(byte[] pub, byte[] dataForSigning,
		BigInteger[] rs) throws Exception {
	ECDSASigner signer = new ECDSASigner();
	X9ECParameters params = SECNamedCurves.getByName("secp256k1");
	ECDomainParameters ecParams = new ECDomainParameters(params.getCurve(),
			params.getG(), params.getN(), params.getH());
	ECPublicKeyParameters pubKeyParams = new ECPublicKeyParameters(ecParams
			.getCurve().decodePoint(pub), ecParams);
	signer.init(false, pubKeyParams);

	return signer.verifySignature(dataForSigning, rs[0].abs(), rs[1].abs());
}
 
开发者ID:eBay,项目名称:UAF,代码行数:13,代码来源:NamedCurve.java

示例12: getOID

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
/**
 * return the object identifier signified by the passed in name. Null
 * if there is no object identifier associated with name.
 *
 * @return the object identifier associated with name, if present.
 */
public static ASN1ObjectIdentifier getOID(
    String name)
{
    ASN1ObjectIdentifier oid = X962NamedCurves.getOID(name);

    if (oid == null)
    {
        oid = SECNamedCurves.getOID(name);
    }

    if (oid == null)
    {
        oid = TeleTrusTNamedCurves.getOID(name);
    }

    if (oid == null)
    {
        oid = NISTNamedCurves.getOID(name);
    }

    return oid;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:29,代码来源:ECNamedCurveTable.java

示例13: getByOID

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
/**
 * return a X9ECParameters object representing the passed in named
 * curve.
 *
 * @param oid the object id of the curve requested
 * @return an X9ECParameters object or null if the curve is not available.
 */
public static X9ECParameters getByOID(
    ASN1ObjectIdentifier oid)
{
    X9ECParameters ecP = X962NamedCurves.getByOID(oid);

    if (ecP == null)
    {
        ecP = SECNamedCurves.getByOID(oid);
    }

    if (ecP == null)
    {
        ecP = TeleTrusTNamedCurves.getByOID(oid);
    }

    // NOTE: All the NIST curves are currently from SEC, so no point in redundant OID lookup

    return ecP;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:27,代码来源:ECNamedCurveTable.java

示例14: decodePublicKey

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
/**
 * 
 * @param encodedPublicKey This is the (uncompressed) x,y-representation of a curve point on the P-256 NIST elliptic curve.
 * @return
 */
public static PublicKey decodePublicKey(byte[] encodedPublicKey) {
	PublicKey result = null;
	
	try {
		
		X9ECParameters curve = SECNamedCurves.getByName("secp256r1");
		ECPoint point = curve.getCurve().decodePoint(encodedPublicKey);
		
		result = KeyFactory.getInstance("ECDSA",new BouncyCastleProvider()).generatePublic(new ECPublicKeySpec(point, new ECParameterSpec(curve.getCurve(), curve.getG(), curve.getN(), curve.getH())));
		
	} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
			e.printStackTrace();
	}
	
	return result;
}
 
开发者ID:arietimmerman,项目名称:OpenAM-U2F,代码行数:22,代码来源:CryptoHelper.java

示例15: testEncoding

import org.bouncycastle.asn1.sec.SECNamedCurves; //导入依赖的package包/类
@Test
public void testEncoding()
    throws IOException
{
    X9ECParameters params = SECNamedCurves.getByName("secp256r1");
    ECDomainParameters domainParams = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH(), params.getSeed());

    ECPoint[]   factors = new ECPoint[] { domainParams.getCurve().decodePoint(cf1_1), domainParams.getCurve().decodePoint(cf1_2) };
    ECPoint[]   qFactors = new ECPoint[] { domainParams.getCurve().decodePoint(cf2_2), domainParams.getCurve().decodePoint(cf2_1) };

    ECCommittedSecretShareMessage msg1 = new ECCommittedSecretShareMessage(0, v1, w1, factors, domainParams.getCurve().decodePoint(cf1_1), qFactors);

    ECCommittedSecretShareMessage msg2 = ECCommittedSecretShareMessage.getInstance(domainParams.getCurve(), msg1.getEncoded());

    Assert.assertEquals(v1, msg2.getValue());
    Assert.assertEquals(w1, msg2.getWitness());
    Assert.assertEquals(factors[0], msg2.getCommitmentFactors()[0]);
    Assert.assertEquals(factors[1], msg2.getCommitmentFactors()[1]);
    Assert.assertEquals(factors[0], msg2.getQ());
    Assert.assertEquals(qFactors[0], msg2.getQCommitmentFactors()[0]);
    Assert.assertEquals(qFactors[1], msg2.getQCommitmentFactors()[1]);
}
 
开发者ID:cwgit,项目名称:ximix,代码行数:23,代码来源:ECCommittedSecretShareMessageTest.java


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