FileDocCategorySizeDatePackage
PrivateKeyInfo.javaAPI DocAzureus 3.0.3.42826Tue Jun 08 05:12:58 BST 2004org.bouncycastle.asn1.pkcs

PrivateKeyInfo

public class PrivateKeyInfo extends Object implements org.bouncycastle.asn1.DEREncodable, PKCSObjectIdentifiers

Fields Summary
private org.bouncycastle.asn1.DERObject
privKey
private org.bouncycastle.asn1.x509.AlgorithmIdentifier
algId
Constructors Summary
public PrivateKeyInfo(org.bouncycastle.asn1.x509.AlgorithmIdentifier algId, org.bouncycastle.asn1.DERObject privateKey)

        this.privKey = privateKey;
        this.algId = algId;
    
public PrivateKeyInfo(org.bouncycastle.asn1.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");
        }
    
Methods Summary
public org.bouncycastle.asn1.x509.AlgorithmIdentifiergetAlgorithmId()

        return algId;
    
public org.bouncycastle.asn1.DERObjectgetDERObject()
write out an RSA private key with it's asscociated information as described in PKCS8.
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

        ASN1EncodableVector v = new ASN1EncodableVector();

        v.add(new DERInteger(0));
        v.add(algId);
        v.add(new DEROctetString(privKey));

        return new DERSequence(v);
    
public org.bouncycastle.asn1.DERObjectgetPrivateKey()

        return privKey;