Class SymmetricSecretKey

  • All Implemented Interfaces:
    javax.security.auth.Destroyable, Key, SymmetricKey

    public final class SymmetricSecretKey
    extends java.lang.Object
    implements SymmetricKey, javax.security.auth.Destroyable
    Basic class describing a secret key implementation. The key will be zeroized explicitly on garbage collection and is protected from being shared between approved an un-approved threads.

    Note: it the module is run under the SecurityManager only invokers with CryptoServicesPermission.FIPS_MODE_EXPORT_SECRET_KEY permission can successfully call the getKeyBytes() method.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()  
      boolean equals​(java.lang.Object o)
      Return true if o is an equivalent key to this.
      Algorithm getAlgorithm()
      Return the algorithm this secret key is for.
      byte[] getKeyBytes()
      Return the bytes representing this keys value.
      int hashCode()
      Return the hashCode for the key.
      boolean isDestroyed()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SymmetricSecretKey

        public SymmetricSecretKey​(Algorithm algorithm,
                                  byte[] bytes)
        Base constructor.
        Parameters:
        algorithm - the algorithm this secret key is associated with.
        bytes - the bytes representing the key's value.
      • SymmetricSecretKey

        public SymmetricSecretKey​(Parameters parameterSet,
                                  byte[] bytes)
        Base constructor for a specific algorithm associated with a parameter set.
        Parameters:
        parameterSet - the parameter set with the algorithm this secret key is associated with.
        bytes - the bytes representing the key's value.
    • Method Detail

      • getAlgorithm

        public Algorithm getAlgorithm()
        Return the algorithm this secret key is for.
        Specified by:
        getAlgorithm in interface Key
        Returns:
        the secret keys algorithm.
      • getKeyBytes

        public byte[] getKeyBytes()
        Return the bytes representing this keys value. See CryptoServicesPermission.FIPS_MODE_EXPORT_SECRET_KEY for the permission associated with this method.
        Specified by:
        getKeyBytes in interface SymmetricKey
        Returns:
        the bytes making up this key.
      • equals

        public boolean equals​(java.lang.Object o)
        Description copied from interface: Key
        Return true if o is an equivalent key to this.
        Specified by:
        equals in interface Key
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - object to compare to.
        Returns:
        true if o is the same or equivalent key, false otherwise.
      • hashCode

        public int hashCode()
        Description copied from interface: Key
        Return the hashCode for the key.
        Specified by:
        hashCode in interface Key
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the key's hashCode.
      • destroy

        public void destroy()
                     throws javax.security.auth.DestroyFailedException
        Specified by:
        destroy in interface javax.security.auth.Destroyable
        Throws:
        javax.security.auth.DestroyFailedException
      • isDestroyed

        public boolean isDestroyed()
        Specified by:
        isDestroyed in interface javax.security.auth.Destroyable