⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 privatekeyinfo.java

📁 说明: 1、里面有什么: 1.1、org.bouncycastle.*下的所有软件是bouncycastle组织开发的软件包 1.2、org.infosecurity.*下的软件包括
💻 JAVA
字号:
package org.bouncycastle.asn1.pkcs;import java.io.*;import java.util.Enumeration;import java.math.BigInteger;import org.bouncycastle.asn1.*;import org.bouncycastle.asn1.x509.AlgorithmIdentifier;public class PrivateKeyInfo    implements PKCSObjectIdentifiers, DEREncodable{    private DERObject               privKey;    private AlgorithmIdentifier     algId;    public PrivateKeyInfo(        AlgorithmIdentifier algId,        DERObject           privateKey)    {        this.privKey = privateKey;        this.algId = algId;    }    public PrivateKeyInfo(        ASN1Sequence  seq)    {        Enumeration e = seq.getObjects();        BigInteger  version = ((DERInteger)e.nextElement()).getValue();        if (version.intValue() != 0)        {            throw new IllegalArgumentException("wrong version for private key info");        }        algId = new AlgorithmIdentifier((ASN1Sequence)e.nextElement());        try        {            ByteArrayInputStream    bIn = new ByteArrayInputStream(((ASN1OctetString)e.nextElement()).getOctets());            DERInputStream          dIn = new DERInputStream(bIn);            privKey = dIn.readObject();        }        catch (IOException ex)        {            throw new IllegalArgumentException("Error recoverying private key from sequence");        }    }    public AlgorithmIdentifier getAlgorithmId()    {        return algId;    }    public DERObject getPrivateKey()    {        return privKey;    }    /**     * write out an RSA private key with it's asscociated information     * as described in PKCS8.     * <pre>     *      PrivateKeyInfo ::= SEQUENCE {     *                              version Version,     *                              privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},     *                              privateKey PrivateKey,     *                              attributes [0] IMPLICIT Attributes OPTIONAL      *                          }     *      Version ::= INTEGER {v1(0)} (v1,...)     *     *      PrivateKey ::= OCTET STRING     *     *      Attributes ::= SET OF Attribute     * </pre>     */    public DERObject getDERObject()    {        ASN1EncodableVector v = new ASN1EncodableVector();        v.add(new DERInteger(0));        v.add(algId);        v.add(new DEROctetString(privKey));        return new DERSequence(v);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -