本文整理汇总了Java中org.bouncycastle.asn1.x9.X962Parameters.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java X962Parameters.getInstance方法的具体用法?Java X962Parameters.getInstance怎么用?Java X962Parameters.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x9.X962Parameters
的用法示例。
在下文中一共展示了X962Parameters.getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: engineInit
import org.bouncycastle.asn1.x9.X962Parameters; //导入方法依赖的package包/类
@Override
protected void engineInit(byte[] bytes, String format)
throws IOException
{
if (isASN1FormatString(format))
{
X962Parameters params = X962Parameters.getInstance(bytes);
ECCurve curve = EC5Util.getCurve(BouncyCastleProvider.CONFIGURATION, params);
if (params.isNamedCurve())
{
curveName = ECNamedCurveTable.getName(ASN1ObjectIdentifier.getInstance(params.getParameters()));
}
ecParameterSpec = EC5Util.convertToSpec(params, curve);
}
else
{
throw new IOException("Unknown encoded parameters format in AlgorithmParameters object: " + format);
}
}
示例2: populateFromPrivKeyInfo
import org.bouncycastle.asn1.x9.X962Parameters; //导入方法依赖的package包/类
private void populateFromPrivKeyInfo(PrivateKeyInfo info)
throws IOException
{
X962Parameters params = X962Parameters.getInstance(info.getPrivateKeyAlgorithm().getParameters());
ECCurve curve = EC5Util.getCurve(configuration, params);
ecSpec = EC5Util.convertToSpec(params, curve);
ASN1Encodable privKey = info.parsePrivateKey();
if (privKey instanceof ASN1Integer)
{
ASN1Integer derD = ASN1Integer.getInstance(privKey);
this.d = derD.getValue();
}
else
{
org.bouncycastle.asn1.sec.ECPrivateKey ec = org.bouncycastle.asn1.sec.ECPrivateKey.getInstance(privKey);
this.d = ec.getKey();
this.publicKey = ec.getPublicKey();
}
}
示例3: testKeyConversion
import org.bouncycastle.asn1.x9.X962Parameters; //导入方法依赖的package包/类
private void testKeyConversion()
throws Exception
{
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("ECDSA", "BC");
kpGen.initialize(new ECGenParameterSpec("prime192v1"));
KeyPair pair = kpGen.generateKeyPair();
PublicKey pubKey = ECKeyUtil.publicToExplicitParameters(pair.getPublic(), "BC");
SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(pubKey.getEncoded()));
X962Parameters params = X962Parameters.getInstance(info.getAlgorithmId().getParameters());
if (params.isNamedCurve() || params.isImplicitlyCA())
{
fail("public key conversion to explicit failed");
}
if (!((ECPublicKey)pair.getPublic()).getW().equals(((ECPublicKey)pubKey).getW()))
{
fail("public key conversion check failed");
}
PrivateKey privKey = ECKeyUtil.privateToExplicitParameters(pair.getPrivate(), "BC");
PrivateKeyInfo privInfo = PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(privKey.getEncoded()));
params = X962Parameters.getInstance(privInfo.getAlgorithmId().getParameters());
if (params.isNamedCurve() || params.isImplicitlyCA())
{
fail("private key conversion to explicit failed");
}
if (!((ECPrivateKey)pair.getPrivate()).getS().equals(((ECPrivateKey)privKey).getS()))
{
fail("private key conversion check failed");
}
}