View Javadoc
1    /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.commons.crypto.cipher;
19  
20  import java.util.HashMap;
21  import java.util.Map;
22  
23  import org.apache.commons.crypto.utils.AES;
24  
25  public class TestData {
26  
27      private static final String[] CBCNoPaddingTests = {
28      /*
29       * key_len,key,iv,plainText,cipherText
30       */
31              "128", "2b7e151628aed2a6abf7158809cf4f3c",
32              "000102030405060708090a0b0c0d0e0f",
33              "6bc1bee22e409f96e93d7e117393172a",
34              "7649abac8119b246cee98e9b12e9197d",
35  
36              "128", "2b7e151628aed2a6abf7158809cf4f3c",
37              "7649ABAC8119B246CEE98E9B12E9197D",
38              "ae2d8a571e03ac9c9eb76fac45af8e51",
39              "5086cb9b507219ee95db113a917678b2",
40  
41              "192", "603deb1015ca71be2b73aef0857d77811f352c073b6108d7",
42              "9CFC4E967EDB808D679F777BC6702C7D",
43              "30c81c46a35ce411e5fbc1191a0a52ef",
44              "78C57E3F543A18F472756DAC2F018523",
45  
46              "192", "603deb1015ca71be2b73aef0857d77811f352c073b6108d7",
47              "39F23369A9D9BACFA530E26304231461",
48              "f69f2445df4f9b17ad2b417be66c3710",
49              "79ECA9610F0B9AAFB8C7C2D655047A41",
50  
51              "256",
52              "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
53              "000102030405060708090a0b0c0d0e0f",
54              "6bc1bee22e409f96e93d7e117393172a",
55              "f58c4c04d6e5f1ba779eabfb5f7bfbd6",
56  
57              "256",
58              "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
59              "F58C4C04D6E5F1BA779EABFB5F7BFBD6",
60              "ae2d8a571e03ac9c9eb76fac45af8e51",
61              "9cfc4e967edb808d679f777bc6702c7d" };
62  
63      private static final String[] CBCPKCS5PaddingTests = {
64              /*
65               * key_len,key,iv,plainText,cipherText
66               */
67              // Test#0 for input of 6 bytes
68              "128",
69              "ac5800ac3cb59c7c14f36019e43b44fe",
70              "f013ce1ec901b5b60a85a986b3b72eba",
71              "f6cee5ff28fd",
72              "e8a846fd9718507371604504d4ca1ac7",
73  
74              // Test#0 for input of 15 bytes
75              "128",
76              "0784fa652e733cb699f250b0df2c4b41",
77              "106519760fb3ef97e1ccea073b27122d",
78              "6842455a2992c2e5193056a5524075",
79              "56a8e0c3ee3315f913693c0ca781e917",
80  
81              // Test#0 for input of 16 bytes
82              "128",
83              "04952c3fcf497a4d449c41e8730c5d9a",
84              "53549bf7d5553b727458c1abaf0ba167",
85              "c9a44f6f75e98ddbca7332167f5c45e3",
86              "7fa290322ca7a1a04b61a1147ff20fe66fde58510a1d0289d11c0ddf6f4decfd",
87  
88              // Test#0 for input of 32 bytes
89              "128",
90              "2ae7081caebe54909820620a44a60a0f",
91              "fc5e783fbe7be12f58b1f025d82ada50",
92              "1ba93ee6f83752df47909585b3f28e56693f89e169d3093eee85175ea3a46cd3",
93              "7944957a99e473e2c07eb496a83ec4e55db2fb44ebdd42bb611e0def29b23a73ac37eb0f4f5d86f090f3ddce3980425a",
94  
95              // Test#0 for input of 33 bytes
96              "128",
97              "898be9cc5004ed0fa6e117c9a3099d31",
98              "9dea7621945988f96491083849b068df",
99              "0397f4f6820b1f9386f14403be5ac16e50213bd473b4874b9bcbf5f318ee686b1d",
100             "e232cd6ef50047801ee681ec30f61d53cfd6b0bca02fd03c1b234baa10ea82ac9dab8b960926433a19ce6dea08677e34" };
101 
102     private static final String[] cipherCTRTests = {
103             /*
104              * key_len,key,iv,plainText,cipherText
105              */
106             "128",
107             "2b7e151628aed2a6abf7158809cf4f3c",
108             "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
109             "6bc1bee22e409f96e93d7e117393172a",
110             "874d6191b620e3261bef6864990db6ce",
111 
112             "128",
113             "2b7e151628aed2a6abf7158809cf4f3c",
114             "f0f1f2f3f4f5f6f7f8f9fafbfcfdff00",
115             "ae2d8a571e03ac9c9eb76fac45af8e51",
116             "9806f66b7970fdff8617187bb9fffdff",
117 
118             // Test for input of 15 bytes
119             "128", "2b7e151628aed2a6abf7158809cf4f3c",
120             "f0f1f2f3f4f5f6f7f8f9fafbfcfdff01",
121             "30c81c46a35ce411e5fbc1191a0a52", "5ae4df3edbd5d35e5b4f09020db03e",
122 
123             "256",
124             "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
125             "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
126             "6bc1bee22e409f96e93d7e117393172a",
127             "601ec313775789a5b7a7f504bbf3d228",
128 
129             "256",
130             "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
131             "f0f1f2f3f4f5f6f7f8f9fafbfcfdff00",
132             "ae2d8a571e03ac9c9eb76fac45af8e51",
133             "f443e3ca4d62b59aca84e990cacaf5c5",
134 
135             // Test for input of 15 bytes
136             "256",
137             "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
138             "f0f1f2f3f4f5f6f7f8f9fafbfcfdff01",
139             "30c81c46a35ce411e5fbc1191a0a52", "2b0930daa23de94ce87017ba2d8498" };
140 
141     private static final Map<String, String[]> testData = new HashMap<>();
142 
143     static {
144         testData.put(AES.CBC_NO_PADDING, CBCNoPaddingTests);
145         testData.put(AES.CBC_PKCS5_PADDING, CBCPKCS5PaddingTests);
146         testData.put(AES.CTR_NO_PADDING, cipherCTRTests);
147     }
148 
149     public static String[] getTestData(final String transformation) {
150         return testData.get(transformation);
151     }
152 }