OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / luni / src / test / java / org / apache / harmony / crypto / tests / javax / crypto / EncryptedPrivateKeyInfoTest.java
1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17
18 /**
19 * @author Vladimir N. Molotkov
20 * @version $Revision$
21 */
22
23 package org.apache.harmony.crypto.tests.javax.crypto;
24
25 import dalvik.annotation.TestTargetClass;
26 import dalvik.annotation.TestLevel;
27 import dalvik.annotation.TestTargetNew;
28
29 import java.io.IOException;
30 import java.security.AlgorithmParameters;
31 import java.security.AlgorithmParametersSpi;
32 import java.security.InvalidAlgorithmParameterException;
33 import java.security.InvalidKeyException;
34 import java.security.Key;
35 import java.security.KeyPair;
36 import java.security.KeyPairGenerator;
37 import java.security.NoSuchAlgorithmException;
38 import java.security.NoSuchProviderException;
39 import java.security.Provider;
40 import java.security.Security;
41 import java.security.spec.InvalidKeySpecException;
42 import java.security.spec.InvalidParameterSpecException;
43 import java.security.spec.PKCS8EncodedKeySpec;
44 import java.util.Arrays;
45
46 import javax.crypto.BadPaddingException;
47 import javax.crypto.Cipher;
48 import javax.crypto.EncryptedPrivateKeyInfo;
49 import javax.crypto.IllegalBlockSizeException;
50 import javax.crypto.KeyGenerator;
51 import javax.crypto.NoSuchPaddingException;
52 import javax.crypto.SecretKeyFactory;
53 import javax.crypto.spec.PBEKeySpec;
54 import javax.crypto.spec.PBEParameterSpec;
55
56 import org.apache.harmony.crypto.tests.support.EncryptedPrivateKeyInfoData;
57
58 import junit.framework.TestCase;
59
60 @TestTargetClass(EncryptedPrivateKeyInfo.class)
61 /**
62  * Test for EncryptedPrivateKeyInfo class.
63  *
64  * All binary data for this test were generated using BEA JRockit j2sdk1.4.2_04
65  * (http://www.bea.com) with security providers list extended by Bouncy Castle's
66  * one (http://www.bouncycastle.org)
67  */
68 public class EncryptedPrivateKeyInfoTest extends TestCase {
69
70     private static final Provider[] provider = Security.getProviders();
71
72     /**
73      * Algorithm names/transformations used in roundtrip tests of
74      * getKeySpec(...) methods
75      */
76     private static final String[][] algName = {
77     // AES
78             { "AES", null},
79             //            {"AES", "AES/ECB/PKCS5Padding"},
80             //            {"AES", "AES/CBC/PKCS5Padding"},
81             //            {"AES", "AES/OFB/PKCS5Padding"},
82             //            {"AES", "AES/CFB/PKCS5Padding"},
83             //            {"2.16.840.1.101.3.4.1.1", null},
84             //            {"2.16.840.1.101.3.4.1.2", null},
85             //            {"2.16.840.1.101.3.4.1.3", null},
86             //            {"2.16.840.1.101.3.4.1.4", null},
87             //            {"2.16.840.1.101.3.4.1.5", null},
88             //            {"2.16.840.1.101.3.4.1.21", null},
89             //            {"2.16.840.1.101.3.4.1.22", null},
90             //            {"2.16.840.1.101.3.4.1.23", null},
91             //            {"2.16.840.1.101.3.4.1.24", null},
92             //            {"2.16.840.1.101.3.4.1.25", null},
93             //            {"2.16.840.1.101.3.4.1.41", null},
94             //            {"2.16.840.1.101.3.4.1.42", null},
95             //            {"2.16.840.1.101.3.4.1.43", null},
96             //            {"2.16.840.1.101.3.4.1.44", null},
97             //            {"2.16.840.1.101.3.4.1.45", null},
98
99             // Blowfish
100             // NO OIDs for Blowfish defined (?)
101             { "Blowfish", null },
102             //            {"Blowfish","Blowfish/CBC/PKCS5Padding"},
103             //            {"Blowfish","Blowfish/CFB/PKCS5Padding"},
104             //            {"Blowfish","Blowfish/OFB/PKCS5Padding"},
105             //            {"Blowfish","Blowfish/PCBC/PKCS5Padding"},
106
107             // DES: OIW OIDs only
108             // {iso(1) identified-organization(3) oiw(14) secsig(3)
109             // algorithms(2) desECB(6)}
110             // 1.3.14.3.2.6
111             // 1.3.14.3.2.7
112             // 1.3.14.3.2.8
113             // 1.3.14.3.2.9
114             { "DES", null },
115             //            {"DES", "DES/CBC/PKCS5Padding"},
116             //            {"DES","DES/CFB/PKCS5Padding"},
117             //            {"DES","DES/OFB/PKCS5Padding"},
118             //            {"DES","DES/PCBC/PKCS5Padding"},
119
120             // DESede (=TripleDes)
121             //{iso(1) identified-organization(3) oiw(14) secsig(3)
122             // algorithms(2) desEDE(17)}
123             // 1.3.14.3.2.17
124             //            {"DESede",null},
125             //            {"DESede","DESede/CBC/PKCS5Padding"},
126             //            {"DESede","DESede/CFB/PKCS5Padding"},
127             //            {"DESede","DESede/OFB/PKCS5Padding"},
128             //            {"DESede","DESede/PCBC/PKCS5Padding"},
129             { "TripleDES", null },
130             //            {"TripleDES","TripleDES/CBC/PKCS5Padding"},
131             //            {"TripleDES","TripleDES/CFB/PKCS5Padding"},
132             //            {"TripleDES","TripleDES/OFB/PKCS5Padding"},
133             //            {"TripleDES","TripleDES/PCBC/PKCS5Padding"},
134
135             // PBEWith<digest>And<encryption>
136             { "PBEWithMD5AndTripleDES", null },
137             // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-5(5)
138             // pbeWithMD5AndDES-CBC(3)}
139             { "PBEWithMD5AndDES", "PBEWithMD5AndDES/CBC/PKCS5Padding", "PBEWithMD5AndDES"},
140             { "PBEWithMD5AndDES", null, "PBEWithMD5AndDES"}, { "PBEWithHmacSHA1AndDESede", null },
141             // more oids:
142             // {iso(1) member-body(2) us(840) nortelnetworks(113533) entrust(7)
143             // algorithms(66) pbeWithMD5AndCAST5-CBC(12)}
144             //
145             // also named pbeWithSHAAnd128BitRC4, pbeWithSHA1And128BitRC4:
146             // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12)
147             // pkcs-12-PbeIds(1) pkcs-12-OfflineTransportMode(1)}
148             //
149             // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12)
150             // pkcs-12-PbeIds(1)} +
151             // pbeWithSHAAnd40BitRC4(2) pbeWithSHAAnd3-KeyTripleDES-CBC(3)
152             // pbeWithSHAAnd2-KeyTripleDES-CBC(4) pbeWithSHAAnd128BitRC2-CBC(5)
153             // pbeWithSHAAnd40BitRC2-CBC(6)
154
155             // DiffieHellman
156             { "DiffieHellman", null }, // 1.2.840.10046.2.1
157             //            {"DH",null}, // 1.2.840.10046.2.1
158             //            {"1.2.840.113549.1.3.1", null},
159
160             { "DSA", null }, // 1.2.840.10040.4.1
161
162             { "RC2", null },
163
164             { "RC4", null },
165
166             { "RC5", null },
167
168             //            {"1.2.840.113549.1.12.1.1",null},
169             //            {"1.2.840.113549.1.12.1.2",null},
170             //{ "1.2.840.113549.1.12.1.3", null, "PBEWithSHA1AndDESede"},
171             //{ "PBEWithSHA1AndDESede", null, "PBEWithSHA1AndDESede"},
172     //            {"1.2.840.113549.1.12.1.4",null},
173     //            {"1.2.840.113549.1.12.1.5",null},
174     //            {"1.2.840.113549.1.12.1.6",null},
175     //            {"ELGAMAL/PKCS1", "ELGAMAL/ECB/PKCS1PADDING"},
176     //            {"ELGAMAL/PKCS1","ELGAMAL/NONE/PKCS1PADDING"},
177     //            {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC", null},
178     //            {"PBEWITHSHA1ANDDESEDE", null},
179     //            {"PBEWithSHAAnd3KeyTripleDES",null},
180     //            {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC",null},
181     //
182     //            {"RC5-32",null},
183     //
184     //            {"RSA/1", "RSA/1/PKCS1PADDING"},
185     //            {"RSA/2", "RSA/2/PKCS1PADDING"},
186     //            {"RSA/ISO9796-1", "RSA/ECB/ISO9796-1PADDING"},
187     //            {"RSA", "RSA/ECB/NOPADDING"},
188     //            {"RSA/OAEP", "RSA/ECB/OAEPPADDING"},
189     //            {"RSA/PKCS1", "RSA/ECB/PKCS1PADDING"},
190     //            {"RSA/ISO9796-1", "RSA/NONE/ISO9796-1PADDING"},
191     //            {"RSA", "RSA/NONE/NOPADDING"},
192     //            {"RSA/OAEP", "RSA/NONE/OAEPPADDING"},
193     //            {"RSA/PKCS1", "RSA/NONE/PKCS1PADDING"},
194     //            {"RSA",null}, // 1.2.840.113549.1.1.1
195     //            {"1.2.840.113549.1.1.1", null},
196     };
197
198     @Override protected void setUp() throws Exception {
199         super.setUp();
200     }
201
202     @TestTargetNew(
203         level = TestLevel.COMPLETE,
204         notes = "",
205         method = "getAlgName",
206         args = {}
207     )
208     public void test_getAlgName () {
209         boolean performed = false;
210         for (int i = 0; i < algName.length; i++) {
211             try {
212                 // generate test data
213                 TestDataGenerator g = new TestDataGenerator(algName[i][0],
214                         algName[i][1], privateKeyInfoDamaged, null);
215
216                 // create test object
217                 EncryptedPrivateKeyInfo epki;
218                 if (g.ap() == null) {
219                     epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
220                 } else {
221                     epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
222                 }
223
224                 // call methods under test
225                 if (algName[i].length == 3) {
226                     assertEquals(algName[i][2], epki.getAlgName());
227                 }
228
229                 performed = true;
230             } catch (TestDataGenerator.AllowedFailure allowedFailure) {
231             } catch (NoSuchAlgorithmException allowedFailure) {
232             }
233         }
234         assertTrue("Test not performed", performed);
235     }
236
237     /**
238      * Test #1 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
239      * <br>
240      * Assertion: creates <code>EncryptedPrivateKeyInfo</code> instance <br>
241      * Test preconditions: valid parameters passed <br>
242      * Expected: must pass without any exceptions
243      *
244      * @throws IOException
245      * @throws NoSuchAlgorithmException
246      */
247     @TestTargetNew(
248         level = TestLevel.PARTIAL_COMPLETE,
249         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.",
250         method = "EncryptedPrivateKeyInfo",
251         args = {byte[].class}
252     )
253     public final void testEncryptedPrivateKeyInfobyteArray1() throws Exception {
254         new EncryptedPrivateKeyInfo(EncryptedPrivateKeyInfoData
255                 .getValidEncryptedPrivateKeyInfoEncoding("DH"));
256     }
257
258     /**
259      * Test #2 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
260      * <br>
261      * Assertion: <code>NullPointerException</code> if encoding is
262      * <code>null</code><br>
263      * Test preconditions: <code>null</code> passed as a parameter <br>
264      * Expected: <code>NullPointerException</code>
265      *
266      * @throws IOException
267      */
268     @TestTargetNew(
269         level = TestLevel.PARTIAL_COMPLETE,
270         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.",
271         method = "EncryptedPrivateKeyInfo",
272         args = {byte[].class}
273     )
274     public final void testEncryptedPrivateKeyInfobyteArray2()
275             throws IOException {
276         try {
277             new EncryptedPrivateKeyInfo(null);
278             fail(getName() + ": NullPointerException has not been thrown");
279         } catch (NullPointerException ok) {
280         }
281     }
282
283     /**
284      * Test #3 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
285      * <br>
286      * Assertion: <code>IOException</code> if encoding is wrong <br>
287      * Test preconditions: wrong encoding passed as a parameter <br>
288      * Expected: <code>IOException</code>
289      */
290     @TestTargetNew(
291         level = TestLevel.PARTIAL_COMPLETE,
292         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.",
293         method = "EncryptedPrivateKeyInfo",
294         args = {byte[].class}
295     )
296     public final void testEncryptedPrivateKeyInfobyteArray3() {
297         try {
298             new EncryptedPrivateKeyInfo(new byte[0]);
299             fail(getName() + ": IOException has not been thrown");
300         } catch (IOException ok) {
301         }
302     }
303
304     /**
305      * Test #4 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
306      * <br>
307      * Assertion: <code>IOException</code> if encoding is wrong <br>
308      * Test preconditions: wrong encoding passed as a parameter <br>
309      * Expected: <code>IOException</code>
310      */
311     @TestTargetNew(
312         level = TestLevel.PARTIAL_COMPLETE,
313         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.",
314         method = "EncryptedPrivateKeyInfo",
315         args = {byte[].class}
316     )
317     public final void testEncryptedPrivateKeyInfobyteArray4() {
318         try {
319             new EncryptedPrivateKeyInfo(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9,
320                     10 });
321             fail(getName() + ": IOException has not been thrown");
322         } catch (IOException ok) {
323         }
324     }
325
326     /**
327      * Test #5 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
328      * <br>
329      * Assertion: <code>IOException</code> if encoding is wrong <br>
330      * Test preconditions: wrong encoding passed as a parameter <br>
331      * Expected: <code>IOException</code>
332      */
333     @TestTargetNew(
334         level = TestLevel.PARTIAL_COMPLETE,
335         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.",
336         method = "EncryptedPrivateKeyInfo",
337         args = {byte[].class}
338     )
339     public final void testEncryptedPrivateKeyInfobyteArray5() throws Exception {
340         byte[] enc = null;
341         try {
342             // 1: get valid encoding
343             enc = EncryptedPrivateKeyInfoData
344                     .getValidEncryptedPrivateKeyInfoEncoding("DSA");
345
346             // ... and corrupt it (set wrong alg OID length)
347             enc[9] = (byte) 6;
348
349             new EncryptedPrivateKeyInfo(enc);
350             fail(getName() + "(1): IOException has not been thrown");
351         } catch (IOException ok) {
352         }
353
354         try {
355             // 2: get valid encoding
356             enc = EncryptedPrivateKeyInfoData
357                     .getValidEncryptedPrivateKeyInfoEncoding("DSA");
358             // ... and corrupt it (set wrong encrypted data tag)
359             enc[307] = (byte) 6;
360             new EncryptedPrivateKeyInfo(enc);
361             fail(getName() + "(2): IOException has not been thrown");
362         } catch (IOException ok) {
363         }
364
365         try {
366             // 3: get valid encoding
367             enc = EncryptedPrivateKeyInfoData
368                     .getValidEncryptedPrivateKeyInfoEncoding("DSA");
369             // ... and corrupt it (set wrong encrypted data length)
370             enc[310] = (byte) 1;
371             new EncryptedPrivateKeyInfo(enc);
372             fail(getName() + "(3): IOException has not been thrown");
373         } catch (IOException ok) {
374         }
375
376         try {
377             // 4: get valid encoding
378             enc = EncryptedPrivateKeyInfoData
379                     .getValidEncryptedPrivateKeyInfoEncoding("DSA");
380             // ... and corrupt it (set wrong tag for alg params sequence)
381             enc[17] = (byte) 0x29;
382             EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc);
383
384             if (epki.getAlgParameters() == null) {
385                 // This kind of encoding corruption can
386                 // be only determined while AlgorithmParameters
387                 // initialization BUT No AlgorithmParameters instance
388                 // available for algName0[i][0].
389                 // So just skip this sub test
390             } else {
391                 fail(getName() + "(4): IOException has not been thrown");
392             }
393
394         } catch (IOException ok) {
395         }
396
397         try {
398             // 5: get valid encoding
399             enc = EncryptedPrivateKeyInfoData
400                     .getValidEncryptedPrivateKeyInfoEncoding("DSA");
401             // ... and corrupt it (set wrong length for alg params sequence)
402             enc[20] = (byte) 0x1d;
403             new EncryptedPrivateKeyInfo(enc);
404             fail(getName() + "(5): IOException has not been thrown");
405         } catch (IOException ok) {
406         }
407
408         try {
409             // 6: get valid encoding
410             enc = EncryptedPrivateKeyInfoData
411                     .getValidEncryptedPrivateKeyInfoEncoding("DSA");
412             // ... and corrupt it (set wrong length for alg params sequence)
413             enc[20] = (byte) 0x1f;
414             new EncryptedPrivateKeyInfo(enc);
415             fail(getName() + "(6): IOException has not been thrown");
416         } catch (IOException ok) {
417         }
418     }
419
420     /**
421      * Test #6 for <code>EncryptedPrivateKeyInfo(byte[])</code> constructor
422      * <br>
423      * Assertion: byte array is copied to prevent subsequent modification <br>
424      * Test preconditions: valid array passed then modified <br>
425      * Expected: getEncoded(), invoked after above modification, must return
426      * array as it was before the modification
427      *
428      * @throws IOException
429      */
430     @TestTargetNew(
431         level = TestLevel.PARTIAL_COMPLETE,
432         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(byte[]) constructor.",
433         method = "EncryptedPrivateKeyInfo",
434         args = {byte[].class}
435     )
436     public final void testEncryptedPrivateKeyInfobyteArray6() throws Exception {
437         byte[] encoded = EncryptedPrivateKeyInfoData
438                 .getValidEncryptedPrivateKeyInfoEncoding("DSA");
439         byte[] encodedCopy = encoded.clone();
440         // pass valid array
441         EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(encodedCopy);
442         // modify array passed
443         encodedCopy[9] = (byte) 6;
444         // check that internal state has not been affected
445         assertTrue(Arrays.equals(encoded, epki.getEncoded()));
446     }
447
448     /**
449      * Test #1 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
450      * constructor <br>
451      * Assertion: creates <code>EncryptedPrivateKeyInfo</code> instance <br>
452      * Test preconditions: valid parameters passed <br>
453      * Expected: must pass without any exceptions
454      */
455     @TestTargetNew(
456         level = TestLevel.PARTIAL_COMPLETE,
457         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.",
458         method = "EncryptedPrivateKeyInfo",
459         args = {java.lang.String.class, byte[].class}
460     )
461     public final void testEncryptedPrivateKeyInfoStringbyteArray1() {
462         boolean performed = false;
463
464         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
465             try {
466                 new EncryptedPrivateKeyInfo(
467                         EncryptedPrivateKeyInfoData.algName0[i][0],
468                         EncryptedPrivateKeyInfoData.encryptedData);
469                 performed = true;
470             } catch (NoSuchAlgorithmException allowed) {
471             }
472         }
473
474         assertTrue("Test not performed", performed);
475     }
476
477     /**
478      * Test #2 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
479      * constructor <br>
480      * Assertion: <code>NoSuchAlgorithmException</code>- if the specified
481      * algorithm is not supported <br>
482      * Test preconditions: pass nonexistent algorithm name <br>
483      * Expected: <code>NoSuchAlgorithmException</code>
484      */
485     @TestTargetNew(
486         level = TestLevel.PARTIAL_COMPLETE,
487         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.",
488         method = "EncryptedPrivateKeyInfo",
489         args = {java.lang.String.class, byte[].class}
490     )
491     public final void testEncryptedPrivateKeyInfoStringbyteArray2() {
492         try {
493             new EncryptedPrivateKeyInfo("bla-bla",
494                     EncryptedPrivateKeyInfoData.encryptedData);
495             fail(getName() + ": NoSuchAlgorithmException has not been thrown");
496         } catch (NoSuchAlgorithmException ok) {
497         }
498
499         try {
500             new EncryptedPrivateKeyInfo("",
501                     EncryptedPrivateKeyInfoData.encryptedData);
502             fail(getName() + ": NoSuchAlgorithmException has not been thrown");
503         } catch (NoSuchAlgorithmException ok) {
504         }
505     }
506
507     /**
508      * Test #3 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
509      * constructor <br>
510      * Assertion: <code>NullPointerException</code>- if the specified
511      * algorithm or encrypted data is <code>null</code><br>
512      * Test preconditions: pass <code>null</code> as algorithm name then as
513      * encrypted data <br>
514      * Expected: <code>NullPointerException</code> in both cases
515      *
516      * @throws NoSuchAlgorithmException
517      */
518     @TestTargetNew(
519         level = TestLevel.PARTIAL_COMPLETE,
520         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.",
521         method = "EncryptedPrivateKeyInfo",
522         args = {java.lang.String.class, byte[].class}
523     )
524     public final void testEncryptedPrivateKeyInfoStringbyteArray3()
525             throws NoSuchAlgorithmException {
526         // pass null as name
527         try {
528             new EncryptedPrivateKeyInfo((String) null,
529                     EncryptedPrivateKeyInfoData.encryptedData);
530             fail(getName() + ": NullPointerException has not been thrown");
531         } catch (NullPointerException ok) {
532         }
533
534         // pass null as encrypted data
535         try {
536             new EncryptedPrivateKeyInfo("DSA", null);
537             fail(getName() + ": NullPointerException has not been thrown");
538         } catch (NullPointerException ok) {
539         }
540     }
541
542     /**
543      * Test #4 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
544      * constructor <br>
545      * Assertion: <code>IllegalArgumentException</code>- if encrypted data is
546      * empty, i.e. 0-length <br>
547      * Test preconditions: pass empty encrypted data <br>
548      * Expected: <code>IllegalArgumentException</code>
549      */
550     @TestTargetNew(
551         level = TestLevel.PARTIAL_COMPLETE,
552         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.",
553         method = "EncryptedPrivateKeyInfo",
554         args = {java.lang.String.class, byte[].class}
555     )
556     public final void testEncryptedPrivateKeyInfoStringbyteArray4()
557             throws Exception {
558         try {
559             new EncryptedPrivateKeyInfo("DSA", new byte[] {});
560             fail(getName() + ": IllegalArgumentException has not been thrown");
561         } catch (IllegalArgumentException ok) {
562         }
563     }
564
565     /**
566      * Test #5 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
567      * constructor <br>
568      * Assertion: byte array is copied to prevent subsequent modification <br>
569      * Test preconditions: valid array passed then modified <br>
570      * Expected: getEncryptedData(), invoked after above modification, must
571      * return array as it was before the modification
572      *
573      * @throws IOException
574      */
575     @TestTargetNew(
576         level = TestLevel.PARTIAL_COMPLETE,
577         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.",
578         method = "EncryptedPrivateKeyInfo",
579         args = {java.lang.String.class, byte[].class}
580     )
581     public final void testEncryptedPrivateKeyInfoStringbyteArray5()
582             throws Exception {
583         byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData
584                 .clone();
585         // pass valid array
586         EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("DSA",
587                 encryptedDataCopy);
588         // modify array passed
589         encryptedDataCopy[0] = (byte) 6;
590         // check that internal state has not been affected
591         assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData,
592                 epki.getEncryptedData()));
593     }
594
595     /**
596      * @tests javax/crypto/EncryptedPrivateKeyInfo(String, byte[])
597      * Checks exception order
598      */
599     @TestTargetNew(
600         level = TestLevel.PARTIAL_COMPLETE,
601         notes = "This is a complete subset of tests for EncryptedPrivateKeyInfo(String, byte[]) constructor.",
602         method = "EncryptedPrivateKeyInfo",
603         args = {java.lang.String.class, byte[].class}
604     )
605     public final void testEncryptedPrivateKeyInfoStringbyteArray6() {
606         //Regression for HARMONY-768
607         try {
608             new EncryptedPrivateKeyInfo("0", new byte[] {});
609             fail("NoSuchAlgorithmException expected");
610         } catch (NoSuchAlgorithmException e) {
611             //expected
612         }
613     }
614
615     class Mock_AlgorithmParameters extends AlgorithmParameters {
616         protected Mock_AlgorithmParameters(AlgorithmParametersSpi paramSpi, Provider provider, String algorithm) {
617             super(paramSpi, provider, algorithm);
618         }
619     }
620
621 /**
622      * Test #1 for
623      * <code>EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[])
624      * </code>
625      * constructor <br>
626      * Assertion: creates <code>EncryptedPrivateKeyInfo</code> instance <br>
627      * Test preconditions: valid parameters passed <br>
628      * Expected: must pass without any exceptions
629      *
630      * @throws IOException
631      * @throws NoSuchAlgorithmException
632      */
633     @TestTargetNew(
634         level = TestLevel.PARTIAL_COMPLETE,
635         notes = "Functionality checked. NoSuchAlgorithmException should be tested for complete tests subset.",
636         method = "EncryptedPrivateKeyInfo",
637         args = {java.security.AlgorithmParameters.class, byte[].class}
638     )
639     public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray1()
640             throws IOException, NoSuchAlgorithmException {
641         AlgorithmParameters ap = null;
642
643         boolean performed = false;
644         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
645             try {
646                 ap = AlgorithmParameters
647                         .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
648                 // use pregenerated AlgorithmParameters encodings
649                 ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding(
650                         EncryptedPrivateKeyInfoData.algName0[i][0]));
651
652                 new EncryptedPrivateKeyInfo(ap,
653                         EncryptedPrivateKeyInfoData.encryptedData);
654
655                 performed = true;
656             } catch (NoSuchAlgorithmException allowedFailure) {
657             }
658         }
659         assertTrue("Test not performed", performed);
660
661         ap = new Mock_AlgorithmParameters(null, null, "Wrong alg name");
662
663         try {
664             new EncryptedPrivateKeyInfo(ap,
665                 EncryptedPrivateKeyInfoData.encryptedData);
666             fail("NoSuchAlgorithmException expected");
667         } catch (NoSuchAlgorithmException e) {
668             //expected
669         }
670     }
671
672     /**
673      * Test #2 for
674      * <code>EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[])
675      * </code>
676      * constructor <br>
677      * Assertion: <code>NullPointerException</code>- if the specified
678      * algorithm parameters or encrypted data is <code>null</code><br>
679      * Test preconditions: pass <code>null</code> as algorithm parameters then
680      * as encrypted data <br>
681      * Expected: <code>NullPointerException</code> in both cases
682      *
683      * @throws NoSuchAlgorithmException
684      * @throws IOException
685      */
686     @TestTargetNew(
687         level = TestLevel.PARTIAL_COMPLETE,
688         notes = "NullPointerException checked.",
689         method = "EncryptedPrivateKeyInfo",
690         args = {java.security.AlgorithmParameters.class, byte[].class}
691     )
692     public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray2()
693             throws NoSuchAlgorithmException, IOException {
694         // 1: pass null as AlgorithmParameters
695         try {
696             new EncryptedPrivateKeyInfo((AlgorithmParameters) null,
697                     EncryptedPrivateKeyInfoData.encryptedData);
698             fail(getName() + ": NullPointerException has not been thrown");
699         } catch (NullPointerException ok) {
700         }
701
702         // 2: pass null as encrypted data
703         try {
704             AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
705             // use pregenerated AlgorithmParameters encodings
706             ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));
707             new EncryptedPrivateKeyInfo(ap, null);
708             fail(getName() + ": NullPointerException has not been thrown");
709         } catch (NullPointerException ok) {
710         }
711     }
712
713     /**
714      * Test #3 for
715      * <code>EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[])
716      * </code>
717      * constructor <br>
718      * Assertion: <code>IllegalArgumentException</code>- if encrypted data is
719      * empty, i.e. 0-length <br>
720      * Test preconditions: pass empty encrypted data <br>
721      * Expected: <code>IllegalArgumentException</code>
722      *
723      * @throws NoSuchAlgorithmException
724      * @throws IOException
725      */
726     @TestTargetNew(
727         level = TestLevel.PARTIAL_COMPLETE,
728         notes = "IllegalArgumentException checked.",
729         method = "EncryptedPrivateKeyInfo",
730         args = {java.security.AlgorithmParameters.class, byte[].class}
731     )
732     public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray3()
733             throws Exception {
734         try {
735             AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
736             // use pregenerated AlgorithmParameters encodings
737             ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));
738
739             new EncryptedPrivateKeyInfo(ap, new byte[] {});
740             fail(getName() + ": IllegalArgumentException has not been thrown");
741
742         } catch (IllegalArgumentException ok) {
743         }
744     }
745
746     /**
747      * Test #4 for
748      * <code>EncryptedPrivateKeyInfo(java.security.AlgorithmParameters, byte[])
749      * </code>
750      * constructor <br>
751      * Assertion: byte array is copied to prevent subsequent modification <br>
752      * Test preconditions: valid array passed then modified <br>
753      * Expected: getEncryptedData(), invoked after above modification, must
754      * return array as it was before the modification
755      *
756      * @throws IOException
757      */
758     @TestTargetNew(
759         level = TestLevel.PARTIAL_COMPLETE,
760         notes = "Functionality checked.",
761         method = "EncryptedPrivateKeyInfo",
762         args = {java.security.AlgorithmParameters.class, byte[].class}
763     )
764     public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray4()
765             throws Exception {
766         AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
767         // use pregenerated AlgorithmParameters encodings
768         ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));
769
770         byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData.clone();
771         // pass valid array
772         EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
773                 encryptedDataCopy);
774
775         // modify array passed
776         encryptedDataCopy[0] = (byte) 6;
777
778         // check that internal state has not been affected
779         assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData,
780                 epki.getEncryptedData()));
781     }
782
783     /**
784      * Test #1 for <code>getAlgParameters()</code> method <br>
785      * Assertion: returns the algorithm parameters <br>
786      * Test preconditions: test object created using ctor which takes encoded
787      * form as the only parameter; encoded form passed contains algorithm
788      * parameters encoding <br>
789      * Expected: corresponding algorithm parameters must be returned
790      *
791      * @throws IOException
792      */
793     @TestTargetNew(
794         level = TestLevel.PARTIAL_COMPLETE,
795         notes = "This is a complete subset of tests for getAlgParameters method.",
796         method = "getAlgParameters",
797         args = {}
798     )
799     public final void testGetAlgParameters01() throws IOException {
800         boolean performed = false;
801         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
802             try {
803                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
804                         EncryptedPrivateKeyInfoData
805                                 .getValidEncryptedPrivateKeyInfoEncoding(
806                                         EncryptedPrivateKeyInfoData.algName0[i][0]));
807
808                 AlgorithmParameters apar = epki.getAlgParameters();
809                 if (apar == null) {
810                     continue;
811                 }
812
813                 // check that method under test returns
814                 // parameters with the same encoded form
815                 assertTrue(Arrays
816                         .equals(
817                                 EncryptedPrivateKeyInfoData
818                                         .getParametersEncoding(EncryptedPrivateKeyInfoData.algName0[i][0]),
819                                 apar.getEncoded()));
820                 performed = true;
821             } catch (NoSuchAlgorithmException allowedFailure) {
822             }
823         }
824         assertTrue("Test not performed", performed);
825     }
826
827     @TestTargetNew(
828         level = TestLevel.PARTIAL_COMPLETE,
829         notes = "This is a complete subset of tests for getAlgParameters method.",
830         method = "getAlgParameters",
831         args = {}
832     )
833     public final void testGetAlgParameters01_01() throws Exception {
834         byte[] validEncodingWithUnknownAlgOID = EncryptedPrivateKeyInfoData
835                 .getValidEncryptedPrivateKeyInfoEncoding("DH");
836         // correct oid value
837         validEncodingWithUnknownAlgOID[18] = 0;
838         EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
839                 validEncodingWithUnknownAlgOID);
840
841         assertNull(epki.getAlgParameters());
842     }
843
844     /**
845      * Test #2 for <code>getAlgParameters()</code> method <br>
846      * Assertion: returns the algorithm parameters <br>
847      * Test preconditions: test object created using ctor which takes encoded
848      * form as the only parameter; encoded form passed does not contain
849      * algorithm parameters encoding <br>
850      * Expected: <code>null</code> must be returned
851      *
852      * @throws IOException
853      */
854     @TestTargetNew(
855         level = TestLevel.PARTIAL_COMPLETE,
856         notes = "This is a complete subset of tests for getAlgParameters method.",
857         method = "getAlgParameters",
858         args = {}
859     )
860     public final void testGetAlgParameters02() throws IOException {
861         boolean performed = false;
862         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
863             try {
864                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
865                         EncryptedPrivateKeyInfoData
866                                 .getValidEncryptedPrivateKeyInfoEncoding(
867                                         EncryptedPrivateKeyInfoData.algName0[i][0],
868                                         false));
869
870                 // check that method under test returns null
871                 assertNull(epki.getAlgParameters());
872
873                 performed = true;
874             } catch (NoSuchAlgorithmException allowedFailure) {
875             }
876         }
877         assertTrue("Test not performed", performed);
878     }
879
880     /**
881      * Test #3 for <code>getAlgParameters()</code> method <br>
882      * Assertion: returns the algorithm parameters <br>
883      * Test #6 for <code>EncryptedPrivateKeyInfo(String, byte[])</code>
884      * constructor <br>
885      * Assertion: ...This constructor will use null as the value of the
886      * algorithm parameters. <br>
887      * Test preconditions: test object created using ctor which takes algorithm
888      * name and encrypted data as a parameters <br>
889      * Expected: <code>null</code> must be returned
890      *
891      * @throws IOException
892      */
893     @TestTargetNew(
894         level = TestLevel.PARTIAL_COMPLETE,
895         notes = "This is a complete subset of tests for getAlgParameters method.",
896         method = "getAlgParameters",
897         args = {}
898     )
899     public final void testGetAlgParameters03() throws IOException {
900         boolean performed = false;
901         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
902             try {
903                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
904                         EncryptedPrivateKeyInfoData.algName0[i][0],
905                         EncryptedPrivateKeyInfoData.encryptedData);
906
907                 // check that method under test returns null
908                 // for object constructed in such a way
909                 assertNull(epki.getAlgParameters());
910
911                 performed = true;
912             } catch (NoSuchAlgorithmException allowedFailure) {
913             }
914         }
915         assertTrue("Test not performed", performed);
916     }
917
918     /**
919      * Test #4 for <code>getAlgParameters()</code> method <br>
920      * Assertion: returns the algorithm parameters <br>
921      * Test preconditions: test object created using ctor which takes
922      * AlgorithmParameters and encrypted data as a parameters; <br>
923      * Expected: the same algorithm parameters as ones passed to the ctor must be
924      * returned
925      *
926      * @throws IOException
927      */
928     @TestTargetNew(
929         level = TestLevel.PARTIAL_COMPLETE,
930         notes = "This is a complete subset of tests for getAlgParameters method.",
931         method = "getAlgParameters",
932         args = {}
933     )
934     public final void testGetAlgParameters04() throws IOException {
935         boolean performed = false;
936         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
937             try {
938                 AlgorithmParameters ap = AlgorithmParameters
939                         .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
940                 // use pregenerated AlgorithmParameters encodings
941                 ap
942                         .init(EncryptedPrivateKeyInfoData
943                                 .getParametersEncoding(
944                                         EncryptedPrivateKeyInfoData.algName0[i][0]));
945
946                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
947                         EncryptedPrivateKeyInfoData.encryptedData);
948
949                 // check that method under test returns
950                 // the same parameters instance
951                 assertSame(ap, epki.getAlgParameters());
952
953                 performed = true;
954             } catch (NoSuchAlgorithmException allowedFailure) {
955             }
956         }
957         assertTrue("Test not performed", performed);
958     }
959
960     /**
961      * Test #1 for <code>getEncryptedData()</code> method <br>
962      * Assertion: returns the encrypted data <br>
963      * Test preconditions: test object created using ctor which takes encoded
964      * form as the only parameter; encoded form passed contains encrypted data
965      * <br>
966      * Expected: the equivalent encrypted data must be returned
967      *
968      * @throws IOException
969      */
970     @TestTargetNew(
971         level = TestLevel.PARTIAL_COMPLETE,
972         notes = "This is a complete subset of tests for getEncryptedData method.",
973         method = "getEncryptedData",
974         args = {}
975     )
976     public final void testGetEncryptedData01() throws IOException {
977         boolean performed = false;
978         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
979             try {
980                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
981                         EncryptedPrivateKeyInfoData
982                                 .getValidEncryptedPrivateKeyInfoEncoding(
983                                         EncryptedPrivateKeyInfoData.algName0[i][0]));
984
985                 // check that method under test returns
986                 // valid encrypted data
987                 assertTrue(Arrays.equals(
988                         EncryptedPrivateKeyInfoData.encryptedData, epki
989                                 .getEncryptedData()));
990
991                 performed = true;
992             } catch (NoSuchAlgorithmException allowedFailure) {
993             }
994         }
995         assertTrue("Test not performed", performed);
996     }
997
998     /**
999      * Test #2 for <code>getEncryptedData()</code> method <br>
1000      * Assertion: returns the encrypted data <br>
1001      * Test preconditions: test object created using ctor which takes algorithm
1002      * name and encrypted data as a parameters <br>
1003      * Expected: the equivalent encrypted data must be returned
1004      */
1005     @TestTargetNew(
1006         level = TestLevel.PARTIAL_COMPLETE,
1007         notes = "This is a complete subset of tests for getEncryptedData method.",
1008         method = "getEncryptedData",
1009         args = {}
1010     )
1011     public final void testGetEncryptedData02() {
1012         boolean performed = false;
1013         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1014             try {
1015                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
1016                         EncryptedPrivateKeyInfoData.algName0[i][0],
1017                         EncryptedPrivateKeyInfoData.encryptedData);
1018
1019                 // check that method under test returns
1020                 // valid encrypted data
1021                 assertTrue(Arrays.equals(
1022                         EncryptedPrivateKeyInfoData.encryptedData, epki
1023                                 .getEncryptedData()));
1024
1025                 performed = true;
1026             } catch (NoSuchAlgorithmException allowedFailure) {
1027             }
1028         }
1029         assertTrue("Test not performed", performed);
1030     }
1031
1032     /**
1033      * Test #3 for <code>getEncryptedData()</code> method <br>
1034      * Assertion: returns the encrypted data <br>
1035      * Test preconditions: test object created using ctor which takes algorithm
1036      * parameters and encrypted data as a parameters <br>
1037      * Expected: the equivalent encrypted data must be returned
1038      *
1039      * @throws IOException
1040      */
1041     @TestTargetNew(
1042         level = TestLevel.PARTIAL_COMPLETE,
1043         notes = "This is a complete subset of tests for getEncryptedData method.",
1044         method = "getEncryptedData",
1045         args = {}
1046     )
1047     public final void testGetEncryptedData03() throws IOException {
1048         boolean performed = false;
1049         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1050             try {
1051                 AlgorithmParameters ap = AlgorithmParameters
1052                         .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
1053                 // use pregenerated AlgorithmParameters encodings
1054                 ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding(
1055                         EncryptedPrivateKeyInfoData.algName0[i][0]));
1056
1057                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
1058                         EncryptedPrivateKeyInfoData.encryptedData);
1059
1060                 // check that method under test returns
1061                 // valid encrypted data
1062                 assertTrue(Arrays.equals(
1063                         EncryptedPrivateKeyInfoData.encryptedData, epki
1064                                 .getEncryptedData()));
1065
1066                 performed = true;
1067             } catch (NoSuchAlgorithmException allowedFailure) {
1068             }
1069         }
1070         assertTrue("Test not performed", performed);
1071     }
1072
1073     /**
1074      * Test #4 for <code>getEncryptedData()</code> method <br>
1075      * Assertion: returns a new array each time this method is called <br>
1076      * Test preconditions: test object created using ctor which takes algorithm
1077      * name and encrypted data as a parameters <br>
1078      * Expected: refs to encrypted data byte array passed to the ctor and
1079      * returned by the method under test must be different
1080      */
1081     @TestTargetNew(
1082         level = TestLevel.PARTIAL_COMPLETE,
1083         notes = "This is a complete subset of tests for getEncryptedData method.",
1084         method = "getEncryptedData",
1085         args = {}
1086     )
1087     public final void testGetEncryptedData04() {
1088         boolean performed = false;
1089         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1090             try {
1091                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
1092                         EncryptedPrivateKeyInfoData.algName0[i][0],
1093                         EncryptedPrivateKeyInfoData.encryptedData);
1094
1095                 // check that method under test returns
1096                 // new array each time
1097                 byte[] ecd1 = epki.getEncryptedData();
1098                 byte[] ecd2 = epki.getEncryptedData();
1099                 assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd1);
1100                 assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd2);
1101                 assertNotSame(ecd1, ecd2);
1102
1103                 performed = true;
1104             } catch (NoSuchAlgorithmException allowedFailure) {
1105             }
1106         }
1107         assertTrue("Test not performed", performed);
1108     }
1109
1110     /**
1111      * Test #1 for <code>getEncoded()</code> method <br>
1112      * Assertion: returns the ASN.1 encoding of this object <br>
1113      * Test preconditions: test object created using ctor which takes encoded
1114      * form as the only parameter <br>
1115      * Expected: equivalent encoded form must be returned
1116      *
1117      * @throws IOException
1118      */
1119     @TestTargetNew(
1120         level = TestLevel.PARTIAL_COMPLETE,
1121         notes = "Can not check IOException",
1122         method = "getEncoded",
1123         args = {}
1124     )
1125     public final void testGetEncoded01() throws IOException {
1126         boolean performed = false;
1127         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1128             try {
1129                 byte[] enc = EncryptedPrivateKeyInfoData
1130                         .getValidEncryptedPrivateKeyInfoEncoding(
1131                                 EncryptedPrivateKeyInfoData.algName0[i][0]);
1132                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc);
1133
1134                 // check that method under test returns
1135                 // valid encoded form
1136                 assertTrue(Arrays.equals(enc, epki.getEncoded()));
1137
1138                 performed = true;
1139             } catch (NoSuchAlgorithmException allowedFailure) {
1140             }
1141         }
1142         assertTrue("Test not performed", performed);
1143     }
1144
1145     /**
1146      * Test #2 for <code>getEncoded()</code> method <br>
1147      * Assertion: returns the ASN.1 encoding of this object <br>
1148      * Test preconditions: test object created using ctor which takes algorithm
1149      * name and encrypted data as a parameters <br>
1150      * Expected: equivalent encoded form (without alg params) must be returned
1151      *
1152      * @throws IOException
1153      */
1154     @TestTargetNew(
1155         level = TestLevel.PARTIAL_COMPLETE,
1156         notes = "Can not check IOException",
1157         method = "getEncoded",
1158         args = {}
1159     )
1160     public final void testGetEncoded02() throws IOException {
1161         boolean performed = false;
1162         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1163             try {
1164                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
1165                         EncryptedPrivateKeyInfoData.algName0[i][0],
1166                         EncryptedPrivateKeyInfoData.encryptedData);
1167
1168                 // check that method under test returns
1169                 // valid encoded form
1170                 byte[] refEnc = EncryptedPrivateKeyInfoData
1171                         .getValidEncryptedPrivateKeyInfoEncoding(
1172                                 EncryptedPrivateKeyInfoData.algName0[i][0],
1173                                 false);
1174                 //                System.out.println(Array.toString(refEnc, " "));
1175                 byte[] actEnc = epki.getEncoded();
1176                 //                System.out.println(Array.toString(actEnc, " "));
1177                 assertTrue(Arrays.equals(refEnc, actEnc));
1178
1179                 performed = true;
1180             } catch (NoSuchAlgorithmException allowedFailure) {
1181             }
1182         }
1183         assertTrue("Test not performed", performed);
1184     }
1185
1186     /**
1187      * Test #3 for <code>getEncoded()</code> method <br>
1188      * Assertion: returns the ASN.1 encoding of this object <br>
1189      * Test preconditions: test object created using ctor which takes algorithm
1190      * name and encrypted data as a parameters <br>
1191      * Expected: equivalent encoded form (without alg params) must be returned
1192      *
1193      * @throws IOException
1194      */
1195     @TestTargetNew(
1196         level = TestLevel.PARTIAL_COMPLETE,
1197         notes = "Can not check IOException",
1198         method = "getEncoded",
1199         args = {}
1200     )
1201     public final void testGetEncoded03() throws IOException {
1202         boolean performed = false;
1203         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1204             try {
1205                 AlgorithmParameters ap = AlgorithmParameters
1206                         .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
1207                 // use pregenerated AlgorithmParameters encodings
1208                 ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding(
1209                         EncryptedPrivateKeyInfoData.algName0[i][0]));
1210
1211                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
1212                         EncryptedPrivateKeyInfoData.encryptedData);
1213
1214                 // check that method under test returns
1215                 // valid encoded form
1216                 assertTrue(Arrays.equals(
1217                         EncryptedPrivateKeyInfoData
1218                             .getValidEncryptedPrivateKeyInfoEncoding(
1219                                 EncryptedPrivateKeyInfoData.algName0[i][0]),
1220                                 epki.getEncoded()));
1221
1222                 performed = true;
1223             } catch (NoSuchAlgorithmException allowedFailure) {
1224             }
1225         }
1226         assertTrue("Test not performed", performed);
1227     }
1228
1229     /**
1230      * Test #4 for <code>getEncoded()</code> method <br>
1231      * Assertion: returns a new array each time this method is called <br>
1232      * Test preconditions: test object created using ctor which takes algorithm
1233      * name and encrypted data as a parameters <br>
1234      * Expected: several refs to byte array returned by the method under test
1235      * must be different
1236      *
1237      * @throws IOException
1238      */
1239     @TestTargetNew(
1240         level = TestLevel.PARTIAL_COMPLETE,
1241         notes = "Can not check IOException",
1242         method = "getEncoded",
1243         args = {}
1244     )
1245     public final void testGetEncoded04() throws IOException {
1246         boolean performed = false;
1247         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1248             try {
1249                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
1250                         EncryptedPrivateKeyInfoData.algName0[i][0],
1251                         EncryptedPrivateKeyInfoData.encryptedData);
1252
1253                 // check that method under test returns
1254                 // new array each time
1255                 byte[] ec1 = epki.getEncoded();
1256                 byte[] ec2 = epki.getEncoded();
1257                 byte[] ec3 = epki.getEncoded();
1258                 assertNotSame(ec1, ec2);
1259                 assertNotSame(ec2, ec3);
1260                 assertNotSame(ec1, ec3);
1261
1262                 performed = true;
1263             } catch (NoSuchAlgorithmException allowedFailure) {
1264             }
1265         }
1266         assertTrue("Test not performed", performed);
1267     }
1268
1269     @TestTargetNew(
1270         level = TestLevel.PARTIAL_COMPLETE,
1271         notes = "This is a complete subset of tests for getKeySpec method.",
1272         method = "getKeySpec",
1273         args = {javax.crypto.Cipher.class}
1274     )
1275     public final void testGetKeySpecCipher01() {
1276         boolean performed = false;
1277         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1278             try {
1279                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
1280                         EncryptedPrivateKeyInfoData.algName0[i][0],
1281                         EncryptedPrivateKeyInfoData.encryptedData);
1282
1283                 try {
1284
1285                     // check that method under test throws NPE
1286                     epki.getKeySpec((Cipher) null);
1287                     fail(getName() + "NullPointerException has not been thrown");
1288
1289                 } catch (NullPointerException ok) {
1290                 } catch (InvalidKeySpecException e) {
1291                     fail(getName() + "Unexpected exception: " + e);
1292                 }
1293
1294                 performed = true;
1295             } catch (NoSuchAlgorithmException allowedFailure) {
1296             }
1297         }
1298         assertTrue("Test not performed", performed);
1299     }
1300
1301     /**
1302      * Encrypted data contains valid PKCS8 key info encoding
1303      */
1304     @TestTargetNew(
1305         level = TestLevel.PARTIAL_COMPLETE,
1306         notes = "This is a complete subset of tests for getKeySpec method.",
1307         method = "getKeySpec",
1308         args = {javax.crypto.Cipher.class}
1309     )
1310     public final void test_ROUNDTRIP_GetKeySpecCipher01() {
1311         boolean performed = false;
1312
1313         for (int i = 0; i < algName.length; i++) {
1314             try {
1315                 // generate test data
1316                 TestDataGenerator g = new TestDataGenerator(algName[i][0],
1317                         algName[i][1], privateKeyInfo, null);
1318
1319                 // create test object
1320                 EncryptedPrivateKeyInfo epki;
1321                 if (g.ap() == null) {
1322                     epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
1323                 } else {
1324                     epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
1325                 }
1326
1327                 // call methods under test
1328                 try {
1329
1330                     PKCS8EncodedKeySpec eks = epki.getKeySpec(g.c());
1331
1332                     if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
1333                         fail(algName[i][0] + " != " + algName[i][1]);
1334                     }
1335                 } catch (InvalidKeySpecException e) {
1336                     fail(algName[i][0] + ", " + algName[i][1] + e + "\n");
1337                 }
1338                 performed = true;
1339
1340             } catch (TestDataGenerator.AllowedFailure allowedFailure) {
1341             } catch (NoSuchAlgorithmException allowed) {
1342             }
1343         }
1344         assertTrue("Test not performed", performed);
1345     }
1346
1347     /**
1348      * Encrypted data contains invalid PKCS8 key info encoding
1349      */
1350     @TestTargetNew(
1351         level = TestLevel.PARTIAL_COMPLETE,
1352         notes = "This is a complete subset of tests for getKeySpec method.",
1353         method = "getKeySpec",
1354         args = {javax.crypto.Cipher.class}
1355     )
1356     public final void test_ROUNDTRIP_GetKeySpecCipher02() {
1357         boolean performed = false;
1358         for (int i = 0; i < algName.length; i++) {
1359             try {
1360                 // generate test data
1361                 TestDataGenerator g = new TestDataGenerator(algName[i][0],
1362                         algName[i][1], privateKeyInfoDamaged, null);
1363
1364                 // create test object
1365                 EncryptedPrivateKeyInfo epki;
1366                 if (g.ap() == null) {
1367                     epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
1368                 } else {
1369                     epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
1370                 }
1371
1372                 // call methods under test
1373                 try {
1374                     epki.getKeySpec(g.c());
1375
1376                     // must not get here because decrypted data does
1377                     // not represent valid PKCS8 encoding
1378                     fail(algName[i][0] + ", " + algName[i][1]);
1379                 } catch (InvalidKeySpecException ok) {
1380                 }
1381
1382                 performed = true;
1383             } catch (TestDataGenerator.AllowedFailure allowedFailure) {
1384             } catch (NoSuchAlgorithmException allowedFailure) {
1385             }
1386         }
1387         assertTrue("Test not performed", performed);
1388     }
1389
1390     @TestTargetNew(
1391         level = TestLevel.PARTIAL_COMPLETE,
1392         notes = "Can not check NoSuchAlgorithmException",
1393         method = "getKeySpec",
1394         args = {java.security.Key.class}
1395     )
1396     public final void testGetKeySpecKey01() {
1397         boolean performed = false;
1398         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1399             try {
1400                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
1401                         EncryptedPrivateKeyInfoData.algName0[i][0],
1402                         EncryptedPrivateKeyInfoData.encryptedData);
1403
1404                 try {
1405
1406                     // check that method under test throws NPE
1407                     epki.getKeySpec((Key) null);
1408                     fail(getName() + "NullPointerException has not been thrown");
1409
1410                 } catch (NullPointerException ok) {
1411                 } catch (InvalidKeyException e) {
1412                     fail(getName() + "Unexpected exception: " + e);
1413                 }
1414
1415                 performed = true;
1416             } catch (NoSuchAlgorithmException allowedFailure) {
1417             }
1418         }
1419         assertTrue("Test not performed", performed);
1420     }
1421
1422     /**
1423      * Encrypted data contains valid PKCS8 key info encoding
1424      */
1425     @TestTargetNew(
1426         level = TestLevel.PARTIAL_COMPLETE,
1427         notes = "Can not check NoSuchAlgorithmException",
1428         method = "getKeySpec",
1429         args = {java.security.Key.class}
1430     )
1431     public final void test_ROUNDTRIP_GetKeySpecKey01() {
1432         boolean performed = false;
1433         for (int i = 0; i < algName.length; i++) {
1434             try {
1435                 // generate test data
1436                 TestDataGenerator g = new TestDataGenerator(algName[i][0],
1437                         algName[i][1], privateKeyInfo, null);
1438
1439                 // create test object
1440                 EncryptedPrivateKeyInfo epki;
1441                 if (g.ap() == null) {
1442                     epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
1443                 } else {
1444                     epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
1445                 }
1446
1447                 try {
1448                     PKCS8EncodedKeySpec eks = epki
1449                             .getKeySpec(g.pubK() == null ? g.k() : g.pubK());
1450
1451                     if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
1452                         fail(algName[i][0] + " != " + algName[i][1]);
1453                     }
1454                 } catch (InvalidKeyException e) {
1455                     fail(algName[i][0] + ", " + algName[i][1] + ": " + e);
1456                 }
1457
1458                 performed = true;
1459             } catch (TestDataGenerator.AllowedFailure allowedFailure) {
1460             } catch (NoSuchAlgorithmException allowedFailure) {
1461             }
1462         }
1463         assertTrue("Test not performed", performed);
1464     }
1465
1466     /**
1467      * Encrypted data contains invalid PKCS8 key info encoding
1468      */
1469     @TestTargetNew(
1470         level = TestLevel.PARTIAL_COMPLETE,
1471         notes = "Can not check NoSuchAlgorithmException",
1472         method = "getKeySpec",
1473         args = {java.security.Key.class}
1474     )
1475     public final void test_ROUNDTRIP_GetKeySpecKey02() {
1476         boolean performed = false;
1477         for (int i = 0; i < algName.length; i++) {
1478             try {
1479                 // generate test data
1480                 TestDataGenerator g = new TestDataGenerator(algName[i][0],
1481                         algName[i][1], privateKeyInfoDamaged, null);
1482
1483                 // create test object
1484                 EncryptedPrivateKeyInfo epki;
1485                 if (g.ap() == null) {
1486                     epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
1487                 } else {
1488                     epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
1489                 }
1490
1491                 try {
1492                     epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK());
1493                     fail(algName[i][0] + ", " + algName[i][1]);
1494                 } catch (InvalidKeyException e) {
1495                 }
1496
1497                 performed = true;
1498             } catch (TestDataGenerator.AllowedFailure allowedFailure) {
1499             } catch (NoSuchAlgorithmException allowedFailure) {
1500             }
1501         }
1502         assertTrue("Test not performed", performed);
1503     }
1504
1505     @TestTargetNew(
1506         level = TestLevel.PARTIAL_COMPLETE,
1507         notes = "NoSuchAlgorithmException can not be checking",
1508         method = "getKeySpec",
1509         args = {java.security.Key.class, java.lang.String.class}
1510     )
1511     public final void testGetKeySpecKeyString01() throws Exception {
1512         boolean performed = false;
1513         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1514             try {
1515                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
1516                         EncryptedPrivateKeyInfoData.algName0[i][0],
1517                         EncryptedPrivateKeyInfoData.encryptedData);
1518
1519                 try {
1520                     // check that method under test throws NPE
1521                     epki.getKeySpec((Key) null, "SomeProviderName");
1522                     fail(getName() + "NullPointerException has not been thrown");
1523
1524                 } catch (NullPointerException ok) {
1525                 }
1526
1527                 try {
1528                     epki.getKeySpec(new Key() {
1529                         public String getAlgorithm() {
1530                             return "alg";
1531                         }
1532
1533                         public String getFormat() {
1534                             return "fmt";
1535                         }
1536
1537                         public byte[] getEncoded() {
1538                             return new byte[] {};
1539                         }
1540                     }, "StrangeProviderName");
1541                     fail(getName() + "NoSuchProviderException has not been thrown");
1542                 } catch (NoSuchProviderException ok) {
1543                     //expected
1544                 }
1545
1546                 try {
1547
1548                     // check that method under test throws NPE
1549                     epki.getKeySpec(new Key() {
1550                         public String getAlgorithm() {
1551                             return "alg";
1552                         }
1553
1554                         public String getFormat() {
1555                             return "fmt";
1556                         }
1557
1558                         public byte[] getEncoded() {
1559                             return new byte[] {};
1560                         }
1561                     }, (String) null);
1562
1563                     fail(getName() + "NullPointerException has not been thrown");
1564
1565                 } catch (NullPointerException ok) {
1566                 }
1567
1568                 performed = true;
1569             } catch (NoSuchAlgorithmException allowedFailure) {
1570             }
1571         }
1572         assertTrue("Test not performed", performed);
1573     }
1574
1575     /**
1576      * Encrypted data contains valid PKCS8 key info encoding
1577      */
1578     @TestTargetNew(
1579         level = TestLevel.PARTIAL_COMPLETE,
1580         notes = "In subset missed NoSuchProviderException & NoSuchAlgorithmException checking",
1581         method = "getKeySpec",
1582         args = {java.security.Key.class, java.lang.String.class}
1583     )
1584     public final void test_ROUNDTRIP_GetKeySpecKeyString01() throws Exception {
1585         boolean performed = false;
1586         for (int i = 0; i < algName.length; i++) {
1587             for (int l = 0; l < provider.length; l++) {
1588                 if (provider[l] == null) {
1589                     continue;
1590                 }
1591                 TestDataGenerator g;
1592                 try {
1593                     // generate test data
1594                     g = new TestDataGenerator(algName[i][0], algName[i][1],
1595                             privateKeyInfo, provider[l]);
1596                 } catch (TestDataGenerator.AllowedFailure allowedFailure) {
1597                     continue;
1598                 }
1599
1600                 try {
1601                     // create test object
1602                     EncryptedPrivateKeyInfo epki;
1603                     if (g.ap() == null) {
1604                         epki = new EncryptedPrivateKeyInfo(algName[i][0], g
1605                                 .ct());
1606                     } else {
1607                         epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
1608                     }
1609                     try {
1610
1611                         PKCS8EncodedKeySpec eks = epki.getKeySpec(
1612                                 g.pubK() == null ? g.k() : g.pubK(),
1613                                 provider[l].getName());
1614
1615                         if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
1616                             fail(algName[i][0] + " != " + algName[i][1]);
1617                         }
1618                     } catch (InvalidKeyException e) {
1619                         fail(algName[i][0] + ", " + algName[i][1] + ": " + e);
1620                     }
1621
1622                     performed = true;
1623                 } catch (NoSuchAlgorithmException allowedFailure) {
1624                 }
1625             }
1626         }
1627         assertTrue("Test not performed", performed);
1628     }
1629
1630     /**
1631      * Encrypted data contains invalid PKCS8 key info encoding
1632      */
1633     @TestTargetNew(
1634         level = TestLevel.PARTIAL_COMPLETE,
1635         notes = "In subset missed NoSuchProviderException & NoSuchAlgorithmException checking",
1636         method = "getKeySpec",
1637         args = {java.security.Key.class, java.lang.String.class}
1638     )
1639     public final void test_ROUNDTRIP_GetKeySpecKeyString02() throws Exception {
1640         boolean performed = false;
1641         for (int i = 0; i < algName.length; i++) {
1642             for (int l = 0; l < provider.length; l++) {
1643                 if (provider[l] == null) {
1644                     continue;
1645                 }
1646                 TestDataGenerator g;
1647                 try {
1648                     // generate test data
1649                     g = new TestDataGenerator(algName[i][0], algName[i][1],
1650                             privateKeyInfoDamaged, provider[l]);
1651                 } catch (TestDataGenerator.AllowedFailure allowedFailure) {
1652                     continue;
1653                 }
1654
1655                 try {
1656                     // create test object
1657                     EncryptedPrivateKeyInfo epki;
1658                     if (g.ap() == null) {
1659                         epki = new EncryptedPrivateKeyInfo(algName[i][0], g
1660                                 .ct());
1661                     } else {
1662                         epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
1663                     }
1664
1665                     try {
1666
1667                         epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK(),
1668                                 provider[l].getName());
1669
1670                         fail(algName[i][0] + ", " + algName[i][1]);
1671
1672                     } catch (InvalidKeyException e) {
1673                     }
1674
1675                     performed = true;
1676                 } catch (NoSuchAlgorithmException allowedFailure) {
1677                 }
1678             }
1679         }
1680         assertTrue("Test not performed", performed);
1681     }
1682
1683     @TestTargetNew(
1684         level = TestLevel.PARTIAL_COMPLETE,
1685         notes = "Can not check NoSuchAlgorithmException",
1686         method = "getKeySpec",
1687         args = {java.security.Key.class, java.security.Provider.class}
1688     )
1689     public final void testGetKeySpecKeyProvider01() throws Exception {
1690         boolean performed = false;
1691
1692         for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
1693             try {
1694                 EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
1695                         EncryptedPrivateKeyInfoData.algName0[i][0],
1696                         EncryptedPrivateKeyInfoData.encryptedData);
1697
1698                 try {
1699
1700                     // check that method under test throws NPE
1701                     epki.getKeySpec((Key) null, (Provider) null);
1702                     fail(getName() + "NullPointerException has not been thrown");
1703                 } catch (NullPointerException ok) {
1704                 }
1705
1706                 try {
1707
1708                     // check that method under test throws NPE
1709                     epki.getKeySpec(new Key() {
1710                         public String getAlgorithm() {
1711                             return "alg";
1712                         }
1713
1714                         public String getFormat() {
1715                             return "fmt";
1716                         }
1717
1718                         public byte[] getEncoded() {
1719                             return new byte[] {};
1720                         }
1721                     }, (Provider) null);
1722
1723                     fail(getName() + "NullPointerException has not been thrown");
1724                 } catch (NullPointerException ok) {
1725                 }
1726
1727                 performed = true;
1728             } catch (NoSuchAlgorithmException allowedFailure) {
1729             }
1730         }
1731         assertTrue("Test not performed", performed);
1732     }
1733
1734     /**
1735      * Encrypted data contains valid PKCS8 key info encoding
1736      */
1737     @TestTargetNew(
1738         level = TestLevel.PARTIAL_COMPLETE,
1739         notes = "Can not check NoSuchAlgorithmException",
1740         method = "getKeySpec",
1741         args = {java.security.Key.class, java.security.Provider.class}
1742     )
1743     public final void test_ROUNDTRIP_GetKeySpecKeyProvider01() {
1744         boolean performed = false;
1745
1746         for (int i = 0; i < algName.length; i++) {
1747             for (int l = 0; l < provider.length; l++) {
1748                 if (provider[l] == null) {
1749                     continue;
1750                 }
1751                 TestDataGenerator g;
1752                 try {
1753                     // generate test data
1754                     g = new TestDataGenerator(algName[i][0], algName[i][1],
1755                             privateKeyInfo, provider[l]);
1756                 } catch (TestDataGenerator.AllowedFailure allowedFailure) {
1757                     continue;
1758                 }
1759                 try {
1760                     // create test object
1761                     EncryptedPrivateKeyInfo epki;
1762                     if (g.ap() == null) {
1763                         epki = new EncryptedPrivateKeyInfo(algName[i][0], g
1764                                 .ct());
1765                     } else {
1766                         epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
1767                     }
1768                     try {
1769
1770                         PKCS8EncodedKeySpec eks = epki.getKeySpec(
1771                                 g.pubK() == null ? g.k() : g.pubK(),
1772                                 provider[l]);
1773
1774                         if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
1775                             fail(algName[i][0] + " != " + algName[i][1]);
1776                         }
1777                     } catch (InvalidKeyException e) {
1778                         fail(algName[i][0] + ", " + algName[i][1] + ": " + e);
1779                     }
1780                     performed = true;
1781
1782                 } catch (NoSuchAlgorithmException allowedFailure) {
1783                 }
1784             }
1785         }
1786         assertTrue("Test not performed", performed);
1787     }
1788
1789     /**
1790      * Encrypted data contains invalid PKCS8 key info encoding
1791      */
1792     @TestTargetNew(
1793         level = TestLevel.PARTIAL_COMPLETE,
1794         notes = "Can not check NoSuchAlgorithmException",
1795         method = "getKeySpec",
1796         args = {java.security.Key.class, java.security.Provider.class}
1797     )
1798     public final void test_ROUNDTRIP_GetKeySpecKeyProvider02() {
1799         boolean performed = false;
1800
1801         for (int i = 0; i < algName.length; i++) {
1802             for (int l = 0; l < provider.length; l++) {
1803                 if (provider[l] == null) {
1804                     continue;
1805                 }
1806                 TestDataGenerator g;
1807                 try {
1808                     // generate test data
1809                     g = new TestDataGenerator(algName[i][0], algName[i][1],
1810                             privateKeyInfoDamaged, provider[l]);
1811                 } catch (TestDataGenerator.AllowedFailure allowedFailure) {
1812                     continue;
1813                 }
1814
1815                 try {
1816                     // create test object
1817                     EncryptedPrivateKeyInfo epki;
1818                     if (g.ap() == null) {
1819                         epki = new EncryptedPrivateKeyInfo(algName[i][0], g
1820                                 .ct());
1821                     } else {
1822                         epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
1823                     }
1824                     try {
1825
1826                         epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK(),
1827                                 provider[l]);
1828
1829                         fail(algName[i][0] + ", " + algName[i][1]);
1830
1831                     } catch (InvalidKeyException e) {
1832                     }
1833                     performed = true;
1834                 } catch (NoSuchAlgorithmException allowedFailure) {
1835                 }
1836             }
1837         }
1838         assertTrue("Test not performed", performed);
1839     }
1840
1841     public static class TestDataGenerator {
1842
1843         public static class AllowedFailure extends Exception {
1844             AllowedFailure(String msg) {
1845                 super(msg);
1846             }
1847         }
1848
1849         private Cipher c = null;
1850
1851         private Key k = null, pubK = null;
1852
1853         private AlgorithmParameters ap = null;
1854
1855         byte[] ct;
1856
1857         public TestDataGenerator(String algName, String transformation,
1858                 byte[] privateKeyInfo, Provider provider) throws AllowedFailure {
1859             try {
1860                 c = (provider == null) ? Cipher
1861                         .getInstance(transformation != null ? transformation
1862                                 : algName) : Cipher.getInstance(
1863                         transformation != null ? transformation : algName,
1864                         provider);
1865             } catch (NoSuchAlgorithmException e) {
1866                 throw new AllowedFailure(e.getMessage());
1867             } catch (NoSuchPaddingException e) {
1868                 throw new AllowedFailure(e.getMessage());
1869             }
1870
1871             try {
1872                 KeyGenerator kg = (provider == null) ? KeyGenerator
1873                         .getInstance(algName) : KeyGenerator.getInstance(
1874                         algName, provider);
1875                 k = kg.generateKey();
1876             } catch (NoSuchAlgorithmException e) {
1877             }
1878
1879             if (k == null) {
1880                 try {
1881                     KeyPairGenerator kpg = (provider == null) ? KeyPairGenerator
1882                             .getInstance(algName)
1883                             : KeyPairGenerator.getInstance(algName, provider);
1884                     KeyPair kp = kpg.genKeyPair();
1885                     k = kp.getPrivate();
1886                     pubK = kp.getPublic();
1887                 } catch (NoSuchAlgorithmException e) {
1888                 }
1889             }
1890
1891             PBEParameterSpec pbeParamSpec = null;
1892             if (k == null) {
1893                 try {
1894                     pbeParamSpec = new PBEParameterSpec(new byte[] { 1, 2, 3,
1895                             4, 5, 6, 7, 8 }, 10);
1896                     SecretKeyFactory skf = (provider == null) ? SecretKeyFactory
1897                             .getInstance(algName)
1898                             : SecretKeyFactory.getInstance(algName, provider);
1899                     PBEKeySpec ks = new PBEKeySpec("12345678".toCharArray());
1900                     try {
1901                         k = skf.generateSecret(ks);
1902                     } catch (InvalidKeySpecException e) {
1903                         throw new AllowedFailure(e.getMessage());
1904                     }
1905
1906                 } catch (NoSuchAlgorithmException e) {
1907                     throw new AllowedFailure(e.getMessage());
1908                 }
1909             }
1910
1911             try {
1912                 if (pbeParamSpec == null) {
1913                     c.init(Cipher.ENCRYPT_MODE, k);
1914                 } else {
1915                     c.init(Cipher.ENCRYPT_MODE, k, pbeParamSpec);
1916                 }
1917             } catch (InvalidKeyException e) {
1918                 throw new AllowedFailure(e.getMessage());
1919             } catch (SecurityException e) {
1920                 throw new AllowedFailure(e.getMessage());
1921             } catch (InvalidAlgorithmParameterException e) {
1922                 throw new AllowedFailure(e.getMessage());
1923             }
1924
1925             ap = c.getParameters();
1926
1927             try {
1928                 ct = c.doFinal(privateKeyInfo);
1929             } catch (IllegalStateException e) {
1930                 throw new AllowedFailure(e.getMessage());
1931             } catch (IllegalBlockSizeException e) {
1932                 throw new AllowedFailure(e.getMessage());
1933             } catch (BadPaddingException e) {
1934                 throw new AllowedFailure(e.getMessage());
1935             } catch (RuntimeException e) {
1936                 throw new AllowedFailure(e.getMessage());
1937             }
1938
1939             try {
1940                 // try to convert pbeParamSpec->ap
1941                 if (pbeParamSpec != null) {
1942                     try {
1943                         ap = (provider == null) ? AlgorithmParameters
1944                                 .getInstance(algName) : AlgorithmParameters
1945                                 .getInstance(algName, provider);
1946                         ap.init(pbeParamSpec);
1947                         pbeParamSpec = null;
1948                     } catch (NoSuchAlgorithmException e) {
1949                         // couldn't convert
1950                         throw new AllowedFailure(e.getMessage());
1951                     } catch (InvalidParameterSpecException e) {
1952                         // couldn't convert
1953                         throw new AllowedFailure(e.getMessage());
1954                     }
1955                 }
1956
1957                 if (ap == null) {
1958                     c.init(Cipher.DECRYPT_MODE, pubK == null ? k : pubK);
1959                 } else {
1960                     c.init(Cipher.DECRYPT_MODE, pubK == null ? k : pubK, ap);
1961                 }
1962
1963             } catch (InvalidKeyException e) {
1964                 throw new AllowedFailure(e.getMessage());
1965             } catch (SecurityException e) {
1966                 throw new AllowedFailure(e.getMessage());
1967             } catch (InvalidAlgorithmParameterException e) {
1968                 throw new AllowedFailure(e.getMessage());
1969             }
1970         }
1971
1972         public Key k() {
1973             return k;
1974         }
1975
1976         public Key pubK() {
1977             return pubK;
1978         }
1979
1980         public Cipher c() {
1981             return c;
1982         }
1983
1984         public byte[] ct() {
1985             return ct;
1986         }
1987
1988         public AlgorithmParameters ap() {
1989             return ap;
1990         }
1991     }
1992
1993     // valid PrivateKeyInfo encoding
1994     private static final byte[] privateKeyInfo = { (byte) 0x30, (byte) 0x82,
1995             (byte) 0x02, (byte) 0x77, (byte) 0x02, (byte) 0x01, (byte) 0x00,
1996             (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a,
1997             (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d,
1998             (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00,
1999             (byte) 0x04, (byte) 0x82, (byte) 0x02, (byte) 0x61, (byte) 0x30,
2000             (byte) 0x82, (byte) 0x02, (byte) 0x5d, (byte) 0x02, (byte) 0x01,
2001             (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00,
2002             (byte) 0xb2, (byte) 0x4a, (byte) 0x9b, (byte) 0x5b, (byte) 0xba,
2003             (byte) 0x01, (byte) 0xc0, (byte) 0xcd, (byte) 0x65, (byte) 0x09,
2004             (byte) 0x63, (byte) 0x70, (byte) 0x0b, (byte) 0x5a, (byte) 0x1b,
2005             (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55, (byte) 0x5e,
2006             (byte) 0x7c, (byte) 0x1b, (byte) 0x50, (byte) 0x17, (byte) 0xec,
2007             (byte) 0x44, (byte) 0x4c, (byte) 0x58, (byte) 0x42, (byte) 0x2b,
2008             (byte) 0x41, (byte) 0x09, (byte) 0x59, (byte) 0xf2, (byte) 0xe1,
2009             (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d, (byte) 0x92,
2010             (byte) 0x03, (byte) 0x1d, (byte) 0xb6, (byte) 0x6c, (byte) 0x7f,
2011             (byte) 0x5d, (byte) 0x48, (byte) 0xcd, (byte) 0x17, (byte) 0xec,
2012             (byte) 0xd7, (byte) 0x4c, (byte) 0x39, (byte) 0xb1, (byte) 0x7b,
2013             (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77, (byte) 0xbe,
2014             (byte) 0xd0, (byte) 0xa0, (byte) 0xf0, (byte) 0x2d, (byte) 0x6b,
2015             (byte) 0x24, (byte) 0xaa, (byte) 0x14, (byte) 0xba, (byte) 0x82,
2016             (byte) 0x79, (byte) 0x10, (byte) 0x9b, (byte) 0x16, (byte) 0x68,
2017             (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2, (byte) 0xfa,
2018             (byte) 0x91, (byte) 0x9e, (byte) 0x0a, (byte) 0x2a, (byte) 0x53,
2019             (byte) 0xa6, (byte) 0xe7, (byte) 0x9e, (byte) 0x7d, (byte) 0x29,
2020             (byte) 0x33, (byte) 0xd8, (byte) 0x05, (byte) 0xfc, (byte) 0x02,
2021             (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e, (byte) 0xed,
2022             (byte) 0xaa, (byte) 0x30, (byte) 0x6c, (byte) 0x5f, (byte) 0x52,
2023             (byte) 0xed, (byte) 0x35, (byte) 0x65, (byte) 0x4b, (byte) 0x0e,
2024             (byte) 0xc8, (byte) 0xa7, (byte) 0x12, (byte) 0x10, (byte) 0x56,
2025             (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa, (byte) 0x21,
2026             (byte) 0x0e, (byte) 0x99, (byte) 0xff, (byte) 0xfa, (byte) 0x8c,
2027             (byte) 0x65, (byte) 0x8e, (byte) 0x6d, (byte) 0x02, (byte) 0x03,
2028             (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x81,
2029             (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72, (byte) 0x40,
2030             (byte) 0x90, (byte) 0x59, (byte) 0x96, (byte) 0x5d, (byte) 0xf3,
2031             (byte) 0x84, (byte) 0x3d, (byte) 0x99, (byte) 0xd9, (byte) 0x4e,
2032             (byte) 0x51, (byte) 0xc2, (byte) 0x52, (byte) 0x62, (byte) 0x8d,
2033             (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73, (byte) 0x1e,
2034             (byte) 0x6f, (byte) 0xb2, (byte) 0x31, (byte) 0x7c, (byte) 0x66,
2035             (byte) 0x45, (byte) 0x1e, (byte) 0x7c, (byte) 0xdc, (byte) 0x3a,
2036             (byte) 0xc2, (byte) 0x5f, (byte) 0x51, (byte) 0x9a, (byte) 0x1e,
2037             (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4, (byte) 0xf9,
2038             (byte) 0x81, (byte) 0x7e, (byte) 0xbe, (byte) 0x17, (byte) 0xf7,
2039             (byte) 0xc7, (byte) 0x3c, (byte) 0x00, (byte) 0xa1, (byte) 0xf9,
2040             (byte) 0x60, (byte) 0x82, (byte) 0x34, (byte) 0x8f, (byte) 0x9c,
2041             (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42, (byte) 0x1b,
2042             (byte) 0x7f, (byte) 0x45, (byte) 0xf1, (byte) 0x31, (byte) 0xc3,
2043             (byte) 0x63, (byte) 0x47, (byte) 0x5c, (byte) 0xc1, (byte) 0xb2,
2044             (byte) 0x5f, (byte) 0x57, (byte) 0xee, (byte) 0x02, (byte) 0x9f,
2045             (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba, (byte) 0x74,
2046             (byte) 0xba, (byte) 0x81, (byte) 0xb7, (byte) 0x30, (byte) 0xac,
2047             (byte) 0x4c, (byte) 0x01, (byte) 0x35, (byte) 0xce, (byte) 0x46,
2048             (byte) 0x47, (byte) 0x8c, (byte) 0xe4, (byte) 0x62, (byte) 0x36,
2049             (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33, (byte) 0x56,
2050             (byte) 0xf9, (byte) 0xb7, (byte) 0xa0, (byte) 0xc4, (byte) 0xb6,
2051             (byte) 0x82, (byte) 0x55, (byte) 0x7d, (byte) 0x36, (byte) 0x55,
2052             (byte) 0xc0, (byte) 0x52, (byte) 0x5e, (byte) 0x35, (byte) 0x54,
2053             (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00, (byte) 0xbf,
2054             (byte) 0x10, (byte) 0xdc, (byte) 0x1b, (byte) 0x51, (byte) 0x02,
2055             (byte) 0x41, (byte) 0x00, (byte) 0xe7, (byte) 0x68, (byte) 0x03,
2056             (byte) 0x3e, (byte) 0x21, (byte) 0x64, (byte) 0x68, (byte) 0x24,
2057             (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0, (byte) 0xa2,
2058             (byte) 0xd9, (byte) 0x87, (byte) 0x6d, (byte) 0x79, (byte) 0x81,
2059             (byte) 0x8f, (byte) 0x8f, (byte) 0x2d, (byte) 0x7a, (byte) 0x95,
2060             (byte) 0x2e, (byte) 0x55, (byte) 0x9f, (byte) 0xd7, (byte) 0x86,
2061             (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04, (byte) 0x7e,
2062             (byte) 0x4f, (byte) 0xdb, (byte) 0x56, (byte) 0xf1, (byte) 0x75,
2063             (byte) 0xd0, (byte) 0x4b, (byte) 0x00, (byte) 0x3a, (byte) 0xe0,
2064             (byte) 0x26, (byte) 0xf6, (byte) 0xab, (byte) 0x9e, (byte) 0x0b,
2065             (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7, (byte) 0xff,
2066             (byte) 0xbe, (byte) 0x01, (byte) 0xeb, (byte) 0x9b, (byte) 0x81,
2067             (byte) 0xc7, (byte) 0x5f, (byte) 0x02, (byte) 0x73, (byte) 0xe1,
2068             (byte) 0x2b, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xc5,
2069             (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6, (byte) 0xab,
2070             (byte) 0x3e, (byte) 0x29, (byte) 0xfd, (byte) 0x98, (byte) 0xd0,
2071             (byte) 0xa4, (byte) 0x3e, (byte) 0x58, (byte) 0xee, (byte) 0x48,
2072             (byte) 0x45, (byte) 0xa3, (byte) 0x66, (byte) 0xac, (byte) 0xe9,
2073             (byte) 0x4d, (byte) 0xbd, (byte) 0x60, (byte) 0xea, (byte) 0x24,
2074             (byte) 0xff, (byte) 0xed, (byte) 0x0c, (byte) 0x67, (byte) 0xc5,
2075             (byte) 0xfd, (byte) 0x36, (byte) 0x28, (byte) 0xea, (byte) 0x74,
2076             (byte) 0x88, (byte) 0xd1, (byte) 0xd1, (byte) 0xad, (byte) 0x58,
2077             (byte) 0xd7, (byte) 0xf0, (byte) 0x67, (byte) 0x20, (byte) 0xc1,
2078             (byte) 0xe3, (byte) 0xb3, (byte) 0xdb, (byte) 0x52, (byte) 0xad,
2079             (byte) 0xf3, (byte) 0xc4, (byte) 0x21, (byte) 0xd8, (byte) 0x8c,
2080             (byte) 0x4c, (byte) 0x41, (byte) 0x27, (byte) 0xdb, (byte) 0xd0,
2081             (byte) 0x35, (byte) 0x92, (byte) 0xc7, (byte) 0x02, (byte) 0x41,
2082             (byte) 0x00, (byte) 0xe0, (byte) 0x99, (byte) 0x42, (byte) 0xb4,
2083             (byte) 0x76, (byte) 0x02, (byte) 0x97, (byte) 0x55, (byte) 0xf9,
2084             (byte) 0xda, (byte) 0x3b, (byte) 0xa0, (byte) 0xd7, (byte) 0x0e,
2085             (byte) 0xdc, (byte) 0xf4, (byte) 0x33, (byte) 0x7f, (byte) 0xbd,
2086             (byte) 0xcf, (byte) 0xd0, (byte) 0xeb, (byte) 0x6e, (byte) 0x89,
2087             (byte) 0xf7, (byte) 0x4f, (byte) 0x5a, (byte) 0x07, (byte) 0x7c,
2088             (byte) 0xa9, (byte) 0x49, (byte) 0x47, (byte) 0x68, (byte) 0x35,
2089             (byte) 0xa8, (byte) 0x05, (byte) 0x3d, (byte) 0xfd, (byte) 0x04,
2090             (byte) 0x7b, (byte) 0x17, (byte) 0x31, (byte) 0x0d, (byte) 0xc8,
2091             (byte) 0xa3, (byte) 0x98, (byte) 0x34, (byte) 0xa0, (byte) 0x50,
2092             (byte) 0x44, (byte) 0x00, (byte) 0xf1, (byte) 0x0c, (byte) 0xe6,
2093             (byte) 0xe5, (byte) 0xc4, (byte) 0x41, (byte) 0x3d, (byte) 0xf8,
2094             (byte) 0x3d, (byte) 0x4e, (byte) 0x0b, (byte) 0x1c, (byte) 0xdb,
2095             (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0x82, (byte) 0x9b,
2096             (byte) 0x8a, (byte) 0xfd, (byte) 0xa1, (byte) 0x98, (byte) 0x41,
2097             (byte) 0x68, (byte) 0xc2, (byte) 0xd1, (byte) 0xdf, (byte) 0x4e,
2098             (byte) 0xf3, (byte) 0x2e, (byte) 0x26, (byte) 0x53, (byte) 0x5b,
2099             (byte) 0x31, (byte) 0xb1, (byte) 0x7a, (byte) 0xcc, (byte) 0x5e,
2100             (byte) 0xbb, (byte) 0x09, (byte) 0xa2, (byte) 0xe2, (byte) 0x6f,
2101             (byte) 0x4a, (byte) 0x04, (byte) 0x0d, (byte) 0xef, (byte) 0x90,
2102             (byte) 0x15, (byte) 0xbe, (byte) 0x10, (byte) 0x4a, (byte) 0xac,
2103             (byte) 0x92, (byte) 0xeb, (byte) 0xda, (byte) 0x72, (byte) 0xdb,
2104             (byte) 0x43, (byte) 0x08, (byte) 0xb7, (byte) 0x2b, (byte) 0x4c,
2105             (byte) 0xe1, (byte) 0xbb, (byte) 0x58, (byte) 0xcb, (byte) 0x71,
2106             (byte) 0x80, (byte) 0xad, (byte) 0xbc, (byte) 0xdc, (byte) 0x62,
2107             (byte) 0x5e, (byte) 0x3e, (byte) 0xcb, (byte) 0x92, (byte) 0xda,
2108             (byte) 0xf6, (byte) 0xdf, (byte) 0x02, (byte) 0x40, (byte) 0x4d,
2109             (byte) 0x81, (byte) 0x90, (byte) 0xc5, (byte) 0x77, (byte) 0x30,
2110             (byte) 0xb7, (byte) 0x29, (byte) 0x00, (byte) 0xa8, (byte) 0xf1,
2111             (byte) 0xb4, (byte) 0xae, (byte) 0x52, (byte) 0x63, (byte) 0x00,
2112             (byte) 0xb2, (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6,
2113             (byte) 0x4d, (byte) 0xf9, (byte) 0x8a, (byte) 0xc1, (byte) 0xb1,
2114             (byte) 0x98, (byte) 0x89, (byte) 0x52, (byte) 0x40, (byte) 0x14,
2115             (byte) 0x1b, (byte) 0x0e, (byte) 0x61, (byte) 0x8f, (byte) 0xf4,
2116             (byte) 0xbe, (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95,
2117             (byte) 0x19, (byte) 0x5c, (byte) 0x51, (byte) 0x08, (byte) 0x66,
2118             (byte) 0xc1, (byte) 0x42, (byte) 0x30, (byte) 0xb3, (byte) 0x7a,
2119             (byte) 0x86, (byte) 0x9f, (byte) 0x3e, (byte) 0xf5, (byte) 0x19,
2120             (byte) 0xa3, (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14,
2121             (byte) 0x07, (byte) 0x50, (byte) 0x97, };
2122
2123     // valid PrivateKeyInfo encoding (Damaged)
2124     private static final byte[] privateKeyInfoDamaged = { (byte) 0x30,
2125             (byte) 0x82, (byte) 0x02, (byte) 0x77, (byte) 0x02, (byte) 0x01,
2126             (byte) 0x00, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09,
2127             (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7,
2128             (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05,
2129             (byte) 0x00, (byte) 0x04, // private key octet str
2130             (byte) 0x82, (byte) 0x02, (byte) 0x62, // Damage: l=460->461
2131                                                    // (0x61->0x62)
2132             (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x5d, (byte) 0x02,
2133             (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81,
2134             (byte) 0x00, (byte) 0xb2, (byte) 0x4a, (byte) 0x9b, (byte) 0x5b,
2135             (byte) 0xba, (byte) 0x01, (byte) 0xc0, (byte) 0xcd, (byte) 0x65,
2136             (byte) 0x09, (byte) 0x63, (byte) 0x70, (byte) 0x0b, (byte) 0x5a,
2137             (byte) 0x1b, (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55,
2138             (byte) 0x5e, (byte) 0x7c, (byte) 0x1b, (byte) 0x50, (byte) 0x17,
2139             (byte) 0xec, (byte) 0x44, (byte) 0x4c, (byte) 0x58, (byte) 0x42,
2140             (byte) 0x2b, (byte) 0x41, (byte) 0x09, (byte) 0x59, (byte) 0xf2,
2141             (byte) 0xe1, (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d,
2142             (byte) 0x92, (byte) 0x03, (byte) 0x1d, (byte) 0xb6, (byte) 0x6c,
2143             (byte) 0x7f, (byte) 0x5d, (byte) 0x48, (byte) 0xcd, (byte) 0x17,
2144             (byte) 0xec, (byte) 0xd7, (byte) 0x4c, (byte) 0x39, (byte) 0xb1,
2145             (byte) 0x7b, (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77,
2146             (byte) 0xbe, (byte) 0xd0, (byte) 0xa0, (byte) 0xf0, (byte) 0x2d,
2147             (byte) 0x6b, (byte) 0x24, (byte) 0xaa, (byte) 0x14, (byte) 0xba,
2148             (byte) 0x82, (byte) 0x79, (byte) 0x10, (byte) 0x9b, (byte) 0x16,
2149             (byte) 0x68, (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2,
2150             (byte) 0xfa, (byte) 0x91, (byte) 0x9e, (byte) 0x0a, (byte) 0x2a,
2151             (byte) 0x53, (byte) 0xa6, (byte) 0xe7, (byte) 0x9e, (byte) 0x7d,
2152             (byte) 0x29, (byte) 0x33, (byte) 0xd8, (byte) 0x05, (byte) 0xfc,
2153             (byte) 0x02, (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e,
2154             (byte) 0xed, (byte) 0xaa, (byte) 0x30, (byte) 0x6c, (byte) 0x5f,
2155             (byte) 0x52, (byte) 0xed, (byte) 0x35, (byte) 0x65, (byte) 0x4b,
2156             (byte) 0x0e, (byte) 0xc8, (byte) 0xa7, (byte) 0x12, (byte) 0x10,
2157             (byte) 0x56, (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa,
2158             (byte) 0x21, (byte) 0x0e, (byte) 0x99, (byte) 0xff, (byte) 0xfa,
2159             (byte) 0x8c, (byte) 0x65, (byte) 0x8e, (byte) 0x6d, (byte) 0x02,
2160             (byte) 0x03, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02,
2161             (byte) 0x81, (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72,
2162             (byte) 0x40, (byte) 0x90, (byte) 0x59, (byte) 0x96, (byte) 0x5d,
2163             (byte) 0xf3, (byte) 0x84, (byte) 0x3d, (byte) 0x99, (byte) 0xd9,
2164             (byte) 0x4e, (byte) 0x51, (byte) 0xc2, (byte) 0x52, (byte) 0x62,
2165             (byte) 0x8d, (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73,
2166             (byte) 0x1e, (byte) 0x6f, (byte) 0xb2, (byte) 0x31, (byte) 0x7c,
2167             (byte) 0x66, (byte) 0x45, (byte) 0x1e, (byte) 0x7c, (byte) 0xdc,
2168             (byte) 0x3a, (byte) 0xc2, (byte) 0x5f, (byte) 0x51, (byte) 0x9a,
2169             (byte) 0x1e, (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4,
2170             (byte) 0xf9, (byte) 0x81, (byte) 0x7e, (byte) 0xbe, (byte) 0x17,
2171             (byte) 0xf7, (byte) 0xc7, (byte) 0x3c, (byte) 0x00, (byte) 0xa1,
2172             (byte) 0xf9, (byte) 0x60, (byte) 0x82, (byte) 0x34, (byte) 0x8f,
2173             (byte) 0x9c, (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42,
2174             (byte) 0x1b, (byte) 0x7f, (byte) 0x45, (byte) 0xf1, (byte) 0x31,
2175             (byte) 0xc3, (byte) 0x63, (byte) 0x47, (byte) 0x5c, (byte) 0xc1,
2176             (byte) 0xb2, (byte) 0x5f, (byte) 0x57, (byte) 0xee, (byte) 0x02,
2177             (byte) 0x9f, (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba,
2178             (byte) 0x74, (byte) 0xba, (byte) 0x81, (byte) 0xb7, (byte) 0x30,
2179             (byte) 0xac, (byte) 0x4c, (byte) 0x01, (byte) 0x35, (byte) 0xce,
2180             (byte) 0x46, (byte) 0x47, (byte) 0x8c, (byte) 0xe4, (byte) 0x62,
2181             (byte) 0x36, (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33,
2182             (byte) 0x56, (byte) 0xf9, (byte) 0xb7, (byte) 0xa0, (byte) 0xc4,
2183             (byte) 0xb6, (byte) 0x82, (byte) 0x55, (byte) 0x7d, (byte) 0x36,
2184             (byte) 0x55, (byte) 0xc0, (byte) 0x52, (byte) 0x5e, (byte) 0x35,
2185             (byte) 0x54, (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00,
2186             (byte) 0xbf, (byte) 0x10, (byte) 0xdc, (byte) 0x1b, (byte) 0x51,
2187             (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xe7, (byte) 0x68,
2188             (byte) 0x03, (byte) 0x3e, (byte) 0x21, (byte) 0x64, (byte) 0x68,
2189             (byte) 0x24, (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0,
2190             (byte) 0xa2, (byte) 0xd9, (byte) 0x87, (byte) 0x6d, (byte) 0x79,
2191             (byte) 0x81, (byte) 0x8f, (byte) 0x8f, (byte) 0x2d, (byte) 0x7a,
2192             (byte) 0x95, (byte) 0x2e, (byte) 0x55, (byte) 0x9f, (byte) 0xd7,
2193             (byte) 0x86, (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04,
2194             (byte) 0x7e, (byte) 0x4f, (byte) 0xdb, (byte) 0x56, (byte) 0xf1,
2195             (byte) 0x75, (byte) 0xd0, (byte) 0x4b, (byte) 0x00, (byte) 0x3a,
2196             (byte) 0xe0, (byte) 0x26, (byte) 0xf6, (byte) 0xab, (byte) 0x9e,
2197             (byte) 0x0b, (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7,
2198             (byte) 0xff, (byte) 0xbe, (byte) 0x01, (byte) 0xeb, (byte) 0x9b,
2199             (byte) 0x81, (byte) 0xc7, (byte) 0x5f, (byte) 0x02, (byte) 0x73,
2200             (byte) 0xe1, (byte) 0x2b, (byte) 0x02, (byte) 0x41, (byte) 0x00,
2201             (byte) 0xc5, (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6,
2202             (byte) 0xab, (byte) 0x3e, (byte) 0x29, (byte) 0xfd, // 88
2203             (byte) 0x98, (byte) 0xd0, (byte) 0xa4, (byte) 0x3e, (byte) 0x58,
2204             (byte) 0xee, (byte) 0x48, (byte) 0x45, (byte) 0xa3, (byte) 0x66,
2205             (byte) 0xac, (byte) 0xe9, (byte) 0x4d, (byte) 0xbd, (byte) 0x60,
2206             (byte) 0xea, (byte) 0x24, (byte) 0xff, (byte) 0xed, (byte) 0x0c,
2207             (byte) 0x67, (byte) 0xc5, (byte) 0xfd, (byte) 0x36, (byte) 0x28,
2208             (byte) 0xea, (byte) 0x74, (byte) 0x88, (byte) 0xd1, (byte) 0xd1,
2209             (byte) 0xad, (byte) 0x58, (byte) 0xd7, (byte) 0xf0, (byte) 0x67,
2210             (byte) 0x20, (byte) 0xc1, (byte) 0xe3, (byte) 0xb3, (byte) 0xdb,
2211             (byte) 0x52, (byte) 0xad, (byte) 0xf3, (byte) 0xc4, (byte) 0x21,
2212             (byte) 0xd8, (byte) 0x8c, (byte) 0x4c, (byte) 0x41, (byte) 0x27,
2213             (byte) 0xdb, (byte) 0xd0, (byte) 0x35, (byte) 0x92, (byte) 0xc7,
2214             (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xe0, (byte) 0x99,
2215             (byte) 0x42, (byte) 0xb4, (byte) 0x76, (byte) 0x02, (byte) 0x97,
2216             (byte) 0x55, (byte) 0xf9, (byte) 0xda, (byte) 0x3b, (byte) 0xa0,
2217             (byte) 0xd7, (byte) 0x0e, (byte) 0xdc, (byte) 0xf4, (byte) 0x33,
2218             (byte) 0x7f, (byte) 0xbd, (byte) 0xcf, (byte) 0xd0, (byte) 0xeb,
2219             (byte) 0x6e, (byte) 0x89, (byte) 0xf7, (byte) 0x4f, (byte) 0x5a,
2220             (byte) 0x07, (byte) 0x7c, (byte) 0xa9, (byte) 0x49, (byte) 0x47,
2221             (byte) 0x68, (byte) 0x35, (byte) 0xa8, (byte) 0x05, (byte) 0x3d,
2222             (byte) 0xfd, (byte) 0x04, (byte) 0x7b, (byte) 0x17, (byte) 0x31,
2223             (byte) 0x0d, (byte) 0xc8, (byte) 0xa3, (byte) 0x98, (byte) 0x34,
2224             (byte) 0xa0, (byte) 0x50, (byte) 0x44, (byte) 0x00, (byte) 0xf1,
2225             (byte) 0x0c, (byte) 0xe6, (byte) 0xe5, (byte) 0xc4, (byte) 0x41,
2226             (byte) 0x3d, (byte) 0xf8, (byte) 0x3d, (byte) 0x4e, (byte) 0x0b, // 118
2227             (byte) 0x1c, (byte) 0xdb, (byte) 0x02, (byte) 0x41, (byte) 0x00,
2228             (byte) 0x82, (byte) 0x9b, (byte) 0x8a, (byte) 0xfd, (byte) 0xa1,
2229             (byte) 0x98, (byte) 0x41, (byte) 0x68, (byte) 0xc2, (byte) 0xd1,
2230             (byte) 0xdf, (byte) 0x4e, (byte) 0xf3, (byte) 0x2e, (byte) 0x26,
2231             (byte) 0x53, (byte) 0x5b, (byte) 0x31, (byte) 0xb1, (byte) 0x7a,
2232             (byte) 0xcc, (byte) 0x5e, (byte) 0xbb, (byte) 0x09, (byte) 0xa2,
2233             (byte) 0xe2, (byte) 0x6f, (byte) 0x4a, (byte) 0x04, (byte) 0x0d,
2234             (byte) 0xef, (byte) 0x90, (byte) 0x15, (byte) 0xbe, (byte) 0x10,
2235             (byte) 0x4a, (byte) 0xac, (byte) 0x92, (byte) 0xeb, (byte) 0xda,
2236             (byte) 0x72, (byte) 0xdb, (byte) 0x43, (byte) 0x08, (byte) 0xb7,
2237             (byte) 0x2b, (byte) 0x4c, (byte) 0xe1, (byte) 0xbb, (byte) 0x58,
2238             (byte) 0xcb, (byte) 0x71, (byte) 0x80, (byte) 0xad, (byte) 0xbc,
2239             (byte) 0xdc, (byte) 0x62, (byte) 0x5e, (byte) 0x3e, (byte) 0xcb,
2240             (byte) 0x92, (byte) 0xda, (byte) 0xf6, (byte) 0xdf, (byte) 0x02,
2241             (byte) 0x40, (byte) 0x4d, (byte) 0x81, (byte) 0x90, (byte) 0xc5,
2242             (byte) 0x77, (byte) 0x30, (byte) 0xb7, (byte) 0x29, (byte) 0x00,
2243             (byte) 0xa8, (byte) 0xf1, (byte) 0xb4, (byte) 0xae, (byte) 0x52,
2244             (byte) 0x63, (byte) 0x00, (byte) 0xb2, // 140
2245             (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6, (byte) 0x4d,
2246             (byte) 0xf9, (byte) 0x8a, (byte) 0xc1, (byte) 0xb1, (byte) 0x98,
2247             (byte) 0x89, (byte) 0x52, (byte) 0x40, (byte) 0x14, (byte) 0x1b,
2248             (byte) 0x0e, (byte) 0x61, (byte) 0x8f, (byte) 0xf4, (byte) 0xbe,
2249             (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95, (byte) 0x19,
2250             (byte) 0x5c, (byte) 0x51, (byte) 0x08, (byte) 0x66, (byte) 0xc1,
2251             (byte) 0x42, (byte) 0x30, (byte) 0xb3, (byte) 0x7a, (byte) 0x86,
2252             (byte) 0x9f, (byte) 0x3e, (byte) 0xf5, (byte) 0x19, (byte) 0xa3, // 150
2253             (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14, (byte) 0x07,
2254             (byte) 0x50, (byte) 0x97, };
2255 }