01: package org.bouncycastle.crypto.test;
02:
03: import org.bouncycastle.crypto.engines.TwofishEngine;
04: import org.bouncycastle.crypto.params.KeyParameter;
05: import org.bouncycastle.util.encoders.Hex;
06: import org.bouncycastle.util.test.SimpleTest;
07:
08: public class TwofishTest extends CipherTest {
09: static String key1 = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
10: static String key2 = "000102030405060708090a0b0c0d0e0f1011121314151617";
11: static String key3 = "000102030405060708090a0b0c0d0e0f";
12:
13: static String input = "000102030405060708090A0B0C0D0E0F";
14:
15: static SimpleTest[] tests = {
16: new BlockCipherVectorTest(0, new TwofishEngine(),
17: new KeyParameter(Hex.decode(key1)), input,
18: "8ef0272c42db838bcf7b07af0ec30f38"),
19: new BlockCipherVectorTest(1, new TwofishEngine(),
20: new KeyParameter(Hex.decode(key2)), input,
21: "95accc625366547617f8be4373d10cd7"),
22: new BlockCipherVectorTest(2, new TwofishEngine(),
23: new KeyParameter(Hex.decode(key3)), input,
24: "9fb63337151be9c71306d159ea7afaa4") };
25:
26: TwofishTest() {
27: super (tests, new TwofishEngine(),
28: new KeyParameter(new byte[32]));
29: }
30:
31: public String getName() {
32: return "Twofish";
33: }
34:
35: public static void main(String[] args) {
36: runTest(new TwofishTest());
37: }
38: }
|