demo.cipher
Class DES
java.lang.Object
|
+--demo.cipher.DES
- public class DES
- extends Object
This class tests the correctness of the DES and Triple-DES implementation.
The test data is taken from SSLeay 0.8.0.
Generally the test data consist of plain text, cipher text, key data and - except for
the ECB mode - an initialization vector (iv).
Note that the plain_data, cipher_data and key_data array variables
hold text and key data for the ECB-Mode; all the variable names used by the other modes are
self explanatory.
The test procedure can be devided into an encrypting and decrypting phase:
First the plain data is encrypted according to the selected DES-Mode and
compared with the given cipher data. The encrypting algorithm works correctly
if each block of the cipher data equals to the corresponding block of the encrypted
plain data.
Following this the cipher data is decrypted and compared with the input plain data.
This step prooves the correctness of the decrypting phase.
Constructor Summary |
DES()
|
Method Summary |
static void |
main(String[] arg)
Performs some tests for DES and Triple-DES. |
void |
start()
Tests the several modes (ECB, CBC, PCBC, CFB, OFB, CBC for Triple-DES)
of the DES algorithm. |
boolean |
testECB()
Test the DES - ECB Mode implementation several times. |
boolean |
testMode(String algorithm,
String mode,
byte[] key,
byte[] iv,
byte[] plainData,
byte[] cipherData)
Test the DES implementation in the desired mode. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DES
public DES()
testECB
public boolean testECB()
throws Exception
- Test the DES - ECB Mode implementation several times.
testMode
public boolean testMode(String algorithm,
String mode,
byte[] key,
byte[] iv,
byte[] plainData,
byte[] cipherData)
throws Exception
- Test the DES implementation in the desired mode.
- Parameters:
algorithm
- the implementation to test (DES, 3DES, ...)mode
- the mode of operation (CBC, PCBC, OFB, CFB)key
- the key to useiv
- the initializiation vector to useplainData
- the plainData to encryptcipherData
- the encrypted data to test the correctness
start
public void start()
- Tests the several modes (ECB, CBC, PCBC, CFB, OFB, CBC for Triple-DES)
of the DES algorithm.
main
public static void main(String[] arg)
- Performs some tests for DES and Triple-DES.
IAIK-JCE ME 3.04, (c) 2002 IAIK, (c) 2003 to 2006 Stiftung SIC