SecretKey (Java SE 15 & JDK 15) (original) (raw)

All Superinterfaces:

[Destroyable](../security/auth/Destroyable.html "interface in javax.security.auth"), [Key](../../java/security/Key.html "interface in java.security"), [Serializable](../../java/io/Serializable.html "interface in java.io")

All Known Subinterfaces:

[PBEKey](interfaces/PBEKey.html "interface in javax.crypto.interfaces")

All Known Implementing Classes:

[EncryptionKey](../../../java.security.jgss/javax/security/auth/kerberos/EncryptionKey.html "class in javax.security.auth.kerberos"), [KerberosKey](../../../java.security.jgss/javax/security/auth/kerberos/KerberosKey.html "class in javax.security.auth.kerberos"), [SecretKeySpec](spec/SecretKeySpec.html "class in javax.crypto.spec")


public interface SecretKey extends Key, Destroyable

A secret (symmetric) key. The purpose of this interface is to group (and provide type safety for) all secret key interfaces.

Provider implementations of this interface must overwrite theequals and hashCode methods inherited fromObject, so that secret keys are compared based on their underlying key material and not based on reference. Implementations should override the default destroy andisDestroyed methods from theDestroyable interface to enable sensitive key information to be destroyed, cleared, or in the case where such information is immutable, unreferenced. Finally, since SecretKey is Serializable, implementations should also overrideObjectOutputStream.writeObject(java.lang.Object) to prevent keys that have been destroyed from being serialized.

Keys that implement this interface return the string RAW as their encoding format (see getFormat), and return the raw key bytes as the result of a getEncoded method call. (ThegetFormat and getEncoded methods are inherited from the Key parent interface.)

Since:

1.4

See Also:

SecretKeyFactory, Cipher

Fields

Modifier and Type Field Description
static long serialVersionUID Deprecated.