01: package org.bouncycastle.crypto.test;
02:
03: import org.bouncycastle.crypto.engines.BlowfishEngine;
04: import org.bouncycastle.crypto.params.KeyParameter;
05: import org.bouncycastle.util.encoders.Hex;
06: import org.bouncycastle.util.test.SimpleTest;
07:
08: /**
09: * blowfish tester - vectors from http://www.counterpane.com/vectors.txt
10: */
11: public class BlowfishTest extends CipherTest {
12: static SimpleTest[] tests = {
13: new BlockCipherVectorTest(0, new BlowfishEngine(),
14: new KeyParameter(Hex.decode("0000000000000000")),
15: "0000000000000000", "4EF997456198DD78"),
16: new BlockCipherVectorTest(1, new BlowfishEngine(),
17: new KeyParameter(Hex.decode("FFFFFFFFFFFFFFFF")),
18: "FFFFFFFFFFFFFFFF", "51866FD5B85ECB8A"),
19: new BlockCipherVectorTest(2, new BlowfishEngine(),
20: new KeyParameter(Hex.decode("3000000000000000")),
21: "1000000000000001", "7D856F9A613063F2"),
22: new BlockCipherVectorTest(3, new BlowfishEngine(),
23: new KeyParameter(Hex.decode("1111111111111111")),
24: "1111111111111111", "2466DD878B963C9D"),
25: new BlockCipherVectorTest(4, new BlowfishEngine(),
26: new KeyParameter(Hex.decode("0123456789ABCDEF")),
27: "1111111111111111", "61F9C3802281B096"),
28: new BlockCipherVectorTest(5, new BlowfishEngine(),
29: new KeyParameter(Hex.decode("FEDCBA9876543210")),
30: "0123456789ABCDEF", "0ACEAB0FC6A0A28D"),
31: new BlockCipherVectorTest(6, new BlowfishEngine(),
32: new KeyParameter(Hex.decode("7CA110454A1A6E57")),
33: "01A1D6D039776742", "59C68245EB05282B"),
34: new BlockCipherVectorTest(7, new BlowfishEngine(),
35: new KeyParameter(Hex.decode("0131D9619DC1376E")),
36: "5CD54CA83DEF57DA", "B1B8CC0B250F09A0"), };
37:
38: BlowfishTest() {
39: super (tests, new BlowfishEngine(), new KeyParameter(
40: new byte[16]));
41: }
42:
43: public String getName() {
44: return "Blowfish";
45: }
46:
47: public static void main(String[] args) {
48: runTest(new BlowfishTest());
49: }
50: }
|