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


Java X962Parameters.getInstance方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:23,代码来源:AlgorithmParametersSpi.java

示例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();
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:24,代码来源:BCECPrivateKey.java

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


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