Sharkysoft home

lava.security.des
Class DesKey

java.lang.Object
  |
  +--lava.security.des.DesKey

public final class DesKey
extends java.lang.Object

DES key.

Details: A DesKey defines a 64-bit DES key, 56-bits of which are used to select a DES encryption function.

bit ordering

Refer to the package summary for important information regarding bit ordering.

Since:
1999.08.04
Author:
Sharky
See Also:
DesEngine, TripleDesKey

Constructor Summary
DesKey(byte[] bytes, int offset)
          Specifies key as a byte sequence.
DesKey(int[] halves, int offset)
          Specifies 32-bit left and right halves.
DesKey(int lh, int rh)
          Sets key halves.
DesKey(long key)
          Sets key.
 
Method Summary
 boolean hasOddParity()
          Tests for odd parity.
 long longValue()
          Converts this key to long value.
 java.lang.String toString()
          Converts this key to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DesKey

public DesKey(int lh,
              int rh)
Sets key halves.

Details: This constructor initializes the key using the 32-bit left and right halves provided. The MSB of lh corresponds to bit 1 of the key described in FIPS PUB 46, while the LSB of rh corresponds to bit 64.

Parameters:
lh - the left half
rh - the right half

DesKey

public DesKey(long key)
Sets key.

Details: This constructor initializes the key using the given 64-bit value. The MSB corresponds to bit 1 of the key described in FIPS PUB 46.

Parameters:
key - the key

DesKey

public DesKey(int[] halves,
              int offset)
Specifies 32-bit left and right halves.

Details: This constructor initializes the key using the 32-bit left and right halves provided. The left half is index by offset and the right half is index by offset + 1.

Parameters:
halves - the left and right halves
offset - index of left half

DesKey

public DesKey(byte[] bytes,
              int offset)
Specifies key as a byte sequence.

Details: This constructor initializes the key using the given 8 bytes. The bytes are ordered in big endian order, and the first byte is indexed by offset, and the MSB of the first byte corresponds to bit 1 of the key described in FIPS PUB 46.

Parameters:
bytes - the byte array
offset - index of first byte
Method Detail

hasOddParity

public boolean hasOddParity()
Tests for odd parity.

Details: This method determines whether this DES key has odd parity. A DES key is said to have odd parity when each octet (byte) of the key has odd parity (i.e., total number of set bits is odd).

A correctly specified DES key should have odd parity.

Returns:
true iff parity is odd

longValue

public long longValue()
Converts this key to long value.

Details: This method returns this key as a long value.

Returns:
the long value
Since:
1999.08.17

toString

public java.lang.String toString()
Converts this key to a String.

Details: This method returns this key as a 16 character hexadecimal String.

Overrides:
toString in class java.lang.Object
Returns:
the String
Since:
1999.08.17

Sharkysoft home