public class DES extends BaseCipher
The Data Encryption Standard. DES is a 64-bit block cipher with a 56-bit key, developed by IBM in the 1970's for the standardization process begun by the National Bureau of Standards (now NIST).
New applications should not use DES except for compatibility.
This version is based upon the description and sample implementation in [1].
References:
Modifier and Type | Field and Description |
---|---|
static int |
BLOCK_SIZE
DES operates on 64 bit blocks.
|
static int |
KEY_SIZE
DES uses 56 bits of a 64 bit parity-adjusted key.
|
static byte[][] |
POSSIBLE_WEAK_KEYS
Possible weak keys (parity adjusted) --produce 4 instead of 16 subkeys.
|
static byte[][] |
SEMIWEAK_KEYS
Semi-weak keys (parity adjusted): Some pairs of keys encrypt plain text
to identical cipher text.
|
static byte[][] |
WEAK_KEYS
Weak keys (parity adjusted): If all the bits in each half are either 0
or 1, then the key used for any cycle of the algorithm is the same as
all other cycles.
|
currentBlockSize, currentKey, defaultBlockSize, defaultKeySize, lock, name
CIPHER_BLOCK_SIZE, KEY_MATERIAL
Constructor and Description |
---|
DES()
Default 0-argument constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
adjustParity(byte[] kb,
int offset)
Adjust the parity for a raw key array.
|
java.util.Iterator |
blockSizes()
Returns an
Iterator over the supported block sizes. |
java.lang.Object |
clone()
Returns a clone of this instance.
|
void |
decrypt(byte[] in,
int i,
byte[] out,
int o,
java.lang.Object K,
int bs) |
void |
encrypt(byte[] in,
int i,
byte[] out,
int o,
java.lang.Object K,
int bs) |
static boolean |
isParityAdjusted(byte[] kb,
int offset)
Test if a byte array, which must be at least 8 bytes long, is parity
adjusted.
|
static boolean |
isPossibleWeak(byte[] kb)
Test if the designated byte array represents a possibly weak key.
|
static boolean |
isSemiWeak(byte[] kb)
Test if a key is a semi-weak key.
|
static boolean |
isWeak(byte[] kb)
Test if a key is a weak key.
|
java.util.Iterator |
keySizes()
Returns an
Iterator over the supported key sizes. |
java.lang.Object |
makeKey(byte[] kb,
int bs) |
currentBlockSize, decryptBlock, defaultBlockSize, defaultKeySize, encryptBlock, init, name, reset, selfTest, testKat, testKat
public static final int BLOCK_SIZE
public static final int KEY_SIZE
public static final byte[][] WEAK_KEYS
public static final byte[][] SEMIWEAK_KEYS
public static final byte[][] POSSIBLE_WEAK_KEYS
public static void adjustParity(byte[] kb, int offset)
Adjust the parity for a raw key array. This essentially means that each byte in the array will have an odd number of '1' bits (the last bit in each byte is unused.
kb
- The key array, to be parity-adjusted.offset
- The starting index into the key bytes.public static boolean isParityAdjusted(byte[] kb, int offset)
Test if a byte array, which must be at least 8 bytes long, is parity adjusted.
kb
- The key bytes.offset
- The starting index into the key bytes.true
if the first 8 bytes of kb have been
parity adjusted. false
otherwise.public static boolean isWeak(byte[] kb)
Test if a key is a weak key.
kb
- The key to test.true
if the key is weak.public static boolean isSemiWeak(byte[] kb)
Test if a key is a semi-weak key.
kb
- The key to test.true
if this key is semi-weak.public static boolean isPossibleWeak(byte[] kb)
Test if the designated byte array represents a possibly weak key.
kb
- the byte array to test.true
if kb
represents a possibly weak key.
Returns false
otherwise.public java.lang.Object clone()
IBlockCipher
Returns a clone of this instance.
clone
in interface IBlockCipher
clone
in class BaseCipher
public java.util.Iterator blockSizes()
IBlockCipher
Returns an Iterator
over the supported block sizes. Each
element returned by this object is an Integer
.
Iterator
over the supported block sizes.public java.util.Iterator keySizes()
IBlockCipher
Returns an Iterator
over the supported key sizes. Each element
returned by this object is an Integer
.
Iterator
over the supported key sizes.public java.lang.Object makeKey(byte[] kb, int bs) throws java.security.InvalidKeyException
java.security.InvalidKeyException
public void encrypt(byte[] in, int i, byte[] out, int o, java.lang.Object K, int bs)
public void decrypt(byte[] in, int i, byte[] out, int o, java.lang.Object K, int bs)
Copyright © 2025. All rights reserved.