APIdia Launch Partner
Top Description Fields Constructors Methods
javax.security.auth.kerberos

public final Class EncryptionKey

extends Object
implements SecretKey
Class Inheritance
All Implemented Interfaces
javax.crypto.SecretKey, javax.security.auth.Destroyable, java.security.Key, java.io.Serializable
Imports
java.io.Serial, java.util.Arrays, .Objects, javax.crypto.SecretKey, javax.security.auth.DestroyFailedException

This class encapsulates an EncryptionKey used in Kerberos.

An EncryptionKey is defined in Section 4.2.9 of the Kerberos Protocol Specification (RFC 4120) as:

    EncryptionKey   ::= SEQUENCE {
            keytype         [0] Int32 -- actually encryption type --,
            keyvalue        [1] OCTET STRING
    }
The key material of an EncryptionKey is defined as the value of the keyValue above.
Since
9

Field Summary

Modifier and TypeField and Description
private transient boolean
private final KeyImpl
key

KeyImpl is serialized by writing out the ASN.1 encoded bytes of the encryption key.

private static final long

Constructor Summary

AccessConstructor and Description
public
EncryptionKey(byte[]
the key material for the key
keyBytes
,
int
the key type for the key as defined by the Kerberos protocol specification.
keyType
)

Constructs an EncryptionKey from the given bytes and the key type.

Method Summary

Modifier and TypeMethod and Description
public void
destroy()

Overrides default javax.security.auth.Destroyable.destroy.

Destroys this key by clearing out the key material of this key.

public boolean

Returns:

true if the specified object is equal to this EncryptionKey, false otherwise.
equals
(Object
the object to compare to
other
)

Overrides java.lang.Object.equals.

Compares the specified object with this key for equality.

public String

Returns:

the name of the algorithm associated with this key.
getAlgorithm
()

Implements java.security.Key.getAlgorithm.

Returns the standard algorithm name for this key.

public byte[]

Returns:

a newly allocated byte array that contains the key material
getEncoded
()

Implements java.security.Key.getEncoded.

Returns the key material of this key.

public String

Returns:

the String "RAW"
getFormat
()

Implements java.security.Key.getFormat.

Returns the name of the encoding format for this key.

public int

Returns:

the key type.
getKeyType
()

Returns the key type for this key.

public int

Returns:

a hash code for this EncryptionKey
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code for this EncryptionKey.

public boolean
isDestroyed()

Overrides default javax.security.auth.Destroyable.isDestroyed.

Determine if this Object has been destroyed.

public String

Returns:

an informative textual representation of this EncryptionKey.
toString
()

Overrides java.lang.Object.toString.

Returns an informative textual representation of this EncryptionKey.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

destroyedback to summary
private transient boolean destroyed
keyback to summary
private final KeyImpl key

KeyImpl is serialized by writing out the ASN.1 encoded bytes of the encryption key.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides javax.crypto.SecretKey.serialVersionUID.

Annotations
@Serial

Constructor Detail

EncryptionKeyback to summary
public EncryptionKey(byte[] keyBytes, int keyType)

Constructs an EncryptionKey from the given bytes and the key type.

The contents of the byte array are copied; subsequent modification of the byte array does not affect the newly created key.

Parameters
keyBytes:byte[]

the key material for the key

keyType:int

the key type for the key as defined by the Kerberos protocol specification.

Exceptions
NullPointerException:
if keyBytes is null

Method Detail

destroyback to summary
public void destroy() throws DestroyFailedException

Overrides default javax.security.auth.Destroyable.destroy.

Destroys this key by clearing out the key material of this key.

Annotations
@Override
Exceptions
DestroyFailedException:
if some error occurs while destroying this key.
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Compares the specified object with this key for equality. Returns true if the given object is also an EncryptionKey and the two EncryptionKey instances are equivalent. More formally two EncryptionKey instances are equal if they have equal key types and key material. A destroyed EncryptionKey object is only equal to itself.

Parameters
other:Object

the object to compare to

Returns:boolean

true if the specified object is equal to this EncryptionKey, false otherwise.

Annotations
@Override
getAlgorithmback to summary
public String getAlgorithm()

Implements java.security.Key.getAlgorithm.

Returns the standard algorithm name for this key. The algorithm names are the encryption type string defined on the IANA Kerberos Encryption Type Numbers page.

This method can return the following value not defined on the IANA page:

  1. none: for etype equal to 0
  2. unknown: for etype greater than 0 but unsupported by the implementation
  3. private: for etype smaller than 0
Returns:String

the name of the algorithm associated with this key.

Annotations
@Override
Exceptions
IllegalStateException:
if the key is destroyed
getEncodedback to summary
public byte[] getEncoded()

Implements java.security.Key.getEncoded.

Returns the key material of this key.

Returns:byte[]

a newly allocated byte array that contains the key material

Annotations
@Override
Exceptions
IllegalStateException:
if the key is destroyed
getFormatback to summary
public String getFormat()

Implements java.security.Key.getFormat.

Returns the name of the encoding format for this key.

Returns:String

the String "RAW"

Annotations
@Override
Exceptions
IllegalStateException:
if the key is destroyed
getKeyTypeback to summary
public int getKeyType()

Returns the key type for this key.

Returns:int

the key type.

Exceptions
IllegalStateException:
if the key is destroyed
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code for this EncryptionKey.

Returns:int

a hash code for this EncryptionKey

Annotations
@Override
isDestroyedback to summary
public boolean isDestroyed()

Overrides default javax.security.auth.Destroyable.isDestroyed.

Doc from javax.security.auth.Destroyable.isDestroyed.

Determine if this Object has been destroyed.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns an informative textual representation of this EncryptionKey.

Returns:String

an informative textual representation of this EncryptionKey.

Annotations
@Override