Class HMACKey

java.lang.Object
com.ibm.crypto.hdwrCCA.provider.HMACKey
All Implemented Interfaces:
Serializable, Key, SecretKey, Destroyable

public class HMACKey extends Object implements SecretKey
This class represents an HMAC secret key.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Call the class IBMJCECCACleaner to clean up the bytes of this key, ICSF token, or CKDS label.
    void
    Delete the CKDS entry associated with this key object.
    boolean
    Performs a deep compare to determine whether the given object represents a key identical to the key represented by this object.
    Returns the HMAC algorithm name associated with this key object.
    byte[]
    Returns the CKDS label for a "CKDSLabel" type key.
    Returns the key type or key format of this key object, this will always be "CKDSLabel".
    Returns a copy of the CKDS label associated with this key object if this is a "CKDSLabel" key object.
    int
    Calculates a hash code value for this key object.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface javax.security.auth.Destroyable

    destroy, isDestroyed
  • Method Details

    • getEncoded

      public byte[] getEncoded()
      Returns the CKDS label for a "CKDSLabel" type 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 interface Key
      Returns:
      a clone of the encoded key value which will be the CKDS label of the key. The CKDS label returned will be in the IBM-1047 codepage. If an error is encountered, null is returned.
    • getLabelString

      public String getLabelString() throws InvalidKeyException
      Returns a copy of the CKDS label associated with this key object if this is a "CKDSLabel" key object.
      Returns:
      a copy of the CKDS label if this is a "CKDSLabel" key object. This value will be exactly what is used within the CCA key repository as a label, including trailing blanks.
      Throws:
      InvalidKeyException - if this is not a "CKDSLabel" key object.
    • getAlgorithm

      public String getAlgorithm()
      Returns the HMAC algorithm name associated with this key object.
      Specified by:
      getAlgorithm in interface Key
      Returns:
      the HMAC algorithm name.
    • getFormat

      public String getFormat()
      Returns the key type or key format of this key object, this will always be "CKDSLabel".
      Specified by:
      getFormat in interface Key
      Returns:
      the key type of this key object. In this case "CKDSLabel".
    • deleteCKDSEntry

      public void deleteCKDSEntry() throws InvalidKeyException
      Delete the CKDS entry associated with this key object.
      Throws:
      InvalidKeyException - if this is not a "CKDSLabel" key object.
      RuntimeException - if there is an error while deleting the CKDS entry.
    • hashCode

      public int hashCode()
      Calculates a hash code value for this key object. Objects that are equal will also have the same hash value.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this key object.
    • equals

      public boolean equals(Object obj)
      Performs a deep compare to determine whether the given object represents a key identical to the key represented by this object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare to this key object
      Returns:
      true if the given object is equal to this key object, false otherwise.
    • cleaner

      protected void cleaner()
      Call the class IBMJCECCACleaner to clean up the bytes of this key, ICSF token, or CKDS label.