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


Java X962Parameters类代码示例

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


X962Parameters类属于org.bouncycastle.asn1.x9包,在下文中一共展示了X962Parameters类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: populateFromPubKeyInfo

import org.bouncycastle.asn1.x9.X962Parameters; //导入依赖的package包/类
private void populateFromPubKeyInfo(SubjectPublicKeyInfo info)
{
    X962Parameters params = new X962Parameters((ASN1Primitive)info.getAlgorithm().getParameters());
    ECCurve curve = EC5Util.getCurve(configuration, params);
    ecSpec = EC5Util.convertToSpec(params, curve);

    DERBitString    bits = info.getPublicKeyData();
    byte[]          data = bits.getBytes();
    ASN1OctetString key = new DEROctetString(data);

    //
    // extra octet string - one of our old certs...
    //
    if (data[0] == 0x04 && data[1] == data.length - 2
        && (data[2] == 0x02 || data[2] == 0x03))
    {
        int qLength = new X9IntegerConverter().getByteLength(curve);

        if (qLength >= data.length - 3)
        {
            try
            {
                key = (ASN1OctetString) ASN1Primitive.fromByteArray(data);
            }
            catch (IOException ex)
            {
                throw new IllegalArgumentException("error recovering public key");
            }
        }
    }

    X9ECPoint derQ = new X9ECPoint(curve, key);

    this.q = derQ.getPoint();
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:36,代码来源:BCECPublicKey.java

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