001: package org.bouncycastle.crypto.test;
002:
003: import org.bouncycastle.crypto.engines.RijndaelEngine;
004: import org.bouncycastle.crypto.params.KeyParameter;
005: import org.bouncycastle.util.encoders.Hex;
006: import org.bouncycastle.util.test.SimpleTest;
007:
008: /**
009: * Test vectors from the NIST standard tests and Brian Gladman's vector set
010: * <a href="http://fp.gladman.plus.com/cryptography_technology/rijndael/">
011: * http://fp.gladman.plus.com/cryptography_technology/rijndael/</a>
012: */
013: public class RijndaelTest extends CipherTest {
014: static SimpleTest[] tests = {
015: new BlockCipherVectorTest(
016: 0,
017: new RijndaelEngine(128),
018: new KeyParameter(Hex
019: .decode("80000000000000000000000000000000")),
020: "00000000000000000000000000000000",
021: "0EDD33D3C621E546455BD8BA1418BEC8"),
022: new BlockCipherVectorTest(
023: 1,
024: new RijndaelEngine(128),
025: new KeyParameter(Hex
026: .decode("00000000000000000000000000000080")),
027: "00000000000000000000000000000000",
028: "172AEAB3D507678ECAF455C12587ADB7"),
029: new BlockCipherMonteCarloTest(2, 10000, new RijndaelEngine(
030: 128), new KeyParameter(Hex
031: .decode("00000000000000000000000000000000")),
032: "00000000000000000000000000000000",
033: "C34C052CC0DA8D73451AFE5F03BE297F"),
034: new BlockCipherMonteCarloTest(3, 10000, new RijndaelEngine(
035: 128), new KeyParameter(Hex
036: .decode("5F060D3716B345C253F6749ABAC10917")),
037: "355F697E8B868B65B25A04E18D782AFA",
038: "ACC863637868E3E068D2FD6E3508454A"),
039: new BlockCipherVectorTest(
040: 4,
041: new RijndaelEngine(128),
042: new KeyParameter(
043: Hex
044: .decode("000000000000000000000000000000000000000000000000")),
045: "80000000000000000000000000000000",
046: "6CD02513E8D4DC986B4AFE087A60BD0C"),
047: new BlockCipherMonteCarloTest(
048: 5,
049: 10000,
050: new RijndaelEngine(128),
051: new KeyParameter(
052: Hex
053: .decode("AAFE47EE82411A2BF3F6752AE8D7831138F041560631B114")),
054: "F3F6752AE8D7831138F041560631B114",
055: "77BA00ED5412DFF27C8ED91F3C376172"),
056: new BlockCipherVectorTest(
057: 6,
058: new RijndaelEngine(128),
059: new KeyParameter(
060: Hex
061: .decode("0000000000000000000000000000000000000000000000000000000000000000")),
062: "80000000000000000000000000000000",
063: "DDC6BF790C15760D8D9AEB6F9A75FD4E"),
064: new BlockCipherMonteCarloTest(
065: 7,
066: 10000,
067: new RijndaelEngine(128),
068: new KeyParameter(
069: Hex
070: .decode("28E79E2AFC5F7745FCCABE2F6257C2EF4C4EDFB37324814ED4137C288711A386")),
071: "C737317FE0846F132B23C8C2A672CE22",
072: "E58B82BFBA53C0040DC610C642121168"),
073: new BlockCipherVectorTest(
074: 8,
075: new RijndaelEngine(160),
076: new KeyParameter(Hex
077: .decode("2b7e151628aed2a6abf7158809cf4f3c")),
078: "3243f6a8885a308d313198a2e03707344a409382",
079: "16e73aec921314c29df905432bc8968ab64b1f51"),
080: new BlockCipherVectorTest(
081: 8,
082: new RijndaelEngine(160),
083: new KeyParameter(
084: Hex
085: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160")),
086: "3243f6a8885a308d313198a2e03707344a409382",
087: "0553eb691670dd8a5a5b5addf1aa7450f7a0e587"),
088: new BlockCipherVectorTest(
089: 8,
090: new RijndaelEngine(160),
091: new KeyParameter(
092: Hex
093: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5")),
094: "3243f6a8885a308d313198a2e03707344a409382",
095: "73cd6f3423036790463aa9e19cfcde894ea16623"),
096: new BlockCipherVectorTest(
097: 8,
098: new RijndaelEngine(160),
099: new KeyParameter(
100: Hex
101: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90")),
102: "3243f6a8885a308d313198a2e03707344a409382",
103: "601b5dcd1cf4ece954c740445340bf0afdc048df"),
104: new BlockCipherVectorTest(
105: 8,
106: new RijndaelEngine(160),
107: new KeyParameter(
108: Hex
109: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe")),
110: "3243f6a8885a308d313198a2e03707344a409382",
111: "579e930b36c1529aa3e86628bacfe146942882cf"),
112: new BlockCipherVectorTest(
113: 8,
114: new RijndaelEngine(192),
115: new KeyParameter(Hex
116: .decode("2b7e151628aed2a6abf7158809cf4f3c")),
117: "3243f6a8885a308d313198a2e03707344a4093822299f31d",
118: "b24d275489e82bb8f7375e0d5fcdb1f481757c538b65148a"),
119: new BlockCipherVectorTest(
120: 9,
121: new RijndaelEngine(192),
122: new KeyParameter(
123: Hex
124: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5")),
125: "3243f6a8885a308d313198a2e03707344a4093822299f31d",
126: "725ae43b5f3161de806a7c93e0bca93c967ec1ae1b71e1cf"),
127: new BlockCipherVectorTest(
128: 10,
129: new RijndaelEngine(192),
130: new KeyParameter(
131: Hex
132: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90")),
133: "3243f6a8885a308d313198a2e03707344a4093822299f31d",
134: "bbfc14180afbf6a36382a061843f0b63e769acdc98769130"),
135: new BlockCipherVectorTest(
136: 11,
137: new RijndaelEngine(192),
138: new KeyParameter(
139: Hex
140: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe")),
141: "3243f6a8885a308d313198a2e03707344a4093822299f31d",
142: "0ebacf199e3315c2e34b24fcc7c46ef4388aa475d66c194c"),
143: new BlockCipherVectorTest(
144: 12,
145: new RijndaelEngine(224),
146: new KeyParameter(Hex
147: .decode("2b7e151628aed2a6abf7158809cf4f3c")),
148: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9",
149: "b0a8f78f6b3c66213f792ffd2a61631f79331407a5e5c8d3793aceb1"),
150: new BlockCipherVectorTest(
151: 13,
152: new RijndaelEngine(224),
153: new KeyParameter(
154: Hex
155: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160")),
156: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9",
157: "08b99944edfce33a2acb131183ab0168446b2d15e958480010f545e3"),
158: new BlockCipherVectorTest(
159: 14,
160: new RijndaelEngine(224),
161: new KeyParameter(
162: Hex
163: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5")),
164: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9",
165: "be4c597d8f7efe22a2f7e5b1938e2564d452a5bfe72399c7af1101e2"),
166: new BlockCipherVectorTest(
167: 15,
168: new RijndaelEngine(224),
169: new KeyParameter(
170: Hex
171: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90")),
172: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9",
173: "ef529598ecbce297811b49bbed2c33bbe1241d6e1a833dbe119569e8"),
174: new BlockCipherVectorTest(
175: 16,
176: new RijndaelEngine(224),
177: new KeyParameter(
178: Hex
179: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe")),
180: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9",
181: "02fafc200176ed05deb8edb82a3555b0b10d47a388dfd59cab2f6c11"),
182: new BlockCipherVectorTest(
183: 17,
184: new RijndaelEngine(256),
185: new KeyParameter(Hex
186: .decode("2b7e151628aed2a6abf7158809cf4f3c")),
187: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8",
188: "7d15479076b69a46ffb3b3beae97ad8313f622f67fedb487de9f06b9ed9c8f19"),
189: new BlockCipherVectorTest(
190: 18,
191: new RijndaelEngine(256),
192: new KeyParameter(
193: Hex
194: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160")),
195: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8",
196: "514f93fb296b5ad16aa7df8b577abcbd484decacccc7fb1f18dc567309ceeffd"),
197: new BlockCipherVectorTest(
198: 19,
199: new RijndaelEngine(256),
200: new KeyParameter(
201: Hex
202: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5")),
203: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8",
204: "5d7101727bb25781bf6715b0e6955282b9610e23a43c2eb062699f0ebf5887b2"),
205: new BlockCipherVectorTest(
206: 20,
207: new RijndaelEngine(256),
208: new KeyParameter(
209: Hex
210: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90")),
211: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8",
212: "d56c5a63627432579e1dd308b2c8f157b40a4bfb56fea1377b25d3ed3d6dbf80"),
213: new BlockCipherVectorTest(
214: 21,
215: new RijndaelEngine(256),
216: new KeyParameter(
217: Hex
218: .decode("2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe")),
219: "3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8",
220: "a49406115dfb30a40418aafa4869b7c6a886ff31602a7dd19c889dc64f7e4e7a") };
221:
222: RijndaelTest() {
223: super (tests, new RijndaelEngine(128), new KeyParameter(
224: new byte[16]));
225: }
226:
227: public String getName() {
228: return "Rijndael";
229: }
230:
231: public static void main(String[] args) {
232: runTest(new RijndaelTest());
233: }
234: }
|