APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.crypto.provider

pack-priv final Class DESKey

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.IOException, .InvalidObjectException, java.lang.ref.Reference, java.security.MessageDigest, .KeyRep, .InvalidKeyException, java.util.Arrays, javax.crypto.SecretKey, javax.crypto.spec.DESKeySpec, jdk.internal.ref.CleanerFactory

This class represents a DES key.
Author
Jan Luehe

Field Summary

Modifier and TypeField and Description
private byte[]
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
DESKey(byte[]
the buffer with the DES key bytes.
key
)

Uses the first 8 bytes of the given key as the DES key.

pack-priv
DESKey(byte[]
the buffer with the DES key bytes.
key
,
int
the offset in key, where the DES key bytes start.
offset
)

Uses the first 8 bytes in key, beginning at offset, as the DES key

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String
getAlgorithm()

Implements java.security.Key.getAlgorithm.

Returns the standard algorithm name for this key.

public byte[]
getEncoded()

Implements java.security.Key.getEncoded.

Returns the key in its primary encoding format, or null if this key does not support encoding.

public String
getFormat()

Implements java.security.Key.getFormat.

Returns the name of the primary encoding format of this key, or null if this key does not support encoding.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Calculates a hash code value for the object.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

Restores the state of this object from the stream.

private Object

Returns:

the standard KeyRep object to be serialized
writeReplace
()

Replace the DES key to be serialized.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private byte[] key
serialVersionUIDback to summary
private static final long serialVersionUID

Hides javax.crypto.SecretKey.serialVersionUID.

Annotations
@Serial

Constructor Detail

DESKeyback to summary
pack-priv DESKey(byte[] key) throws InvalidKeyException

Uses the first 8 bytes of the given key as the DES key.

Parameters
key:byte[]

the buffer with the DES key bytes.

Exceptions
InvalidKeyException:
if less than 8 bytes are available for the key.
DESKeyback to summary
pack-priv DESKey(byte[] key, int offset) throws InvalidKeyException

Uses the first 8 bytes in key, beginning at offset, as the DES key

Parameters
key:byte[]

the buffer with the DES key bytes.

offset:int

the offset in key, where the DES key bytes start.

Exceptions
InvalidKeyException:
if less than 8 bytes are available for the key.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getAlgorithmback to summary
public String getAlgorithm()

Implements java.security.Key.getAlgorithm.

Doc from java.security.Key.getAlgorithm.

Returns the standard algorithm name for this key. For example, "RSA" would indicate that this key is an RSA key. See the Key Algorithms section in the Java Security Standard Algorithm Names Specification for information about standard key algorithm names.

getEncodedback to summary
public byte[] getEncoded()

Implements java.security.Key.getEncoded.

Doc from java.security.Key.getEncoded.

Returns the key in its primary encoding format, or null if this key does not support encoding.

getFormatback to summary
public String getFormat()

Implements java.security.Key.getFormat.

Doc from java.security.Key.getFormat.

Returns the name of the primary encoding format of this key, or null if this key does not support encoding. The primary encoding format is named in terms of the appropriate ASN.1 data format, if an ASN.1 specification for this key exists. For example, the name of the ASN.1 data format for public keys is SubjectPublicKeyInfo, as defined by the X.509 standard; in this case, the returned format is "X.509". Similarly, the name of the ASN.1 data format for private keys is PrivateKeyInfo, as defined by the PKCS #8 standard; in this case, the returned format is "PKCS#8".

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Calculates a hash code value for the object. Objects that are equal will also have the same hashcode.

Annotations
@Override
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Restores the state of this object from the stream.

Parameters
s:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
writeReplaceback to summary
private Object writeReplace() throws ObjectStreamException

Replace the DES key to be serialized.

Returns:Object

the standard KeyRep object to be serialized

Annotations
@Serial
Exceptions
ObjectStreamException:
if a new object representing this DES key could not be created