Top Description Fields Constructors Methods
org.bouncycastle.asn1.pkcs

public Class PrivateKeyInfo

extends ASN1Object
Class Inheritance
Imports
java.io.IOException, java.util.Enumeration, org.bouncycastle.asn1.ASN1BitString, .ASN1Encodable, .ASN1EncodableVector, .ASN1Integer, .ASN1Object, .ASN1OctetString, .ASN1Primitive, .ASN1Sequence, .ASN1Set, .ASN1TaggedObject, .DERBitString, .DEROctetString, .DERSequence, .DERTaggedObject, org.bouncycastle.asn1.x509.AlgorithmIdentifier, org.bouncycastle.util.BigIntegers

RFC 5958
 [IMPLICIT TAGS]

 OneAsymmetricKey ::= SEQUENCE {
     version                   Version,
     privateKeyAlgorithm       PrivateKeyAlgorithmIdentifier,
     privateKey                PrivateKey,
     attributes            [0] Attributes OPTIONAL,
     ...,
     [[2: publicKey        [1] PublicKey OPTIONAL ]],
     ...
 }

 PrivateKeyInfo ::= OneAsymmetricKey

 Version ::= INTEGER { v1(0), v2(1) } (v1, ..., v2)

 PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
                                    { PUBLIC-KEY,
                                      { PrivateKeyAlgorithms } }

 PrivateKey ::= OCTET STRING
                    -- Content varies based on type of key.  The
                    -- algorithm identifier dictates the format of
                    -- the key.

 PublicKey ::= BIT STRING
                    -- Content varies based on type of key.  The
                    -- algorithm identifier dictates the format of
                    -- the key.

 Attributes ::= SET OF Attribute { { OneAsymmetricKeyAttributes } }
 

Field Summary

Modifier and TypeField and Description
private ASN1Set
private ASN1OctetString
private AlgorithmIdentifier
private ASN1BitString
private ASN1Integer

Constructor Summary

AccessConstructor and Description
public
PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey)

public
PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey, ASN1Set attributes)

public
PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey, ASN1Set attributes, byte[] publicKey)

private

Method Summary

Modifier and TypeMethod and Description
public ASN1Set
public static PrivateKeyInfo
getInstance(ASN1TaggedObject obj, boolean explicit)

public static PrivateKeyInfo
public ASN1OctetString
public AlgorithmIdentifier
public int
public ASN1BitString

Returns:

the public key as the raw bit string...
getPublicKeyData
()

for when the public key is raw bits.

public ASN1Integer
private static int
public boolean

Returns:

true if public included, otherwise false.
hasPublicKey
()

Return true if a public key is present, false otherwise.

public ASN1Encodable
public ASN1Encodable

Returns:

the public key as an ASN.1 primitive.
parsePublicKey
()

for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.

public ASN1Primitive
toASN1Primitive()

Implements abstract org.bouncycastle.asn1.ASN1Object.toASN1Primitive.

Implements org.bouncycastle.asn1.ASN1Encodable.toASN1Primitive.

Method providing a primitive representation of this object suitable for encoding.
Inherited from org.bouncycastle.asn1.ASN1Object:
encodeToencodeToequalsgetEncodedgetEncodedhasEncodedTagValuehashCode

Field Detail

attributesback to summary
private ASN1Set attributes
privateKeyback to summary
private ASN1OctetString privateKey
privateKeyAlgorithmback to summary
private AlgorithmIdentifier privateKeyAlgorithm
publicKeyback to summary
private ASN1BitString publicKey
versionback to summary
private ASN1Integer version

Constructor Detail

PrivateKeyInfoback to summary
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey) throws IOException
PrivateKeyInfoback to summary
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey, ASN1Set attributes) throws IOException
PrivateKeyInfoback to summary
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey, ASN1Set attributes, byte[] publicKey) throws IOException
PrivateKeyInfoback to summary
private PrivateKeyInfo(ASN1Sequence seq)

Method Detail

getAttributesback to summary
public ASN1Set getAttributes()
getInstanceback to summary
public static PrivateKeyInfo getInstance(ASN1TaggedObject obj, boolean explicit)
getInstanceback to summary
public static PrivateKeyInfo getInstance(Object obj)
getPrivateKeyback to summary
public ASN1OctetString getPrivateKey()
getPrivateKeyAlgorithmback to summary
public AlgorithmIdentifier getPrivateKeyAlgorithm()
getPrivateKeyLengthback to summary
public int getPrivateKeyLength()
getPublicKeyDataback to summary
public ASN1BitString getPublicKeyData()

for when the public key is raw bits.

Returns:ASN1BitString

the public key as the raw bit string...

getVersionback to summary
public ASN1Integer getVersion()
getVersionValueback to summary
private static int getVersionValue(ASN1Integer version)
hasPublicKeyback to summary
public boolean hasPublicKey()

Return true if a public key is present, false otherwise.

Returns:boolean

true if public included, otherwise false.

parsePrivateKeyback to summary
public ASN1Encodable parsePrivateKey() throws IOException
parsePublicKeyback to summary
public ASN1Encodable parsePublicKey() throws IOException

for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.

Returns:ASN1Encodable

the public key as an ASN.1 primitive.

Exceptions
IOException:
- if the bit string doesn't represent a DER encoded object.
toASN1Primitiveback to summary
public ASN1Primitive toASN1Primitive()

Implements abstract org.bouncycastle.asn1.ASN1Object.toASN1Primitive.

Implements org.bouncycastle.asn1.ASN1Encodable.toASN1Primitive.

Doc from org.bouncycastle.asn1.ASN1Object.toASN1Primitive.

Method providing a primitive representation of this object suitable for encoding.

Returns:ASN1Primitive

a primitive representation of this object.