本文整理汇总了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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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]);
}