public class

EncryptionKey

extends Object
implements Cloneable
java.lang.Object
   ↳ sun.security.mule.krb5.EncryptionKey

Class Overview

This class encapsulates the concept of an EncryptionKey. An encryption key is defined in RFC 4120 as: EncryptionKey ::= SEQUENCE { keytype [0] Int32 -- actually encryption type --, keyvalue [1] OCTET STRING } keytype This field specifies the encryption type of the encryption key that follows in the keyvalue field. Although its name is "keytype", it actually specifies an encryption type. Previously, multiple cryptosystems that performed encryption differently but were capable of using keys with the same characteristics were permitted to share an assigned number to designate the type of key; this usage is now deprecated. keyvalue This field contains the key itself, encoded as an octet string.

Summary

Fields
public static final EncryptionKey NULL_KEY
private int keyType
private byte[] keyValue
private Integer kvno
private static final Log logger
Public Constructors
EncryptionKey(byte[] keyValue, int keyType, Integer kvno)
EncryptionKey(int keyType, byte[] keyValue)
Constructs an EncryptionKey by using the specified key type and key value.
EncryptionKey(char[] password, String salt, String algorithm)
EncryptionKey(DerValue encoding)
Constructs an instance of EncryptionKey type.
Public Methods
static EncryptionKey[] acquireSecretKeys(PrincipalName princ, String keytab, Config kerberosConfig)
Obtains all versions of the secret key of the principal from a keytab.
static EncryptionKey[] acquireSecretKeys(char[] password, String salt, Config kerberosConfig)
Generate a list of keys using the given principal and password.
static EncryptionKey[] acquireSecretKeys(char[] password, String salt, boolean pa_exists, int pa_etype, byte[] pa_s2kparams, Config kerberosConfig)
Generates a list of keys using the given principal, password, and the pre-authentication values.
synchronized byte[] asn1Encode()
Returns the ASN.1 encoding of this EncryptionKey.
synchronized Object clone()
synchronized void destroy()
static EncryptionKey findKey(int etype, EncryptionKey[] keys)
final byte[] getBytes()
Returns the raw key bytes, not in any ASN.1 encoding.
synchronized int getEType()
final Integer getKeyVersionNumber()
static EncryptionKey parse(DerInputStream data, byte explicitTag, boolean optional)
Parse (unmarshal) an Encryption key from a DER input stream.
String toString()
synchronized void writeKey(CCacheOutputStream cos)
Writes key value in FCC format to a CCacheOutputStream.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final EncryptionKey NULL_KEY

private int keyType

private byte[] keyValue

private Integer kvno

private static final Log logger

Public Constructors

public EncryptionKey (byte[] keyValue, int keyType, Integer kvno)

Parameters
keyValue
keyType
kvno

public EncryptionKey (int keyType, byte[] keyValue)

Constructs an EncryptionKey by using the specified key type and key value. It is used to recover the key when retrieving data from credential cache file.

Parameters
keyType
keyValue

public EncryptionKey (char[] password, String salt, String algorithm)

Parameters
password
salt
algorithm

public EncryptionKey (DerValue encoding)

Constructs an instance of EncryptionKey type.

Parameters
encoding A single DER-encoded value.
Throws
Asn1Exception if an error occurs while decoding an ASN1 encoded data.
IOException if an I/O error occurs while reading encoded data.

Public Methods

public static EncryptionKey[] acquireSecretKeys (PrincipalName princ, String keytab, Config kerberosConfig)

Obtains all versions of the secret key of the principal from a keytab.

Parameters
princ
keytab The path to the keytab file. A value of null will be accepted to indicate that the default path should be searched.
kerberosConfig
Throws
IOException
KrbException

public static EncryptionKey[] acquireSecretKeys (char[] password, String salt, Config kerberosConfig)

Generate a list of keys using the given principal and password. Construct a key for each configured etype. Caller is responsible for clearing password.

Parameters
password
salt
kerberosConfig
Throws
KrbException

public static EncryptionKey[] acquireSecretKeys (char[] password, String salt, boolean pa_exists, int pa_etype, byte[] pa_s2kparams, Config kerberosConfig)

Generates a list of keys using the given principal, password, and the pre-authentication values.

Parameters
password
salt
pa_exists
pa_etype
pa_s2kparams
kerberosConfig
Throws
KrbException

public synchronized byte[] asn1Encode ()

Returns the ASN.1 encoding of this EncryptionKey.

EncryptionKey ::= SEQUENCE { keytype[0] INTEGER, keyvalue[1] OCTET STRING }

This definition reflects the Network Working Group RFC 4120 specification available at http://www.ietf.org/rfc/rfc4120.txt.

Returns
  • byte array of encoded EncryptionKey object.
Throws
Asn1Exception if an error occurs while decoding an ASN1 encoded data.
IOException if an I/O error occurs while reading encoded data.

public synchronized Object clone ()

public synchronized void destroy ()

public static EncryptionKey findKey (int etype, EncryptionKey[] keys)

Parameters
etype
keys
Throws
KrbException

public final byte[] getBytes ()

Returns the raw key bytes, not in any ASN.1 encoding.

public synchronized int getEType ()

public final Integer getKeyVersionNumber ()

public static EncryptionKey parse (DerInputStream data, byte explicitTag, boolean optional)

Parse (unmarshal) an Encryption key from a DER input stream. This form parsing might be used when expanding a value which is part of a constructed sequence and uses explicitly tagged type.

Parameters
data The Der input stream value, which contains one or more marshaled value.
explicitTag Tag number.
optional Indicate if this data field is optional
Returns
  • an instance of EncryptionKey.
Throws
Asn1Exception if an error occurs while decoding an ASN1 encoded data.
IOException if an I/O error occurs while reading encoded data.

public String toString ()

public synchronized void writeKey (CCacheOutputStream cos)

Writes key value in FCC format to a CCacheOutputStream.

Parameters
cos A CCacheOutputStream to be written to.
Throws
IOException if an I/O exception occurs.