001: package org.bouncycastle.crypto.test;
002:
003: import org.bouncycastle.crypto.engines.SerpentEngine;
004: import org.bouncycastle.crypto.params.KeyParameter;
005: import org.bouncycastle.util.encoders.Hex;
006: import org.bouncycastle.util.test.SimpleTest;
007:
008: /**
009: */
010: public class SerpentTest extends CipherTest {
011: static SimpleTest[] tests = {
012: new BlockCipherVectorTest(
013: 0,
014: new SerpentEngine(),
015: new KeyParameter(
016: Hex
017: .decode("0000000000000000000000000000000000000000000000000000000000000000")),
018: "00000000000000000000000000000000",
019: "8910494504181950f98dd998a82b6749"),
020: new BlockCipherVectorTest(
021: 1,
022: new SerpentEngine(),
023: new KeyParameter(Hex
024: .decode("00000000000000000000000000000000")),
025: "80000000000000000000000000000000",
026: "10b5ffb720b8cb9002a1142b0ba2e94a"),
027: new BlockCipherVectorTest(
028: 2,
029: new SerpentEngine(),
030: new KeyParameter(Hex
031: .decode("00000000000000000000000000000000")),
032: "00000000008000000000000000000000",
033: "4f057a42d8d5bd9746e434680ddcd5e5"),
034: new BlockCipherVectorTest(
035: 3,
036: new SerpentEngine(),
037: new KeyParameter(Hex
038: .decode("00000000000000000000000000000000")),
039: "00000000000000000000400000000000",
040: "99407bf8582ef12550886ef5b6f169b9"),
041: new BlockCipherVectorTest(
042: 4,
043: new SerpentEngine(),
044: new KeyParameter(
045: Hex
046: .decode("000000000000000000000000000000000000000000000000")),
047: "40000000000000000000000000000000",
048: "d522a3b8d6d89d4d2a124fdd88f36896"),
049: new BlockCipherVectorTest(
050: 5,
051: new SerpentEngine(),
052: new KeyParameter(
053: Hex
054: .decode("000000000000000000000000000000000000000000000000")),
055: "00000000000200000000000000000000",
056: "189b8ec3470085b3da97e82ca8964e32"),
057: new BlockCipherVectorTest(
058: 6,
059: new SerpentEngine(),
060: new KeyParameter(
061: Hex
062: .decode("000000000000000000000000000000000000000000000000")),
063: "00000000000000000000008000000000",
064: "f77d868cf760b9143a89809510ccb099"),
065: new BlockCipherVectorTest(
066: 7,
067: new SerpentEngine(),
068: new KeyParameter(
069: Hex
070: .decode("0000000000000000000000000000000000000000000000000000000000000000")),
071: "08000000000000000000000000000000",
072: "d43b7b981b829342fce0e3ec6f5f4c82"),
073: new BlockCipherVectorTest(
074: 8,
075: new SerpentEngine(),
076: new KeyParameter(
077: Hex
078: .decode("0000000000000000000000000000000000000000000000000000000000000000")),
079: "00000000000000000100000000000000",
080: "0bf30e1a0c33ccf6d5293177886912a7"),
081: new BlockCipherVectorTest(
082: 9,
083: new SerpentEngine(),
084: new KeyParameter(
085: Hex
086: .decode("0000000000000000000000000000000000000000000000000000000000000000")),
087: "00000000000000000000000000000001",
088: "6a7f3b805d2ddcba49b89770ade5e507"),
089: new BlockCipherVectorTest(
090: 10,
091: new SerpentEngine(),
092: new KeyParameter(Hex
093: .decode("80000000000000000000000000000000")),
094: "00000000000000000000000000000000",
095: "49afbfad9d5a34052cd8ffa5986bd2dd"),
096: new BlockCipherVectorTest(
097: 11,
098: new SerpentEngine(),
099: new KeyParameter(
100: Hex
101: .decode("000000000000000000000000004000000000000000000000")),
102: "00000000000000000000000000000000",
103: "ba8829b1de058c4b48615d851fc74f17"),
104: new BlockCipherVectorTest(
105: 12,
106: new SerpentEngine(),
107: new KeyParameter(
108: Hex
109: .decode("0000000000000000000000000000000000000000000000000000000100000000")),
110: "00000000000000000000000000000000",
111: "89f64377bf1e8a46c8247044e8056a98"),
112: /*
113: new BlockCipherMonteCarloTest(13, 10000, new SerpentEngine(),
114: new KeyParameter(Hex.decode("47f5f881daab9b67b43bd1342e339c19")),
115: "7a4f7db38c52a8b711b778a38d203b6b", "003380e19f10065740394f48e2fe80b7"),
116: */
117: new BlockCipherMonteCarloTest(
118: 13,
119: 100,
120: new SerpentEngine(),
121: new KeyParameter(Hex
122: .decode("47f5f881daab9b67b43bd1342e339c19")),
123: "7a4f7db38c52a8b711b778a38d203b6b",
124: "4db75303d815c2f7cc6ca935d1c5a046"),
125: /*
126: new BlockCipherMonteCarloTest(14, 10000, new SerpentEngine(),
127: new KeyParameter(Hex.decode("31fba879ebc5e80df35e6fa33eaf92d6")),
128: "70a05e12f74589009692a337f53ff614", "afb5425426906db26b70bdf842ac5400"),
129: */
130: new BlockCipherMonteCarloTest(
131: 14,
132: 100,
133: new SerpentEngine(),
134: new KeyParameter(Hex
135: .decode("31fba879ebc5e80df35e6fa33eaf92d6")),
136: "70a05e12f74589009692a337f53ff614",
137: "fc53a50f4d3bc9836001893d2f41742d"),
138: /*
139: new BlockCipherMonteCarloTest(15, 10000, new SerpentEngine(),
140: new KeyParameter(Hex.decode("bde6dd392307984695aee80e574f9977caae9aa78eda53e8")),
141: "9cc523d034a93740a0aa4e2054bb34d8", "1949d506ada7de1f1344986e8ea049b2"),
142: */
143: new BlockCipherMonteCarloTest(
144: 15,
145: 100,
146: new SerpentEngine(),
147: new KeyParameter(
148: Hex
149: .decode("bde6dd392307984695aee80e574f9977caae9aa78eda53e8")),
150: "9cc523d034a93740a0aa4e2054bb34d8",
151: "77117e6a9e80f40b2a36b7d755573c2d"),
152: /*
153: new BlockCipherMonteCarloTest(16, 10000, new SerpentEngine(),
154: new KeyParameter(Hex.decode("60f6f8ad4290699dc50921a1bbcca92da914e7d9cf01a9317c79c0af8f2487a1")),
155: "ee1a61106fae2d381d686cbf854bab65", "e57f45559027cb1f2ed9603d814e1c34"),
156: */
157: new BlockCipherMonteCarloTest(
158: 16,
159: 100,
160: new SerpentEngine(),
161: new KeyParameter(
162: Hex
163: .decode("60f6f8ad4290699dc50921a1bbcca92da914e7d9cf01a9317c79c0af8f2487a1")),
164: "ee1a61106fae2d381d686cbf854bab65",
165: "dcd7f13ea0dcdfd0139d1a42e2ffb84b") };
166:
167: SerpentTest() {
168: super (tests, new SerpentEngine(),
169: new KeyParameter(new byte[32]));
170: }
171:
172: public String getName() {
173: return "Serpent";
174: }
175:
176: public static void main(String[] args) {
177: runTest(new SerpentTest());
178: }
179: }
|