public class C509PrivateKey
extends java.lang.Object
implements javax.security.auth.Destroyable
C509PrivateKey = [
C509PrivateKeyType: int,
subjectPrivateKeyAlgorithm: AlgorithmIdentifier,
subjectPrivateKey: any,
]
For type 0 the subjectPrivateKey is the PrivateKey OCTET STRING value field of
RFC 5958 as a CBOR byte string; for type 1 it is a COSE_Key structure (RFC 9052),
carried here uninterpreted. The subjectPrivateKeyAlgorithm draws from the C509
Public Key Algorithms Registry (Section 8.15).
The structure transports secret material, so it is Destroyable: after
destroy() the key bytes are zeroized and the accessors fail.
| Modifier and Type | Field and Description |
|---|---|
static int |
TYPE_ASYMMETRIC_KEY_PACKAGE
subjectPrivateKey is the RFC 5958 PrivateKey OCTET STRING value field as a byte string.
|
static int |
TYPE_COSE_KEY
subjectPrivateKey is a COSE_Key structure (RFC 9052) containing a private key.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
boolean |
equals(java.lang.Object o) |
static C509PrivateKey |
fromPrivateKeyInfo(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo)
Build a type 0 C509 private key from a PKCS#8 / RFC 5958 PrivateKeyInfo.
|
byte[] |
getEncoded()
Return the complete CBOR encoding of this structure.
|
static C509PrivateKey |
getInstance(byte[] encoding)
Parse a C509 private key structure from its CBOR encoding.
|
int |
getPrivateKeyType()
Return the private key type (
TYPE_ASYMMETRIC_KEY_PACKAGE or
TYPE_COSE_KEY). |
C509AlgorithmIdentifier |
getSubjectPrivateKeyAlgorithm()
Return the subject private key algorithm.
|
byte[] |
getSubjectPrivateKeyEncoding()
Return the CBOR encoding of the subjectPrivateKey item - the key material.
|
int |
hashCode() |
boolean |
isDestroyed() |
org.bouncycastle.asn1.pkcs.PrivateKeyInfo |
toPrivateKeyInfo()
Return the PKCS#8 / RFC 5958 PrivateKeyInfo view of a type 0 C509 private key.
|
java.lang.String |
toString() |
public static final int TYPE_ASYMMETRIC_KEY_PACKAGE
public static final int TYPE_COSE_KEY
public static C509PrivateKey getInstance(byte[] encoding) throws java.io.IOException
java.io.IOExceptionpublic static C509PrivateKey fromPrivateKeyInfo(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo) throws java.io.IOException
java.io.IOExceptionpublic org.bouncycastle.asn1.pkcs.PrivateKeyInfo toPrivateKeyInfo()
throws java.io.IOException
java.lang.IllegalStateException - if this is a type 1 (COSE_Key) structure or the
key has been destroyed.java.io.IOExceptionpublic int getPrivateKeyType()
TYPE_ASYMMETRIC_KEY_PACKAGE or
TYPE_COSE_KEY).public C509AlgorithmIdentifier getSubjectPrivateKeyAlgorithm()
public byte[] getSubjectPrivateKeyEncoding()
public byte[] getEncoded()
throws java.io.IOException
java.io.IOExceptionpublic void destroy()
throws javax.security.auth.DestroyFailedException
destroy in interface javax.security.auth.Destroyablejavax.security.auth.DestroyFailedExceptionpublic boolean isDestroyed()
isDestroyed in interface javax.security.auth.Destroyablepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object