- All Implemented Interfaces:
Serializable
,Cloneable
,ECKey
,ECPrivateKey
,Key
,PrivateKey
,Destroyable
For more information on different Elliptic Curve key token formats, refer to Appendix B of the "z/OS Cryptographic Services ICSF Application Programmer's Guide, SA22-7522".
- See Also:
-
Field Summary
Fields inherited from class com.ibm.security.pkcs8.PrivateKeyInfo
algid, attributes, encodedKeyNoOptional, key, version
Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method is used to delete the PKDS information that is associated with this key object.void
destroy()
Destroy or clear sensitive information contained in this private key.byte[]
Returns a clone of either the external PKA key token of a CLEAR key or the PKDS record label of a PKDS key.byte[]
Return a clone of the external private key token.Returns either 'ICSFToken' for a CLEAR type key or 'PKDSLabel' for a PKDS type key.Returns the PKDS record label if the key object is a PKDS type of key.Return the Elliptic Curve domain parameters.getS()
This method is not supported for hardware based private keys.The preferred method for retrieving an equivalent software Elliptic Curve private key from a CLEAR hardware Elliptic Curve private key is to use theKeyFactory
class.byte[]
getToken()
Return a clone of either the internal private key token or the PKDS record label.byte
getType()
Return whether this is a CLEAR or PKDS private key.byte
getUsage()
Return whether this key is used for key management or signature services.boolean
This method is called to determine whether this key object still contains key material.protected void
Construct a set of Elliptic Curve domain parameters from the algorithm ID.toString()
Returns the private key in human readable format.Methods inherited from class com.ibm.security.pkcs8.PrivateKeyInfo
addAttribute, addAttributes, clone, decode, encode, equals, finalize, getAlgorithm, getAlgorithmId, getAttribute, getAttributes, getEncodedKeyNoOptionalAttributes, getKeyBytes, hasAttribute, hasAttributes, hashCode, parseKey, parseKey
Methods inherited from class com.ibm.security.pkcsutil.PKCSDerObject
decode, encode, getObjectIdentifier, read, readBASE64, write, write, writeBASE64
Methods inherited from interface java.security.Key
getAlgorithm
-
Method Details
-
parseKeyBits
Construct a set of Elliptic Curve domain parameters from the algorithm ID. This method is called by the parent class PrivateKeyInfo. The 'key' instance variable is a byte array containing the DER-encoded key. Contrary to the method name, this method will not do key parsing, this will be done by the constructor.- Overrides:
parseKeyBits
in classcom.ibm.security.pkcs8.PrivateKeyInfo
- Throws:
IOException
- if unable to construct Elliptic Curve domain parametersIllegalStateException
- if destroy() has been called in this key object
-
getToken
public byte[] getToken()Return a clone of either the internal private key token or the PKDS record label. If a PKDS record label, it will be in ISO_8859_1 character set encoding. Please note that this method is deprecated for use of obtaining a PKDSLabel, it is recommended that the caller make use of the methodgetLabelString()
instead to fetch PKDSLabels.Note that this method returns a clone of sensitive information. It is the caller's responsibility to zero out the information after it is no longer needed.
- Returns:
- A clone of the internal private key token or PKDS record label
- Throws:
IllegalStateException
- If destroy() has been called in this key object
-
getLabelString
Returns the PKDS record label if the key object is a PKDS type of key.- Returns:
- The PKDS label. This value will be exactly what is used within the CCA key repository as a label, including trailing blanks.
- Throws:
InvalidKeyException
- If the key is not a PKDS type of key.
-
getExternalKeyToken
public byte[] getExternalKeyToken()Return a clone of the external private key token.Note that this method returns a clone of sensitive information. It is the caller's responsibility to zero out the information after it is no longer needed.
- Returns:
- A clone of the external private key token of a CLEAR private key, or null if a PKDS private key
- Throws:
IllegalStateException
- If destroy() has been called in this key object
-
getType
public byte getType()Return whether this is a CLEAR or PKDS private key.- Returns:
- whether this is a CLEAR or PKDS private key
- Throws:
IllegalStateException
- if destroy() has been called in this key object
-
getUsage
public byte getUsage()Return whether this key is used for key management or signature services.- Returns:
- whether this key is used for key management or signature services
- Throws:
IllegalStateException
- if destroy() has been called in this key object
-
getS
This method is not supported for hardware based private keys.- Specified by:
getS
in interfaceECPrivateKey
- Throws:
UnsupportedOperationException
- is always thrown
-
getParams
Return the Elliptic Curve domain parameters.- Specified by:
getParams
in interfaceECKey
- Returns:
- Elliptic Curve domain parameters
- Throws:
IllegalStateException
- if destroy() has been called in this key object
-
getEncoded
public byte[] getEncoded()Returns a clone of either the external PKA key token of a CLEAR key or the PKDS record label of a PKDS key.Note that this method returns a clone of sensitive information. It is the caller's responsibility to zero out the information after it is no longer needed.
- Specified by:
getEncoded
in interfaceKey
- Overrides:
getEncoded
in classcom.ibm.security.pkcs8.PrivateKeyInfo
- Returns:
- either the external PKA key token of a CLEAR key or the PKDS record label of a PKDS key. If a PKDS record label is returned the bytes will be encoded in the 8859_1 encoding.
- Throws:
IllegalStateException
- if destroy() has been called in this key object
-
getFormat
Returns either 'ICSFToken' for a CLEAR type key or 'PKDSLabel' for a PKDS type key.- Specified by:
getFormat
in interfaceKey
- Overrides:
getFormat
in classcom.ibm.security.pkcs8.PrivateKeyInfo
- Returns:
- either 'ICSFToken' or 'PKDSLabel' keywords
- Throws:
IllegalStateException
- if destroy() has been called in this key object
-
getSoftwareECPrivateKey
The preferred method for retrieving an equivalent software Elliptic Curve private key from a CLEAR hardware Elliptic Curve private key is to use theKeyFactory
class.Use the JCECCA
KeyFactory.getKeySpec(Key key, Class keySpec)
method to retrieveECPrivateKeySpec
from a CLEAR hardware Elliptic Curve private key. TheECPrivateKeySpec
object can then be used as a parameter to any software provider'sKeyFactory.generatePrivate(KeySpec keySpec)
method in order to retrieve the equivalent software private key for that provider.This method creates and returns the equivalent JCE provider software Elliptic Curve private key. This functionality is only available to CLEAR hardware Elliptic Curve keys.
Please note that in order for the returned JCE provider software key to function normally, such as returning the correct encoded private key value, the JCE provider must support the Elliptic Curve being used by this key.
If the JCE provider does not support the Elliptic Curve used by this key, then the returned JCE software key will encode the associated domain parameters piece by piece, rather than encoding just the OID of the Elliptic Curve used by this key. As a result, the encoded value may not be recognized by other services.
- Returns:
- the equivalent JCE provider software Elliptic Curve private key
- Throws:
InvalidKeyException
- if this is a PKDS hardware key or if unable to create the equivalent JCE provider software private keyIllegalStateException
- if destroy() has been called in this key object
-
toString
Returns the private key in human readable format.- Overrides:
toString
in classcom.ibm.security.pkcs8.PrivateKeyInfo
- Returns:
- a string that represents the private key
- Throws:
IllegalStateException
- if destroy() has been called in this key object
-
deletePKDSEntry
This method is used to delete the PKDS information that is associated with this key object.- Throws:
InvalidKeyException
- Key object is not PKDS type.RuntimeException
- PKDS label length is incorrect or if the ICSF operation is not successfulIllegalStateException
- if destroy() has been called in this key object
-
destroy
Destroy or clear sensitive information contained in this private key. This method is required because the class implementsECPrivateKey
, which implementsDestroyable
. This method destroys data stored in this java object. It does not delete key material from the PKDS.- Specified by:
destroy
in interfaceDestroyable
- Throws:
DestroyFailedException
-
isDestroyed
public boolean isDestroyed()This method is called to determine whether this key object still contains key material.- Specified by:
isDestroyed
in interfaceDestroyable
- Returns:
- true if destroy() has been called, otherwise false.
-