01: package org.bouncycastle.crypto.test;
02:
03: import org.bouncycastle.crypto.engines.RC2Engine;
04: import org.bouncycastle.crypto.params.KeyParameter;
05: import org.bouncycastle.crypto.params.RC2Parameters;
06: import org.bouncycastle.util.encoders.Hex;
07:
08: /**
09: * RC2 tester - vectors from ftp://ftp.isi.edu/in-notes/rfc2268.txt
10: *
11: * RFC 2268 "A Description of the RC2(r) Encryption Algorithm"
12: */
13: public class RC2Test extends CipherTest {
14: static BlockCipherVectorTest[] tests = {
15: new BlockCipherVectorTest(0, new RC2Engine(),
16: new RC2Parameters(Hex.decode("0000000000000000"),
17: 63), "0000000000000000", "ebb773f993278eff"),
18:
19: new BlockCipherVectorTest(1, new RC2Engine(),
20: new RC2Parameters(Hex.decode("ffffffffffffffff"),
21: 64), "ffffffffffffffff", "278b27e42e2f0d49"),
22:
23: new BlockCipherVectorTest(2, new RC2Engine(),
24: new RC2Parameters(Hex.decode("3000000000000000"),
25: 64), "1000000000000001", "30649edf9be7d2c2"),
26:
27: new BlockCipherVectorTest(3, new RC2Engine(),
28: new RC2Parameters(Hex.decode("88"), 64),
29: "0000000000000000", "61a8a244adacccf0"),
30:
31: new BlockCipherVectorTest(
32: 4,
33: new RC2Engine(),
34: new RC2Parameters(Hex.decode("88bca90e90875a"), 64),
35: "0000000000000000", "6ccf4308974c267f"),
36:
37: new BlockCipherVectorTest(
38: 5,
39: new RC2Engine(),
40: new RC2Parameters(
41: Hex
42: .decode("88bca90e90875a7f0f79c384627bafb2"),
43: 64), "0000000000000000", "1a807d272bbe5db1"),
44:
45: new BlockCipherVectorTest(
46: 6,
47: new RC2Engine(),
48: new RC2Parameters(
49: Hex
50: .decode("88bca90e90875a7f0f79c384627bafb2"),
51: 128), "0000000000000000",
52: "2269552ab0f85ca6"),
53:
54: new BlockCipherVectorTest(
55: 7,
56: new RC2Engine(),
57: new RC2Parameters(
58: Hex
59: .decode("88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e"),
60: 129), "0000000000000000",
61: "5b78d3a43dfff1f1") };
62:
63: RC2Test() {
64: super (tests, new RC2Engine(), new KeyParameter(new byte[16]));
65: }
66:
67: public String getName() {
68: return "RC2";
69: }
70:
71: public static void main(String[] args) {
72: runTest(new RC2Test());
73: }
74: }
|