Package org.bouncycastle.asn1.pkcs
Class PrivateKeyInfo
java.lang.Object
org.bouncycastle.asn1.ASN1Object
org.bouncycastle.asn1.pkcs.PrivateKeyInfo
- All Implemented Interfaces:
ASN1Encodable
,Encodable
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 } }
-
Constructor Summary
ConstructorsConstructorDescriptionPrivateKeyInfo
(AlgorithmIdentifier privateKeyAlgorithm, byte[] privateKey) Construct a PrivateKeyInfo around a raw encoding.PrivateKeyInfo
(AlgorithmIdentifier privateKeyAlgorithm, byte[] privateKey, ASN1Set attributes) Construct a PrivateKeyInfo around an ASN.1 structure/primitive with attributes.PrivateKeyInfo
(AlgorithmIdentifier privateKeyAlgorithm, byte[] privateKey, ASN1Set attributes, byte[] publicKey) Construct a PrivateKeyInfo around a raw encoding with attributes and the public key.PrivateKeyInfo
(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey) Construct a PrivateKeyInfo around an ASN.1 structure/primitive.PrivateKeyInfo
(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey, ASN1Set attributes) Construct a PrivateKeyInfo around an ASN.1 structure/primitive with attributes.PrivateKeyInfo
(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey, ASN1Set attributes, byte[] publicKey) Construct a PrivateKeyInfo around an ASN.1 structure/primitive with attributes and the public key. -
Method Summary
Modifier and TypeMethodDescriptionstatic PrivateKeyInfo
getInstance
(Object obj) static PrivateKeyInfo
getInstance
(ASN1TaggedObject obj, boolean explicit) int
for when the public key is raw bits.boolean
Return true if a public key is present, false otherwise.for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.Method providing a primitive representation of this object suitable for encoding.Methods inherited from class org.bouncycastle.asn1.ASN1Object
encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode
-
Constructor Details
-
PrivateKeyInfo
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, byte[] privateKey) throws IOException Construct a PrivateKeyInfo around a raw encoding.- Parameters:
privateKeyAlgorithm
- algorithm identifier for the private key.privateKey
- byte encoding of the private key, used as a raw encoding.- Throws:
IOException
-
PrivateKeyInfo
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey) throws IOException Construct a PrivateKeyInfo around an ASN.1 structure/primitive.- Parameters:
privateKeyAlgorithm
- algorithm identifier for the private key.privateKey
- the ASN.1 structure/primitive representing the private key.- Throws:
IOException
- if encoding the privateKey object into an OCTET STRING fails.
-
PrivateKeyInfo
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey, ASN1Set attributes) throws IOException Construct a PrivateKeyInfo around an ASN.1 structure/primitive with attributes.- Parameters:
privateKeyAlgorithm
- algorithm identifier for the private key.privateKey
- the ASN.1 structure/primitive representing the private key.attributes
- attributes associated with private key.- Throws:
IOException
- if encoding the privateKey object into an OCTET STRING fails.
-
PrivateKeyInfo
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, byte[] privateKey, ASN1Set attributes) throws IOException Construct a PrivateKeyInfo around an ASN.1 structure/primitive with attributes.- Parameters:
privateKeyAlgorithm
- algorithm identifier for the private key.privateKey
- byte encoding of the private key, used as a raw encoding.attributes
- attributes associated with private key.- Throws:
IOException
- if encoding the privateKey object into an OCTET STRING fails.
-
PrivateKeyInfo
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, ASN1Encodable privateKey, ASN1Set attributes, byte[] publicKey) throws IOException Construct a PrivateKeyInfo around an ASN.1 structure/primitive with attributes and the public key.- Parameters:
privateKeyAlgorithm
- algorithm identifier for the private key.privateKey
- the ASN.1 structure/primitive representing the private key.attributes
- attributes associated with private key.publicKey
- public key encoding.- Throws:
IOException
- if encoding the privateKey object into an OCTET STRING fails.
-
PrivateKeyInfo
public PrivateKeyInfo(AlgorithmIdentifier privateKeyAlgorithm, byte[] privateKey, ASN1Set attributes, byte[] publicKey) Construct a PrivateKeyInfo around a raw encoding with attributes and the public key.- Parameters:
privateKeyAlgorithm
- algorithm identifier for the private key.privateKey
- byte encoding of the private key, used as a raw encoding.attributes
- attributes associated with private key.publicKey
- public key encoding.
-
-
Method Details
-
getInstance
-
getInstance
-
getVersion
-
getAttributes
-
getPrivateKeyAlgorithm
-
getPrivateKey
-
getPrivateKeyLength
public int getPrivateKeyLength() -
parsePrivateKey
- Throws:
IOException
-
hasPublicKey
public boolean hasPublicKey()Return true if a public key is present, false otherwise.- Returns:
- true if public included, otherwise false.
-
parsePublicKey
for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.- Returns:
- the public key as an ASN.1 primitive.
- Throws:
IOException
- - if the bit string doesn't represent a DER encoded object.
-
getPublicKeyData
for when the public key is raw bits.- Returns:
- the public key as the raw bit string...
-
toASN1Primitive
Description copied from class:ASN1Object
Method providing a primitive representation of this object suitable for encoding.- Specified by:
toASN1Primitive
in interfaceASN1Encodable
- Specified by:
toASN1Primitive
in classASN1Object
- Returns:
- a primitive representation of this object.
-